Package com.io7m.idstore.model
Record Class IdPassword
java.lang.Object
java.lang.Record
com.io7m.idstore.model.IdPassword
- Record Components:
algorithm
- The hash algorithmhash
- The hashed passwordsalt
- The salt valueexpires
- The expiration date, if any
- All Implemented Interfaces:
Formattable
public record IdPassword(IdPasswordAlgorithmType algorithm, String hash, String salt, Optional<OffsetDateTime> expires)
extends Record
implements Formattable
A hashed password for a user.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionIdPassword
(IdPasswordAlgorithmType algorithm, String hash, String salt, Optional<OffsetDateTime> expires) A hashed password for a user. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thealgorithm
record component.boolean
Check the given plain text password against this hashed password.final boolean
Indicates whether some other object is "equal to" this one.expires()
Returns the value of theexpires
record component.void
Format this object as a string, with the hash redacted so that it cannot appear in logs.hash()
Returns the value of thehash
record component.final int
hashCode()
Returns a hash code value for this object.salt()
Returns the value of thesalt
record component.toString()
Returns a string representation of this record class.withExpirationDate
(Optional<OffsetDateTime> newExpiration)
-
Field Details
-
VALID_HEX
The pattern that defines a valid hash.
-
-
Constructor Details
-
IdPassword
public IdPassword(IdPasswordAlgorithmType algorithm, String hash, String salt, Optional<OffsetDateTime> expires) A hashed password for a user.- Parameters:
algorithm
- The hash algorithmhash
- The hashed passwordsalt
- The salt valueexpires
- The expiration date, if any
-
-
Method Details
-
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. -
check
Check the given plain text password against this hashed password.- Parameters:
clock
- The clock against which to check credentialspasswordText
- The plain text password- Returns:
true
iff the password matches- Throws:
IdPasswordException
- On internal errors such as missing algorithm support- See Also:
-
formatTo
Format this object as a string, with the hash redacted so that it cannot appear in logs.- Specified by:
formatTo
in interfaceFormattable
- Parameters:
formatter
- The formatterflags
- The formatting flagswidth
- The widthprecision
- The precision
-
withExpirationDate
- Parameters:
date
- The date- Returns:
- This password with the given expiration date
-
withoutExpirationDate
- Returns:
- This password without an expiration date
-
withExpirationDate
- Parameters:
newExpiration
- The expiration date, if any- Returns:
- This password with the given expiration date
-
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)
. -
algorithm
Returns the value of thealgorithm
record component.- Returns:
- the value of the
algorithm
record component
-
hash
Returns the value of thehash
record component.- Returns:
- the value of the
hash
record component
-
salt
Returns the value of thesalt
record component.- Returns:
- the value of the
salt
record component
-
expires
Returns the value of theexpires
record component.- Returns:
- the value of the
expires
record component
-