Package com.ongres.scram.common
Enum StringPreparation
- All Implemented Interfaces:
Serializable
,Comparable<StringPreparation>
StringPreparations enumerations to use in SCRAM.
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionImplementation of StringPreparation that performs no preparation.Implementation of StringPreparation that performsSASLprep
preparation for PostgreSQL.Implementation of StringPreparation that performsSASLprep
preparation. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) abstract char[]
doNormalize
(char[] value) char[]
normalize
(char[] value) Normalize acording the selected preparation.static StringPreparation
Returns the enum constant of this type with the specified name.static StringPreparation[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
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
Implementation of StringPreparation that performsSASLprep
preparation. UTF-8 byte sequences that are prohibited by the SASLprep algorithm will produce an exception. -
POSTGRESQL_PREPARATION
Implementation of StringPreparation that performsSASLprep
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
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
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 nameNullPointerException
- 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
-