Class SaltedPasswordEncoder
- java.lang.Object
-
- de.hybris.platform.persistence.security.SaltedPasswordEncoder
-
- All Implemented Interfaces:
PasswordEncoder
,java.io.Serializable
public class SaltedPasswordEncoder extends java.lang.Object implements PasswordEncoder
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SaltedPasswordEncoder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
calculateHash(java.lang.String plain)
boolean
check(java.lang.String uid, java.lang.String encoded, java.lang.String plain)
Checks if theencoded
password (from the user, from the database) and theplain
password (from the login screen) matches.java.lang.String
decode(java.lang.String encoded)
Decode the givenencoded
password.java.lang.String
encode(java.lang.String uid, java.lang.String password)
This implementation will build a string with the following pattern
:: ::
The value for SYSTEM_SPECIFC_SALT will be generated bygetSystemSpecificSalt()
The Value for USER_SPECIFIC_SALT will be generated bygenerateUserSpecificSalt(String)
...protected java.lang.String
generateUserSpecificSalt(java.lang.String uid)
This implementation will still return the assigned user id.java.lang.String
getAlgorithmn()
java.lang.String
getSalt()
Returns the configured SALT (see core-spring-xml).protected java.lang.String
getSystemSpecificSalt()
This implementation will still return the value of the corresponding spring propertyvoid
setAlgorithmn(java.lang.String algorithmn)
void
setSalt(java.lang.String salt)
-
-
-
Method Detail
-
calculateHash
protected java.lang.String calculateHash(java.lang.String plain)
-
encode
public java.lang.String encode(java.lang.String uid, java.lang.String password)
This implementation will build a string with the following pattern
:: ::
The value for SYSTEM_SPECIFC_SALT will be generated bygetSystemSpecificSalt()
The Value for USER_SPECIFIC_SALT will be generated bygenerateUserSpecificSalt(String)
... and will return the hash of this constructed string.- Specified by:
encode
in interfacePasswordEncoder
- Parameters:
uid
- the user idpassword
- the user password- Returns:
- the hashed value of the constructed string expression
- See Also:
SaltedMD5PasswordEncoder
,PlainTextPasswordEncoder
-
check
public boolean check(java.lang.String uid, java.lang.String encoded, java.lang.String plain)
Description copied from interface:PasswordEncoder
Checks if theencoded
password (from the user, from the database) and theplain
password (from the login screen) matches.- Specified by:
check
in interfacePasswordEncoder
- Parameters:
uid
- mostly the user ID and mostly not used. For MD5 used as salt.encoded
- the encoded passwordplain
- the plain text password- Returns:
true
if they match,false
otherwise.- See Also:
MD5PasswordEncoder
-
decode
public java.lang.String decode(java.lang.String encoded) throws EJBCannotDecodePasswordException
Description copied from interface:PasswordEncoder
Decode the givenencoded
password. Throws exception if this is not possible.- Specified by:
decode
in interfacePasswordEncoder
- Parameters:
encoded
- the encoded password- Returns:
- the decoded password
- Throws:
EJBCannotDecodePasswordException
- if the password cannot be decoded. (MD5 passwords cannot be decoded)- See Also:
MD5PasswordEncoder
-
generateUserSpecificSalt
protected java.lang.String generateUserSpecificSalt(java.lang.String uid)
This implementation will still return the assigned user id.- Parameters:
uid
- the suer id- Returns:
- uid the user id as assigned
-
getSystemSpecificSalt
protected java.lang.String getSystemSpecificSalt()
This implementation will still return the value of the corresponding spring property- Returns:
- systemSpecificSalt the value of the corresponding spring property
-
getSalt
public java.lang.String getSalt()
Returns the configured SALT (see core-spring-xml).- Returns:
- the configured SALT
-
setSalt
public void setSalt(java.lang.String salt)
-
getAlgorithmn
public java.lang.String getAlgorithmn()
- Returns:
- the algorithmn
-
setAlgorithmn
public void setAlgorithmn(java.lang.String algorithmn)
- Parameters:
algorithmn
- the algorithmn to set
-
-