Example usage for org.springframework.security.authentication.event AuthenticationFailureBadCredentialsEvent getException

List of usage examples for org.springframework.security.authentication.event AuthenticationFailureBadCredentialsEvent getException

Introduction

In this page you can find the example usage for org.springframework.security.authentication.event AuthenticationFailureBadCredentialsEvent getException.

Prototype

public AuthenticationException getException() 

Source Link

Usage

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  w  w w .java  2  s. c om
        publisher.publishEvent(new PrincipalAuthenticationFailureEvent(principal, details));
    }
}

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 {// w w  w . ja v a2 s  .co m
            uaaAuditService.principalAuthenticationFailure(principal, details);
        }
    }
}