use of io.undertow.security.api.SecurityNotification.EventType in project wildfly by wildfly.
the class AuditNotificationReceiver method handleNotification.
@Override
public void handleNotification(SecurityNotification notification) {
EventType event = notification.getEventType();
if (event == EventType.AUTHENTICATED || event == EventType.FAILED_AUTHENTICATION) {
AuditEvent auditEvent = new AuditEvent(event == EventType.AUTHENTICATED ? AuditLevel.SUCCESS : AuditLevel.FAILURE);
Map<String, Object> ctxMap = new HashMap<String, Object>();
Account account = notification.getAccount();
if (account != null) {
ctxMap.put("principal", account.getPrincipal().getName());
}
ctxMap.put("message", notification.getMessage());
ServletRequestContext src = notification.getExchange().getAttachment(ServletRequestContext.ATTACHMENT_KEY);
if (src != null) {
ServletRequest hsr = src.getServletRequest();
if (hsr instanceof HttpServletRequest) {
ctxMap.put("request", WebUtil.deriveUsefulInfo((HttpServletRequest) hsr));
}
}
ctxMap.put("Source", getClass().getCanonicalName());
auditEvent.setContextMap(ctxMap);
auditManager.audit(auditEvent);
}
}
Aggregations