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;nullwhile it is unused.
A single-use code that replaces the second factor when the authenticator is lost. Only its hash is kept.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRecoveryCode(UUID id, UUID userId, String hashedCode, Instant usedAt) Validates the code. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of thehashedCoderecord component.id()Returns the value of theidrecord component.booleanisUsed()Tells whether the code has been spent.final StringtoString()Returns a string representation of this record class.usedAt()Returns the value of theusedAtrecord component.userId()Returns the value of theuserIdrecord component.
-
Field Details
-
id
The field for theidrecord component. -
userId
The field for theuserIdrecord component. -
hashedCode
The field for thehashedCoderecord component. -
usedAt
The field for theusedAtrecord component.
-
-
Constructor Details
-
RecoveryCode
Validates the code.- Throws:
IllegalArgumentException- if an identifier is missing or the hash is blank.
-
-
Method Details
-
isUsed
public boolean isUsed()Tells whether the code has been spent.- Returns:
truewhen it has a use instant.
-
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
id
Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-
userId
Returns the value of theuserIdrecord component.- Returns:
- the value of the
userIdrecord component
-
hashedCode
Returns the value of thehashedCoderecord component.- Returns:
- the value of the
hashedCoderecord component
-
usedAt
Returns the value of theusedAtrecord component.- Returns:
- the value of the
usedAtrecord component
-