Record Class RememberMeTokenRecord

java.lang.Object
java.lang.Record
com.svenruppert.jsentinel.authentication.RememberMeTokenRecord
Record Components:
tokenHash - non-blank token hash; the plain token is never stored
tenant - tenant scope; null becomes TenantId.DEFAULT
subjectId - authenticated subject the token grants
createdAt - when the token was issued
expiresAt - absolute expiry; must be strictly after createdAt

@ExperimentalJSentinelApi public record RememberMeTokenRecord(String tokenHash, TenantId tenant, SubjectId subjectId, Instant createdAt, Instant expiresAt) extends Record
Persistent representation of a single "remember me" token.

Stores only the hash of the token, never the plain value: the plain token lives in a cookie on the user's device and must not be reconstructable from the store. Implementations of RememberMeTokenStore keep the same hashing convention they apply at lookup time.

expiresAt is the absolute expiry instant; auth flows compare it to Instant.now() (or a clock-injected equivalent) and reject the token outside the validity window.

  • Constructor Details

    • RememberMeTokenRecord

      public RememberMeTokenRecord(String tokenHash, TenantId tenant, SubjectId subjectId, Instant createdAt, Instant expiresAt)
      Validates the record components and normalises null tenant to TenantId.DEFAULT.
      Parameters:
      tokenHash - non-blank token hash
      tenant - tenant scope; null becomes DEFAULT
      subjectId - non-null subject
      createdAt - non-null creation instant
      expiresAt - non-null expiry instant, strictly after createdAt
  • Method Details

    • isExpired

      public boolean isExpired(Instant now)
      Returns true when the token is past its expiry at the supplied instant.
      Parameters:
      now - reference instant; must not be null
      Returns:
      whether the token is expired
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • tokenHash

      public String tokenHash()
      Returns the value of the tokenHash record component.
      Returns:
      the value of the tokenHash record component
    • tenant

      public TenantId tenant()
      Returns the value of the tenant record component.
      Returns:
      the value of the tenant record component
    • subjectId

      public SubjectId subjectId()
      Returns the value of the subjectId record component.
      Returns:
      the value of the subjectId record component
    • createdAt

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

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