/** * Sends information to the {@code AuditManager}. * * @param level * @param auditManager * @param userPrincipal */ private void audit(String level, AuditManager auditManager, Principal userPrincipal) { AuditEvent auditEvent = new AuditEvent(level); Map<String, Object> ctxMap = new HashMap<String, Object>(); ctxMap.put("principal", userPrincipal != null ? userPrincipal.getName() : "null"); ctxMap.put("Source", getClass().getCanonicalName()); ctxMap.put("Action", "authentication"); auditEvent.setContextMap(ctxMap); auditManager.audit(auditEvent); }
protected void audit(String level, Map<String,Object> contextMap, Exception e) { AuditManager am = securityContext.getAuditManager(); if(am == null) return; contextMap.put("Source", getClass().getName()); AuditEvent ae = new AuditEvent(level,contextMap,e); am.audit(ae); }
private void audit(String level, Map<String, Object> contextMap, Exception e) { String requestInfo = ""; try { HttpServletRequest hsr = (HttpServletRequest) PolicyContext.getContext(SecurityConstants.WEB_REQUEST_KEY); requestInfo = WebUtil.deriveUsefulInfo(hsr); contextMap.put("request", requestInfo); } catch (PolicyContextException pe) { if (trace) log.trace("Error obtaining the servlet request:", pe); } contextMap.put("Source", getClass().getName()); AuditEvent ae = new AuditEvent(level); ae.setContextMap(contextMap); ae.setUnderlyingException(e); SecurityContext sc = SecurityAssociationActions.getSecurityContext(); if (sc != null) { AuditManager auditManager = sc.getAuditManager(); if (auditManager != null) auditManager.audit(ae); else log.trace("Audit Manager obtained from Security Context is null"); } }
public String toString() { StringBuilder sbu = new StringBuilder(); sbu.append("[").append(auditLevel).append("]"); sbu.append(dissectContextMap()); return sbu.toString(); }
@Override public String toString() { String SPACE = " "; StringBuilder builder = new StringBuilder(); if (StringUtil.isNotNull(whoIsAuditing)) { builder.append(whoIsAuditing).append(SPACE); } if (type != null) { builder.append(type.name()).append(SPACE); } if (StringUtil.isNotNull(destination)) { builder.append(destination).append(SPACE); } if (StringUtil.isNotNull(subjectName)) { builder.append(subjectName).append(SPACE); } if (StringUtil.isNotNull(assertionID)) { builder.append(assertionID).append(SPACE); } if (StringUtil.isNotNull(httpSessionID)) { builder.append(httpSessionID).append(SPACE); } builder.append(super.toString()); return builder.toString(); } }
public void audit(AuditEvent auditEvent) { Exception e = auditEvent.getUnderlyingException(); if(e != null) log.trace(auditEvent, e); else log.trace(auditEvent); } }
protected void audit(String level, Map<String,Object> contextMap, Exception e) { AuditManager am = securityContext.getAuditManager(); if(am == null) return; contextMap.put("Source", getClass().getName()); AuditEvent ae = new AuditEvent(level,contextMap,e); am.audit(ae); }
public String toString() { StringBuilder sbu = new StringBuilder(); sbu.append("[").append(auditLevel).append("]"); sbu.append(dissectContextMap()); return sbu.toString(); }
@Override public String toString() { String SPACE = " "; StringBuilder builder = new StringBuilder(); if (StringUtil.isNotNull(whoIsAuditing)) { builder.append(whoIsAuditing).append(SPACE); } if (type != null) { builder.append(type.name()).append(SPACE); } if (StringUtil.isNotNull(destination)) { builder.append(destination).append(SPACE); } if (StringUtil.isNotNull(subjectName)) { builder.append(subjectName).append(SPACE); } if (StringUtil.isNotNull(assertionID)) { builder.append(assertionID).append(SPACE); } if (StringUtil.isNotNull(httpSessionID)) { builder.append(httpSessionID).append(SPACE); } builder.append(super.toString()); return builder.toString(); } }
public void audit(AuditEvent auditEvent) { if(!PicketBoxLogger.AUDIT_LOGGER.isTraceEnabled()) { return; } Exception e = auditEvent.getUnderlyingException(); if(e != null) { PicketBoxLogger.AUDIT_LOGGER.trace(auditEvent, e); } else { PicketBoxLogger.AUDIT_LOGGER.trace(auditEvent); } } }
@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", deriveUsefulInfo((HttpServletRequest) hsr)); } } ctxMap.put("Source", getClass().getCanonicalName()); auditEvent.setContextMap(ctxMap); auditManager.audit(auditEvent); } }
protected void audit(String level, Map<String,Object> contextMap, Exception e) { AuditManager am = securityContext.getAuditManager(); if(am == null) return; contextMap.put("Source", getClass().getName()); AuditEvent ae = new AuditEvent(level,contextMap,e); am.audit(ae); }
public String toString() { StringBuilder sbu = new StringBuilder(); sbu.append("[").append(auditLevel).append("]"); sbu.append(dissectContextMap()); return sbu.toString(); }
@Override public String toString() { String SPACE = " "; StringBuilder builder = new StringBuilder(); if (StringUtil.isNotNull(whoIsAuditing)) { builder.append(whoIsAuditing).append(SPACE); } if (type != null) { builder.append(type.name()).append(SPACE); } if (StringUtil.isNotNull(destination)) { builder.append(destination).append(SPACE); } if (StringUtil.isNotNull(subjectName)) { builder.append(subjectName).append(SPACE); } if (StringUtil.isNotNull(assertionID)) { builder.append(assertionID).append(SPACE); } if (StringUtil.isNotNull(httpSessionID)) { builder.append(httpSessionID).append(SPACE); } builder.append(super.toString()); return builder.toString(); } }
/** * Sends information to the {@code AuditManager}. * @param level * @param auditManager * @param userPrincipal * @param entries */ private void audit(String level, AuditManager auditManager, Principal userPrincipal) { AuditEvent auditEvent = new AuditEvent(AuditLevel.SUCCESS); Map<String, Object> ctxMap = new HashMap<String, Object>(); ctxMap.put("principal", userPrincipal != null ? userPrincipal : "null"); ctxMap.put("Source", getClass().getCanonicalName()); ctxMap.put("Action", "authentication"); auditEvent.setContextMap(ctxMap); auditManager.audit(auditEvent); }
@Override public void audit(Subject subject, AuditContext context, String contextName, AuthorizationPermission permission, AuditResponse response) { String level; switch (response) { case ALLOW: level = AuditLevel.SUCCESS; break; case DENY: level = AuditLevel.FAILURE; break; case ERROR: level = AuditLevel.ERROR; break; default: level = AuditLevel.INFO; break; } AuditEvent ae = new AuditEvent(level); auditManager.audit(ae); }
public String toString() { StringBuilder sbu = new StringBuilder(); sbu.append("[").append(auditLevel).append("]"); sbu.append(dissectContextMap()); return sbu.toString(); }
/** * Sends information to the {@code AuditManager}. * @param level * @param auditManager * @param userPrincipal * @param entries */ private void audit(String level, AuditManager auditManager, Principal userPrincipal) { AuditEvent auditEvent = new AuditEvent(AuditLevel.SUCCESS); Map<String, Object> ctxMap = new HashMap<String, Object>(); ctxMap.put("principal", userPrincipal != null ? userPrincipal : "null"); ctxMap.put("Source", getClass().getCanonicalName()); ctxMap.put("Action", "authentication"); auditEvent.setContextMap(ctxMap); auditManager.audit(auditEvent); }
@Override public void audit(Subject subject, AuditContext context, String contextName, AuthorizationPermission permission, AuditResponse response) { String level; switch (response) { case ALLOW: level = AuditLevel.SUCCESS; break; case DENY: level = AuditLevel.FAILURE; break; case ERROR: level = AuditLevel.ERROR; break; default: level = AuditLevel.INFO; break; } AuditEvent ae = new AuditEvent(level); auditManager.audit(ae); }
/** * Sends information to the {@code AuditManager}. * * @param level * @param auditManager * @param userPrincipal */ private void audit(String level, AuditManager auditManager, Principal userPrincipal) { AuditEvent auditEvent = new AuditEvent(level); Map<String, Object> ctxMap = new HashMap<String, Object>(); ctxMap.put("principal", userPrincipal != null ? userPrincipal.getName() : "null"); ctxMap.put("Source", getClass().getCanonicalName()); ctxMap.put("Action", "authentication"); auditEvent.setContextMap(ctxMap); auditManager.audit(auditEvent); }