Class InMemorySamlReplayCache
java.lang.Object
com.revetsec.saml.InMemorySamlReplayCache
- All Implemented Interfaces:
SamlReplayCache
Bounded, process-local SAML assertion replay cache. A restart loses its records; use a shared
SamlReplayCache for more than one node. Live entries are never evicted. Expired records
are removed only when a subsequent write observes a clock at least as late as every prior write.
A clock rollback refuses new admissions until time catches up.- Since:
- 1.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface SamlReplayCache
SamlReplayCache.MarkResultModifier and TypeInterfaceDescriptionstatic enumOutcomes of an atomic replay admission. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull InMemorySamlReplayCachefromConnectionLimits(@NonNull Clock clock, @NonNull Map<@NonNull String, @NonNull Integer> connectionLimits) Creates fixed independent replay reservations for application-approved IdP connections.static @NonNull InMemorySamlReplayCacheCreates a volatile cache with 65536 slots and the system UTC clock.static @NonNull InMemorySamlReplayCacheCreates a volatile cache with an explicit entry limit.markIfAbsent(@NonNull String connectionId, @NonNull String key, @NonNull Instant expiresAt, @NonNull Duration remaining) Atomically admit a replay key within a connection's capacity namespace.Atomically admit a previously unseen key until its final possible acceptance time across supported request bindings and time policies.toString()Redacts replay keys.
-
Method Details
-
fromLimit
public static @NonNull InMemorySamlReplayCache fromLimit(@NonNull Clock clock, @NonNull Integer maximumEntries) Creates a volatile cache with an explicit entry limit. New namespaced admissions are limited to one quarter of the total capacity (at least one). Legacy three-argument admissions retain the full configured capacity. This shared-pool heuristic does not reserve capacity for mutually untrusted connections; usefromConnectionLimits(Clock, Map)for fixed independent reservations.- Parameters:
clock- the time source used for admission and expirymaximumEntries- maximum number of live replay records, from 1 to 1000000- Returns:
- a new empty cache
- Since:
- 1.0.0
-
fromConnectionLimits
public static @NonNull InMemorySamlReplayCache fromConnectionLimits(@NonNull Clock clock, @NonNull Map<@NonNull String, @NonNull Integer> connectionLimits) Creates fixed independent replay reservations for application-approved IdP connections. Each connection can use its entire configured quota even after all others fill theirs. Unknown connection IDs and the namespace-free admission overload cannot consume reserved capacity. Live replay marks are never evicted.Configuration is snapshotted without reading the clock. There is no borrowing or live reconfiguration; replacing a populated cache requires an application transition preserving every still-live replay mark. This remains a volatile, single-process cache; restart loses replay protection.
- Parameters:
clock- admission and expiry clockconnectionLimits- 1–1024 trusted connection IDs, each nonempty and at most 256 characters, with positive quotas totaling at most 1000000 live records- Returns:
- an empty cache with immutable reservations
- Throws:
NullPointerException- if the clock, map, a connection ID or quota is nullIllegalArgumentException- if a configuration bound is exceeded- Since:
- 1.0.0
-
fromDefaults
Creates a volatile cache with 65536 slots and the system UTC clock.- Returns:
- a new cache
- Since:
- 1.0.0
-
markIfAbsent
public @NonNull SamlReplayCache.MarkResult markIfAbsent(@NonNull String key, @NonNull Instant expiresAt, @NonNull Duration remaining) Description copied from interface:SamlReplayCacheAtomically admit a previously unseen key until its final possible acceptance time across supported request bindings and time policies. A backend must retain the key through the supplied absolute expiry without rounding that expiry down.- Specified by:
markIfAbsentin interfaceSamlReplayCache- Parameters:
key- the Revetsec-generated replay keyexpiresAt- the final possible acceptance time across supported completion contextsremaining- positive time budget for this operation- Returns:
- an explicit outcome; only MARKED permits identity release
-
markIfAbsent
public @NonNull SamlReplayCache.MarkResult markIfAbsent(@NonNull String connectionId, @NonNull String key, @NonNull Instant expiresAt, @NonNull Duration remaining) Description copied from interface:SamlReplayCacheAtomically admit a replay key within a connection's capacity namespace. The key itself already binds the connection, SP and IdP identifiers. Implementations shared by mutually untrusted IdP connections should override this method and reserve capacity per connection. The default preserves source compatibility for existing stores but supplies no such capacity isolation.- Specified by:
markIfAbsentin interfaceSamlReplayCache- Parameters:
connectionId- application-approved IdP connection namespacekey- the Revetsec-generated replay keyexpiresAt- the final possible acceptance timeremaining- positive time budget- Returns:
- an explicit atomic outcome
-
toString
-