public class ServletRequestScopedStorageService extends AbstractMapBackedStorageService implements RequestScopedStorageService, 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 | 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 |
|---|---|
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 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 |
|---|---|
boolean |
create(String context,
String key,
String value,
Long expiration) |
void |
deleteContext(String context) |
protected boolean |
deleteImpl(Long version,
String context,
String key) |
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) |
private boolean |
isDirty()
Get the dirty bit for the current request.
|
protected void |
load()
Reconstitute stored data.
|
void |
reap(String context) |
protected void |
save()
Write/preserve stored data for subsequent requests.
|
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. |
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. |
void |
updateContextExpiration(String context,
Long expiration) |
protected Long |
updateImpl(Long version,
String context,
String key,
String value,
Long expiration) |
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
@Nonnull @NotEmpty private static final String DEFAULT_COOKIE_NAME
@Nonnull private static final ReadWriteLock DUMMY_LOCK
@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 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 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 AbstractMapBackedStorageServiceIOExceptionpublic void updateContextExpiration(@Nonnull@NotEmpty String context, @Nullable Long expiration) throws IOException
updateContextExpiration in interface StorageServiceupdateContextExpiration in class AbstractMapBackedStorageServiceIOExceptionpublic void deleteContext(@Nonnull@NotEmpty String context) throws IOException
deleteContext in interface StorageServicedeleteContext in class AbstractMapBackedStorageServiceIOExceptionpublic void reap(@Nonnull@NotEmpty String context) throws IOException
reap in interface StorageServicereap in class AbstractMapBackedStorageServiceIOExceptionpublic 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 AbstractMapBackedStorageServiceIOExceptionVersionMismatchExceptionprotected boolean deleteImpl(@Nullable@Positive Long version, @Nonnull@NotEmpty String context, @Nonnull@NotEmpty String key) throws IOException, VersionMismatchException
deleteImpl 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 AbstractMapBackedStorageServiceprivate void setDirty(boolean flag)
flag - dirty bit to setprivate boolean isDirty()
Copyright © 1999–2015. All rights reserved.