Class MessageDigestPassword.Encoder
- All Implemented Interfaces:
Password.Encoder<MessageDigestPassword,MessageDigestPassword.Encoder>
- Enclosing class:
MessageDigestPassword
A MessageDigest based password encoder implementation.
- Since:
- 1.5
- Author:
- Jeremy Kuhn
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default algorithm:SHA-512.static final intThe default salt length in bytes:16.static final byte[]The default secret:new byte[0]. -
Constructor Summary
ConstructorsConstructorDescriptionEncoder()Creates a default message digest password encoder.Creates a message digest password encoder using the specified algorithm.Creates a message digest password encoder using the specified algorithm and secret.Creates a message digest password encoder using the specified algorithm, secret and salt length.Encoder(String algorithm, byte[] secret, int saltLength, SecureRandom secureRandom) Creates a message digest password encoder using the specified algorithm, secret, salt length and secure random. -
Method Summary
Modifier and TypeMethodDescriptionEncodes the specified raw password.booleanReturns the algorithm.intReturns the salt length in kikibytes.byte[]Returns the secret.Returns the secure random.inthashCode()booleanMatches the specified raw password with the specified encoded representation.Recovers a password from its encoded representation generated with this encoder.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.inverno.mod.security.authentication.password.Password.Encoder
matches
-
Field Details
-
DEFAULT_ALGORITHM
The default algorithm:SHA-512.- See Also:
-
DEFAULT_SECRET
public static final byte[] DEFAULT_SECRETThe default secret:new byte[0]. -
DEFAULT_SALT_LENGTH
public static final int DEFAULT_SALT_LENGTHThe default salt length in bytes:16.- See Also:
-
-
Constructor Details
-
Encoder
public Encoder()Creates a default message digest password encoder.
-
Encoder
Creates a message digest password encoder using the specified algorithm.
- Parameters:
algorithm- the algorithm
-
Encoder
Creates a message digest password encoder using the specified algorithm and secret.
- Parameters:
algorithm- the algorithmsecret- the secret
-
Encoder
Creates a message digest password encoder using the specified algorithm, secret and salt length.
- Parameters:
algorithm- the algorithmsecret- the secretsaltLength- the salt length in kikibytes
-
Encoder
Creates a message digest password encoder using the specified algorithm, secret, salt length and secure random.
- Parameters:
algorithm- the algorithmsecret- the secretsaltLength- the salt length in kikibytessecureRandom- the secure random
-
-
Method Details
-
getAlgorithm
Returns the algorithm.
- Returns:
- the algorithm
-
getSecret
public byte[] getSecret()Returns the secret.
- Returns:
- the secret
-
getSaltLength
public int getSaltLength()Returns the salt length in kikibytes.
- Returns:
- the salt length
-
getSecureRandom
Returns the secure random.
- Returns:
- the secure random
-
recover
Description copied from interface:Password.EncoderRecovers a password from its encoded representation generated with this encoder.
- Specified by:
recoverin interfacePassword.Encoder<MessageDigestPassword,MessageDigestPassword.Encoder> - Parameters:
encoded- an encoded password representation- Returns:
- a password
- Throws:
PasswordException- if there was an error recovering the password or if the specified encoded representation was not generated with this encoder
-
encode
Description copied from interface:Password.EncoderEncodes the specified raw password.
- Specified by:
encodein interfacePassword.Encoder<MessageDigestPassword,MessageDigestPassword.Encoder> - Parameters:
raw- a raw password- Returns:
- an encoded password
- Throws:
PasswordException- if there was an error encoding the password
-
matches
Description copied from interface:Password.EncoderMatches the specified raw password with the specified encoded representation.
- Specified by:
matchesin interfacePassword.Encoder<MessageDigestPassword,MessageDigestPassword.Encoder> - Parameters:
raw- a raw passwordencoded- an encoded password- Returns:
- true if passwords match, false otherwise
- Throws:
PasswordException- if there was an error matching passwords
-
hashCode
public int hashCode() -
equals
-