From e433824f46514e6ed863eb6b95c70038331c8c24 Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Tue, 24 Nov 2015 12:49:54 +0000
Subject: [PATCH] OPENDJ-2260 OPENDJ-2271 Integration of common audit into the server

---
 opendj-server-legacy/src/main/java/org/opends/server/protocols/http/LdapHttpApplication.java |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/protocols/http/LdapHttpApplication.java b/opendj-server-legacy/src/main/java/org/opends/server/protocols/http/LdapHttpApplication.java
index 0850d8c..0dd19b6 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/protocols/http/LdapHttpApplication.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/protocols/http/LdapHttpApplication.java
@@ -34,6 +34,7 @@
 import org.forgerock.http.Handler;
 import org.forgerock.http.HttpApplication;
 import org.forgerock.http.HttpApplicationException;
+import org.forgerock.http.filter.TransactionIdInboundFilter;
 import org.forgerock.http.handler.Handlers;
 import org.forgerock.http.io.Buffer;
 import org.forgerock.http.protocol.Request;
@@ -57,7 +58,10 @@
 import org.forgerock.util.Factory;
 import org.forgerock.util.promise.NeverThrowsException;
 import org.forgerock.util.promise.Promise;
+import org.forgerock.util.time.TimeService;
 import org.opends.messages.ProtocolMessages;
+import org.opends.server.core.ServerContext;
+import org.opends.server.util.DynamicConstants;
 
 /** Main class of the HTTP Connection Handler web application */
 class LdapHttpApplication implements HttpApplication
@@ -115,9 +119,11 @@
   private HTTPConnectionHandler connectionHandler;
   private LdapHttpHandler handler;
   private CollectClientConnectionsFilter filter;
+  private final ServerContext serverContext;
 
-  LdapHttpApplication(HTTPConnectionHandler connectionHandler)
+  LdapHttpApplication(ServerContext serverContext, HTTPConnectionHandler connectionHandler)
   {
+    this.serverContext = serverContext;
     this.connectionHandler = connectionHandler;
   }
 
@@ -132,7 +138,15 @@
       handler = new LdapHttpHandler(configuration);
       filter = new CollectClientConnectionsFilter(connectionHandler, getAuthenticationConfig(configuration));
       configuration.verifyAllKeysAccessed();
-      return Handlers.chainOf(handler, filter);
+
+      TransactionIdInboundFilter transactionIdFilter = new TransactionIdInboundFilter();
+      RequestHandler requestHandler = serverContext.getCommonAudit().getAuditServiceForHttpAccessLog();
+      CommonAuditHttpAccessAuditFilter httpAccessFilter =
+          new CommonAuditHttpAccessAuditFilter(DynamicConstants.PRODUCT_NAME, requestHandler, TimeService.SYSTEM);
+      CommonAuditHttpAccessCheckEnabledFilter checkFilter =
+          new CommonAuditHttpAccessCheckEnabledFilter(serverContext, httpAccessFilter);
+
+      return Handlers.chainOf(handler, transactionIdFilter, checkFilter, filter);
     }
     catch (final Exception e)
     {

--
Gitblit v1.10.0