Spring Security——认证失败时获取认证信息
2021-07-20 本文已影响0人
CoderZS
@Component
public class AuthenticationFailureListener implements ApplicationListener<AbstractAuthenticationFailureEvent> {
@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();
}
}
