Example usage for org.springframework.security.authentication.event AbstractAuthenticationEvent getTimestamp

List of usage examples for org.springframework.security.authentication.event AbstractAuthenticationEvent getTimestamp

Introduction

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

Prototype

public final long getTimestamp() 

Source Link

Document

Return the system time in milliseconds when the event occurred.

Usage

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

private EventBuilder createEvent(String uei, AbstractAuthenticationEvent authEvent) {
    EventBuilder builder = new EventBuilder(uei, "OpenNMS.WebUI");
    builder.setTime(new Date(authEvent.getTimestamp()));
    org.springframework.security.core.Authentication auth = authEvent.getAuthentication();
    if (auth != null && auth.getName() != null) {
        builder.addParam("user", WebSecurityUtils.sanitizeString(auth.getName()));
    }//from   ww  w .  jav a2  s. c o m
    if (auth != null && auth.getDetails() != null && auth.getDetails() instanceof WebAuthenticationDetails) {
        WebAuthenticationDetails webDetails = (WebAuthenticationDetails) auth.getDetails();
        if (webDetails.getRemoteAddress() != null) {
            builder.addParam("ip", webDetails.getRemoteAddress());
        }
    }
    return builder;
}