Record Class BootstrapToken

java.lang.Object
java.lang.Record
com.svenruppert.jsentinel.bootstrap.BootstrapToken
Record Components:
value - the opaque token value
createdAt - the instant the token was generated, used to evaluate expiry against a configurable validity window

public record BootstrapToken(String value, Instant createdAt) extends Record
One-time bootstrap token.

The token authorizes the creation of the very first administrator while the system is uninitialized. It is not an administrator credential and must not be confused with one.

  • Constructor Details

    • BootstrapToken

      public BootstrapToken(String value, Instant createdAt)
      Defensive constructor — rejects null / blank values.
  • Method Details

    • matches

      public boolean matches(String candidate)
      Constant-time comparison against a candidate string. Safe against timing attacks.
      Parameters:
      candidate - the candidate token value to compare against this token
      Returns:
      true if the candidate matches this token's value
    • isExpired

      public boolean isExpired(Instant now, Duration validity)
      Parameters:
      now - the reference instant to evaluate expiry against
      validity - the validity duration since createdAt
      Returns:
      true when now is after createdAt + validity.
    • 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.
    • value

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

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