Interface RefreshTokenStore
- All Known Implementing Classes:
InMemoryRefreshTokenStore
Persistent store for
RefreshTokenRecords — backs the
planned rotating-refresh-token flow (V00.70 Phase 7b).
Hash-only lookups. Rotation is recorded by calling
markReplaced(String, String, Instant) on the consumed
record after saving its successor. Replayed/already-rotated
tokens are detected by inspecting
RefreshTokenRecord.replacedByHash() at validation time;
a chain-revoke is the application's responsibility.
Implementations must be thread-safe.
-
Method Summary
Modifier and TypeMethodDescriptionintdeleteBySubject(TenantId tenant, SubjectId subjectId) Drops every token (active, replaced or revoked) issued tosubjectIdwithintenant.findByHash(String tokenHash) Looks up a record by its hash.booleanmarkReplaced(String oldHash, String newHash, Instant at) LinksoldHashas replaced bynewHashatat.booleanmarkRevoked(String tokenHash, Instant at) Marks the record fortokenHashrevoked atat.intpurgeExpired(Instant now) Drops every record whoseRefreshTokenRecord.expiresAt()is at or beforenow.voidsave(RefreshTokenRecord record) Persists or replaces the supplied record.
-
Method Details
-
findByHash
Looks up a record by its hash.- Parameters:
tokenHash- token hash; must not benullor blank- Returns:
- the record, if present
-
save
Persists or replaces the supplied record. Keyed onRefreshTokenRecord.tokenHash().- Parameters:
record- record to persist; must not benull
-
markReplaced
LinksoldHashas replaced bynewHashatat. No-op whenoldHashalready carries a successor.- Parameters:
oldHash- hash of the consumed token; non-blanknewHash- hash of the successor; non-blankat- rotation instant; non-null (recorded as the consumed record'srevokedAtis left untouched — replacement is tracked throughreplacedByHashonly)- Returns:
trueif the link was set on a record that previously had no successor;falseotherwise
-
markRevoked
-
deleteBySubject
-
purgeExpired
Drops every record whoseRefreshTokenRecord.expiresAt()is at or beforenow.- Parameters:
now- retention boundary; non-null- Returns:
- number of records purged
-