Class ModularCrypt
- java.lang.Object
-
- org.wildfly.security.password.util.ModularCrypt
-
public final class ModularCrypt extends Object
Helper utility methods for operation on passwords based on the Modular Crypt Format(MCF).- Author:
- Juraci Paixão Kröhling, David M. Lloyd
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
composePassword(ByteArrayOutputStream out, Password password)
static Password
createPassword(byte[] password, String algorithm)
static Password
decode(char[] cryptString)
Decode the given char array and creates aPassword
instance.static Password
decode(String cryptString)
Decode the given string and creates aPassword
instance.static char[]
encode(Password password)
Encode the givenPassword
to a char array.static String
encodeAsString(Password password)
Encode the givenPassword
to a string.static String
identifyAlgorithm(char[] chars)
Attempt to identify the algorithm used by the given crypt string password.
-
-
-
Method Detail
-
identifyAlgorithm
public static String identifyAlgorithm(char[] chars)
Attempt to identify the algorithm used by the given crypt string password.- Parameters:
chars
- the password crypt string characters- Returns:
- the algorithm name, or
null
if no algorithm could be guessed
-
encode
public static char[] encode(Password password) throws InvalidKeySpecException
Encode the givenPassword
to a char array.- Parameters:
password
- the password to encode- Returns:
- a char array representing the encoded password
- Throws:
InvalidKeySpecException
- if the given password is not supported or could be encoded
-
encodeAsString
public static String encodeAsString(Password password) throws InvalidKeySpecException
Encode the givenPassword
to a string.- Parameters:
password
- the password to encode- Returns:
- a string representing the encoded password
- Throws:
InvalidKeySpecException
- if the given password is not supported or could be encoded
-
decode
public static Password decode(String cryptString) throws InvalidKeySpecException
Decode the given string and creates aPassword
instance.- Parameters:
cryptString
- the string representing the encoded format of the password- Returns:
- a
Password
instance created from the given string - Throws:
InvalidKeySpecException
- if the given password is not supported or could be decoded
-
decode
public static Password decode(char[] cryptString) throws InvalidKeySpecException
Decode the given char array and creates aPassword
instance.- Parameters:
cryptString
- the char array representing the encoded format of the password- Returns:
- a
Password
instance created from the given string - Throws:
InvalidKeySpecException
- if the given password is not supported or could be decoded
-
createPassword
public static Password createPassword(byte[] password, String algorithm) throws InvalidKeySpecException
- Throws:
InvalidKeySpecException
-
composePassword
public static void composePassword(ByteArrayOutputStream out, Password password) throws IOException
- Throws:
IOException
-
-