[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
Thu Mar 7 22:14:44 EST 2013
Author: tzeller
Date: Thu Mar 7 22:14:44 2013
New Revision: 4312
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4312&view=rev
Log:
This action will be called at the start of every flow, so we need to get it right. Override execute() rather than doExecute(), since the profile request context must be initialized and stored in the spring request context before it can be retrieved by doExecute().
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=4312&r1=4311&r2=4312&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 Thu Mar 7 22:14:44 2013
@@ -25,6 +25,7 @@
import net.shibboleth.idp.profile.ActionSupport;
import net.shibboleth.idp.profile.ProfileException;
import net.shibboleth.idp.profile.ProfileRequestContext;
+import net.shibboleth.utilities.java.support.component.ComponentSupport;
import org.springframework.webflow.execution.Event;
import org.springframework.webflow.execution.RequestContext;
@@ -37,10 +38,22 @@
public final class InitializeProfileRequestContext extends AbstractProfileAction {
/** {@inheritDoc} */
- protected Event doExecute(final HttpServletRequest httpRequest, final HttpServletResponse httpResponse,
- final RequestContext springRequestContext, final ProfileRequestContext profileRequestContext)
- throws ProfileException {
- springRequestContext.getConversationScope().put(ProfileRequestContext.BINDING_KEY, new ProfileRequestContext());
+ public Event execute(final RequestContext springRequestContext) throws ProfileException {
+
+ // TODO I think this is correct, we have to override execute() rather than doExecute().
+
+ ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
+
+ final HttpServletRequest httpRequest =
+ (HttpServletRequest) getHttpRequestLookupStrategy().apply(springRequestContext);
+ final HttpServletResponse httpResponse =
+ (HttpServletResponse) getHttpResponseLookupStrategy().apply(springRequestContext);
+
+ ProfileRequestContext profileRequestContext = new ProfileRequestContext();
+ profileRequestContext.setHttpRequest(httpRequest);
+ profileRequestContext.setHttpResponse(httpResponse);
+ springRequestContext.getConversationScope().put(ProfileRequestContext.BINDING_KEY, profileRequestContext);
+
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=4312&r1=4311&r2=4312&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 Thu Mar 7 22:14:44 2013
@@ -20,7 +20,7 @@
import net.shibboleth.idp.profile.ProfileRequestContext;
import net.shibboleth.idp.profile.RequestContextBuilder;
-import org.springframework.webflow.execution.RequestContext;
+import org.springframework.webflow.test.MockRequestContext;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -29,12 +29,13 @@
@Test public void testExecute() throws Exception {
- RequestContext springRequestContext = new RequestContextBuilder().buildRequestContext();
+ MockRequestContext springRequestContext = new MockRequestContext();
+ springRequestContext.setExternalContext(new RequestContextBuilder().buildServletExternalContext());
InitializeProfileRequestContext action = new InitializeProfileRequestContext();
action.initialize();
- action.doExecute(null, null, springRequestContext, null);
+ action.execute(springRequestContext);
Assert.assertNotNull(springRequestContext.getConversationScope().get(ProfileRequestContext.BINDING_KEY));
}
More information about the commits
mailing list