public class DefaulPasswordEncoderService extends Object implements PasswordEncoderService
| Constructor and Description |
|---|
DefaulPasswordEncoderService() |
| Modifier and Type | Method and Description |
|---|---|
String |
decode(UserModel user)
Tries to decodes from the given
user the encoded password based on the encoding set to the user. |
String |
encode(UserModel user,
String plainTextPassword,
String passwordEncoding)
Encodes the given
plainTextPassword with the corresponding PasswordEncoder (based on the
passwordEncoding) and returns it. |
Collection<String> |
getSupportedEncodings() |
boolean |
isSupportedEncoding(String encoding)
Checks if the given password encoding is supported.
|
boolean |
isValid(UserModel user,
String plainPassword)
Checks if the encoded password (stored in the user) matches the given plain text password.
|
boolean |
isValid(UserModel user,
String encoding,
String encodedPassword) |
void |
setEncoderFactory(PasswordEncoderFactory encoderFactory) |
public String encode(UserModel user, String plainTextPassword, String passwordEncoding) throws PasswordEncoderNotFoundException
PasswordEncoderServiceplainTextPassword with the corresponding PasswordEncoder (based on the
passwordEncoding) and returns it. The user can be used as 'salt' in the implementation
of the PasswordEncodersencode in interface PasswordEncoderServiceuser - can be used as 'salt'. See MD5PasswordEncoderplainTextPassword - the plain passwordpasswordEncoding - based on this encoding the correct PasswordEncoder is usedPasswordEncoderNotFoundException - if for the given passwordEncoding no PasswordEncoder is knownpublic String decode(UserModel user) throws PasswordEncoderNotFoundException, CannotDecodePasswordException
PasswordEncoderServiceuser the encoded password based on the encoding set to the user.
see UserModel.getEncodedPassword() and UserModel.getPasswordEncoding()decode in interface PasswordEncoderServiceuser - contains the encoded password and the encodingPasswordEncoderNotFoundException - if for the given passwordEncoding no PasswordEncoder is known in the systemCannotDecodePasswordException - if the encoded password cannot be decoded, see MD5PasswordEncoderpublic boolean isSupportedEncoding(String encoding)
PasswordEncoderServiceisSupportedEncoding in interface PasswordEncoderServiceencoding - the password encodingtrue if the given encoding is supported, false otherwise.PasswordEncoderConstants.DEFAULT_ENCODINGpublic boolean isValid(UserModel user, String plainPassword)
PasswordEncoderServiceisValid in interface PasswordEncoderServiceuser - the user contains the encoded password and the (password) encodingplainPassword - the plain text passwordtrue if the encoded passwords matches, false otherwisepublic Collection<String> getSupportedEncodings()
getSupportedEncodings in interface PasswordEncoderServicepublic void setEncoderFactory(PasswordEncoderFactory encoderFactory)
Copyright © 2017 SAP SE. All Rights Reserved.