Class JBCryptPasswordEncoder
- java.lang.Object
-
- org.pac4j.core.credentials.password.JBCryptPasswordEncoder
-
- All Implemented Interfaces:
PasswordEncoder
public class JBCryptPasswordEncoder extends java.lang.Object implements PasswordEncoder
A password encoder for bcrypt and using a salt. Add thejBcrypt
dependency to use this class.- Since:
- 1.9.2
- Author:
- Victor Noël
-
-
Constructor Summary
Constructors Constructor Description JBCryptPasswordEncoder()
Use the default salt generated byBCrypt.gensalt()
.JBCryptPasswordEncoder(java.lang.String salt)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
encode(java.lang.String password)
Encode a password.java.lang.String
getSalt()
boolean
matches(java.lang.String plainPassword, java.lang.String encodedPassword)
Validate if a plainPassword matchesvoid
setSalt(java.lang.String salt)
-
-
-
Constructor Detail
-
JBCryptPasswordEncoder
public JBCryptPasswordEncoder(java.lang.String salt)
- Parameters:
salt
- the salt to hash with (perhaps generated usingBCrypt.gensalt()
)- See Also:
BCrypt
-
JBCryptPasswordEncoder
public JBCryptPasswordEncoder()
Use the default salt generated byBCrypt.gensalt()
.
-
-
Method Detail
-
encode
public java.lang.String encode(java.lang.String password)
Description copied from interface:PasswordEncoder
Encode a password.- Specified by:
encode
in interfacePasswordEncoder
- Parameters:
password
- the not encoded password- Returns:
- the encoded password
-
matches
public boolean matches(java.lang.String plainPassword, java.lang.String encodedPassword)
Description copied from interface:PasswordEncoder
Validate if a plainPassword matches- Specified by:
matches
in interfacePasswordEncoder
- Parameters:
plainPassword
- the not encoded password to checkencodedPassword
- the encoded password- Returns:
true
if they match
-
getSalt
public java.lang.String getSalt()
-
setSalt
public void setSalt(java.lang.String salt)
- Parameters:
salt
- the salt to hash with (perhaps generated usingBCrypt.gensalt()
)- See Also:
BCrypt
-
-