Record Class EmailVerificationTokenRecord

java.lang.Object
java.lang.Record
com.svenruppert.jsentinel.accountlifecycle.EmailVerificationTokenRecord
Record Components:
tokenHash - non-blank token hash
tenant - tenant scope; null becomes TenantId.DEFAULT
subjectId - subject whose email the token verifies
email - non-blank email address being verified
createdAt - when the token was issued
expiresAt - absolute expiry, strictly after createdAt
consumedAt - instant the token was consumed, or empty when still pending; if present must be strictly after createdAt

@ExperimentalJSentinelApi public record EmailVerificationTokenRecord(String tokenHash, TenantId tenant, SubjectId subjectId, String email, Instant createdAt, Instant expiresAt, Optional<Instant> consumedAt) extends Record
Persistent representation of a single email-verification token.

Carries the email address the token confirms — different from a password-reset record, where the address is implicit in the subject. Single-use, hash-only, identical lifecycle shape to PasswordResetTokenRecord.

  • Constructor Details

    • EmailVerificationTokenRecord

      public EmailVerificationTokenRecord(String tokenHash, TenantId tenant, SubjectId subjectId, String email, Instant createdAt, Instant expiresAt, Optional<Instant> consumedAt)
      Validates the record components and normalises null tenant / consumedAt.
      Parameters:
      tokenHash - non-blank token hash
      tenant - null becomes DEFAULT
      subjectId - non-null subject
      email - non-blank email
      createdAt - non-null creation instant
      expiresAt - non-null expiry, strictly after createdAt
      consumedAt - null becomes empty Optional
  • Method Details

    • withConsumedAt

      public EmailVerificationTokenRecord withConsumedAt(Instant at)
      Returns a copy with consumedAt() set to at.
      Parameters:
      at - instant the token was consumed; non-null
      Returns:
      new record with consumedAt = Optional.of(at)
    • isConsumed

      public boolean isConsumed()
      Returns whether the token has been consumed.
      Returns:
      true when consumedAt is present
    • isExpired

      public boolean isExpired(Instant now)
      Returns true when the token is past its expiry at the supplied instant.
      Parameters:
      now - reference instant; non-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
    • email

      public String email()
      Returns the value of the email record component.
      Returns:
      the value of the email 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
    • consumedAt

      public Optional<Instant> consumedAt()
      Returns the value of the consumedAt record component.
      Returns:
      the value of the consumedAt record component