@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class AES256EncodedPassword extends java.lang.Object implements java.io.Serializable
NOTE: This class, and other classes within the
com.unboundid.ldap.sdk.unboundidds
package structure, are only
supported for use against Ping Identity, UnboundID, and
Nokia/Alcatel-Lucent 8661 server products. These classes provide support
for proprietary functionality or for external specifications that are not
considered stable or mature enough to be guaranteed to work in an
interoperable way with other types of LDAP servers.
Modifier and Type | Field and Description |
---|---|
static int |
ENCODING_VERSION_0
The integer value for encoding version 0.
|
static java.lang.String |
ENCODING_VERSION_0_CIPHER_ALGORITHM
The name of the cipher algorithm that should be used with an encoding
version of zero.
|
static java.lang.String |
ENCODING_VERSION_0_CIPHER_TRANSFORMATION
The name of the cipher transformation that should be used with an encoding
version of zero.
|
static int |
ENCODING_VERSION_0_GCM_TAG_LENGTH_BITS
The GCM tag length in bits to use with an encoding version of zero.
|
static int |
ENCODING_VERSION_0_GENERATED_KEY_LENGTH_BITS
The generated secret key length in bits to use with an encoding version of
zero.
|
static int |
ENCODING_VERSION_0_IV_LENGTH_BYTES
The size in bytes to use for the initialization vector with an encoding
version of zero.
|
static java.lang.String |
ENCODING_VERSION_0_KEY_FACTORY_ALGORITHM
The name of the key factory algorithm should be used with an encoding
version of zero.
|
static int |
ENCODING_VERSION_0_KEY_FACTORY_ITERATION_COUNT
The key factory iteration count to use with an encoding version of zero.
|
static int |
ENCODING_VERSION_0_KEY_FACTORY_SALT_LENGTH_BYTES
The size in bytes to use for the key factory salt with an encoding version
of zero.
|
static byte |
ENCODING_VERSION_0_MASK
The bitmask that will be used to indicate an encoding version of zero.
|
static int |
ENCODING_VERSION_0_PADDING_MODULUS
The padding modulus to use with an encoding version of zero.
|
static java.lang.String |
PASSWORD_STORAGE_SCHEME_PREFIX
The prefix that will appear at the beginning of the string representation
for an encoded password.
|
Modifier and Type | Method and Description |
---|---|
static AES256EncodedPassword |
decode(byte[] encodedPassword)
Decodes the provided password into its component parts.
|
static AES256EncodedPassword |
decode(java.lang.String encodedPassword)
Decodes the provided password into its component parts.
|
byte[] |
decrypt(AES256EncodedPasswordSecretKey secretKey)
Decrypts this encoded password to obtain the original clear-text password
used to generate it.
|
byte[] |
decrypt(char[] encryptionSettingsDefinitionPassphrase)
Decrypts this encoded password to obtain the original clear-text password
used to generate it.
|
byte[] |
decrypt(java.lang.String encryptionSettingsDefinitionPassphrase)
Decrypts this encoded password to obtain the original clear-text password
used to generate it.
|
static AES256EncodedPassword |
encode(AES256EncodedPasswordSecretKey secretKey,
byte[] initializationVector,
byte[] clearTextPassword)
Encodes a password using the provided information.
|
static AES256EncodedPassword |
encode(byte[] encryptionSettingsDefinitionID,
char[] encryptionSettingsDefinitionPassphrase,
byte[] clearTextPassword)
Encodes a password using the provided information.
|
static AES256EncodedPassword |
encode(byte[] encryptionSettingsDefinitionID,
char[] encryptionSettingsDefinitionPassphrase,
byte[] keyFactorySalt,
byte[] initializationVector,
byte[] clearTextPassword)
Encodes a password using the provided information.
|
static AES256EncodedPassword |
encode(java.lang.String encryptionSettingsDefinitionID,
java.lang.String encryptionSettingsDefinitionPassphrase,
java.lang.String clearTextPassword)
Encodes a password using the provided information.
|
byte[] |
getEncodedRepresentation()
Retrieves the bytes that comprise the complete raw encoded representation
of the password.
|
int |
getEncodingVersion()
Retrieves the encoding version for this encoded password.
|
byte[] |
getEncryptionSettingsDefinitionIDBytes()
Retrieves the bytes that comprise the raw ID of the encryption settings
definition whose passphrase is used to generate the encryption key.
|
java.lang.String |
getEncryptionSettingsDefinitionIDString()
Retrieves a string representation of the ID of the encryption settings
definition whose passphrase is used to generate the encryption key.
|
byte[] |
getInitializationVector()
Retrieves the initialization vector used to randomize the cipher output.
|
byte[] |
getKeyFactorySalt()
Retrieves the salt used to generate the encryption key from the encryption
settings definition passphrase.
|
int |
getPaddingBytes()
Retrieves the number of bytes of padding that need to be appended to the
clear-text password to make its length a multiple of sixteen bytes.
|
java.lang.String |
getStringRepresentation(boolean includeScheme)
Retrieves the string representation of this AES256 password.
|
java.lang.String |
toString()
Retrieves a string representation of this AES256 password.
|
void |
toString(java.lang.StringBuilder buffer)
Appends a string representation of this AES256 encoded password to the
provided buffer.
|
public static final byte ENCODING_VERSION_0_MASK
public static final int ENCODING_VERSION_0
public static final int ENCODING_VERSION_0_GCM_TAG_LENGTH_BITS
public static final int ENCODING_VERSION_0_GENERATED_KEY_LENGTH_BITS
public static final int ENCODING_VERSION_0_IV_LENGTH_BYTES
public static final int ENCODING_VERSION_0_KEY_FACTORY_ITERATION_COUNT
public static final int ENCODING_VERSION_0_KEY_FACTORY_SALT_LENGTH_BYTES
public static final int ENCODING_VERSION_0_PADDING_MODULUS
@NotNull public static final java.lang.String ENCODING_VERSION_0_CIPHER_ALGORITHM
@NotNull public static final java.lang.String ENCODING_VERSION_0_CIPHER_TRANSFORMATION
@NotNull public static final java.lang.String ENCODING_VERSION_0_KEY_FACTORY_ALGORITHM
@NotNull public static final java.lang.String PASSWORD_STORAGE_SCHEME_PREFIX
public int getEncodingVersion()
public int getPaddingBytes()
@NotNull public byte[] getKeyFactorySalt()
@NotNull public byte[] getInitializationVector()
@NotNull public byte[] getEncryptionSettingsDefinitionIDBytes()
@NotNull public java.lang.String getEncryptionSettingsDefinitionIDString()
@NotNull public byte[] getEncodedRepresentation()
@NotNull public java.lang.String getStringRepresentation(boolean includeScheme)
includeScheme
- Indicates whether to include the "{AES256}" prefix
at the beginning of the string representation.@NotNull public static AES256EncodedPassword encode(@NotNull java.lang.String encryptionSettingsDefinitionID, @NotNull java.lang.String encryptionSettingsDefinitionPassphrase, @NotNull java.lang.String clearTextPassword) throws java.security.GeneralSecurityException, java.text.ParseException
encryptionSettingsDefinitionID
- A string with the hexadecimal representation of the
encryption settings definition whose passphrase was used to
generate the encoded password. It must not be
null
or empty, and it must represent a valid
hexadecimal string whose length is an even number less than
or equal to 510 bytes.encryptionSettingsDefinitionPassphrase
- The passphrase associated with the specified encryption
settings definition. It must not be null
or empty.clearTextPassword
- The clear-text password to encode. It must not be
null
or empty.java.security.GeneralSecurityException
- If a problem occurs while attempting to
perform any of the cryptographic
processing.java.text.ParseException
- If the provided encryption settings definition ID
cannot be parsed as a valid hexadecimal string.@NotNull public static AES256EncodedPassword encode(@NotNull byte[] encryptionSettingsDefinitionID, @NotNull char[] encryptionSettingsDefinitionPassphrase, @NotNull byte[] clearTextPassword) throws java.security.GeneralSecurityException
encryptionSettingsDefinitionID
- The bytes that comprise the raw encryption settings definition
ID whose passphrase was used to generate the encoded password.
It must not be null
or empty, and its length must be
less than or equal to 255 bytes.encryptionSettingsDefinitionPassphrase
- The passphrase associated with the specified encryption
settings definition. It must not be null
or empty.clearTextPassword
- The bytes that comprise the clear-text password to encode.
It must not be null
or empty.java.security.GeneralSecurityException
- If a problem occurs while attempting to
perform any of the cryptographic
processing.@NotNull public static AES256EncodedPassword encode(@NotNull byte[] encryptionSettingsDefinitionID, @NotNull char[] encryptionSettingsDefinitionPassphrase, @NotNull byte[] keyFactorySalt, @NotNull byte[] initializationVector, @NotNull byte[] clearTextPassword) throws java.security.GeneralSecurityException
encryptionSettingsDefinitionID
- The bytes that comprise the raw encryption settings definition
ID whose passphrase was used to generate the encoded password.
It must not be null
or empty, and its length must be
less than or equal to 255 bytes.encryptionSettingsDefinitionPassphrase
- The passphrase associated with the specified encryption
settings definition. It must not be null
or empty.keyFactorySalt
- The salt used to generate the encryption key from the
encryption settings definition passphrase. It must not be
null
and it must have a length of exactly 16 bytes.initializationVector
- The initialization vector used to randomize the cipher output.
It must not be [@code null} and it must have a length of
exactly 16 bytes.clearTextPassword
- The bytes that comprise the clear-text password to encode.
It must not be null
or empty.java.security.GeneralSecurityException
- If a problem occurs while attempting to
perform any of the cryptographic
processing.@NotNull public static AES256EncodedPassword encode(@NotNull AES256EncodedPasswordSecretKey secretKey, @NotNull byte[] initializationVector, @NotNull byte[] clearTextPassword) throws java.security.GeneralSecurityException
secretKey
- The secret key that should be used to encrypt the password.
It must not be null
. The secret key can be reused
wheninitializationVector
- The initialization vector used to randomize the cipher output.
It must not be [@code null} and it must have a length of
exactly 16 bytes.clearTextPassword
- The bytes that comprise the clear-text password to encode.
It must not be null
or empty.java.security.GeneralSecurityException
- If a problem occurs while attempting to
perform any of the cryptographic
processing.@NotNull public static AES256EncodedPassword decode(@NotNull java.lang.String encodedPassword) throws java.text.ParseException
encodedPassword
- The string representation of the encoded password to be
decoded. It must not be null
or empty, and it must
contain the base64-encoded representation of the raw encoded
password, optionally preceded by the "{AES256}" prefix.java.text.ParseException
- If the provided string does not represent a valid
encoded password.@NotNull public static AES256EncodedPassword decode(@NotNull byte[] encodedPassword) throws java.text.ParseException
encodedPassword
- The bytes that comprise the complete raw encoded
representation of the password. It must not be null
or empty.java.text.ParseException
- If the provided string does not represent a valid
encoded password.@NotNull public byte[] decrypt(@NotNull java.lang.String encryptionSettingsDefinitionPassphrase) throws java.security.GeneralSecurityException
encryptionSettingsDefinitionPassphrase
- The passphrase associated with the encryption settings
definition used to encrypt the password. It must not be
null
or empty.java.security.GeneralSecurityException
- If an error occurs while attempting to
decrypt the password using the
provided encryption settings ID
passphrase.@NotNull public byte[] decrypt(@NotNull char[] encryptionSettingsDefinitionPassphrase) throws java.security.GeneralSecurityException
encryptionSettingsDefinitionPassphrase
- The passphrase associated with the encryption settings
definition used to encrypt the password. It must not be
null
or empty.java.security.GeneralSecurityException
- If an error occurs while attempting to
decrypt the password using the
provided encryption settings ID
passphrase.@NotNull public byte[] decrypt(@NotNull AES256EncodedPasswordSecretKey secretKey) throws java.security.GeneralSecurityException
secretKey
- The that will be used to decrypt the password. It must not
be null
.java.security.GeneralSecurityException
- If an error occurs while attempting to
decrypt the password using the
provided encryption settings ID
passphrase.@NotNull public java.lang.String toString()
toString
in class java.lang.Object