Class CustomPasswordEncoder
java.lang.Object
org.opencastproject.kernel.security.CustomPasswordEncoder
- All Implemented Interfaces:
org.springframework.security.authentication.encoding.PasswordEncoder
public class CustomPasswordEncoder
extends Object
implements org.springframework.security.authentication.encoding.PasswordEncoder
Password encoder using bcrypt for password hashing while still supporting the verification of olf md5 based
passwords.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionencodePassword(String rawPassword) Encode the raw password for storage using bcrypt.encodePassword(String rawPassword, Object ignored) Encode the raw password for storage using bcrypt.booleanisPasswordValid(String encodedPassword, String rawPassword, Object salt) Verify the encoded password obtained from storage matches the submitted raw password after it too is encoded.static StringEncode a clear text password using Opencast's legacy MD5 based hashing with salt.
-
Constructor Details
-
CustomPasswordEncoder
public CustomPasswordEncoder()
-
-
Method Details
-
encodePassword
Encode the raw password for storage using bcrypt.- Parameters:
rawPassword- raw password to encrypt/hash- Returns:
- hashed password
-
encodePassword
Encode the raw password for storage using bcrypt.- Specified by:
encodePasswordin interfaceorg.springframework.security.authentication.encoding.PasswordEncoder- Parameters:
rawPassword- raw password to encrypt/hashignored- This parameter will not be used. A random salt is generated by bcrypt.- Returns:
- hashed password
-
isPasswordValid
Verify the encoded password obtained from storage matches the submitted raw password after it too is encoded. Returns true if the passwords match, false if they do not. The stored password itself is never decoded.- Specified by:
isPasswordValidin interfaceorg.springframework.security.authentication.encoding.PasswordEncoder- Parameters:
encodedPassword- the encoded password from storage to compare withrawPassword- the raw password to encode and match- Returns:
- true if the raw password, after encoding, matches the encoded password from storage
-
md5Encode
Encode a clear text password using Opencast's legacy MD5 based hashing with salt. The username was used as salt for this.- Parameters:
clearText- the passwordsalt- the salt- Returns:
- the hashed password
- Throws:
IllegalArgumentException- if clearText or salt are null
-