Example usage for org.springframework.security.access.event AuthenticationCredentialsNotFoundEvent getCredentialsNotFoundException

List of usage examples for org.springframework.security.access.event AuthenticationCredentialsNotFoundEvent getCredentialsNotFoundException

Introduction

In this page you can find the example usage for org.springframework.security.access.event AuthenticationCredentialsNotFoundEvent getCredentialsNotFoundException.

Prototype

public AuthenticationCredentialsNotFoundException getCredentialsNotFoundException() 

Source Link

Usage

From source file:org.springframework.security.access.event.LoggerListener.java

public void onApplicationEvent(AbstractAuthorizationEvent event) {
    if (event instanceof AuthenticationCredentialsNotFoundEvent) {
        AuthenticationCredentialsNotFoundEvent authEvent = (AuthenticationCredentialsNotFoundEvent) event;

        if (logger.isWarnEnabled()) {
            logger.warn("Security interception failed due to: " + authEvent.getCredentialsNotFoundException()
                    + "; secure object: " + authEvent.getSource() + "; configuration attributes: "
                    + authEvent.getConfigAttributes());
        }/*from   w w w  .  j  a  v  a  2s. co m*/
    }

    if (event instanceof AuthorizationFailureEvent) {
        AuthorizationFailureEvent authEvent = (AuthorizationFailureEvent) event;

        if (logger.isWarnEnabled()) {
            logger.warn("Security authorization failed due to: " + authEvent.getAccessDeniedException()
                    + "; authenticated principal: " + authEvent.getAuthentication() + "; secure object: "
                    + authEvent.getSource() + "; configuration attributes: " + authEvent.getConfigAttributes());
        }
    }

    if (event instanceof AuthorizedEvent) {
        AuthorizedEvent authEvent = (AuthorizedEvent) event;

        if (logger.isInfoEnabled()) {
            logger.info("Security authorized for authenticated principal: " + authEvent.getAuthentication()
                    + "; secure object: " + authEvent.getSource() + "; configuration attributes: "
                    + authEvent.getConfigAttributes());
        }
    }

    if (event instanceof PublicInvocationEvent) {
        PublicInvocationEvent authEvent = (PublicInvocationEvent) event;

        if (logger.isInfoEnabled()) {
            logger.info(
                    "Security interception not required for public secure object: " + authEvent.getSource());
        }
    }
}