|
|
|
@ -91,11 +91,11 @@ public final class PasswordComparisonAuthenticator extends AbstractLdapAuthentic |
|
|
|
ctx.getAttributes(relativeName, getUserAttributes())); |
|
|
|
ctx.getAttributes(relativeName, getUserAttributes())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(user == null && getUserSearch() != null) { |
|
|
|
if (user == null && getUserSearch() != null) { |
|
|
|
user = getUserSearch().searchForUser(username); |
|
|
|
user = getUserSearch().searchForUser(username); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(user == null) { |
|
|
|
if (user == null) { |
|
|
|
throw new UsernameNotFoundException(username); |
|
|
|
throw new UsernameNotFoundException(username); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -104,19 +104,19 @@ public final class PasswordComparisonAuthenticator extends AbstractLdapAuthentic |
|
|
|
if(passwordAttribute != null) { |
|
|
|
if(passwordAttribute != null) { |
|
|
|
Object retrievedPassword = passwordAttribute.get(); |
|
|
|
Object retrievedPassword = passwordAttribute.get(); |
|
|
|
|
|
|
|
|
|
|
|
if(!(retrievedPassword instanceof String)) { |
|
|
|
if (!(retrievedPassword instanceof String)) { |
|
|
|
// Assume it's binary
|
|
|
|
// Assume it's binary
|
|
|
|
retrievedPassword = new String((byte[])retrievedPassword); |
|
|
|
retrievedPassword = new String((byte[])retrievedPassword); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(!verifyPassword(password, (String)retrievedPassword)) { |
|
|
|
if (!verifyPassword(password, (String)retrievedPassword)) { |
|
|
|
throw new BadCredentialsException(messages.getMessage( |
|
|
|
throw new BadCredentialsException(messages.getMessage( |
|
|
|
"PasswordComparisonAuthenticator.badCredentials", |
|
|
|
"PasswordComparisonAuthenticator.badCredentials", |
|
|
|
"Bad credentials")); |
|
|
|
"Bad credentials")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if(logger.isDebugEnabled()) { |
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
logger.debug("Password attribute " + passwordAttributeName |
|
|
|
logger.debug("Password attribute " + passwordAttributeName |
|
|
|
+ " wasn't retrieved for user " + username); |
|
|
|
+ " wasn't retrieved for user " + username); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -136,7 +136,7 @@ public final class PasswordComparisonAuthenticator extends AbstractLdapAuthentic |
|
|
|
* Allows the use of both simple and hashed passwords in the directory. |
|
|
|
* Allows the use of both simple and hashed passwords in the directory. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private boolean verifyPassword(String password, String ldapPassword) { |
|
|
|
private boolean verifyPassword(String password, String ldapPassword) { |
|
|
|
if(ldapPassword.equals(password)) { |
|
|
|
if (ldapPassword.equals(password)) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -148,7 +148,7 @@ public final class PasswordComparisonAuthenticator extends AbstractLdapAuthentic |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void doPasswordCompare(DirContext ctx, String name, String password) throws NamingException { |
|
|
|
private void doPasswordCompare(DirContext ctx, String name, String password) throws NamingException { |
|
|
|
if(logger.isDebugEnabled()) { |
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
logger.debug("Performing LDAP compare of password for " + name); |
|
|
|
logger.debug("Performing LDAP compare of password for " + name); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|