Class PreserveStateDataAction

All Implemented Interfaces:
Component, DestructableComponent, InitializableComponent, ProfileAction, Aware, MessageSource, MessageSourceAware, Action

public class PreserveStateDataAction extends AbstractApplicationAction
Base class for an action that maps StateData from a StateDataContext to a token suitable for safe transmission to a peer such that it can be used later to recover the information.

Errors may be ignored or result in an EventIds.IO_ERROR event.

The action will bypass execution if no StateDataContext exists or if StateDataContext.getStateToken() is non-nul or StateDataContext.getStateData() is null.

The default implementation simply generates the token and stores it to the context. Subclasses may override the processToken(ProfileRequestContext,String) action to perform protocol-specific processing of the token.

Event:
EventIds.PROCEED_EVENT_ID, EventIds.INVALID_MESSAGE, EventIds.IO_ERROR
Precondition:
AgentRequestContext.getOutput().isstruct()
,
AgentRequestContext.getRemotedServletResponse() != null
Postcondition:
ProfileRequestContext.getSubcontext(StateDataContext.class) == null or ProfileRequestContext.getSubcontext(StateDataContext.class).getStateData() == null or ProfileRequestContext.getSubcontext(StateDataContext.class).getStateToken() != null
  • Field Details

  • Constructor Details

    • PreserveStateDataAction

      public PreserveStateDataAction()
      Constructor.
  • Method Details

    • setStateDataContextLookupStrategy

      public void setStateDataContextLookupStrategy(@Nonnull Function<ProfileRequestContext,StateDataContext> strategy)
      Sets the strategy used to lookup the StateDataContext.
      Parameters:
      strategy - lookup strategy
    • setErrorFatal

      public void setErrorFatal(boolean flag)
      Sets whether an error computing a state token should result in a fatal event.

      Defaults to false.

      Parameters:
      flag - flag to set
    • doPreExecute

      protected boolean doPreExecute(@Nonnull ProfileRequestContext profileRequestContext)
      Overrides:
      doPreExecute in class AbstractApplicationAction
    • doExecute

      protected void doExecute(@Nonnull ProfileRequestContext profileRequestContext)
      Overrides:
      doExecute in class AbstractProfileAction
    • processToken

      protected void processToken(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull @NotEmpty String token)
      Perform additional processing on the generated state token as required by a particular protocol.

      The default implementation is a no-op.

      Parameters:
      profileRequestContext - profile request context
      token - state token