Spring Security——认证失败时获取认证信息

@Component
public class AuthenticationFailureListener implements ApplicationListener {
  @Override
  public void onApplicationEvent(AbstractAuthenticationFailureEvent event) {
    //登陆账号 密码
    Object username = event.getAuthentication().getPrincipal();
    Object credentials = event.getAuthentication().getCredentials();
    Object details=event.getAuthentication().getDetails();
    String ip = ((WebAuthenticationDetails)details).getRemoteAddress();
  }
}
图片.png

你可能感兴趣的:(Spring Security——认证失败时获取认证信息)