Example usage for org.springframework.context ApplicationEvent getTimestamp

List of usage examples for org.springframework.context ApplicationEvent getTimestamp

Introduction

In this page you can find the example usage for org.springframework.context ApplicationEvent getTimestamp.

Prototype

public final long getTimestamp() 

Source Link

Document

Return the system time in milliseconds when the event occurred.

Usage

From source file:com.foo.example.AbstractBean.java

public void publishEvent(ApplicationEvent event) {
    logger.info("publishEvent(" + event.getClass().getSimpleName() + ")@" + event.getTimestamp());
}

From source file:com.foo.example.AbstractBean.java

public void multicastEvent(ApplicationEvent event) {
    logger.info("multicastEvent(" + event.getClass().getSimpleName() + ")@" + event.getTimestamp());
}

From source file:com.foo.example.AbstractBean.java

public void onApplicationEvent(ApplicationEvent event) {
    logger.info("onApplicationEvent(" + event.getClass().getSimpleName() + ")@" + event.getTimestamp());
}

From source file:org.opentides.persistence.user.AuthenticationDaoJdbcImpl.java

@Override
public void onApplicationEvent(ApplicationEvent event) {
    if (enableUserLockCheck) {
        if (event instanceof AuthenticationSuccessEvent) {
            userService.unlockUser(((AbstractAuthenticationEvent) event).getAuthentication().getName());
        } else if (event instanceof AbstractAuthenticationFailureEvent) {
            String username = ((AbstractAuthenticationEvent) event).getAuthentication().getName();
            String origin = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes())
                    .getRequest().getRemoteAddr();
            String cause = ((AbstractAuthenticationFailureEvent) event).getException().toString();
            logger.info("Failed authentication for user '" + username + "' from ip " + origin + " caused by "
                    + cause);//from w w w.  ja v  a2s  . c o m
            if (event instanceof AuthenticationFailureBadCredentialsEvent) {
                if (!userService.isUserLockedOut(username, maxAttempts, lockoutSeconds))
                    userService.updateFailedLogin(username, event.getTimestamp());
            }
        }
    }
}

From source file:org.opennms.web.springframework.security.SecurityAuthenticationEventOnmsEventBuilder.java

/** {@inheritDoc} */
@Override/*  ww w  .  ja  v a2  s.c  o  m*/
public void onApplicationEvent(ApplicationEvent event) {
    LOG.debug("Received ApplicationEvent {}", event.getClass());
    if (event instanceof AuthenticationSuccessEvent) {
        AuthenticationSuccessEvent authEvent = (AuthenticationSuccessEvent) event;

        EventBuilder builder = createEvent(SUCCESS_UEI, authEvent);
        // Sync the timestamp
        builder.setTime(new Date(event.getTimestamp()));
        if (!"true".equalsIgnoreCase(System.getProperty("org.opennms.security.disableLoginSuccessEvent"))) {
            sendEvent(builder.getEvent());
        }
    }

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

        LOG.debug("AbstractAuthenticationFailureEvent was received, exception message - {}",
                authEvent.getException().getMessage());
        EventBuilder builder = createEvent(FAILURE_UEI, authEvent);
        // Sync the timestamp
        builder.setTime(new Date(event.getTimestamp()));
        builder.addParam("exceptionName", authEvent.getException().getClass().getSimpleName());
        builder.addParam("exceptionMessage", authEvent.getException().getMessage());
        sendEvent(builder.getEvent());
    }

    if (event instanceof AuthorizedEvent) {
        AuthorizedEvent authEvent = (AuthorizedEvent) event;
        LOG.debug("AuthorizedEvent received - \n  Details - {}\n  Principal - {}",
                authEvent.getAuthentication().getDetails(), authEvent.getAuthentication().getPrincipal());
    }
    if (event instanceof AuthorizationFailureEvent) {
        AuthorizationFailureEvent authEvent = (AuthorizationFailureEvent) event;
        LOG.debug("AuthorizationFailureEvent received  -\n   Details - {}\n  Principal - {}",
                authEvent.getAuthentication().getDetails(), authEvent.getAuthentication().getPrincipal());
    }
    if (event instanceof InteractiveAuthenticationSuccessEvent) {
        InteractiveAuthenticationSuccessEvent authEvent = (InteractiveAuthenticationSuccessEvent) event;
        LOG.debug("InteractiveAuthenticationSuccessEvent received - \n  Details - {}\n  Principal - {}",
                authEvent.getAuthentication().getDetails(), authEvent.getAuthentication().getPrincipal());

    }
    if (event instanceof ServletRequestHandledEvent) {
        ServletRequestHandledEvent authEvent = (ServletRequestHandledEvent) event;
        LOG.debug("ServletRequestHandledEvent received - {}\n  Servlet - {}\n  URL - {}",
                authEvent.getDescription(), authEvent.getServletName(), authEvent.getRequestUrl());
        LOG.info("{} requested from {} by user {}", authEvent.getRequestUrl(), authEvent.getClientAddress(),
                authEvent.getUserName());
    }

}