Record Class ResetTokenRecord

java.lang.Object
java.lang.Record
com.svenruppert.jsentinel.credential.reset.ResetTokenRecord

public record ResetTokenRecord(TokenDigestRecord digest, String username, Instant issuedAt, Instant expiresAt, ResetTokenStatus status, long version) extends Record
Persisted password-reset token. Holds the selector, the digest of the verifier (never the verifier itself), the owner's username, the lifecycle status and the timestamps that drive single-use and expiry.

The version field is an optimistic-lock counter — bumped on every status transition so the store can CAS without losing concurrent updates (CWE-362).

  • Constructor Details

    • ResetTokenRecord

      public ResetTokenRecord(TokenDigestRecord digest, String username, Instant issuedAt, Instant expiresAt, ResetTokenStatus status, long version)
      Creates an instance of a ResetTokenRecord record class.
      Parameters:
      digest - the value for the digest record component
      username - the value for the username record component
      issuedAt - the value for the issuedAt record component
      expiresAt - the value for the expiresAt record component
      status - the value for the status record component
      version - the value for the version record component
  • Method Details

    • selector

      public String selector()
    • isExpired

      public boolean isExpired(Instant now)
    • withStatus

      public ResetTokenRecord withStatus(ResetTokenStatus newStatus)
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • digest

      public TokenDigestRecord digest()
      Returns the value of the digest record component.
      Returns:
      the value of the digest record component
    • username

      public String username()
      Returns the value of the username record component.
      Returns:
      the value of the username record component
    • issuedAt

      public Instant issuedAt()
      Returns the value of the issuedAt record component.
      Returns:
      the value of the issuedAt record component
    • expiresAt

      public Instant expiresAt()
      Returns the value of the expiresAt record component.
      Returns:
      the value of the expiresAt record component
    • status

      public ResetTokenStatus status()
      Returns the value of the status record component.
      Returns:
      the value of the status record component
    • version

      public long version()
      Returns the value of the version record component.
      Returns:
      the value of the version record component