Package net.shibboleth.sp.state.impl
Class CookieStateManager
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.CookieStateManager
- All Implemented Interfaces:
Component,DestructableComponent,IdentifiableComponent,IdentifiedComponent,InitializableComponent,StateManager
StateManager implemented by storing the data directly into a cookie.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate CookieManagerCookie manager.private StringFixed prefix for cookie names.static StringDefault cookie prefix.private org.slf4j.LoggerClass logger. -
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.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.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. -
cookieManager
Cookie manager. -
cookiePrefix
Fixed prefix for cookie names.
-
-
Constructor Details
-
CookieStateManager
public CookieStateManager()Constructor.
-
-
Method Details
-
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
-
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
-