Search in sources :

Example 11 with AuditContext

use of org.apache.knox.gateway.audit.api.AuditContext in project knox by apache.

the class Log4jAuditor method audit.

@Override
public void audit(CorrelationContext correlationContext, AuditContext auditContext, String action, String resourceName, String resourceType, String outcome, String message) {
    CorrelationContext previousCorrelationContext = null;
    AuditContext previousAuditContext = null;
    try {
        previousCorrelationContext = correlationService.getContext();
        previousAuditContext = auditService.getContext();
        auditService.attachContext(auditContext);
        correlationService.attachContext(correlationContext);
        auditLog(action, resourceName, resourceType, outcome, message);
    } finally {
        if (previousAuditContext != null) {
            auditService.attachContext(previousAuditContext);
        }
        if (previousCorrelationContext != null) {
            correlationService.attachContext(previousCorrelationContext);
        }
    }
}
Also used : CorrelationContext(org.apache.knox.gateway.audit.api.CorrelationContext) AuditContext(org.apache.knox.gateway.audit.api.AuditContext)

Aggregations

AuditContext (org.apache.knox.gateway.audit.api.AuditContext)11 CorrelationContext (org.apache.knox.gateway.audit.api.CorrelationContext)7 LoggingEvent (org.apache.log4j.spi.LoggingEvent)3 Test (org.junit.Test)3 IOException (java.io.IOException)2 ServletException (javax.servlet.ServletException)2 URISyntaxException (java.net.URISyntaxException)1 Principal (java.security.Principal)1 PrivilegedActionException (java.security.PrivilegedActionException)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 FilterChain (javax.servlet.FilterChain)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 PrimaryPrincipal (org.apache.knox.gateway.security.PrimaryPrincipal)1 TokenServiceException (org.apache.knox.gateway.services.security.token.TokenServiceException)1 Topology (org.apache.knox.gateway.topology.Topology)1 Matcher (org.apache.knox.gateway.util.urltemplate.Matcher)1 Template (org.apache.knox.gateway.util.urltemplate.Template)1