[java-opensaml COMMIT] in /trunk/opensaml-profile-api/src/main/java/org/opensaml/profile: action/AbstractProfileActio...

noreply at shibboleth.net noreply at shibboleth.net
Thu Jan 2 15:41:46 EST 2014


Author: scantor
Date: Thu Jan  2 15:41:46 2014
New Revision: 3542

URL: http://svn.shibboleth.net/view/java-opensaml?rev=3542&view=rev
Log:
Manage a "previous" EventContext to allow access to that without Spring WebFlow.

Added:
    trunk/opensaml-profile-api/src/main/java/org/opensaml/profile/context/PreviousEventContext.java   (with props)
Modified:
    trunk/opensaml-profile-api/src/main/java/org/opensaml/profile/action/AbstractProfileAction.java

Modified: trunk/opensaml-profile-api/src/main/java/org/opensaml/profile/action/AbstractProfileAction.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-profile-api/src/main/java/org/opensaml/profile/action/AbstractProfileAction.java?rev=3542&r1=3541&r2=3542&view=diff
==============================================================================
--- trunk/opensaml-profile-api/src/main/java/org/opensaml/profile/action/AbstractProfileAction.java (original)
+++ trunk/opensaml-profile-api/src/main/java/org/opensaml/profile/action/AbstractProfileAction.java Thu Jan  2 15:41:46 2014
@@ -25,6 +25,7 @@
 import org.apache.log4j.Logger;
 import org.opensaml.profile.ProfileException;
 import org.opensaml.profile.context.EventContext;
+import org.opensaml.profile.context.PreviousEventContext;
 import org.opensaml.profile.context.ProfileRequestContext;
 
 import net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent;
@@ -40,8 +41,8 @@
  * @param <OutboundMessageType> type of out-bound message
  */
 public abstract class AbstractProfileAction<InboundMessageType, OutboundMessageType>
-    extends AbstractIdentifiableInitializableComponent
-    implements ProfileAction<InboundMessageType, OutboundMessageType> {
+        extends AbstractIdentifiableInitializableComponent
+        implements ProfileAction<InboundMessageType, OutboundMessageType> {
 
     /** Current HTTP request, if available. */
     @Nullable private HttpServletRequest httpServletRequest;
@@ -55,12 +56,11 @@
      * Initializes the ID of this action to the class name.
      */
     public AbstractProfileAction() {
-        super();
-
         setId(getClass().getName());
     }
 
     /** {@inheritDoc} */
+    @Override
     public synchronized void setId(String componentId) {
         super.setId(componentId);
     }
@@ -107,12 +107,21 @@
     }
     
     /** {@inheritDoc} */
+    @Override
     public void execute(
             @Nonnull final ProfileRequestContext<InboundMessageType, OutboundMessageType> profileRequestContext)
             throws ProfileException {
         
-        // Clear any existing EventContext that might be hanging around.
-        profileRequestContext.removeSubcontext(EventContext.class);
+        // Clear any existing EventContext that might be hanging around, and if it exists,
+        // copy the Event to a PreviousEventContext.
+        EventContext previousEvent = profileRequestContext.getSubcontext(EventContext.class, false);
+        if (previousEvent != null) {
+            profileRequestContext.getSubcontext(PreviousEventContext.class, true).setEvent(previousEvent.getEvent());
+            profileRequestContext.removeSubcontext(EventContext.class);
+        } else {
+            // If there's no previous event, don't expose one.
+            profileRequestContext.removeSubcontext(PreviousEventContext.class);
+        }
         
         // The try/catch logic is designed to suppress a checked exception raised by
         // the doInvoke step by any unchecked errors in the doPostInvoke method.



More information about the commits mailing list