public class ServletRequestScopedStorageService extends AbstractMapBackedStorageService implements RequestScopedStorageService, javax.servlet.Filter, StorageCapabilitiesEx
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 | Class and Description |
|---|---|
private static class |
ServletRequestScopedStorageService.DummyReadWriteLock
Dummy shared lock that no-ops.
|
private class |
ServletRequestScopedStorageService.OutputInterceptingHttpServletResponseProxy
An implementation of
HttpServletResponse which detects a response going out
from a servlet and executes a save operation. |
| Modifier and Type | Field and Description |
|---|---|
private int |
capabilitySize
Size to report for context, key, and value limits.
|
protected static String |
CONTEXT_MAP_ATTRIBUTE
Name of request attribute for context map.
|
private CookieManager |
cookieManager
Manages creation of cookies.
|
private String |
cookieName
Name of cookie used to track storage.
|
private DataSealer |
dataSealer
DataSealer instance to secure data.
|
private static String |
DEFAULT_COOKIE_NAME
Default cookie name for storage tracking.
|
protected static String |
DIRTY_BIT_ATTRIBUTE
Name of request attribute used as a dirty bit.
|
private static ReadWriteLock |
DUMMY_LOCK
A dummy lock implementation.
|
private com.google.common.escape.Escaper |
escaper
URL encoder.
|
private javax.servlet.http.HttpServletRequest |
httpServletRequest
Servlet request.
|
private javax.servlet.http.HttpServletResponse |
httpServletResponse
Servlet response.
|
private DataSealerKeyStrategy |
keyStrategy
KeyStrategy enabling us to detect whether data has been sealed with an older key.
|
private org.slf4j.Logger |
log
Class logger.
|
| Constructor and Description |
|---|
ServletRequestScopedStorageService()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
doFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
javax.servlet.FilterChain chain) |
protected void |
doInitialize() |
protected TimerTask |
getCleanupTask() |
protected Map<String,Map<String,MutableStorageRecord>> |
getContextMap() |
String |
getCookieName()
Get the cookie name to use for storage tracking.
|
protected ReadWriteLock |
getLock() |
void |
init(javax.servlet.FilterConfig filterConfig) |
boolean |
isClustered() |
private boolean |
isDirty()
Get the dirty bit for the current request.
|
boolean |
isServerSide() |
protected void |
load()
Reconstitute stored data.
|
protected void |
save()
Write/preserve stored data for subsequent requests.
|
void |
setCapabilitySize(int size)
Set the size to report via the
StorageCapabilities interface for
context, key, and value maximums. |
void |
setCleanupInterval(long interval) |
void |
setCookieManager(CookieManager manager)
Set the
CookieManager to use. |
void |
setCookieName(String name)
Set the cookie name to use for storage tracking.
|
void |
setDataSealer(DataSealer sealer)
Set the
DataSealer to use for data security. |
void |
setDirty() |
private void |
setDirty(boolean flag)
Set the dirty bit for the current request.
|
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(DataSealerKeyStrategy strategy)
Set the
DataSealerKeyStrategy to use for stale key detection. |
protected Long |
updateImpl(Long version,
String context,
String key,
String value,
Long expiration) |
create, delete, deleteContext, deleteImpl, deleteWithVersion, read, read, readImpl, reap, reapWithLock, update, updateContextExpiration, 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, create, delete, delete, deleteContext, deleteWithVersion, deleteWithVersion, getCapabilities, read, read, read, reap, update, update, update, updateContextExpiration, updateExpiration, updateExpiration, updateWithVersion, updateWithVersion, updateWithVersiongetIdgetContextSize, getKeySize, getValueSize@Nonnull protected static final String CONTEXT_MAP_ATTRIBUTE
@Nonnull protected static final String DIRTY_BIT_ATTRIBUTE
@Nonnull @NotEmpty private static final String DEFAULT_COOKIE_NAME
@Nonnull private static final ReadWriteLock DUMMY_LOCK
@Nonnull private final org.slf4j.Logger log
private int capabilitySize
@NonnullAfterInit private javax.servlet.http.HttpServletRequest httpServletRequest
@NonnullAfterInit private javax.servlet.http.HttpServletResponse httpServletResponse
@NonnullAfterInit private CookieManager cookieManager
@NonnullAfterInit private DataSealer dataSealer
@Nullable private DataSealerKeyStrategy keyStrategy
@Nonnull private com.google.common.escape.Escaper escaper
public ServletRequestScopedStorageService()
public void setCleanupInterval(long interval)
setCleanupInterval in class AbstractStorageServicepublic void setCapabilitySize(int size)
StorageCapabilities interface for
context, key, and value maximums.
Defaults to 4096 to reflect the limitations of cookies on Safari.
size - size in characters to reportpublic 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 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 DataSealer sealer)
DataSealer to use for data security.sealer - DataSealer to use for data securitypublic void setKeyStrategy(@Nonnull DataSealerKeyStrategy strategy)
DataSealerKeyStrategy to use for stale key detection.strategy - DataSealerKeyStrategy to use for stale key detectionpublic boolean isServerSide()
isServerSide in interface StorageCapabilitiesExpublic boolean isClustered()
isClustered in interface StorageCapabilitiesExprotected void doInitialize()
throws ComponentInitializationException
doInitialize in class AbstractStorageServiceComponentInitializationExceptionpublic 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 AbstractMapBackedStorageServiceIOExceptionVersionMismatchException@Nullable protected TimerTask getCleanupTask()
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 AbstractMapBackedStorageServicepublic void setDirty()
setDirty in class AbstractMapBackedStorageServiceprivate void setDirty(boolean flag)
flag - dirty bit to setprivate boolean isDirty()
Copyright © 1999–2019 Shibboleth Consortium. All rights reserved.