Interface PasswordResetTokenStore

All Known Implementing Classes:
InMemoryPasswordResetTokenStore

@ExperimentalJSentinelApi public interface PasswordResetTokenStore
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 Details

    • findByHash

      Optional<PasswordResetTokenRecord> findByHash(String tokenHash)
      Looks up a token record by its hash.
      Parameters:
      tokenHash - token hash; must not be null or blank
      Returns:
      the record, if present (consumed or otherwise)
    • save

      void save(PasswordResetTokenRecord record)
      Persists or replaces the supplied token record (keyed on PasswordResetTokenRecord.tokenHash()).
      Parameters:
      record - record to persist; must not be null
    • markConsumed

      boolean markConsumed(String tokenHash, Instant at)
      Marks the record for tokenHash consumed. No-op when the record is already consumed.
      Parameters:
      tokenHash - token hash; must not be null or blank
      at - instant of consumption; must not be null
      Returns:
      true if a not-yet-consumed record was marked, false when no such record existed or when it was already consumed
    • deleteBySubject

      int deleteBySubject(TenantId tenant, SubjectId subjectId)
      Drops every token (consumed or pending) issued to subjectId within tenant.
      Parameters:
      tenant - tenant scope; must not be null
      subjectId - subject; must not be null
      Returns:
      number of records removed
    • purgeExpired

      int purgeExpired(Instant now)
      Drops every record whose expiresAt is at or before now.
      Parameters:
      now - retention boundary; must not be null
      Returns:
      number of records purged