org.springframework.security.authentication.event.AuthenticationFailureDisabledEvent Java Examples
The following examples show how to use
org.springframework.security.authentication.event.AuthenticationFailureDisabledEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpringEventListener.java From ranger with Apache License 2.0 | 6 votes |
@Override public void onApplicationEvent(AbstractAuthenticationEvent event) { try { if (event instanceof AuthenticationSuccessEvent) { process((AuthenticationSuccessEvent) event); } else if (event instanceof AuthenticationFailureBadCredentialsEvent) { process((AuthenticationFailureBadCredentialsEvent) event); } else if (event instanceof AuthenticationFailureDisabledEvent) { process((AuthenticationFailureDisabledEvent) event); } // igonre all other events } catch (Exception e) { logger.error("Exception in Spring Event Listener.", e); } }
Example #2
Source File: SpringEventListener.java From ranger with Apache License 2.0 | 6 votes |
protected void process(AuthenticationFailureDisabledEvent authFailEvent) { Authentication auth = authFailEvent.getAuthentication(); WebAuthenticationDetails details = (WebAuthenticationDetails) auth .getDetails(); String remoteAddress = details != null ? details.getRemoteAddress() : ""; String sessionId = details != null ? details.getSessionId() : ""; logger.info("Login Unsuccessful:" + auth.getName() + " | Ip Address:" + remoteAddress); sessionMgr.processFailureLogin(XXAuthSession.AUTH_STATUS_DISABLED, XXAuthSession.AUTH_TYPE_PASSWORD, auth.getName(), remoteAddress, sessionId); }
Example #3
Source File: SpringSecurityListener.java From lemon with Apache License 2.0 | 5 votes |
public void onApplicationEvent(ApplicationEvent event) { try { if (event instanceof InteractiveAuthenticationSuccessEvent) { this.logLoginSuccess(event); } if (event instanceof AuthenticationFailureBadCredentialsEvent) { this.logBadCredential(event); } if (event instanceof AuthenticationFailureLockedEvent) { this.logLocked(event); } if (event instanceof AuthenticationFailureDisabledEvent) { this.logDisabled(event); } if (event instanceof AuthenticationFailureExpiredEvent) { this.logAccountExpired(event); } if (event instanceof AuthenticationFailureCredentialsExpiredEvent) { this.logCredentialExpired(event); } } catch (Exception ex) { logger.error(ex.getMessage(), ex); } }
Example #4
Source File: SpringSecurityListener.java From lemon with Apache License 2.0 | 5 votes |
public void logDisabled(ApplicationEvent event) throws Exception { AuthenticationFailureDisabledEvent authenticationFailureDisabledEvent = (AuthenticationFailureDisabledEvent) event; Authentication authentication = authenticationFailureDisabledEvent .getAuthentication(); logger.info("logDisabled : {}", authentication); String tenantId = this.getTenantId(authentication); Object principal = authentication.getPrincipal(); String userId = null; if (principal instanceof SpringSecurityUserAuth) { userId = ((SpringSecurityUserAuth) principal).getId(); } else { userId = authentication.getName(); } AuditDTO auditDto = new AuditDTO(); auditDto.setUserId(userId); auditDto.setAuditTime(new Date()); auditDto.setAction("login"); auditDto.setResult("failure"); auditDto.setApplication("lemon"); auditDto.setClient(getUserIp(authentication)); auditDto.setServer(InetAddress.getLocalHost().getHostAddress()); auditDto.setDescription(authenticationFailureDisabledEvent .getException().getMessage()); auditDto.setTenantId(tenantId); auditConnector.log(auditDto); ctx.publishEvent(new LoginEvent(authentication, userId, this .getSessionId(authentication), "disabled", "default", tenantId)); }