public final class RFC2307SMD5PasswordEncryptor extends Object implements PasswordEncryptor
Utility class for easily performing password digesting and checking according to {SMD5}, a password encryption scheme defined in RFC2307 and commonly found in LDAP systems.
This class internally holds a StandardStringDigester
configured this way:
setSaltSizeBytes(int)
).This class is thread-safe
Constructor and Description |
---|
RFC2307SMD5PasswordEncryptor()
Creates a new instance of RFC2307OpenLDAPSSHAPasswordEncryptor
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkPassword(String plainPassword,
String encryptedPassword)
Checks an unencrypted (plain) password against an encrypted one
(a digest) to see if they match.
|
String |
encryptPassword(String password)
Encrypts (digests) a password.
|
void |
setSaltSizeBytes(int saltSizeBytes)
Sets the size (in bytes) of the salt to be used.
|
void |
setStringOutputType(String stringOutputType)
Sets the the form in which String output
will be encoded.
|
public RFC2307SMD5PasswordEncryptor()
public void setSaltSizeBytes(int saltSizeBytes)
Sets the size (in bytes) of the salt to be used.
Default is 8.
saltSizeBytes
- the salt size in bytespublic void setStringOutputType(String stringOutputType)
Sets the the form in which String output will be encoded. Available encoding types are:
stringOutputType
- the string output type.public String encryptPassword(String password)
encryptPassword
in interface PasswordEncryptor
password
- the password to be encrypted.StandardStringDigester.digest(String)
public boolean checkPassword(String plainPassword, String encryptedPassword)
Checks an unencrypted (plain) password against an encrypted one (a digest) to see if they match.
This password encryptor expects encrypted passwords being matched to include the "{SMD5}" prefix, and will fail if not.
checkPassword
in interface PasswordEncryptor
plainPassword
- the plain password to check.encryptedPassword
- the digest against which to check the password.StandardStringDigester.matches(String, String)
Copyright © 2018 JBoss by Red Hat. All rights reserved.