Interface StateManager

All Known Implementing Classes:
AbstractStateManager, CookieStateManager, PassthroughStateManager, StorageServiceStateManager

public interface StateManager
Interface to a service that manages "state" tokens, used in most SSO protocols to manage stateful request/response correlation and to limit exposure of the resource URLs accessed by clients to allow recovery of the URL for final redirection.

SAML refers to this notion as RelayState, while OpenID Connect just refers to it as state.

There are multiple possible implementations of this concept, all involving cookies to provide CSRF protection.

  • Method Details

    • preserveToStateToken

      @Nonnull String preserveToStateToken(@Nonnull Agent agent, @Nonnull Application application, @Nonnull StateData data) throws IOException
      Preserves data while transforming it into a state token.
      Parameters:
      agent - agent owning the state
      application - application owning the state
      data - data to preserve
      Returns:
      state token representing value
      Throws:
      IOException - if creation of token fails
    • recoverFromStateToken

      @Nullable <T extends StateData> T recoverFromStateToken(@Nonnull Agent agent, @Nonnull Application application, @Nonnull String token, @Nonnull Class<T> type) throws IOException
      Recovers stored data from a state token.

      In most implementations, the state token mapping should be cleared on successful use of this method.

      Type Parameters:
      T - type of state
      Parameters:
      agent - agent owning the state
      application - application owning the state
      token - state token
      type - specific subtype of StateData to recover
      Returns:
      the recovered data, or null if unable to recover without underlying cause
      Throws:
      IOException - if recovery from token fails