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

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

Introduction

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

Prototype

public Object getSource() 

Source Link

Document

The object on which the Event initially occurred.

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   www.  j ava2  s. 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());
        }
    }
}