Interface PasswordResetTokenStore
- All Known Implementing Classes:
InMemoryPasswordResetTokenStore
Persistent store for
PasswordResetTokenRecords — backs the
planned password-reset workflow (V00.70 Phase 7).
Tokens are looked up by their hash. Single-use:
after markConsumed(String, Instant) the same hash must
never be honoured for a reset again. Implementations must keep
consumed records visible to findByHash(String) so callers
can distinguish "already consumed" from "never existed".
Implementations must be thread-safe.
-
Method Summary
Modifier and TypeMethodDescriptionintdeleteBySubject(TenantId tenant, SubjectId subjectId) Drops every token (consumed or pending) issued tosubjectIdwithintenant.findByHash(String tokenHash) Looks up a token record by its hash.booleanmarkConsumed(String tokenHash, Instant at) Marks the record fortokenHashconsumed.intpurgeExpired(Instant now) Drops every record whoseexpiresAtis at or beforenow.voidsave(PasswordResetTokenRecord record) Persists or replaces the supplied token record (keyed onPasswordResetTokenRecord.tokenHash()).
-
Method Details
-
findByHash
Looks up a token record by its hash.- Parameters:
tokenHash- token hash; must not benullor blank- Returns:
- the record, if present (consumed or otherwise)
-
save
Persists or replaces the supplied token record (keyed onPasswordResetTokenRecord.tokenHash()).- Parameters:
record- record to persist; must not benull
-
markConsumed
Marks the record fortokenHashconsumed. No-op when the record is already consumed.- Parameters:
tokenHash- token hash; must not benullor blankat- instant of consumption; must not benull- Returns:
trueif a not-yet-consumed record was marked,falsewhen no such record existed or when it was already consumed
-
deleteBySubject
-
purgeExpired
Drops every record whoseexpiresAtis at or beforenow.- Parameters:
now- retention boundary; must not benull- Returns:
- number of records purged
-