|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.security.authentication.encoding.BasePasswordEncoder org.springframework.security.authentication.encoding.PlaintextPasswordEncoder
public class PlaintextPasswordEncoder
Plaintext implementation of PasswordEncoder.
As callers may wish to extract the password and salts separately from the encoded password, the salt must not contain reserved characters (specifically '{' and '}').
Constructor Summary | |
---|---|
PlaintextPasswordEncoder()
|
Method Summary | |
---|---|
String |
encodePassword(String rawPass,
Object salt)
Encodes the specified raw password with an implementation specific algorithm. |
boolean |
isIgnorePasswordCase()
|
boolean |
isPasswordValid(String encPass,
String rawPass,
Object salt)
Validates a specified "raw" password against an encoded password. |
String[] |
obtainPasswordAndSalt(String password)
Demerges the previously encodePassword(String, Object) String . |
void |
setIgnorePasswordCase(boolean ignorePasswordCase)
Indicates whether the password comparison is case sensitive. |
Methods inherited from class org.springframework.security.authentication.encoding.BasePasswordEncoder |
---|
demergePasswordAndSalt, mergePasswordAndSalt |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PlaintextPasswordEncoder()
Method Detail |
---|
public String encodePassword(String rawPass, Object salt)
PasswordEncoder
Encodes the specified raw password with an implementation specific algorithm.
This will generally be a one-way message digest such as MD5 or SHA, but may also be a plaintext variant which does no encoding at all, but rather returns the same password it was fed. The latter is useful to plug in when the original password must be stored as-is.
The specified salt will potentially be used by the implementation to "salt" the initial value before encoding. A salt is usually a user-specific value which is added to the password before the digest is computed. This means that computation of digests for common dictionary words will be different than those in the backend store, because the dictionary word digests will not reflect the addition of the salt. If a per-user salt is used (rather than a system-wide salt), it also means users with the same password will have different digest encoded passwords in the backend store.
If a salt value is provided, the same salt value must be use when calling the PasswordEncoder.isPasswordValid(String, String, Object)
method. Note that a specific implementation may choose to ignore the
salt value (via null
), or provide its own.
rawPass
- the password to encodesalt
- optionally used by the implementation to "salt" the raw password before encoding. A
null
value is legal.
public boolean isIgnorePasswordCase()
public boolean isPasswordValid(String encPass, String rawPass, Object salt)
PasswordEncoder
Validates a specified "raw" password against an encoded password.
The encoded password should have previously been generated by PasswordEncoder.encodePassword(String,
Object)
. This method will encode the rawPass
(using the optional salt
), and then
compared it with the presented encPass
.
For a discussion of salts, please refer to PasswordEncoder.encodePassword(String, Object)
.
encPass
- a pre-encoded passwordrawPass
- a raw password to encode and compare against the pre-encoded passwordsalt
- optionally used by the implementation to "salt" the raw password before encoding. A
null
value is legal.
public String[] obtainPasswordAndSalt(String password)
encodePassword(String, Object)
String
.The resulting array is guaranteed to always contain two elements. The first is the password, and the second is the salt.
Throws an exception if null
or an empty String
is passed to the method.
password
- from encodePassword(String, Object)
public void setIgnorePasswordCase(boolean ignorePasswordCase)
Defaults to false
, meaning
an exact case match is required.
ignorePasswordCase
- set to true
for less stringent comparison
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |