Class InMemoryEmailVerificationTokenStore
java.lang.Object
com.svenruppert.jsentinel.accountlifecycle.InMemoryEmailVerificationTokenStore
- All Implemented Interfaces:
EmailVerificationTokenStore
@ExperimentalJSentinelApi
public final class InMemoryEmailVerificationTokenStore
extends Object
implements EmailVerificationTokenStore
In-memory
EmailVerificationTokenStore backed by a
ConcurrentHashMap keyed on the token hash.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintdeleteBySubject(TenantId tenant, SubjectId subjectId) Drops every token 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(EmailVerificationTokenRecord record) Persists or replaces the supplied token record (keyed onEmailVerificationTokenRecord.tokenHash()).
-
Constructor Details
-
InMemoryEmailVerificationTokenStore
public InMemoryEmailVerificationTokenStore()Creates an empty store.
-
-
Method Details
-
findByHash
Description copied from interface:EmailVerificationTokenStoreLooks up a token record by its hash.- Specified by:
findByHashin interfaceEmailVerificationTokenStore- Parameters:
tokenHash- token hash; must not benullor blank- Returns:
- the record, if present (consumed or otherwise)
-
save
Description copied from interface:EmailVerificationTokenStorePersists or replaces the supplied token record (keyed onEmailVerificationTokenRecord.tokenHash()).- Specified by:
savein interfaceEmailVerificationTokenStore- Parameters:
record- record to persist; must not benull
-
markConsumed
Description copied from interface:EmailVerificationTokenStoreMarks the record fortokenHashconsumed. No-op when already consumed.- Specified by:
markConsumedin interfaceEmailVerificationTokenStore- Parameters:
tokenHash- token hash; must not benullor blankat- consumption instant; must not benull- Returns:
trueif a pending record was just marked consumed;falseotherwise
-
deleteBySubject
Description copied from interface:EmailVerificationTokenStoreDrops every token issued tosubjectIdwithintenant.- Specified by:
deleteBySubjectin interfaceEmailVerificationTokenStore- Parameters:
tenant- tenant scope; must not benullsubjectId- subject; must not benull- Returns:
- number of records removed
-
purgeExpired
Description copied from interface:EmailVerificationTokenStoreDrops every record whoseexpiresAtis at or beforenow.- Specified by:
purgeExpiredin interfaceEmailVerificationTokenStore- Parameters:
now- retention boundary; must not benull- Returns:
- number of records purged
-