public Authentication authenticate(Authentication auth) throws AuthenticationException {
logger.debug("Authentication using {}", getClass());
User user = attachToUser(auth);
if (!passwordEncoder.isPasswordValid(user.getPassword(), (String) auth.getCredentials())) {
throw new BadCredentialsException(Authentication.ERROR_PASSWORD);
}
return auth;
}