List of usage examples for org.springframework.security.authentication.event AuthenticationFailureBadCredentialsEvent getAuthentication
public Authentication getAuthentication()
Authentication
request that caused the event. From source file:cz.fi.muni.pa036.airticketbooking.rest.MyApplicationListener.java
@Override public void onApplicationEvent(AuthenticationFailureBadCredentialsEvent event) { Object userName = event.getAuthentication().getPrincipal(); Object credentials = event.getAuthentication().getCredentials(); LOG.debug("Failed login using USERNAME [" + userName + "]"); LOG.debug("Failed login using PASSWORD [" + credentials + "]"); }
From source file:com.example.securelogin.domain.service.account.AccountAuthenticationFailureBadCredentialsEventListener.java
@EventListener public void onApplicationEvent(AuthenticationFailureBadCredentialsEvent event) { String username = (String) event.getAuthentication().getPrincipal(); authenticationEventSharedService.authenticationFailure(username); }
From source file:fr.univrouen.poste.provider.AuthenticationFailureListener.java
@Override @Transactional/* w ww .ja va 2 s . c o m*/ public void onApplicationEvent(AuthenticationFailureBadCredentialsEvent ev) { try { String username = ev.getAuthentication().getName(); TypedQuery<User> query = User.findUsersByEmailAddress(username, null, null); User targetUser = (User) query.getSingleResult(); if (targetUser != null) { // only for existing users targetUser.reportLoginFailure(); targetUser.persist(); } } catch (Exception e) { } }
From source file:org.cloudfoundry.identity.uaa.authentication.event.BadCredentialsListener.java
@Override public void onApplicationEvent(AuthenticationFailureBadCredentialsEvent event) { AuthenticationFailureBadCredentialsEvent bce = (AuthenticationFailureBadCredentialsEvent) event; String principal = bce.getAuthentication().getName(); UaaAuthenticationDetails details = (UaaAuthenticationDetails) bce.getAuthentication().getDetails(); if (bce.getException() instanceof UsernameNotFoundException) { publisher.publishEvent(new PrincipalNotFoundEvent(principal, details)); } else {/*from www. ja v a 2 s . co m*/ publisher.publishEvent(new PrincipalAuthenticationFailureEvent(principal, details)); } }
From source file:com.nagarro.core.security.AuthenticationFailureListener.java
@Override public void onApplicationEvent(final AuthenticationFailureBadCredentialsEvent ev) { final String userName = ev.getAuthentication().getName(); LOG.debug("Authentication failure for user : " + userName); getBruteForceAttackCounter().registerLoginFailure(userName); if (getBruteForceAttackCounter().isAttack(userName)) { disableUser(userName);/*from ww w . ja v a 2s. co m*/ } }
From source file:org.cloudfoundry.identity.uaa.event.listener.AuditListener.java
@Override public void onApplicationEvent(ApplicationEvent event) { if (event instanceof AbstractUaaEvent) { ((AbstractUaaEvent) event).process(uaaAuditService); } else if (event instanceof AuthenticationFailureBadCredentialsEvent) { AuthenticationFailureBadCredentialsEvent bce = (AuthenticationFailureBadCredentialsEvent) event; String principal = bce.getAuthentication().getName(); UaaAuthenticationDetails details = (UaaAuthenticationDetails) bce.getAuthentication().getDetails(); if (bce.getException() instanceof UsernameNotFoundException) { uaaAuditService.principalNotFound(principal, details); } else {//from ww w. j ava2s.c om uaaAuditService.principalAuthenticationFailure(principal, details); } } }