Class InMemoryPendingSamlAuthenticationStore
java.lang.Object
com.revetsec.saml.InMemoryPendingSamlAuthenticationStore
- All Implemented Interfaces:
PendingSamlAuthenticationStore
@ThreadSafe
public final class InMemoryPendingSamlAuthenticationStore
extends Object
implements PendingSamlAuthenticationStore
Bounded, process-local store for pending SAML login and logout with atomic single consumption.
Restarting this process loses pending attempts. Distributed deployments supply their own shared store.
Expiry maintenance removes at most 64 unrelated expired records per operation, plus the
addressed record when expired. An ordered index retains exactly one node per stored record;
consuming a record also unlinks its node. Operations remain serialized, including conditional
validation, and their time budget does not guarantee a wall-clock execution bound.
- Since:
- 1.0.0
-
Method Summary
Modifier and TypeMethodDescriptionconsume(@NonNull String browserBinding, @NonNull String relayStateHandle, @NonNull Duration remaining) Atomically removes and returns one matching record.consumeIfMatches(@NonNull String browserBinding, @NonNull String relayStateHandle, @NonNull Predicate<@NonNull String> sealedRecordMatches, @NonNull Duration remaining) Validates one live sealed record before atomically removing that same record.Creates a process-local store with 65536 slots.Creates an empty store with an explicit capacity.save(@NonNull String browserBinding, @NonNull String relayStateHandle, @NonNull String sealedRecord, @NonNull Instant expiresAt, @NonNull Duration remaining) Saves a fresh record without replacing a live record with the same binding and handle.toString()Redacts pending data.
-
Method Details
-
fromLimit
public static @NonNull InMemoryPendingSamlAuthenticationStore fromLimit(@NonNull Clock clock, @NonNull Integer maximumEntries) Creates an empty store with an explicit capacity.- Parameters:
clock- validation clockmaximumEntries- maximum live attempts, from 1 to 1000000- Returns:
- local store
- Since:
- 1.0.0
-
fromDefaults
Creates a process-local store with 65536 slots.- Returns:
- local store
- Since:
- 1.0.0
-
save
public @NonNull SamlPendingSaveResult save(@NonNull String browserBinding, @NonNull String relayStateHandle, @NonNull String sealedRecord, @NonNull Instant expiresAt, @NonNull Duration remaining) Description copied from interface:PendingSamlAuthenticationStoreSaves a fresh record without replacing a live record with the same binding and handle.- Specified by:
savein interfacePendingSamlAuthenticationStore- Parameters:
browserBinding- browser-specific secretrelayStateHandle- generated opaque lookup handlesealedRecord- Revetsec-sealed recordexpiresAt- exact expiryremaining- positive operation budget- Returns:
- the save outcome
-
consume
public @NonNull SamlPendingConsumeResult consume(@NonNull String browserBinding, @NonNull String relayStateHandle, @NonNull Duration remaining) Description copied from interface:PendingSamlAuthenticationStoreAtomically removes and returns one matching record. An uncertain removal is indeterminate.- Specified by:
consumein interfacePendingSamlAuthenticationStore- Parameters:
browserBinding- browser-specific secretrelayStateHandle- generated opaque lookup handleremaining- positive operation budget- Returns:
- the consume outcome
-
consumeIfMatches
public @NonNull SamlPendingConsumeResult consumeIfMatches(@NonNull String browserBinding, @NonNull String relayStateHandle, @NonNull Predicate<@NonNull String> sealedRecordMatches, @NonNull Duration remaining) Description copied from interface:PendingSamlAuthenticationStoreValidates one live sealed record before atomically removing that same record. The predicate must accept the exact record returned by a successful consume; a replacement record must be validated separately. A false predicate returnsSamlPendingConsumeResult.Missingwithout removing the record. A predicate exception or exhausted operation budget returnsSamlPendingConsumeResult.Unavailablewithout removal. An uncertain removal is indeterminate.The default implementation returns unavailable without reading, validating or consuming state. Implementations must supply an atomic conditional consume to support this operation; falling back to
PendingSamlAuthenticationStore.consume(String, String, Duration)cannot preserve rejected state. Logout completion requires this operation and fails closed until the store overrides it. The predicate should perform only bounded validation and must not mutate store state.- Specified by:
consumeIfMatchesin interfacePendingSamlAuthenticationStore- Parameters:
browserBinding- browser-specific secretrelayStateHandle- generated opaque lookup handlesealedRecordMatches- validation of the exact live sealed recordremaining- positive budget including validation and removal- Returns:
- conditional consume outcome
-
toString
-