public class ServletRequestScopedStorageService extends AbstractMapBackedStorageService implements RequestScopedStorageService, javax.servlet.Filter
RequestScopedStorageService that stores data in-memory in a servlet request attribute,
and reads and writes the data with a secured string form using JSON as the underlying format.| Modifier and Type | Field and Description |
|---|---|
protected static String |
CONTEXT_MAP_ATTRIBUTE
Name of request attribute for context map.
|
protected static String |
DIRTY_BIT_ATTRIBUTE
Name of request attribute used as a dirty bit.
|
| Constructor and Description |
|---|
ServletRequestScopedStorageService()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
create(String context,
String key,
String value,
Long expiration)
Creates a new record in the store with an expiration.
|
void |
deleteContext(String context)
Forcibly removes all records in a given context along with any
associated resources devoted to maintaining the context.
|
protected boolean |
deleteImpl(Long version,
String context,
String key)
Internal method to implement delete functions.
|
void |
doFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
javax.servlet.FilterChain chain) |
protected void |
doInitialize() |
protected TimerTask |
getCleanupTask()
Returns a cleanup task function to schedule for background cleanup.
|
protected Map<String,Map<String,MutableStorageRecord>> |
getContextMap()
Get the map of contexts to manipulate during operations.
|
String |
getCookieName()
Get the cookie name to use for storage tracking.
|
protected ReadWriteLock |
getLock()
Get the shared lock to synchronize access.
|
void |
init(javax.servlet.FilterConfig filterConfig) |
protected void |
load()
Reconstitute stored data.
|
void |
reap(String context)
Manually trigger a cleanup of expired records.
|
protected void |
save()
Write/preserve stored data for subsequent requests.
|
void |
setCleanupInterval(long interval)
Sets the number of milliseconds between one cleanup and another.
|
void |
setCookieManager(net.shibboleth.utilities.java.support.net.CookieManager manager)
Set the
CookieManager to use. |
void |
setCookieName(String name)
Set the cookie name to use for storage tracking.
|
void |
setDataSealer(net.shibboleth.utilities.java.support.security.DataSealer sealer)
Set the
DataSealer to use for data security. |
void |
setHttpServletRequest(javax.servlet.http.HttpServletRequest request)
Set the servlet request in which to manage per-request data.
|
void |
setHttpServletResponse(javax.servlet.http.HttpServletResponse response)
Set the servlet response in which to manage per-request data.
|
void |
setKeyStrategy(net.shibboleth.utilities.java.support.security.DataSealerKeyStrategy strategy)
Set the
DataSealerKeyStrategy to use for stale key detection. |
void |
updateContextExpiration(String context,
Long expiration)
Updates the expiration time of all records in the context.
|
protected Long |
updateImpl(Long version,
String context,
String key,
String value,
Long expiration)
Internal method to implement update functions.
|
delete, deleteWithVersion, read, read, readImpl, reapWithLock, update, updateExpiration, updateWithVersioncreate, create, delete, deleteWithVersion, doDestroy, getCapabilities, getCleanupInterval, getCleanupTaskTimer, getContextSize, getKeySize, getValueSize, read, setCleanupTaskTimer, setContextSize, setKeySize, setValueSize, update, update, updateExpiration, updateWithVersion, updateWithVersionsetIdgetIddestroy, initialize, isDestroyed, isInitializedclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreate, create, delete, delete, deleteWithVersion, deleteWithVersion, getCapabilities, read, read, read, update, update, update, updateExpiration, updateExpiration, updateWithVersion, updateWithVersion, updateWithVersion@Nonnull protected static final String CONTEXT_MAP_ATTRIBUTE
@Nonnull protected static final String DIRTY_BIT_ATTRIBUTE
public ServletRequestScopedStorageService()
public void setCleanupInterval(long interval)
setCleanupInterval in class AbstractStorageServiceinterval - number of milliseconds between one cleanup and anotherpublic void setHttpServletRequest(@Nonnull javax.servlet.http.HttpServletRequest request)
request - servlet request in which to manage datapublic void setHttpServletResponse(@Nonnull javax.servlet.http.HttpServletResponse response)
response - servlet response in which to manage datapublic void setCookieManager(@Nonnull net.shibboleth.utilities.java.support.net.CookieManager manager)
CookieManager to use.manager - the CookieManager to use.@Nonnull @NotEmpty public String getCookieName()
public void setCookieName(@Nonnull @NotEmpty String name)
name - cookie name to usepublic void setDataSealer(@Nonnull net.shibboleth.utilities.java.support.security.DataSealer sealer)
DataSealer to use for data security.sealer - DataSealer to use for data securitypublic void setKeyStrategy(@Nonnull net.shibboleth.utilities.java.support.security.DataSealerKeyStrategy strategy)
DataSealerKeyStrategy to use for stale key detection.strategy - DataSealerKeyStrategy to use for stale key detectionprotected void doInitialize()
throws net.shibboleth.utilities.java.support.component.ComponentInitializationException
doInitialize in class AbstractStorageServicenet.shibboleth.utilities.java.support.component.ComponentInitializationExceptionpublic boolean create(@Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key, @Nonnull @NotEmpty String value, @Nullable Long expiration) throws IOException
create in interface StorageServicecreate in class AbstractMapBackedStorageServicecontext - a storage context labelkey - a key unique to contextvalue - value to storeexpiration - expiration for record, or nullIOException - if fatal errors occur in the insertion processpublic void updateContextExpiration(@Nonnull @NotEmpty String context, @Nullable Long expiration) throws IOException
updateContextExpiration in interface StorageServiceupdateContextExpiration in class AbstractMapBackedStorageServicecontext - a storage context labelexpiration - a new expiration timestamp, or nullIOException - if errors occur in the cleanup processpublic void deleteContext(@Nonnull @NotEmpty String context) throws IOException
deleteContext in interface StorageServicedeleteContext in class AbstractMapBackedStorageServicecontext - a storage context labelIOException - if errors occur in the cleanup processpublic void reap(@Nonnull @NotEmpty String context) throws IOException
reap in interface StorageServicereap in class AbstractMapBackedStorageServicecontext - a storage context labelIOException - if errors occur in the cleanup processpublic void init(javax.servlet.FilterConfig filterConfig)
throws javax.servlet.ServletException
init in interface javax.servlet.Filterjavax.servlet.ServletExceptionpublic void doFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
javax.servlet.FilterChain chain)
throws IOException,
javax.servlet.ServletException
doFilter in interface javax.servlet.FilterIOExceptionjavax.servlet.ServletExceptionprotected void load()
throws IOException
IOException - if an error occurs reconstituting the data@Nullable protected void save() throws IOException
IOException - if an error occurs preserving the data@Nullable protected Long updateImpl(@Nullable Long version, @Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key, @Nullable String value, @Nullable Long expiration) throws IOException, VersionMismatchException
updateImpl in class AbstractMapBackedStorageServiceversion - only update if the current version matches this valuecontext - a storage context labelkey - a key unique to contextvalue - updated valueexpiration - expiration for record. or nullIOException - if errors occur in the update processVersionMismatchException - if the record has already been updated to a newer versionprotected boolean deleteImpl(@Nullable @Positive Long version, @Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key) throws IOException, VersionMismatchException
deleteImpl in class AbstractMapBackedStorageServiceversion - only update if the current version matches this valuecontext - a storage context labelkey - a key unique to contextIOException - if errors occur in the update processVersionMismatchException - if the record has already been updated to a newer version@Nullable protected TimerTask getCleanupTask()
The default implementation does not supply one.
getCleanupTask in class AbstractStorageService@Nonnull @NonnullElements @Live protected Map<String,Map<String,MutableStorageRecord>> getContextMap()
getContextMap in class AbstractMapBackedStorageService@Nonnull protected ReadWriteLock getLock()
getLock in class AbstractMapBackedStorageServiceCopyright © 2021. All rights reserved.