@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());
/*
* HttpServletRequest hsr = getServletRequest(); if (hsr != null) { ctxMap.put("request",
* WebUtil.deriveUsefulInfo(hsr)); }
*/
ctxMap.put("Source", getClass().getCanonicalName());
auditEvent.setContextMap(ctxMap);
auditManager.audit(auditEvent);
}
}