use of org.springframework.web.context.support.ServletRequestHandledEvent in project spring-framework by spring-projects.
the class FrameworkServlet method publishRequestHandledEvent.
private void publishRequestHandledEvent(HttpServletRequest request, HttpServletResponse response, long startTime, Throwable failureCause) {
if (this.publishEvents) {
// Whether or not we succeeded, publish an event.
long processingTime = System.currentTimeMillis() - startTime;
this.webApplicationContext.publishEvent(new ServletRequestHandledEvent(this, request.getRequestURI(), request.getRemoteAddr(), request.getMethod(), getServletConfig().getServletName(), WebUtils.getSessionId(request), getUsernameForRequest(request), processingTime, failureCause, response.getStatus()));
}
}
use of org.springframework.web.context.support.ServletRequestHandledEvent in project opennms by OpenNMS.
the class SecurityAuthenticationEventOnmsEventBuilder method onApplicationEvent.
/** {@inheritDoc} */
@Override
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());
}
}
Aggregations