Class PBKDF2Password.Encoder
- All Implemented Interfaces:
Password.Encoder<PBKDF2Password,PBKDF2Password.Encoder>
- Enclosing class:
PBKDF2Password
A PBKDF2 based password encoder implementation.
- Since:
- 1.5
- Author:
- Jeremy Kuhn
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault hash length in kikibytes:32.static final intDefault iteration count:1000.static final StringDefault pseudorandom function.static final intDefault salt length in kikibytes:16.static final StringSHA256 pseudorandom function.static final StringSHA384 pseudorandom function.static final StringSHA512 pseudorandom function. -
Constructor Summary
ConstructorsConstructorDescriptionEncoder()Creates a default PBKDF2 password encoder.Creates a PBKDF2 password encoder with the specified pseudorandom function.Creates a PBKDF2 password encoder with the specified pseudorandom function, iteration count, salt length and hash length.Encoder(String prf, int iterationCount, int saltLength, int hashLength, SecureRandom secureRandom) Creates a PBKDF2 password encoder with the specified pseudorandom function, iteration count, salt length, hash length and secure random. -
Method Summary
Modifier and TypeMethodDescriptionEncodes the specified raw password.booleanintReturns the hash length in kikibytes.intReturns the iteration count.Returns the pseudorandom function.intReturns the salt length in kikibytes.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
-
PRF_SHA256
SHA256 pseudorandom function.- See Also:
-
PRF_SHA384
SHA384 pseudorandom function.- See Also:
-
PRF_SHA512
SHA512 pseudorandom function.- See Also:
-
DEFAULT_PRF
Default pseudorandom function.- See Also:
-
DEFAULT_SALT_LENGTH
public static final int DEFAULT_SALT_LENGTHDefault salt length in kikibytes:16.- See Also:
-
DEFAULT_HASH_LENGTH
public static final int DEFAULT_HASH_LENGTHDefault hash length in kikibytes:32.- See Also:
-
DEFAULT_ITERATION_COUNT
public static final int DEFAULT_ITERATION_COUNTDefault iteration count:1000.- See Also:
-
-
Constructor Details
-
Encoder
public Encoder()Creates a default PBKDF2 password encoder.
-
Encoder
Creates a PBKDF2 password encoder with the specified pseudorandom function.
- Parameters:
prf- the pseudorandom function
-
Encoder
Creates a PBKDF2 password encoder with the specified pseudorandom function, iteration count, salt length and hash length.
- Parameters:
prf- the pseudorandom functioniterationCount- the iteration countsaltLength- the salt length in kikibyteshashLength- the hash length in kikibytes
-
Encoder
public Encoder(String prf, int iterationCount, int saltLength, int hashLength, SecureRandom secureRandom) Creates a PBKDF2 password encoder with the specified pseudorandom function, iteration count, salt length, hash length and secure random.
- Parameters:
prf- the pseudorandom functioniterationCount- the iteration countsaltLength- the salt length in kikibyteshashLength- the hash length in kikibytessecureRandom- the secure random
-
-
Method Details
-
getPseudoRandomFunction
Returns the pseudorandom function.
- Returns:
- the pseudorandom function
-
getIterationCount
public int getIterationCount()Returns the iteration count.
- Returns:
- the iteration count
-
getSaltLength
public int getSaltLength()Returns the salt length in kikibytes.
- Returns:
- the salt length
-
getHashLength
public int getHashLength()Returns the hash length in kikibytes.
- Returns:
- the hash 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<PBKDF2Password,PBKDF2Password.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<PBKDF2Password,PBKDF2Password.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<PBKDF2Password,PBKDF2Password.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
-