Interface LoginAttemptStore
- All Known Implementing Classes:
InMemoryLoginAttemptStore
Persistent counter store for the
LoginAttemptPolicy family.
The existing default InMemoryLoginAttemptPolicy keeps its
counters in process memory — fine for a single-instance demo, but
unsuited for clustered deployments or for tracking lockouts across
restarts. A store-backed policy (planned for Phase 4) delegates
counter mutation and lookup to a LoginAttemptStore, so the
lockout state survives the process and is shared across nodes.
The API is behaviour-flavoured rather than pure CRUD because the data shape is so narrow (counter + timestamp): callers either record an additional failure, ask how many failures the key has accumulated, or reset it on a successful login.
Implementations must be thread-safe; concurrent
recordFailure calls happen on every failed login.
-
Method Summary
Modifier and TypeMethodDescriptionintReturns the number of failures currently held againstkey.Returns the timestamp of the most recent failure onkey, if any.voidrecordFailure(LoginAttemptKey key, Instant at) Increments the failure counter forkeyby one and updates its last-failure instant toat.voidreset(LoginAttemptKey key) Clears any state associated withkey— used after a successful login to start the counter from zero again.
-
Method Details
-
recordFailure
Increments the failure counter forkeyby one and updates its last-failure instant toat.- Parameters:
key- failure dimension; must not benullat- instant the failure occurred; must not benull
-
failureCount
Returns the number of failures currently held againstkey. Zero when the key has never failed or has beenreset(LoginAttemptKey).- Parameters:
key- failure dimension; must not benull- Returns:
- non-negative failure count
-
lastFailureAt
Returns the timestamp of the most recent failure onkey, if any.- Parameters:
key- failure dimension; must not benull- Returns:
- last failure instant, or empty when never failed
-
reset
Clears any state associated withkey— used after a successful login to start the counter from zero again.- Parameters:
key- failure dimension; must not benull
-