Search in sources :

Example 16 with CorrelationContext

use of org.apache.knox.gateway.audit.api.CorrelationContext 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

CorrelationContext (org.apache.knox.gateway.audit.api.CorrelationContext)16 AuditContext (org.apache.knox.gateway.audit.api.AuditContext)7 LoggingEvent (org.apache.log4j.spi.LoggingEvent)5 Test (org.junit.Test)5 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 ObjectInput (java.io.ObjectInput)1 ObjectInputStream (java.io.ObjectInputStream)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 Callable (java.util.concurrent.Callable)1 ExecutorService (java.util.concurrent.ExecutorService)1 FilterChain (javax.servlet.FilterChain)1 FilterConfig (javax.servlet.FilterConfig)1 ServletContext (javax.servlet.ServletContext)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 CorrelationService (org.apache.knox.gateway.audit.api.CorrelationService)1 GatewayConfig (org.apache.knox.gateway.config.GatewayConfig)1