Package net.shibboleth.sp.state.impl
Class StorageServiceStateManager
java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
net.shibboleth.sp.state.AbstractStateManager
net.shibboleth.sp.state.impl.StorageServiceStateManager
- All Implemented Interfaces:
Component,DestructableComponent,IdentifiableComponent,IdentifiedComponent,InitializableComponent,StateManager
StateManager implemented with a StorageService and an optional CSRF-mitigation cookie.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate CookieManagerCookie manager.private StringFixed prefix for cookie names.static StringDefault cookie prefix.private org.slf4j.LoggerClass logger.private StorageServiceStorage back-end. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected StringdoPreserve(Agent agent, Application application, String data, boolean sealed) Subclasses implement this method to preserve the transformed data in whatever way is necessary and return a token.protected StringdoRecover(Agent agent, Application application, String stateToken, boolean sealed) Subclasses implement this method to recover the stored data in whatever way is necessary and return the supplied data string as a successful result.private StringgetContext(Agent agent, Application application) Compute the storage context to use.getCookieName(Application application, String uniquePortion) Computes the name of a new state cookie.voidsetCookieManager(CookieManager manager) Set theCookieManagerto use.voidsetCookiePrefix(String prefix) Set the fixed prefix to use for the cookies.voidsetStorageService(StorageService storage) SetStorageServiceto use.Methods inherited from class net.shibboleth.sp.state.AbstractStateManager
generateToken, getClientAddress, getDataSealer, getExpiration, getIdentifierGenerationStrategy, getReplayCache, preserveToStateToken, recoverFromStateToken, setDataSealer, setExpiration, setHttpServletRequestSupplier, setIdentifierGenerationStrategy, setObjectMapper, setPrefix, setReplayCacheMethods inherited from class net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
setIdMethods inherited from class net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
ensureId, getId, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentExceptionMethods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, doDestroy, initialize, isDestroyed, isInitializedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.shibboleth.shared.component.IdentifiedComponent
getId
-
Field Details
-
DEFAULT_PREFIX
Default cookie prefix. -
log
@Nonnull private org.slf4j.Logger logClass logger. -
storageService
Storage back-end. -
cookieManager
Cookie manager. -
cookiePrefix
Fixed prefix for cookie names.
-
-
Constructor Details
-
StorageServiceStateManager
public StorageServiceStateManager()Constructor.
-
-
Method Details
-
setStorageService
SetStorageServiceto use.- Parameters:
storage- storage service
-
setCookiePrefix
Set the fixed prefix to use for the cookies.Defaults to "_shibsp_state".
- Parameters:
prefix- cookie prefix
-
doInitialize
- Overrides:
doInitializein classAbstractStateManager- Throws:
ComponentInitializationException
-
doPreserve
@Nonnull protected String doPreserve(@Nonnull Agent agent, @Nonnull Application application, @Nonnull String data, boolean sealed) throws IOException Subclasses implement this method to preserve the transformed data in whatever way is necessary and return a token.- Specified by:
doPreservein classAbstractStateManager- Parameters:
agent- agent owning the stateapplication- application owning the statedata- data to preservesealed- whether the data was sealed (and thus base64-encoded)- Returns:
- the state token
- Throws:
IOException- if an error occurs
-
doRecover
@Nullable protected String doRecover(@Nonnull Agent agent, @Nonnull Application application, @Nonnull @NotEmpty String stateToken, boolean sealed) throws IOException Subclasses implement this method to recover the stored data in whatever way is necessary and return the supplied data string as a successful result.The implementation should ensure when possible that this method works only once for a given state token.
Subclasses may assume that the state token inputs they receive will have been returned by them via the
AbstractStateManager.doPreserve(Agent, Application, String, boolean)method.- Specified by:
doRecoverin classAbstractStateManager- Parameters:
agent- agent owning the stateapplication- application owning the statestateToken- the state token to map from/clearsealed- whether the data was sealed (and thus base64-encoded)- Returns:
- the recovered data, or null if unable to recover without underlying cause
- Throws:
IOException- if an error occurs
-
getContext
Compute the storage context to use.- Parameters:
agent- calling agentapplication- calling application- Returns:
- storage context for request
-
getCookieName
@Nonnull public String getCookieName(@Nonnull Application application, @Nonnull String uniquePortion) Computes the name of a new state cookie.- Parameters:
application- the applicationuniquePortion- unique portion of name- Returns:
- cookie name
-