java.lang.Object | |||
↳ | org.springframework.security.authentication.encoding.BasePasswordEncoder | ||
↳ | org.springframework.security.authentication.encoding.BaseDigestPasswordEncoder | ||
↳ | org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder |
Known Direct Subclasses |
Base for digest password encoders.
This class can be used stand-alone, or one of the subclasses can be used for compatiblity and convenience. When using this class directly you must specify a Message Digest Algorithm to use as a constructor arg.
The encoded password hash is normally returned as Hex (32 char) version of the hash bytes.
Setting the encodeHashAsBase64 property to true will cause the encoded pass to be returned
as Base64 text, which will consume 24 characters.
See setEncodeHashAsBase64(boolean)
This PasswordEncoder
can be used directly as in the following example:
<bean id="passwordEncoder" class="org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder"> <constructor-arg value="MD5"/> </bean>
If desired, the iterations
property can be set to enable
"password stretching" for the digest calculation.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
The digest algorithm to use
Supports the named
Message Digest Algorithms in the Java environment.
| |||||||||||
Convenience constructor for specifying the algorithm and whether or not to enable base64 encoding
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Encodes the rawPass using a MessageDigest.
| |||||||||||
Takes a previously encoded password and compares it with a rawpassword after mixing in the salt and
encoding that value
| |||||||||||
Sets the number of iterations for which the calculated hash value should be "stretched".
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Get a MessageDigest instance for the given algorithm.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.security.authentication.encoding.BaseDigestPasswordEncoder
| |||||||||||
From class
org.springframework.security.authentication.encoding.BasePasswordEncoder
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
org.springframework.security.authentication.encoding.PasswordEncoder
|
The digest algorithm to use Supports the named Message Digest Algorithms in the Java environment.
Convenience constructor for specifying the algorithm and whether or not to enable base64 encoding
IllegalArgumentException | if an unknown |
---|
Encodes the rawPass using a MessageDigest. If a salt is specified it will be merged with the password before encoding.
rawPass | The plain text password |
---|---|
salt | The salt to sprinkle |
Takes a previously encoded password and compares it with a rawpassword after mixing in the salt and encoding that value
encPass | previously encoded password |
---|---|
rawPass | plain text password |
salt | salt to mix into password |
Sets the number of iterations for which the calculated hash value should be "stretched". If this is greater than one, the initial digest is calculated, the digest function will be called repeatedly on the result for the additional number of iterations.
iterations | the number of iterations which will be executed on the hashed password/salt value. Defaults to 1. |
---|
Get a MessageDigest instance for the given algorithm. Throws an IllegalArgumentException if algorithm is unknown
IllegalArgumentException | if NoSuchAlgorithmException is thrown |
---|