Record Class TotpCredential
java.lang.Object
java.lang.Record
com.irurueta.authserver.authorization.domain.totp.TotpCredential
- Record Components:
userId- identifier of the user the credential belongs to.encryptedSecret- the secret, encrypted at rest; copied on the way in and on the way out.confirmed- whether the user proved possession by entering a first valid code.lastUsedStep- time step of the last accepted code, orNEVER_USED; later codes must be newer.createdAt- instant at which the credential was created.
public record TotpCredential(UUID userId, byte[] encryptedSecret, boolean confirmed, long lastUsedStep, Instant createdAt)
extends Record
The TOTP credential of one user. The secret is only ever held encrypted.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanThe field for theconfirmedrecord component.private final InstantThe field for thecreatedAtrecord component.private final byte[]The field for theencryptedSecretrecord component.private final longThe field for thelastUsedSteprecord component.static final longValue of the last used step of a credential that has not accepted any code yet.private final UUIDThe field for theuserIdrecord component. -
Constructor Summary
ConstructorsConstructorDescriptionTotpCredential(UUID userId, byte[] encryptedSecret, boolean confirmed, long lastUsedStep, Instant createdAt) Validates the credential and copies the secret. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the value of theconfirmedrecord component.Returns the value of thecreatedAtrecord component.byte[]Gives the encrypted secret.booleanCompares credentials by value, comparing the secret by content.inthashCode()Computes a hash consistent withequals(Object).longReturns the value of thelastUsedSteprecord component.toString()Describes the credential without its secret.userId()Returns the value of theuserIdrecord component.
-
Field Details
-
userId
The field for theuserIdrecord component. -
encryptedSecret
private final byte[] encryptedSecretThe field for theencryptedSecretrecord component. -
confirmed
private final boolean confirmedThe field for theconfirmedrecord component. -
lastUsedStep
private final long lastUsedStepThe field for thelastUsedSteprecord component. -
createdAt
The field for thecreatedAtrecord component. -
NEVER_USED
public static final long NEVER_USEDValue of the last used step of a credential that has not accepted any code yet.- See Also:
-
-
Constructor Details
-
TotpCredential
public TotpCredential(UUID userId, byte[] encryptedSecret, boolean confirmed, long lastUsedStep, Instant createdAt) Validates the credential and copies the secret.- Throws:
IllegalArgumentException- if the user, the secret or the creation instant is missing or empty, or the step is lower thanNEVER_USED.
-
-
Method Details
-
encryptedSecret
public byte[] encryptedSecret()Gives the encrypted secret.- Returns:
- a copy of the encrypted secret.
-
equals
Compares credentials by value, comparing the secret by content. -
hashCode
public int hashCode()Computes a hash consistent withequals(Object). -
toString
Describes the credential without its secret. -
userId
Returns the value of theuserIdrecord component.- Returns:
- the value of the
userIdrecord component
-
confirmed
public boolean confirmed()Returns the value of theconfirmedrecord component.- Returns:
- the value of the
confirmedrecord component
-
lastUsedStep
public long lastUsedStep()Returns the value of thelastUsedSteprecord component.- Returns:
- the value of the
lastUsedSteprecord component
-
createdAt
Returns the value of thecreatedAtrecord component.- Returns:
- the value of the
createdAtrecord component
-