Class CompositePasswordEncoder
java.lang.Object
org.alfresco.repo.security.authentication.CompositePasswordEncoder
A configurable password encoding that delegates the encoding to a Map of configured encoders.
- Author:
- Gethin James
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringEncode a password using the specified encoderKeyencodePassword(String rawPassword, Object salt, List<String> encodingChain) Encode a passwordencodePreferred(String rawPassword, Object salt) Encodes a password in the preferred encoding.voidinit()Basic init method for checking mandatory propertiesbooleanisSafeToEncodeChain(List<String> encodingChain) Determines if its safe to encode the encoding chain.booleanlastEncodingIsPreferred(List<String> hashIndicator) Is the preferred encoding the last encoding to be used.protected booleanDoes the password match?booleanmatchesPassword(String rawPassword, String encodedPassword, Object salt, List<String> encodingChain) Does the password match?voidsetEncoders(Map<String, Object> encoders) voidsetPreferredEncoding(String preferredEncoding)
-
Field Details
-
MD4_KEY
- See Also:
-
SHA256
-
MD4
-
-
Constructor Details
-
CompositePasswordEncoder
public CompositePasswordEncoder()
-
-
Method Details
-
getPreferredEncoding
-
setPreferredEncoding
-
setEncoders
-
lastEncodingIsPreferred
Is the preferred encoding the last encoding to be used.- Parameters:
hashIndicator- representing the encoding- Returns:
- true if is correct
-
isSafeToEncodeChain
Determines if its safe to encode the encoding chain. This applies particularly to double-hashing. BCRYPT uses its own internal salt so its NOT safe to use it more than once in an encoding chain (because the result will be different each time.) BCRYPT CAN BE USED successfully as the last element in an encoding chain. Anything that implements springframework PasswordEncoder is considered "unsafe" (because the method takes no salt param).- Parameters:
encodingChain- mandatory encoding chain- Returns:
- true if it is okay to encode this chain.
-
init
public void init()Basic init method for checking mandatory properties -
encodePassword
Encode a password- Parameters:
rawPassword- mandatory passwordsalt- optional saltencodingChain- mandatory encoding chain- Returns:
- the encoded password
-
encodePreferred
Encodes a password in the preferred encoding.- Parameters:
rawPassword- mandatory passwordsalt- optional salt- Returns:
- Encoded password
-
encode
Encode a password using the specified encoderKey- Parameters:
encoderKey- the encoder to userawPassword- mandatory passwordsalt- optional salt- Returns:
- the encoded password
-
matchesPassword
public boolean matchesPassword(String rawPassword, String encodedPassword, Object salt, List<String> encodingChain) Does the password match?- Parameters:
rawPassword- mandatory passwordencodedPassword- mandatory hashed versionsalt- optional saltencodingChain- mandatory encoding chain- Returns:
- true if they match
-
matches
protected boolean matches(String encoderKey, String rawPassword, String encodedPassword, Object salt) Does the password match?- Parameters:
encoderKey- the encoder to userawPassword- mandatory passwordencodedPassword- mandatory hashed versionsalt- optional salt- Returns:
- true if they match
-