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"); } }