public enum StringPreparation extends Enum<StringPreparation>
| Enum Constant and Description |
|---|
NO_PREPARATION
Implementation of StringPreparation that performs no preparation.
|
POSTGRESQL_PREPARATION
Implementation of StringPreparation that performs
SASLprep preparation for PostgreSQL. |
SASL_PREPARATION
Implementation of StringPreparation that performs
SASLprep preparation. |
| Modifier and Type | Method and Description |
|---|---|
char[] |
normalize(char[] value)
Normalize acording the selected preparation.
|
static StringPreparation |
valueOf(String name)
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.
|
public static final StringPreparation NO_PREPARATION
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).
public static final StringPreparation SASL_PREPARATION
SASLprep preparation. UTF-8 byte
sequences that are prohibited by the SASLprep algorithm will produce an exception.public static final StringPreparation POSTGRESQL_PREPARATION
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.public static StringPreparation[] values()
for (StringPreparation c : StringPreparation.values()) System.out.println(c);
public static StringPreparation valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic char[] normalize(char[] value)
value - array of chars to normalizeIllegalArgumentException - if the string is null or emptyCopyright © 2017–2025 OnGres, Inc. All rights reserved.