Enum StringPreparation

java.lang.Object
java.lang.Enum<StringPreparation>
com.ongres.scram.common.StringPreparation
All Implemented Interfaces:
Serializable, Comparable<StringPreparation>

public enum StringPreparation extends Enum<StringPreparation>
StringPreparations enumerations to use in SCRAM.
  • Enum Constant Details

    • NO_PREPARATION

      public static final StringPreparation NO_PREPARATION
      Implementation of StringPreparation that performs no preparation. Non US-ASCII characters will produce an exception.

      Even though the [RFC5802] is not very clear about it, this implementation will normalize non-printable US-ASCII characters similarly to what SASLprep does (i.e., removing them).

    • SASL_PREPARATION

      public static final StringPreparation SASL_PREPARATION
      Implementation of StringPreparation that performs SASLprep preparation. UTF-8 byte sequences that are prohibited by the SASLprep algorithm will produce an exception.
    • POSTGRESQL_PREPARATION

      public static final StringPreparation POSTGRESQL_PREPARATION
      Implementation of StringPreparation that performs SASLprep preparation for PostgreSQL.
      The SCRAM specification dictates that the password is also in UTF-8, and is processed with the SASLprep algorithm. PostgreSQL, however, does not require UTF-8 to be used for the password. When a user's password is set, it is processed with SASLprep as if it was in UTF-8, regardless of the actual encoding used. However, if it is not a legal UTF-8 byte sequence, or it contains UTF-8 byte sequences that are prohibited by the SASLprep algorithm, the raw password will be used without SASLprep processing, instead of throwing an error. This allows the password to be normalized when it is in UTF-8, but still allows a non-UTF-8 password to be used, and doesn't require the system to know which encoding the password is in.
      See Also:
  • Constructor Details

    • StringPreparation

      private StringPreparation()
  • Method Details

    • values

      public static StringPreparation[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static StringPreparation valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • doNormalize

      abstract char[] doNormalize(char[] value)
    • normalize

      public char[] normalize(char[] value)
      Normalize acording the selected preparation.
      Parameters:
      value - array of chars to normalize
      Returns:
      the normalized array of chars
      Throws:
      IllegalArgumentException - if the string is null or empty