public class ClientStorageService extends AbstractMapBackedStorageService implements Filter, StorageCapabilitiesEx
StorageService that stores data in-memory in a shared session attribute.
The data for this service is managed in a ClientStorageService.ClientStorageServiceStore object, which must
be created by some operation within the container for this implementation to function. Actual
load/store of the data to/from that object is driven via companion classes. The serialization
of data via JSON is inside the storage object class, but the encryption/decryption is here.
| Modifier and Type | Class and Description |
|---|---|
class |
ClientStorageService.ClientStorageServiceStore
Implements a session-bound backing store and locking mechanism for the
ClientStorageService. |
static class |
ClientStorageService.ClientStorageSource
Enumeration of possible sources for the data.
|
| Modifier and Type | Field and Description |
|---|---|
private Map<ClientStorageService.ClientStorageSource,Integer> |
capabilityMap
Sizes to report for context, key, and value limits when particular sources are used.
|
private net.shibboleth.utilities.java.support.net.CookieManager |
cookieManager
Manages creation of cookies.
|
private net.shibboleth.utilities.java.support.security.DataSealer |
dataSealer
DataSealer instance to secure data.
|
private static String |
DEFAULT_STORAGE_NAME
Default label for storage tracking.
|
private HttpServletRequest |
httpServletRequest
Servlet request.
|
private net.shibboleth.utilities.java.support.security.DataSealerKeyStrategy |
keyStrategy
KeyStrategy enabling us to detect whether data has been sealed with an older key.
|
protected static String |
LOCK_ATTRIBUTE
Name of session attribute for session lock.
|
private Logger |
log
Class logger.
|
protected static String |
STORAGE_ATTRIBUTE
Name of session attribute for storage object.
|
private String |
storageName
Label used to track storage.
|
| Constructor and Description |
|---|
ClientStorageService()
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() |
int |
getContextSize() |
net.shibboleth.utilities.java.support.net.CookieManager |
getCookieManager()
Get the
CookieManager to use. |
int |
getKeySize() |
protected ReadWriteLock |
getLock() |
private String |
getLogPrefix()
Get a prefix for log messages.
|
(package private) ClientStorageService.ClientStorageSource |
getSource()
Get the backing source of the loaded data.
|
String |
getStorageName()
Get the label to use for storage tracking.
|
long |
getValueSize() |
void |
init(FilterConfig filterConfig) |
boolean |
isClustered() |
(package private) boolean |
isLoaded()
Check whether data from the client has been loaded into the current session.
|
boolean |
isServerSide() |
(package private) void |
load(String raw,
ClientStorageService.ClientStorageSource source)
Reconstitute stored data and inject it into the session.
|
(package private) ClientStorageServiceOperation |
save()
Serialize the stored data if it's in a "modified/dirty" state.
|
void |
setCapabilityMap(Map<ClientStorageService.ClientStorageSource,Integer> map)
Set the map of storage sources to capability/size limits.
|
void |
setCleanupInterval(long interval) |
void |
setCookieManager(net.shibboleth.utilities.java.support.net.CookieManager manager)
Set the
CookieManager to use. |
void |
setDataSealer(net.shibboleth.utilities.java.support.security.DataSealer sealer)
Set the
DataSealer to use for data security. |
protected void |
setDirty() |
void |
setHttpServletRequest(HttpServletRequest request)
Set the servlet request 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 |
setStorageName(String name)
Set the label to use for storage tracking.
|
create, delete, deleteContext, deleteImpl, deleteWithVersion, read, read, readImpl, reap, reapWithLock, update, updateContextExpiration, updateExpiration, updateImpl, updateWithVersioncreate, create, delete, deleteWithVersion, doDestroy, getCapabilities, getCleanupInterval, getCleanupTaskTimer, read, setCleanupTaskTimer, setContextSize, setKeySize, setValueSize, update, update, updateExpiration, updateWithVersion, updateWithVersionsetIdgetIddestroy, initialize, isDestroyed, isInitialized@Nonnull protected static final String LOCK_ATTRIBUTE
@Nonnull protected static final String STORAGE_ATTRIBUTE
@Nonnull @NotEmpty private static final String DEFAULT_STORAGE_NAME
@Nonnull @NotEmpty private Map<ClientStorageService.ClientStorageSource,Integer> capabilityMap
@NonnullAfterInit private HttpServletRequest httpServletRequest
@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 void setCleanupInterval(long interval)
setCleanupInterval in class AbstractStorageServicepublic void setCapabilityMap(@Nonnull@NonnullElements Map<ClientStorageService.ClientStorageSource,Integer> map)
The defaults include 4192 characters for cookies and 1024^2 characters for local storage.
map - capability mappublic boolean isServerSide()
isServerSide in interface StorageCapabilitiesExpublic boolean isClustered()
isClustered in interface StorageCapabilitiesExpublic void setHttpServletRequest(@Nonnull HttpServletRequest request)
request - servlet request in which to manage data@NonnullAfterInit public net.shibboleth.utilities.java.support.net.CookieManager getCookieManager()
CookieManager to use.public void setCookieManager(@Nonnull net.shibboleth.utilities.java.support.net.CookieManager manager)
CookieManager to use.manager - the CookieManager to use.@Nonnull @NotEmpty public String getStorageName()
public void setStorageName(@Nonnull@NotEmpty String name)
name - label 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(@Nullable net.shibboleth.utilities.java.support.security.DataSealerKeyStrategy strategy)
DataSealerKeyStrategy to use for stale key detection.strategy - DataSealerKeyStrategy to use for stale key detectionpublic void init(FilterConfig filterConfig) throws ServletException
init in interface FilterServletExceptionpublic void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
doFilter in interface FilterIOExceptionServletExceptionpublic int getContextSize()
getContextSize in interface StorageCapabilitiesgetContextSize in class AbstractStorageServicepublic int getKeySize()
getKeySize in interface StorageCapabilitiesgetKeySize in class AbstractStorageServicepublic long getValueSize()
getValueSize in interface StorageCapabilitiesgetValueSize in class AbstractStorageServiceprotected void doInitialize()
throws net.shibboleth.utilities.java.support.component.ComponentInitializationException
doInitialize in class AbstractStorageServicenet.shibboleth.utilities.java.support.component.ComponentInitializationException@Nullable protected TimerTask getCleanupTask()
getCleanupTask in class AbstractStorageService@Nonnull protected ReadWriteLock getLock()
getLock in class AbstractMapBackedStorageService@Nonnull @NonnullElements @Live protected Map<String,Map<String,MutableStorageRecord>> getContextMap()
getContextMap in class AbstractMapBackedStorageServiceprotected void setDirty()
setDirty in class AbstractMapBackedStorageService@Nonnull ClientStorageService.ClientStorageSource getSource()
This method should not be called while holding the session lock
returned by getLock().
boolean isLoaded()
This method should not be called while holding the session lock
returned by getLock().
HttpSession contains a storage objectvoid load(@Nullable@NotEmpty String raw, @Nonnull ClientStorageService.ClientStorageSource source)
This method should not be called while holding the session lock
returned by getLock().
raw - encrypted data to load as storage contents, or null if nonesource - indicates source of the data for later use@Nullable ClientStorageServiceOperation save()
This method should not be called while holding the session lock
returned by getLock().
Copyright © 1999–2016 Shibboleth Consortium. All rights reserved.