error("Neither user dn pattern or user filter specified");
return;
}
LDAPSecurityProvider provider = new LDAPSecurityProvider(getSecurityManager());
LDAPAuthenticationProvider authProvider = (LDAPAuthenticationProvider) provider
.createAuthenticationProvider(ldapConfig);
Authentication authentication = authProvider
.authenticate(new UsernamePasswordAuthenticationToken(
username, password));
if(authentication == null || !authentication.isAuthenticated()) {
throw new AuthenticationException("Cannot authenticate " + username);
}