Class InMemoryPasswordResetTokenStore
java.lang.Object
com.svenruppert.jsentinel.accountlifecycle.InMemoryPasswordResetTokenStore
- All Implemented Interfaces:
PasswordResetTokenStore
@ExperimentalJSentinelApi
public final class InMemoryPasswordResetTokenStore
extends Object
implements PasswordResetTokenStore
In-memory
PasswordResetTokenStore backed by a
ConcurrentHashMap keyed on the token hash.-
Constructor Summary
Constructors -
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()).
-
Constructor Details
-
InMemoryPasswordResetTokenStore
public InMemoryPasswordResetTokenStore()Creates an empty store.
-
-
Method Details
-
findByHash
Description copied from interface:PasswordResetTokenStoreLooks up a token record by its hash.- Specified by:
findByHashin interfacePasswordResetTokenStore- Parameters:
tokenHash- token hash; must not benullor blank- Returns:
- the record, if present (consumed or otherwise)
-
save
Description copied from interface:PasswordResetTokenStorePersists or replaces the supplied token record (keyed onPasswordResetTokenRecord.tokenHash()).- Specified by:
savein interfacePasswordResetTokenStore- Parameters:
record- record to persist; must not benull
-
markConsumed
Description copied from interface:PasswordResetTokenStoreMarks the record fortokenHashconsumed. No-op when the record is already consumed.- Specified by:
markConsumedin interfacePasswordResetTokenStore- 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
Description copied from interface:PasswordResetTokenStoreDrops every token (consumed or pending) issued tosubjectIdwithintenant.- Specified by:
deleteBySubjectin interfacePasswordResetTokenStore- Parameters:
tenant- tenant scope; must not benullsubjectId- subject; must not benull- Returns:
- number of records removed
-
purgeExpired
Description copied from interface:PasswordResetTokenStoreDrops every record whoseexpiresAtis at or beforenow.- Specified by:
purgeExpiredin interfacePasswordResetTokenStore- Parameters:
now- retention boundary; must not benull- Returns:
- number of records purged
-