Package org.apache.wss4j.common.cache
Class MemoryReplayCache
- java.lang.Object
-
- org.apache.wss4j.common.cache.MemoryReplayCache
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,ReplayCache
public class MemoryReplayCache extends Object implements ReplayCache
A simple in-memory HashSet based cache to prevent against replay attacks. The default TTL is 5 minutes and the max TTL is 60 minutes.
-
-
Field Summary
Fields Modifier and Type Field Description static long
DEFAULT_TTL
static long
MAX_TTL
-
Constructor Summary
Constructors Constructor Description MemoryReplayCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(String identifier)
Add the given identifier to the cache.void
add(String identifier, Instant expiry)
Add the given identifier to the cache to be cached for the given timevoid
close()
boolean
contains(String identifier)
Return true if the given identifier is contained in the cacheprotected void
processTokenExpiry()
-
-
-
Field Detail
-
DEFAULT_TTL
public static final long DEFAULT_TTL
- See Also:
- Constant Field Values
-
MAX_TTL
public static final long MAX_TTL
- See Also:
- Constant Field Values
-
-
Method Detail
-
add
public void add(String identifier)
Add the given identifier to the cache. It will be cached for a default amount of time.- Specified by:
add
in interfaceReplayCache
- Parameters:
identifier
- The identifier to be added
-
add
public void add(String identifier, Instant expiry)
Add the given identifier to the cache to be cached for the given time- Specified by:
add
in interfaceReplayCache
- Parameters:
identifier
- The identifier to be addedexpiry
- A custom expiry time for the identifier
-
contains
public boolean contains(String identifier)
Return true if the given identifier is contained in the cache- Specified by:
contains
in interfaceReplayCache
- Parameters:
identifier
- The identifier to check
-
processTokenExpiry
protected void processTokenExpiry()
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
-