com.atlassian.crowd.password.encoder
Class LdapMd5PasswordEncoder

java.lang.Object
  extended by org.springframework.security.authentication.encoding.BasePasswordEncoder
      extended by org.springframework.security.authentication.encoding.BaseDigestPasswordEncoder
          extended by org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder
              extended by org.springframework.security.authentication.encoding.Md5PasswordEncoder
                  extended by com.atlassian.crowd.password.encoder.LdapMd5PasswordEncoder
All Implemented Interfaces:
InternalPasswordEncoder, LdapPasswordEncoder, org.springframework.security.authentication.encoding.PasswordEncoder

public class LdapMd5PasswordEncoder
extends org.springframework.security.authentication.encoding.Md5PasswordEncoder
implements InternalPasswordEncoder, LdapPasswordEncoder

A version of Md5PasswordEncoder which supports an Ldap version via having a label of "{MD5}" preappended to the encoded hash. This can be made lower-case in the encoded password, if required, by setting the forceLowerCasePrefix property to true.


Field Summary
protected static String MD5_PREFIX
           
protected static String MD5_PREFIX_LC
           
 
Constructor Summary
LdapMd5PasswordEncoder()
           
 
Method Summary
 String encodePassword(String rawPass, Object salt)
          Encodes the specified raw password with an implementation specific algorithm.
 String getKey()
          The key to define this password encoder
 boolean isPasswordValid(String encPass, String rawPass, Object salt)
          Validates a specified "raw" password against an encoded password.
 void setForceLowerCasePrefix(boolean forceLowerCasePrefix)
           
 
Methods inherited from class org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder
getAlgorithm, getMessageDigest, setIterations
 
Methods inherited from class org.springframework.security.authentication.encoding.BaseDigestPasswordEncoder
getEncodeHashAsBase64, setEncodeHashAsBase64
 
Methods inherited from class org.springframework.security.authentication.encoding.BasePasswordEncoder
demergePasswordAndSalt, mergePasswordAndSalt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MD5_PREFIX

protected static final String MD5_PREFIX
See Also:
Constant Field Values

MD5_PREFIX_LC

protected static final String MD5_PREFIX_LC
Constructor Detail

LdapMd5PasswordEncoder

public LdapMd5PasswordEncoder()
Method Detail

encodePassword

public String encodePassword(String rawPass,
                             Object salt)
Description copied from interface: PasswordEncoder

Encodes the specified raw password with an implementation specific algorithm.

This will generally be a one-way message digest such as MD5 or SHA, but may also be a plaintext variant which does no encoding at all, but rather returns the same password it was fed. The latter is useful to plug in when the original password must be stored as-is.

The specified salt will potentially be used by the implementation to "salt" the initial value before encoding. A salt is usually a user-specific value which is added to the password before the digest is computed. This means that computation of digests for common dictionary words will be different than those in the backend store, because the dictionary word digests will not reflect the addition of the salt. If a per-user salt is used (rather than a system-wide salt), it also means users with the same password will have different digest encoded passwords in the backend store.

If a salt value is provided, the same salt value must be use when calling the PasswordEncoder.isPasswordValid(String, String, Object) method. Note that a specific implementation may choose to ignore the salt value (via null), or provide its own.

Specified by:
encodePassword in interface org.springframework.security.authentication.encoding.PasswordEncoder
Overrides:
encodePassword in class org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder
Parameters:
rawPass - the password to encode
salt - optionally used by the implementation to "salt" the raw password before encoding. A null value is legal.
Returns:
encoded password

isPasswordValid

public boolean isPasswordValid(String encPass,
                               String rawPass,
                               Object salt)
Description copied from interface: PasswordEncoder

Validates a specified "raw" password against an encoded password.

The encoded password should have previously been generated by PasswordEncoder.encodePassword(String, Object). This method will encode the rawPass (using the optional salt), and then compared it with the presented encPass.

For a discussion of salts, please refer to PasswordEncoder.encodePassword(String, Object).

Specified by:
isPasswordValid in interface org.springframework.security.authentication.encoding.PasswordEncoder
Overrides:
isPasswordValid in class org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder
Parameters:
encPass - a pre-encoded password
rawPass - a raw password to encode and compare against the pre-encoded password
salt - optionally used by the implementation to "salt" the raw password before encoding. A null value is legal.
Returns:
true if the password is valid , false otherwise

getKey

public String getKey()
Description copied from interface: PasswordEncoder
The key to define this password encoder

Returns:

setForceLowerCasePrefix

public void setForceLowerCasePrefix(boolean forceLowerCasePrefix)


Copyright © 2013 Atlassian. All Rights Reserved.