[java-identity-provider COMMIT] in /trunk/idp-profile-impl/src: main/java/net/shibboleth/idp/profile/impl/InitializeP...
noreply at shibboleth.net
noreply at shibboleth.net
Wed Dec 18 21:27:04 EST 2013
Author: scantor
Date: Wed Dec 18 21:27:04 2013
New Revision: 5059
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=5059&view=rev
Log:
Allow setting profileId from the bootstrap action.
Modified:
trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/InitializeProfileRequestContext.java
trunk/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/InitializeProfileRequestContextTest.java
Modified: trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/InitializeProfileRequestContext.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/InitializeProfileRequestContext.java?rev=5059&r1=5058&r2=5059&view=diff
==============================================================================
--- trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/InitializeProfileRequestContext.java (original)
+++ trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/InitializeProfileRequestContext.java Wed Dec 18 21:27:04 2013
@@ -18,6 +18,7 @@
package net.shibboleth.idp.profile.impl;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;
import net.shibboleth.idp.profile.AbstractProfileAction;
@@ -27,6 +28,7 @@
import org.opensaml.profile.context.ProfileRequestContext;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
import org.springframework.webflow.execution.Event;
import org.springframework.webflow.execution.RequestContext;
@@ -43,6 +45,20 @@
@ThreadSafe
public final class InitializeProfileRequestContext extends AbstractProfileAction {
+ /** The profile ID to initialize the context to. */
+ @Nullable private String profileId;
+
+ /**
+ * Set the profile ID to populate into the context.
+ *
+ * @param id profile ID to populate into the context
+ */
+ public void setProfileId(@Nullable final String id) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+
+ profileId = StringSupport.trimOrNull(id);
+ }
+
/** {@inheritDoc} */
@Override
@Nonnull public Event execute(@Nonnull final RequestContext springRequestContext) throws ProfileException {
@@ -50,8 +66,13 @@
// We have to override execute() because the profile request context doesn't exist yet.
ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
+
+ ProfileRequestContext prc = new ProfileRequestContext();
+ if (profileId != null) {
+ prc.setProfileId(profileId);
+ }
- springRequestContext.getConversationScope().put(ProfileRequestContext.BINDING_KEY, new ProfileRequestContext());
+ springRequestContext.getConversationScope().put(ProfileRequestContext.BINDING_KEY, prc);
return ActionSupport.buildProceedEvent(this);
}
Modified: trunk/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/InitializeProfileRequestContextTest.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/InitializeProfileRequestContextTest.java?rev=5059&r1=5058&r2=5059&view=diff
==============================================================================
--- trunk/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/InitializeProfileRequestContextTest.java (original)
+++ trunk/idp-profile-impl/src/test/java/net/shibboleth/idp/profile/impl/InitializeProfileRequestContextTest.java Wed Dec 18 21:27:04 2013
@@ -33,10 +33,15 @@
springRequestContext.setExternalContext(new RequestContextBuilder().buildServletExternalContext());
InitializeProfileRequestContext action = new InitializeProfileRequestContext();
+ action.setProfileId("test");
action.initialize();
action.execute(springRequestContext);
- Assert.assertNotNull(springRequestContext.getConversationScope().get(ProfileRequestContext.BINDING_KEY));
+ ProfileRequestContext prc =
+ (ProfileRequestContext) springRequestContext.getConversationScope().get(ProfileRequestContext.BINDING_KEY);
+ Assert.assertNotNull(prc);
+ Assert.assertEquals(prc.getProfileId(), "test");
}
+
}
More information about the commits
mailing list