String ldapPassword = null;
try {
ldapPassword = (String) ldapTemplate.lookup(dn, new String[] { "userPassword" },
new ContextMapper() {
public Object mapFromContext(Object ctx) {
DirContextAdapter context = (DirContextAdapter) ctx;
return new String((byte[]) context.getObjectAttribute("userPassword"));
}
});
} catch (EntryNotFoundException e) {
logger.info("cannot found {} in ldap", userName);
throw new AuthenticationException("ldap user " + userName + " not found");