Package org.opensaml.storage
Class ReplayCache
- All Implemented Interfaces:
Component,DestructableComponent,IdentifiableComponent,IdentifiedComponent,InitializableComponent
Tracks non-replayable values in order to detect replays of the values, commonly used to track message identifiers.
This class is thread-safe and uses a synchronized method to prevent race conditions within the underlying store (lacking an atomic "check and insert" operation).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringDigesterDigester if key is too long.private final org.slf4j.LoggerLogger.private StorageServiceBacking storage for the replay cache.private booleanFlag controlling behavior on storage failure. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns true iff the check value is not found in the cache, and stores it.voidGet the backing store for the cache.booleanisStrict()Get the strictness flag.voidsetStorage(StorageService storageService) Set the backing store for the cache.voidsetStrict(boolean flag) Set the strictness flag.Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent
setIdMethods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
getIdMethods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, doDestroy, initialize, isDestroyed, isInitializedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.shibboleth.utilities.java.support.component.IdentifiedComponent
getId
-
Field Details
-
log
private final org.slf4j.Logger logLogger. -
storage
Backing storage for the replay cache. -
digester
Digester if key is too long. -
strict
private boolean strictFlag controlling behavior on storage failure.
-
-
Constructor Details
-
ReplayCache
public ReplayCache()
-
-
Method Details
-
getStorage
Get the backing store for the cache.- Returns:
- the backing store.
-
setStorage
Set the backing store for the cache.- Parameters:
storageService- backing store to use
-
isStrict
public boolean isStrict()Get the strictness flag.- Returns:
- true iff we should treat storage failures as a replay
-
setStrict
public void setStrict(boolean flag) Set the strictness flag.- Parameters:
flag- true iff we should treat storage failures as a replay
-
doInitialize
- Overrides:
doInitializein classAbstractIdentifiedInitializableComponent- Throws:
ComponentInitializationException
-
check
public boolean check(@Nonnull @NotEmpty String context, @Nonnull @NotEmpty String s, @Nonnull Instant expires) Returns true iff the check value is not found in the cache, and stores it.- Parameters:
context- a context label to subdivide the caches- value to checkexpires- time for disposal of value from cache- Returns:
- true iff the check value is not found in the cache
-