Class BasicPasswordSpecEncoding
- java.lang.Object
-
- org.wildfly.security.password.spec.BasicPasswordSpecEncoding
-
public final class BasicPasswordSpecEncoding extends Object
Provide methods for encoding and decoding ofPasswordSpec
.- Author:
- David M. Lloyd, Pedro Igor
-
-
Field Summary
Fields Modifier and Type Field Description private static byte
CLEAR_PASSWORD_SPEC_ID
private static byte
DIGEST_PASSWORD_SPEC_ID
private static byte
HASH_PASSWORD_SPEC_ID
private static byte
ITERATED_SALTED_HASH_SPEC_ID
private static byte
SALTED_HASH_PASSWORD_SPEC_ID
-
Constructor Summary
Constructors Modifier Constructor Description private
BasicPasswordSpecEncoding()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static PasswordSpec
decode(byte[] encoded)
Decode the given byte array and create aPasswordSpec
from it.private static PasswordSpec
decodeClearPasswordSpec(org.wildfly.common.iteration.ByteIterator iterator)
private static PasswordSpec
decodeDigestPasswordSpec(org.wildfly.common.iteration.ByteIterator iterator)
private static PasswordSpec
decodeHashPasswordSpec(org.wildfly.common.iteration.ByteIterator iterator)
private static PasswordSpec
decodeIteratedSaltedHashPasswordSpec(org.wildfly.common.iteration.ByteIterator iterator)
private static PasswordSpec
decodeSaltedHashPasswordSpec(org.wildfly.common.iteration.ByteIterator iterator)
static byte[]
encode(Password password)
Encode the givenPassword
to a byte array.static byte[]
encode(Password password, Supplier<Provider[]> providers)
Encode the givenPassword
to a byte array.static byte[]
encode(PasswordSpec passwordSpec)
Encode the givenPasswordSpec
to a byte array.private static byte[]
encodeClearPasswordSpec(ClearPasswordSpec keySpec)
private static byte[]
encodeDigestPasswordSpec(DigestPasswordSpec keySpec)
private static byte[]
encodeHashPasswordSpec(HashPasswordSpec keySpec)
private static byte[]
encodeIteratedSaltedHashSpec(IteratedSaltedHashPasswordSpec keySpec)
private static byte[]
encodeSaltedHashPasswordSpec(SaltedHashPasswordSpec keySpec)
-
-
-
Field Detail
-
CLEAR_PASSWORD_SPEC_ID
private static final byte CLEAR_PASSWORD_SPEC_ID
- See Also:
- Constant Field Values
-
DIGEST_PASSWORD_SPEC_ID
private static final byte DIGEST_PASSWORD_SPEC_ID
- See Also:
- Constant Field Values
-
HASH_PASSWORD_SPEC_ID
private static final byte HASH_PASSWORD_SPEC_ID
- See Also:
- Constant Field Values
-
SALTED_HASH_PASSWORD_SPEC_ID
private static final byte SALTED_HASH_PASSWORD_SPEC_ID
- See Also:
- Constant Field Values
-
ITERATED_SALTED_HASH_SPEC_ID
private static final byte ITERATED_SALTED_HASH_SPEC_ID
- See Also:
- Constant Field Values
-
-
Method Detail
-
encode
public static byte[] encode(PasswordSpec passwordSpec) throws NoSuchAlgorithmException, InvalidKeySpecException
Encode the givenPasswordSpec
to a byte array.- Parameters:
passwordSpec
- the password spec to encode- Returns:
- a byte array representing the encoded password or null if no encoder was capable to encode the given password
- Throws:
NoSuchAlgorithmException
InvalidKeySpecException
-
encode
public static byte[] encode(Password password) throws NoSuchAlgorithmException, InvalidKeySpecException
Encode the givenPassword
to a byte array.- Parameters:
password
- the password to encode- Returns:
- a byte array representing the encoded password or null if no encoder was capable to encode the given password
- Throws:
NoSuchAlgorithmException
InvalidKeySpecException
-
encode
public static byte[] encode(Password password, Supplier<Provider[]> providers) throws NoSuchAlgorithmException, InvalidKeySpecException
Encode the givenPassword
to a byte array.- Parameters:
password
- the password to encodeproviders
- providers to use with the underlyingPasswordFactory
- Returns:
- a byte array representing the encoded password or null if no encoder was capable to encode the given password
- Throws:
NoSuchAlgorithmException
InvalidKeySpecException
-
decode
public static PasswordSpec decode(byte[] encoded)
Decode the given byte array and create aPasswordSpec
from it.- Parameters:
encoded
- the byte array representing the encoded password- Returns:
- a
PasswordSpec
instance created from the encoded password or null if no decoder was capable to decode the given format.
-
encodeIteratedSaltedHashSpec
private static byte[] encodeIteratedSaltedHashSpec(IteratedSaltedHashPasswordSpec keySpec) throws InvalidKeySpecException
- Throws:
InvalidKeySpecException
-
decodeIteratedSaltedHashPasswordSpec
private static PasswordSpec decodeIteratedSaltedHashPasswordSpec(org.wildfly.common.iteration.ByteIterator iterator)
-
encodeSaltedHashPasswordSpec
private static byte[] encodeSaltedHashPasswordSpec(SaltedHashPasswordSpec keySpec) throws InvalidKeySpecException
- Throws:
InvalidKeySpecException
-
decodeSaltedHashPasswordSpec
private static PasswordSpec decodeSaltedHashPasswordSpec(org.wildfly.common.iteration.ByteIterator iterator)
-
encodeHashPasswordSpec
private static byte[] encodeHashPasswordSpec(HashPasswordSpec keySpec) throws InvalidKeySpecException
- Throws:
InvalidKeySpecException
-
decodeHashPasswordSpec
private static PasswordSpec decodeHashPasswordSpec(org.wildfly.common.iteration.ByteIterator iterator)
-
encodeDigestPasswordSpec
private static byte[] encodeDigestPasswordSpec(DigestPasswordSpec keySpec) throws InvalidKeySpecException
- Throws:
InvalidKeySpecException
-
decodeDigestPasswordSpec
private static PasswordSpec decodeDigestPasswordSpec(org.wildfly.common.iteration.ByteIterator iterator)
-
encodeClearPasswordSpec
private static byte[] encodeClearPasswordSpec(ClearPasswordSpec keySpec) throws InvalidKeySpecException
- Throws:
InvalidKeySpecException
-
decodeClearPasswordSpec
private static PasswordSpec decodeClearPasswordSpec(org.wildfly.common.iteration.ByteIterator iterator)
-
-