Record Class PasswordInputPolicy

java.lang.Object
java.lang.Record
com.svenruppert.jsentinel.credential.input.PasswordInputPolicy
Record Components:
minLengthChars - minimum number of Java characters (default 8); 0 means "no minimum"
maxLengthChars - maximum number of Java characters (default 1024); guards against pathological inputs
unicodeNormalisationEnabled - whether the normalizer runs at all (default true)
normalisationForm - which Unicode form to use; only consulted when normalisation is enabled
rejectControlCharacters - whether Character.isISOControl(int) code points are rejected (default false so newline/tab inside a passphrase remain legal)

public record PasswordInputPolicy(int minLengthChars, int maxLengthChars, boolean unicodeNormalisationEnabled, Normalizer.Form normalisationForm, boolean rejectControlCharacters) extends Record
Operator-configurable input hygiene rules for password material.

Length bounds keep callers safe against overlong-input abuse (CWE-400). The Unicode normalisation flag controls whether passwords are normalised to a canonical form before hashing — if enabled, the same normalisation runs on hash and verify so two representations of the same characters still match (CWE-176).

Pre-hashing of overlong inputs is intentionally absent: silent pre-hashing without a real pepper service makes credentials shuckable (see Konzept §11 and Prompt 011). The bcrypt provider therefore rejects overlong inputs explicitly; the maxLengthChars guard here serves the other algorithms too.

  • Constructor Details

    • PasswordInputPolicy

      public PasswordInputPolicy(int minLengthChars, int maxLengthChars, boolean unicodeNormalisationEnabled, Normalizer.Form normalisationForm, boolean rejectControlCharacters)
      Creates an instance of a PasswordInputPolicy record class.
      Parameters:
      minLengthChars - the value for the minLengthChars record component
      maxLengthChars - the value for the maxLengthChars record component
      unicodeNormalisationEnabled - the value for the unicodeNormalisationEnabled record component
      normalisationForm - the value for the normalisationForm record component
      rejectControlCharacters - the value for the rejectControlCharacters record component
  • Method Details

    • defaults

      public static PasswordInputPolicy defaults()
      OWASP-2023 baseline: 8..1024 characters, NFC normalisation on, control characters allowed.
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      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.
    • minLengthChars

      public int minLengthChars()
      Returns the value of the minLengthChars record component.
      Returns:
      the value of the minLengthChars record component
    • maxLengthChars

      public int maxLengthChars()
      Returns the value of the maxLengthChars record component.
      Returns:
      the value of the maxLengthChars record component
    • unicodeNormalisationEnabled

      public boolean unicodeNormalisationEnabled()
      Returns the value of the unicodeNormalisationEnabled record component.
      Returns:
      the value of the unicodeNormalisationEnabled record component
    • normalisationForm

      public Normalizer.Form normalisationForm()
      Returns the value of the normalisationForm record component.
      Returns:
      the value of the normalisationForm record component
    • rejectControlCharacters

      public boolean rejectControlCharacters()
      Returns the value of the rejectControlCharacters record component.
      Returns:
      the value of the rejectControlCharacters record component