Record Class PasswordHash

java.lang.Object
java.lang.Record
com.svenruppert.jsentinel.authentication.PasswordHash
Record Components:
algorithm - algorithm identifier (e.g. pbkdf2)
encoded - base64-encoded hash bytes (without padding)
parameters - algorithm-specific parameters required to re-derive the hash from a candidate password (e.g. iteration count, salt). The Map is defensively copied so PasswordHash is fully immutable.

public record PasswordHash(String algorithm, String encoded, Map<String,String> parameters) extends Record
Typed representation of a stored password hash.

Used by the PasswordHasher.hashTo(char[]) / PasswordHasher.verify(char[], PasswordHash) / PasswordHasher.needsRehash(PasswordHash) API. The hasher implementation owns the wire format used by the legacy PasswordHasher.hash(char[]) / PasswordHasher.verify(char[], String) methods — see Pbkdf2PasswordHasher.parse(String) and Pbkdf2PasswordHasher.serialize(PasswordHash) for the round-trip.

  • Constructor Details

    • PasswordHash

      public PasswordHash(String algorithm, String encoded, Map<String,String> parameters)
      Creates an instance of a PasswordHash record class.
      Parameters:
      algorithm - the value for the algorithm record component
      encoded - the value for the encoded record component
      parameters - the value for the parameters record component
  • Method Details

    • intParameter

      public int intParameter(String key, int defaultValue)
      Convenience reader for a numeric parameter — returns the parsed value or defaultValue if the key is missing or unparseable.
      Parameters:
      key - parameter name
      defaultValue - fallback when missing/invalid
      Returns:
      parsed integer
    • 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.
    • algorithm

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

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

      public Map<String,String> parameters()
      Returns the value of the parameters record component.
      Returns:
      the value of the parameters record component