Record Class RecoveryCode

java.lang.Object
java.lang.Record
com.irurueta.authserver.authorization.domain.totp.RecoveryCode
Record Components:
id - unique identifier of the code.
userId - identifier of the user the code belongs to.
hashedCode - hash of the code.
usedAt - instant at which the code was spent; null while it is unused.

public record RecoveryCode(UUID id, UUID userId, String hashedCode, Instant usedAt) extends Record
A single-use code that replaces the second factor when the authenticator is lost. Only its hash is kept.
  • Field Details

    • id

      private final UUID id
      The field for the id record component.
    • userId

      private final UUID userId
      The field for the userId record component.
    • hashedCode

      private final String hashedCode
      The field for the hashedCode record component.
    • usedAt

      private final Instant usedAt
      The field for the usedAt record component.
  • Constructor Details

  • Method Details

    • isUsed

      public boolean isUsed()
      Tells whether the code has been spent.
      Returns:
      true when it has a use instant.
    • 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.
    • id

      public UUID id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • userId

      public UUID userId()
      Returns the value of the userId record component.
      Returns:
      the value of the userId record component
    • hashedCode

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

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