mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

jcduff
23.04.2008 f73b655466092169abac34833fb628fce1fcdebe
opends/src/server/org/opends/server/loggers/AccessLogger.java
@@ -32,6 +32,7 @@
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;
@@ -72,8 +73,8 @@
  // The set of access loggers that have been registered with the server.  It
  // will initially be empty.
  static CopyOnWriteArrayList<AccessLogPublisher> accessPublishers =
      new CopyOnWriteArrayList<AccessLogPublisher>();
  static CopyOnWriteArrayList<AccessLogPublisher<?>> accessPublishers =
      new CopyOnWriteArrayList<AccessLogPublisher<?>>();
  // The singleton instance of this class for configuration purposes.
  static final AccessLogger instance = new AccessLogger();
@@ -96,7 +97,7 @@
   * @param publisher The access log publisher to add.
   */
  public synchronized static void addAccessLogPublisher(
      AccessLogPublisher publisher)
      AccessLogPublisher<?> publisher)
  {
    accessPublishers.add(publisher);
  }
@@ -108,7 +109,7 @@
   * @return The publisher that was removed or null if it was not found.
   */
  public synchronized static boolean removeAccessLogPublisher(
      AccessLogPublisher publisher)
      AccessLogPublisher<?> publisher)
  {
    boolean removed = accessPublishers.remove(publisher);
@@ -125,7 +126,7 @@
   */
  public synchronized static void removeAllAccessLogPublishers()
  {
    for(AccessLogPublisher publisher : accessPublishers)
    for(AccessLogPublisher<?> publisher : accessPublishers)
    {
      publisher.close();
    }
@@ -154,7 +155,7 @@
      if(config.isEnabled())
      {
        AccessLogPublisher AccessLogPublisher = getAccessPublisher(config);
        AccessLogPublisher<?> AccessLogPublisher = getAccessPublisher(config);
        addAccessLogPublisher(AccessLogPublisher);
      }
@@ -199,7 +200,7 @@
    {
      try
      {
        AccessLogPublisher AccessLogPublisher = getAccessPublisher(config);
        AccessLogPublisher<?> AccessLogPublisher = getAccessPublisher(config);
        addAccessLogPublisher(AccessLogPublisher);
      }
@@ -241,8 +242,8 @@
    DN dn = config.dn();
    AccessLogPublisher accessLogPublisher = null;
    for(AccessLogPublisher publisher : accessPublishers)
    AccessLogPublisher<?> accessLogPublisher = null;
    for(AccessLogPublisher<?> publisher : accessPublishers)
    {
      if(publisher.getDN().equals(dn))
      {
@@ -293,8 +294,8 @@
  {
    DN dn = config.dn();
    AccessLogPublisher accessLogPublisher = null;
    for(AccessLogPublisher publisher : accessPublishers)
    AccessLogPublisher<?> accessLogPublisher = null;
    for(AccessLogPublisher<?> publisher : accessPublishers)
    {
      if(publisher.getDN().equals(dn))
      {
@@ -317,8 +318,8 @@
    ResultCode resultCode = ResultCode.SUCCESS;
    boolean adminActionRequired = false;
    AccessLogPublisher accessLogPublisher = null;
    for(AccessLogPublisher publisher : accessPublishers)
    AccessLogPublisher<?> accessLogPublisher = null;
    for(AccessLogPublisher<?> publisher : accessPublishers)
    {
      if(publisher.getDN().equals(config.dn()))
      {
@@ -347,7 +348,7 @@
    ClassPropertyDefinition pd =
        d.getJavaClassPropertyDefinition();
    // Load the class and cast it to a DebugLogPublisher.
    AccessLogPublisher publisher = null;
    AccessLogPublisher<?> publisher = null;
    Class<? extends AccessLogPublisher> theClass;
    try {
      theClass = pd.loadClass(className, AccessLogPublisher.class);
@@ -387,7 +388,7 @@
    return true;
  }
  private AccessLogPublisher getAccessPublisher(AccessLogPublisherCfg config)
  private AccessLogPublisher<?> getAccessPublisher(AccessLogPublisherCfg config)
      throws ConfigException {
    String className = config.getJavaClass();
    AccessLogPublisherCfgDefn d = AccessLogPublisherCfgDefn.getInstance();
@@ -395,7 +396,7 @@
        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();
@@ -438,7 +439,7 @@
   */
  public static void logConnect(ClientConnection clientConnection)
  {
    for (AccessLogPublisher publisher : accessPublishers)
    for (AccessLogPublisher<?> publisher : accessPublishers)
    {
      publisher.logConnect(clientConnection);
    }
@@ -460,7 +461,7 @@
                                   DisconnectReason disconnectReason,
                                   Message message)
  {
    for (AccessLogPublisher publisher : accessPublishers)
    for (AccessLogPublisher<?> publisher : accessPublishers)
    {
      publisher.logDisconnect(clientConnection, disconnectReason, message);
    }
@@ -476,7 +477,7 @@
   */
  public static void logAbandonRequest(AbandonOperation abandonOperation)
  {
    for (AccessLogPublisher publisher : accessPublishers)
    for (AccessLogPublisher<?> publisher : accessPublishers)
    {
      publisher.logAbandonRequest(abandonOperation);
    }
@@ -485,6 +486,37 @@
  /**
   * 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.
   *
@@ -493,7 +525,7 @@
   */
  public static void logAbandonResult(AbandonOperation abandonOperation)
  {
    for (AccessLogPublisher publisher : accessPublishers)
    for (AccessLogPublisher<?> publisher : accessPublishers)
    {
      publisher.logAbandonResult(abandonOperation);
    }
@@ -510,7 +542,7 @@
   */
  public static void logAddRequest(AddOperation addOperation)
  {
    for (AccessLogPublisher publisher : accessPublishers)
    for (AccessLogPublisher<?> publisher : accessPublishers)
    {
      publisher.logAddRequest(addOperation);
    }
@@ -519,6 +551,37 @@
  /**
   * 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.
   *
@@ -527,7 +590,7 @@
   */
  public static void logAddResponse(AddOperation addOperation)
  {
    for (AccessLogPublisher publisher : accessPublishers)
    for (AccessLogPublisher<?> publisher : accessPublishers)
    {
      publisher.logAddResponse(addOperation);
    }
@@ -544,7 +607,7 @@
   */
  public static void logBindRequest(BindOperation bindOperation)
  {
    for (AccessLogPublisher publisher : accessPublishers)
    for (AccessLogPublisher<?> publisher : accessPublishers)
    {
      publisher.logBindRequest(bindOperation);
    }
@@ -553,6 +616,37 @@
  /**
   * 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.
   *
@@ -561,7 +655,7 @@
   */
  public static void logBindResponse(BindOperation bindOperation)
  {
    for (AccessLogPublisher publisher : accessPublishers)
    for (AccessLogPublisher<?> publisher : accessPublishers)
    {
      publisher.logBindResponse(bindOperation);
    }
@@ -578,7 +672,7 @@
   */
  public static void logCompareRequest(CompareOperation compareOperation)
  {
    for (AccessLogPublisher publisher : accessPublishers)
    for (AccessLogPublisher<?> publisher : accessPublishers)
    {
      publisher.logCompareRequest(compareOperation);
    }
@@ -587,6 +681,37 @@
  /**
   * 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.
   *
@@ -595,7 +720,7 @@
   */
  public static void logCompareResponse(CompareOperation compareOperation)
  {
    for (AccessLogPublisher publisher : accessPublishers)
    for (AccessLogPublisher<?> publisher : accessPublishers)
    {
      publisher.logCompareResponse(compareOperation);
    }
@@ -612,7 +737,7 @@
   */
  public static void logDeleteRequest(DeleteOperation deleteOperation)
  {
    for (AccessLogPublisher publisher : accessPublishers)
    for (AccessLogPublisher<?> publisher : accessPublishers)
    {
      publisher.logDeleteRequest(deleteOperation);
    }
@@ -621,6 +746,37 @@
  /**
   * 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.
   *
@@ -629,7 +785,7 @@
   */
  public static void logDeleteResponse(DeleteOperation deleteOperation)
  {
    for (AccessLogPublisher publisher : accessPublishers)
    for (AccessLogPublisher<?> publisher : accessPublishers)
    {
      publisher.logDeleteResponse(deleteOperation);
    }
@@ -646,7 +802,7 @@
   */
  public static void logExtendedRequest(ExtendedOperation extendedOperation)
  {
    for (AccessLogPublisher publisher : accessPublishers)
    for (AccessLogPublisher<?> publisher : accessPublishers)
    {
      publisher.logExtendedRequest(extendedOperation);
    }
@@ -655,6 +811,37 @@
  /**
   * 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.
   *
@@ -663,7 +850,7 @@
   */
  public static void logExtendedResponse(ExtendedOperation extendedOperation)
  {
    for (AccessLogPublisher publisher : accessPublishers)
    for (AccessLogPublisher<?> publisher : accessPublishers)
    {
      publisher.logExtendedResponse(extendedOperation);
    }
@@ -680,7 +867,7 @@
   */
  public static void logModifyRequest(ModifyOperation modifyOperation)
  {
    for (AccessLogPublisher publisher : accessPublishers)
    for (AccessLogPublisher<?> publisher : accessPublishers)
    {
      publisher.logModifyRequest(modifyOperation);
    }
@@ -689,6 +876,37 @@
  /**
   * 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.
   *
@@ -697,7 +915,7 @@
   */
  public static void logModifyResponse(ModifyOperation modifyOperation)
  {
    for (AccessLogPublisher publisher : accessPublishers)
    for (AccessLogPublisher<?> publisher : accessPublishers)
    {
      publisher.logModifyResponse(modifyOperation);
    }
@@ -714,7 +932,7 @@
   */
  public static void logModifyDNRequest(ModifyDNOperation modifyDNOperation)
  {
    for (AccessLogPublisher publisher : accessPublishers)
    for (AccessLogPublisher<?> publisher : accessPublishers)
    {
      publisher.logModifyDNRequest(modifyDNOperation);
    }
@@ -723,6 +941,37 @@
  /**
   * 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.
   *
@@ -732,7 +981,7 @@
   */
  public static void logModifyDNResponse(ModifyDNOperation modifyDNOperation)
  {
    for (AccessLogPublisher publisher : accessPublishers)
    for (AccessLogPublisher<?> publisher : accessPublishers)
    {
      publisher.logModifyDNResponse(modifyDNOperation);
    }
@@ -749,7 +998,7 @@
   */
  public static void logSearchRequest(SearchOperation searchOperation)
  {
    for (AccessLogPublisher publisher : accessPublishers)
    for (AccessLogPublisher<?> publisher : accessPublishers)
    {
      publisher.logSearchRequest(searchOperation);
    }
@@ -758,6 +1007,37 @@
  /**
   * 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.
@@ -769,7 +1049,7 @@
  public static void logSearchResultEntry(SearchOperation searchOperation,
                                          SearchResultEntry searchEntry)
  {
    for (AccessLogPublisher publisher : accessPublishers)
    for (AccessLogPublisher<?> publisher : accessPublishers)
    {
      publisher.logSearchResultEntry(searchOperation, searchEntry);
    }
@@ -788,7 +1068,7 @@
  public static void logSearchResultReference(SearchOperation searchOperation,
                          SearchResultReference searchReference)
  {
    for (AccessLogPublisher publisher : accessPublishers)
    for (AccessLogPublisher<?> publisher : accessPublishers)
    {
      publisher.logSearchResultReference(searchOperation, searchReference);
    }
@@ -805,7 +1085,7 @@
   */
  public static void logSearchResultDone(SearchOperation searchOperation)
  {
    for (AccessLogPublisher publisher : accessPublishers)
    for (AccessLogPublisher<?> publisher : accessPublishers)
    {
      publisher.logSearchResultDone(searchOperation);
    }
@@ -822,7 +1102,7 @@
   */
  public static void logUnbind(UnbindOperation unbindOperation)
  {
    for (AccessLogPublisher publisher : accessPublishers)
    for (AccessLogPublisher<?> publisher : accessPublishers)
    {
      publisher.logUnbind(unbindOperation);
    }