public final class BasicPasswordEncryptor extends java.lang.Object implements PasswordEncryptor
Utility class for easily performing password digesting and checking.
This class internally holds a StandardStringDigester
configured this way:
The required steps to use it are:
encryptPassword(String) or
checkPassword(String, String)
operations.This class is thread-safe
| Modifier and Type | Field and Description |
|---|---|
private StandardStringDigester |
digester |
| Constructor and Description |
|---|
BasicPasswordEncryptor()
Creates a new instance of BasicPasswordEncryptor
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
checkPassword(java.lang.String plainPassword,
java.lang.String encryptedPassword)
Checks an unencrypted (plain) password against an encrypted one
(a digest) to see if they match.
|
java.lang.String |
encryptPassword(java.lang.String password)
Encrypts (digests) a password.
|
private final StandardStringDigester digester
public BasicPasswordEncryptor()
public java.lang.String encryptPassword(java.lang.String password)
encryptPassword in interface PasswordEncryptorpassword - the password to be encrypted.StandardStringDigester.digest(String)public boolean checkPassword(java.lang.String plainPassword,
java.lang.String encryptedPassword)
checkPassword in interface PasswordEncryptorplainPassword - the plain password to check.encryptedPassword - the digest against which to check the password.StandardStringDigester.matches(String, String)