Record Class PepperReference

java.lang.Object
java.lang.Record
com.svenruppert.jsentinel.credential.password.pepper.PepperReference
Record Components:
keyId - stable identifier; written into the envelope
key - pepper material; minimum 32 bytes for HMAC-SHA-256

public record PepperReference(String keyId, byte[] key) extends Record
Resolved pepper material handed to a PasswordHashProvider.

Carries the stable keyId (recorded in the envelope so the verifier can resolve the same key) plus a defensive copy of the pepper bytes themselves. The byte array is owned by this record; do not mutate it.

toString() never exposes the key material (CWE-209 / CWE-522).

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Minimum key length expected for HMAC-SHA-256 (256-bit).
  • Constructor Summary

    Constructors
    Constructor
    Description
    PepperReference(String keyId, byte[] key)
    Creates an instance of a PepperReference record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Returns a fresh copy of the key bytes.
    boolean
    Indicates whether some other object is "equal to" this one.
    int
    Returns a hash code value for this object.
    byte[]
    key()
    Returns the value of the key record component.
    Returns the value of the keyId record component.
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • MIN_KEY_BYTES

      public static final int MIN_KEY_BYTES
      Minimum key length expected for HMAC-SHA-256 (256-bit).
      See Also:
  • Constructor Details

    • PepperReference

      public PepperReference(String keyId, byte[] key)
      Creates an instance of a PepperReference record class.
      Parameters:
      keyId - the value for the keyId record component
      key - the value for the key record component
  • Method Details

    • copyKey

      public byte[] copyKey()
      Returns a fresh copy of the key bytes. The internal array stays untouched.
    • equals

      public 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.
    • hashCode

      public 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
    • toString

      public 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
    • keyId

      public String keyId()
      Returns the value of the keyId record component.
      Returns:
      the value of the keyId record component
    • key

      public byte[] key()
      Returns the value of the key record component.
      Returns:
      the value of the key record component