From 62914469967c1c2c20648f40c9b29aa572db01f5 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Fri, 07 Oct 2011 13:26:28 +0000
Subject: [PATCH] Preparation work for OPENDJ-308: Implement access log filtering and configurable message format

---
 opendj-sdk/opends/src/server/org/opends/server/loggers/AccessLogger.java |  353 ++--------------------------------------------------------
 1 files changed, 13 insertions(+), 340 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/loggers/AccessLogger.java b/opendj-sdk/opends/src/server/org/opends/server/loggers/AccessLogger.java
index 18fd8fb..d3b1e84 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/loggers/AccessLogger.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/loggers/AccessLogger.java
@@ -23,6 +23,7 @@
  *
  *
  *      Copyright 2006-2009 Sun Microsystems, Inc.
+ *      Portions copyright 2011 ForgeRock AS.
  */
 package org.opends.server.loggers;
 import org.opends.messages.Message;
@@ -32,7 +33,6 @@
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.List;
 import java.util.ArrayList;
-import java.util.Map;
 import java.lang.reflect.Method;
 import java.lang.reflect.InvocationTargetException;
 
@@ -340,6 +340,7 @@
     return new ConfigChangeResult(resultCode, adminActionRequired);
   }
 
+  @SuppressWarnings("unchecked")
   private boolean isJavaClassAcceptable(AccessLogPublisherCfg config,
                                         List<Message> unacceptableReasons)
   {
@@ -349,9 +350,10 @@
         d.getJavaClassPropertyDefinition();
     // Load the class and cast it to a DebugLogPublisher.
     AccessLogPublisher<?> publisher = null;
-    Class<? extends AccessLogPublisher> theClass;
+    Class<? extends AccessLogPublisher<?>> theClass;
     try {
-      theClass = pd.loadClass(className, AccessLogPublisher.class);
+      theClass = (Class<? extends AccessLogPublisher<?>>)
+        pd.loadClass(className, AccessLogPublisher.class);
       publisher = theClass.newInstance();
     } catch (Exception e) {
       Message message = ERR_CONFIG_LOGGER_INVALID_ACCESS_LOGGER_CLASS.get(
@@ -395,18 +397,20 @@
     ClassPropertyDefinition pd =
         d.getJavaClassPropertyDefinition();
     // Load the class and cast it to a AccessLogPublisher.
-    Class<? extends AccessLogPublisher> theClass;
-    AccessLogPublisher<?> AccessLogPublisher;
+    AccessLogPublisher<?> accessLogPublisher;
     try {
-      theClass = pd.loadClass(className, AccessLogPublisher.class);
-      AccessLogPublisher = theClass.newInstance();
+      @SuppressWarnings("unchecked")
+      Class<? extends AccessLogPublisher<?>> theClass =
+        (Class<? extends AccessLogPublisher<?>>) pd
+          .loadClass(className, AccessLogPublisher.class);
+      accessLogPublisher = theClass.newInstance();
 
       // Determine the initialization method to use: it must take a
       // single parameter which is the exact type of the configuration
       // object.
       Method method = theClass.getMethod("initializeAccessLogPublisher", config
           .configurationClass());
-      method.invoke(AccessLogPublisher, config);
+      method.invoke(accessLogPublisher, config);
     }
     catch (InvocationTargetException ite)
     {
@@ -424,7 +428,7 @@
     }
 
     // The access publisher has been successfully initialized.
-    return AccessLogPublisher;
+    return accessLogPublisher;
   }
 
 
@@ -448,32 +452,6 @@
 
 
   /**
-   * Writes a message to the access logger containing additional
-   * information associated with the provided client connection.
-   *
-   * @param clientConnection
-   *          The client connection that has been established.
-   * @param category
-   *          The category of the intermediate message.
-   * @param content
-   *          The content of the intermediate message. This comprises of
-   *          one or more key/value pairs which form the content of the
-   *          intermediate message.
-   */
-  public static void logConnectIntermediateMessage(
-      ClientConnection clientConnection, String category,
-      Map<String, String> content)
-  {
-    for (AccessLogPublisher<?> publisher : accessPublishers)
-    {
-      publisher.logConnectIntermediateMessage(clientConnection,
-          category, content);
-    }
-  }
-
-
-
-  /**
    * Writes a message to the access logger with information about the
    * termination of an existing client connection.
    *
@@ -496,32 +474,6 @@
 
 
   /**
-   * Writes a message to the access logger containing additional
-   * information associated with the provided client disconnection.
-   *
-   * @param clientConnection
-   *          The client connection that has been terminated.
-   * @param category
-   *          The category of the intermediate message.
-   * @param content
-   *          The content of the intermediate message. This comprises of
-   *          one or more key/value pairs which form the content of the
-   *          intermediate message.
-   */
-  public static void logDisconnectIntermediateMessage(
-      ClientConnection clientConnection, String category,
-      Map<String, String> content)
-  {
-    for (AccessLogPublisher<?> publisher : accessPublishers)
-    {
-      publisher.logDisconnectIntermediateMessage(clientConnection,
-          category, content);
-    }
-  }
-
-
-
-  /**
    * Writes a message to the access logger with information about the abandon
    * request associated with the provided abandon operation.
    *
@@ -539,37 +491,6 @@
 
 
   /**
-   * Writes a message to the access logger containing additional
-   * information associated with the provided abandon operation.
-   * <p>
-   * This method will only be called after the request has been logged
-   * and before the response. Implementations can choose to ignore
-   * intermediate responses or filter them based on their category.
-   *
-   * @param abandonOperation
-   *          The abandon operation containing the information to use
-   *          to log the abandon request.
-   * @param category
-   *          The category of the intermediate message.
-   * @param content
-   *          The content of the intermediate message. This comprises
-   *          of one or more key/value pairs which form the content of
-   *          the intermediate message.
-   */
-  public static void logAbandonIntermediateMessage(
-      AbandonOperation abandonOperation, String category,
-      Map<String, String> content)
-  {
-    for (AccessLogPublisher<?> publisher : accessPublishers)
-    {
-      publisher.logAbandonIntermediateMessage(abandonOperation,
-          category, content);
-    }
-  }
-
-
-
-  /**
    * Writes a message to the access logger with information about the result of
    * the provided abandon operation.
    *
@@ -604,37 +525,6 @@
 
 
   /**
-   * Writes a message to the access logger containing additional
-   * information associated with the provided add operation.
-   * <p>
-   * This method will only be called after the request has been logged
-   * and before the response. Implementations can choose to ignore
-   * intermediate responses or filter them based on their category.
-   *
-   * @param addOperation
-   *          The add operation containing the information to use
-   *          to log the add request.
-   * @param category
-   *          The category of the intermediate message.
-   * @param content
-   *          The content of the intermediate message. This comprises
-   *          of one or more key/value pairs which form the content of
-   *          the intermediate message.
-   */
-  public static void logAddIntermediateMessage(
-      AddOperation addOperation, String category,
-      Map<String, String> content)
-  {
-    for (AccessLogPublisher<?> publisher : accessPublishers)
-    {
-      publisher.logAddIntermediateMessage(addOperation,
-          category, content);
-    }
-  }
-
-
-
-  /**
    * Writes a message to the access logger with information about the add
    * response associated with the provided add operation.
    *
@@ -669,37 +559,6 @@
 
 
   /**
-   * Writes a message to the access logger containing additional
-   * information associated with the provided bind operation.
-   * <p>
-   * This method will only be called after the request has been logged
-   * and before the response. Implementations can choose to ignore
-   * intermediate responses or filter them based on their category.
-   *
-   * @param bindOperation
-   *          The bind operation containing the information to use
-   *          to log the bind request.
-   * @param category
-   *          The category of the intermediate message.
-   * @param content
-   *          The content of the intermediate message. This comprises
-   *          of one or more key/value pairs which form the content of
-   *          the intermediate message.
-   */
-  public static void logBindIntermediateMessage(
-      BindOperation bindOperation, String category,
-      Map<String, String> content)
-  {
-    for (AccessLogPublisher<?> publisher : accessPublishers)
-    {
-      publisher.logBindIntermediateMessage(bindOperation,
-          category, content);
-    }
-  }
-
-
-
-  /**
    * Writes a message to the access logger with information about the bind
    * response associated with the provided bind operation.
    *
@@ -734,37 +593,6 @@
 
 
   /**
-   * Writes a message to the access logger containing additional
-   * information associated with the provided compare operation.
-   * <p>
-   * This method will only be called after the request has been logged
-   * and before the response. Implementations can choose to ignore
-   * intermediate responses or filter them based on their category.
-   *
-   * @param compareOperation
-   *          The compare operation containing the information to use
-   *          to log the compare request.
-   * @param category
-   *          The category of the intermediate message.
-   * @param content
-   *          The content of the intermediate message. This comprises
-   *          of one or more key/value pairs which form the content of
-   *          the intermediate message.
-   */
-  public static void logCompareIntermediateMessage(
-      CompareOperation compareOperation, String category,
-      Map<String, String> content)
-  {
-    for (AccessLogPublisher<?> publisher : accessPublishers)
-    {
-      publisher.logCompareIntermediateMessage(compareOperation,
-          category, content);
-    }
-  }
-
-
-
-  /**
    * Writes a message to the access logger with information about the compare
    * response associated with the provided compare operation.
    *
@@ -799,37 +627,6 @@
 
 
   /**
-   * Writes a message to the access logger containing additional
-   * information associated with the provided delete operation.
-   * <p>
-   * This method will only be called after the request has been logged
-   * and before the response. Implementations can choose to ignore
-   * intermediate responses or filter them based on their category.
-   *
-   * @param deleteOperation
-   *          The delete operation containing the information to use
-   *          to log the delete request.
-   * @param category
-   *          The category of the intermediate message.
-   * @param content
-   *          The content of the intermediate message. This comprises
-   *          of one or more key/value pairs which form the content of
-   *          the intermediate message.
-   */
-  public static void logDeleteIntermediateMessage(
-      DeleteOperation deleteOperation, String category,
-      Map<String, String> content)
-  {
-    for (AccessLogPublisher<?> publisher : accessPublishers)
-    {
-      publisher.logDeleteIntermediateMessage(deleteOperation,
-          category, content);
-    }
-  }
-
-
-
-  /**
    * Writes a message to the access logger with information about the delete
    * response associated with the provided delete operation.
    *
@@ -864,37 +661,6 @@
 
 
   /**
-   * Writes a message to the access logger containing additional
-   * information associated with the provided extended operation.
-   * <p>
-   * This method will only be called after the request has been logged
-   * and before the response. Implementations can choose to ignore
-   * intermediate responses or filter them based on their category.
-   *
-   * @param extendedOperation
-   *          The extended operation containing the information to use
-   *          to log the extended request.
-   * @param category
-   *          The category of the intermediate message.
-   * @param content
-   *          The content of the intermediate message. This comprises
-   *          of one or more key/value pairs which form the content of
-   *          the intermediate message.
-   */
-  public static void logExtendedIntermediateMessage(
-      ExtendedOperation extendedOperation, String category,
-      Map<String, String> content)
-  {
-    for (AccessLogPublisher<?> publisher : accessPublishers)
-    {
-      publisher.logExtendedIntermediateMessage(extendedOperation,
-          category, content);
-    }
-  }
-
-
-
-  /**
    * Writes a message to the access logger with information about the extended
    * response associated with the provided extended operation.
    *
@@ -929,37 +695,6 @@
 
 
   /**
-   * Writes a message to the access logger containing additional
-   * information associated with the provided modify operation.
-   * <p>
-   * This method will only be called after the request has been logged
-   * and before the response. Implementations can choose to ignore
-   * intermediate responses or filter them based on their category.
-   *
-   * @param modifyOperation
-   *          The modify operation containing the information to use
-   *          to log the modify request.
-   * @param category
-   *          The category of the intermediate message.
-   * @param content
-   *          The content of the intermediate message. This comprises
-   *          of one or more key/value pairs which form the content of
-   *          the intermediate message.
-   */
-  public static void logModifyIntermediateMessage(
-      ModifyOperation modifyOperation, String category,
-      Map<String, String> content)
-  {
-    for (AccessLogPublisher<?> publisher : accessPublishers)
-    {
-      publisher.logModifyIntermediateMessage(modifyOperation,
-          category, content);
-    }
-  }
-
-
-
-  /**
    * Writes a message to the access logger with information about the modify
    * response associated with the provided modify operation.
    *
@@ -994,37 +729,6 @@
 
 
   /**
-   * Writes a message to the access logger containing additional
-   * information associated with the provided modify DN operation.
-   * <p>
-   * This method will only be called after the request has been logged
-   * and before the response. Implementations can choose to ignore
-   * intermediate responses or filter them based on their category.
-   *
-   * @param modifyDNOperation
-   *          The modify DN operation containing the information to use
-   *          to log the modify DN request.
-   * @param category
-   *          The category of the intermediate message.
-   * @param content
-   *          The content of the intermediate message. This comprises
-   *          of one or more key/value pairs which form the content of
-   *          the intermediate message.
-   */
-  public static void logModifyDNIntermediateMessage(
-      ModifyDNOperation modifyDNOperation, String category,
-      Map<String, String> content)
-  {
-    for (AccessLogPublisher<?> publisher : accessPublishers)
-    {
-      publisher.logModifyDNIntermediateMessage(modifyDNOperation,
-          category, content);
-    }
-  }
-
-
-
-  /**
    * Writes a message to the access logger with information about the modify DN
    * response associated with the provided modify DN operation.
    *
@@ -1060,37 +764,6 @@
 
 
   /**
-   * Writes a message to the access logger containing additional
-   * information associated with the provided search operation.
-   * <p>
-   * This method will only be called after the request has been logged
-   * and before the response. Implementations can choose to ignore
-   * intermediate responses or filter them based on their category.
-   *
-   * @param searchOperation
-   *          The search operation containing the information to use
-   *          to log the search request.
-   * @param category
-   *          The category of the intermediate message.
-   * @param content
-   *          The content of the intermediate message. This comprises
-   *          of one or more key/value pairs which form the content of
-   *          the intermediate message.
-   */
-  public static void logSearchIntermediateMessage(
-      SearchOperation searchOperation, String category,
-      Map<String, String> content)
-  {
-    for (AccessLogPublisher<?> publisher : accessPublishers)
-    {
-      publisher.logSearchIntermediateMessage(searchOperation,
-          category, content);
-    }
-  }
-
-
-
-  /**
    * Writes a message to the access logger with information about the search
    * result entry that matches the criteria associated with the provided search
    * operation.

--
Gitblit v1.10.0