public Authentication authenticate(Authentication authentication) throws AuthenticationException {
...省略其他代码
String username = authentication.getName();
UserDetails userDetails = this.getUserDetailsService().loadUserByUsername(username);
String presentedPassword = authentication.getCredentials().toString();
String password = authentication.getCredentials().toString();
if (!passwordEncoder.matches(password, userDetails.getPassword())) {
throw new BadCredentialsException("错误信息...");
}
UsernamePasswordAuthenticationToken result = new UsernamePasswordAuthenticationToken(userDetails,
authentication.getCredentials(), userDetails.getAuthorities());
return result;
...省略其他代码
}