public class BCryptPasswordEncoder extends java.lang.Object implements PasswordEncoder
| Modifier and Type | Class and Description |
|---|---|
static class |
BCryptPasswordEncoder.BCryptVersion
Stores the default bcrypt version for use in configuration.
|
| Constructor and Description |
|---|
BCryptPasswordEncoder() |
BCryptPasswordEncoder(BCryptPasswordEncoder.BCryptVersion version) |
BCryptPasswordEncoder(BCryptPasswordEncoder.BCryptVersion version,
int strength) |
BCryptPasswordEncoder(BCryptPasswordEncoder.BCryptVersion version,
int strength,
java.security.SecureRandom random) |
BCryptPasswordEncoder(BCryptPasswordEncoder.BCryptVersion version,
java.security.SecureRandom random) |
BCryptPasswordEncoder(int strength) |
BCryptPasswordEncoder(int strength,
java.security.SecureRandom random) |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
encode(java.lang.CharSequence rawPassword)
Encode the raw password.
|
boolean |
matches(java.lang.CharSequence rawPassword,
java.lang.String encodedPassword)
Verify the encoded password obtained from storage matches the submitted raw
password after it too is encoded.
|
boolean |
upgradeEncoding(java.lang.String encodedPassword)
Returns true if the encoded password should be encoded again for better security,
else false.
|
public BCryptPasswordEncoder()
public BCryptPasswordEncoder(int strength)
strength - the log rounds to use, between 4 and 31public BCryptPasswordEncoder(BCryptPasswordEncoder.BCryptVersion version)
version - the version of bcrypt, can be 2a,2b,2ypublic BCryptPasswordEncoder(BCryptPasswordEncoder.BCryptVersion version, java.security.SecureRandom random)
version - the version of bcrypt, can be 2a,2b,2yrandom - the secure random instance to usepublic BCryptPasswordEncoder(int strength,
java.security.SecureRandom random)
strength - the log rounds to use, between 4 and 31random - the secure random instance to usepublic BCryptPasswordEncoder(BCryptPasswordEncoder.BCryptVersion version, int strength)
version - the version of bcrypt, can be 2a,2b,2ystrength - the log rounds to use, between 4 and 31public BCryptPasswordEncoder(BCryptPasswordEncoder.BCryptVersion version, int strength, java.security.SecureRandom random)
version - the version of bcrypt, can be 2a,2b,2ystrength - the log rounds to use, between 4 and 31random - the secure random instance to usepublic java.lang.String encode(java.lang.CharSequence rawPassword)
PasswordEncoderencode in interface PasswordEncoderpublic boolean matches(java.lang.CharSequence rawPassword,
java.lang.String encodedPassword)
PasswordEncodermatches in interface PasswordEncoderrawPassword - the raw password to encode and matchencodedPassword - the encoded password from storage to compare withpublic boolean upgradeEncoding(java.lang.String encodedPassword)
PasswordEncoderupgradeEncoding in interface PasswordEncoderencodedPassword - the encoded password to check