Package org.opensaml.storage
Class RevocationCache
- All Implemented Interfaces:
Component,DestructableComponent,IdentifiableComponent,IdentifiedComponent,InitializableComponent
@ThreadSafeAfterInit
public class RevocationCache
extends AbstractIdentifiableInitializableComponent
Stores and checks for revocation entries.
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).
- Since:
- 4.2.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidgetRevocationRecord(String context, String s) Attempts to read back a revocation record for a given context and key.Get the backing store for the cache.booleanReturns true iff the value has been revoked.booleanisStrict()Get the strictness flag.booleanInvokesrevoke(String, String, Duration)with a default expiration parameter.booleanInvokesrevoke(String, String, String, Duration)with a default expiration parameter.booleanReturns true if the value is successfully revoked.booleanInvokesrevoke(String, String, String, Duration)with a placeholder value parameter.voidsetEntryExpiration(Duration entryExpiration) Set the default revocation entry expiration.voidsetStorage(StorageService storageService) Set the backing store for the cache.voidsetStrict(boolean flag) Set the strictness flag.booleanRemove a revocation record.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
@Nonnull private final org.slf4j.Logger logLogger. -
storage
Backing storage for the replay cache. -
strict
private boolean strictFlag controlling behavior on storage failure. -
expires
Default lifetime of revocation entry. Default value: 6 hours
-
-
Constructor Details
-
RevocationCache
public RevocationCache()Constructor.
-
-
Method Details
-
setEntryExpiration
Set the default revocation entry expiration.- Parameters:
entryExpiration- lifetime of an revocation entry in milliseconds
-
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 revocation
-
setStrict
public void setStrict(boolean flag) Set the strictness flag.- Parameters:
flag- true iff we should treat storage failures as a revocation
-
doInitialize
- Overrides:
doInitializein classAbstractIdentifiedInitializableComponent- Throws:
ComponentInitializationException
-
revoke
Invokesrevoke(String, String, Duration)with a default expiration parameter.- Parameters:
context- a context label to subdivide the cachekey- key to revoke- Returns:
- true if key has successfully been listed as revoked in the cache
-
revoke
public boolean revoke(@Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key, @Nonnull Duration exp) Invokesrevoke(String, String, String, Duration)with a placeholder value parameter.- Parameters:
context- a context label to subdivide the cachekey- key to revokeexp- entry expiration- Returns:
- true if key has successfully been listed as revoked in the cache
- Since:
- 4.3.0
-
revoke
public boolean revoke(@Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key, @Nonnull @NotEmpty String value) Invokesrevoke(String, String, String, Duration)with a default expiration parameter.If the key has already been revoked, expiration is updated.
- Parameters:
context- a context label to subdivide the cachekey- key to revokevalue- value to insert into revocation record- Returns:
- true if key has successfully been listed as revoked in the cache
- Since:
- 4.3.0
-
revoke
public boolean revoke(@Nonnull @NotEmpty String context, @Nonnull @NotEmpty String s, @Nonnull @NotEmpty String value, @Nonnull Duration exp) Returns true if the value is successfully revoked.If the key has already been revoked, expiration is updated.
- Parameters:
context- a context label to subdivide the caches- key to revokevalue- value to insert into revocation recordexp- entry expiration- Returns:
- true if key has successfully been listed as revoked in the cache
- Since:
- 4.3.0
-
unrevoke
Remove a revocation record.- Parameters:
context- a context label to subdivide the caches- value to remove- Returns:
- true iff a record was removed
- Since:
- 4.3.0
-
isRevoked
Returns true iff the value has been revoked.- Parameters:
context- a context label to subdivide the caches- value to check- Returns:
- true iff the check value is found in the cache
-
getRevocationRecord
@Nullable @NotEmpty public String getRevocationRecord(@Nonnull @NotEmpty String context, @Nonnull @NotEmpty String s) throws IOException Attempts to read back a revocation record for a given context and key.This alternative approach allows revocation records to include richer data, rather than simple presence/absence as a signal.
- Parameters:
context- revocation contexts- revocation key- Returns:
- the matching record, if found, or null if absent
- Throws:
IOException- raised if an error occurs leading to an indeterminate result- Since:
- 4.3.0
-