Class DefaulPasswordEncoderService
- java.lang.Object
-
- de.hybris.platform.servicelayer.user.impl.DefaulPasswordEncoderService
-
- All Implemented Interfaces:
PasswordEncoderService
- Direct Known Subclasses:
LDAPPasswordEncoderService
public class DefaulPasswordEncoderService extends java.lang.Object implements PasswordEncoderService
Default implementation.
-
-
Constructor Summary
Constructors Constructor Description DefaulPasswordEncoderService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringdecode(UserModel user)Tries to decodes from the givenuserthe encoded password based on the encoding set to the user.java.lang.Stringencode(UserModel user, java.lang.String plainTextPassword, java.lang.String passwordEncoding)Encodes the givenplainTextPasswordwith the corresponding PasswordEncoder (based on thepasswordEncoding) and returns it.java.util.Collection<java.lang.String>getSupportedEncodings()booleanisSupportedEncoding(java.lang.String encoding)Checks if the given password encoding is supported.booleanisValid(UserModel user, java.lang.String plainPassword)Checks if the encoded password (stored in the user) matches the given plain text password.booleanisValid(UserModel user, java.lang.String encoding, java.lang.String encodedPassword)voidsetEncoderFactory(PasswordEncoderFactory encoderFactory)
-
-
-
Method Detail
-
encode
public java.lang.String encode(UserModel user, java.lang.String plainTextPassword, java.lang.String passwordEncoding) throws PasswordEncoderNotFoundException
Description copied from interface:PasswordEncoderServiceEncodes the givenplainTextPasswordwith the corresponding PasswordEncoder (based on thepasswordEncoding) and returns it. Theusercan be used as 'salt' in the implementation of thePasswordEncoders- Specified by:
encodein interfacePasswordEncoderService- Parameters:
user- can be used as 'salt'. SeeMD5PasswordEncoderplainTextPassword- the plain passwordpasswordEncoding- based on this encoding the correct PasswordEncoder is used- Returns:
- the encoded password
- Throws:
PasswordEncoderNotFoundException- if for the given passwordEncoding no PasswordEncoder is known
-
decode
public java.lang.String decode(UserModel user) throws PasswordEncoderNotFoundException, CannotDecodePasswordException
Description copied from interface:PasswordEncoderServiceTries to decodes from the givenuserthe encoded password based on the encoding set to the user.see
UserModel.getEncodedPassword()andUserModel.getPasswordEncoding()- Specified by:
decodein interfacePasswordEncoderService- Parameters:
user- contains the encoded password and the encoding- Returns:
- the password in plain text if possible
- Throws:
PasswordEncoderNotFoundException- if for the given passwordEncoding no PasswordEncoder is known in the systemCannotDecodePasswordException- if the encoded password cannot be decoded, see MD5PasswordEncoder
-
isSupportedEncoding
public boolean isSupportedEncoding(java.lang.String encoding)
Description copied from interface:PasswordEncoderServiceChecks if the given password encoding is supported.- Specified by:
isSupportedEncodingin interfacePasswordEncoderService- Parameters:
encoding- the password encoding- Returns:
trueif the given encoding is supported,falseotherwise.- See Also:
PasswordEncoderConstants.DEFAULT_ENCODING
-
isValid
public boolean isValid(UserModel user, java.lang.String plainPassword)
Description copied from interface:PasswordEncoderServiceChecks if the encoded password (stored in the user) matches the given plain text password. For this the plain password will be encoded and compared with the user's encoded password.- Specified by:
isValidin interfacePasswordEncoderService- Parameters:
user- the user contains the encoded password and the (password) encodingplainPassword- the plain text password- Returns:
trueif the encoded passwords matches,falseotherwise
-
isValid
public boolean isValid(UserModel user, java.lang.String encoding, java.lang.String encodedPassword)
-
getSupportedEncodings
public java.util.Collection<java.lang.String> getSupportedEncodings()
- Specified by:
getSupportedEncodingsin interfacePasswordEncoderService- Returns:
- a collection with the supported encodings of this system.
-
setEncoderFactory
public void setEncoderFactory(PasswordEncoderFactory encoderFactory)
-
-