public class ServletRequestScopedStorageService extends AbstractMapBackedStorageService implements RequestScopedStorageService, 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 net.shibboleth.utilities.java.support.net.CookieManager |
cookieManager
Manages creation of cookies.
|
private String |
cookieName
Name of cookie used to track storage.
|
private net.shibboleth.utilities.java.support.security.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 Escaper |
escaper
URL encoder.
|
private HttpServletRequest |
httpServletRequest
Servlet request.
|
private HttpServletResponse |
httpServletResponse
Servlet response.
|
private net.shibboleth.utilities.java.support.security.DataSealerKeyStrategy |
keyStrategy
KeyStrategy enabling us to detect whether data has been sealed with an older key.
|
private Logger |
log
Class logger.
|
| Constructor and Description |
|---|
ServletRequestScopedStorageService()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
doFilter(ServletRequest request,
ServletResponse response,
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(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(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 |
setDirty() |
private void |
setDirty(boolean flag)
Set the dirty bit for the current request.
|
void |
setHttpServletRequest(HttpServletRequest request)
Set the servlet request in which to manage per-request data.
|
void |
setHttpServletResponse(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. |
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
private int capabilitySize
@NonnullAfterInit private HttpServletRequest httpServletRequest
@NonnullAfterInit private HttpServletResponse httpServletResponse
@NonnullAfterInit private net.shibboleth.utilities.java.support.net.CookieManager cookieManager
@NonnullAfterInit private net.shibboleth.utilities.java.support.security.DataSealer dataSealer
@Nullable private net.shibboleth.utilities.java.support.security.DataSealerKeyStrategy keyStrategy
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 HttpServletRequest request)
request - servlet request in which to manage datapublic void setHttpServletResponse(@Nonnull 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 detectionpublic boolean isServerSide()
isServerSide in interface StorageCapabilitiesExpublic boolean isClustered()
isClustered in interface StorageCapabilitiesExprotected void doInitialize()
throws net.shibboleth.utilities.java.support.component.ComponentInitializationException
doInitialize in class AbstractStorageServicenet.shibboleth.utilities.java.support.component.ComponentInitializationExceptionpublic void init(FilterConfig filterConfig) throws ServletException
init in interface FilterServletExceptionpublic void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
doFilter in interface FilterIOExceptionServletExceptionprotected 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–2016 Shibboleth Consortium. All rights reserved.