From be02bbbc3c8cdb00ea07b525045aefa3d18c2bbf Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Thu, 22 Feb 2007 23:33:48 +0000
Subject: [PATCH] Update the access control config manager to send an administrative alert notification whenever the access control handler is enabled or disabled.

---
 opends/src/server/org/opends/server/core/AccessControlConfigManager.java |   80 ++++++++++++++++++++++++++++++++++++++-
 opends/src/server/org/opends/server/util/ServerConstants.java            |   38 +++++++++++++++++++
 2 files changed, 115 insertions(+), 3 deletions(-)

diff --git a/opends/src/server/org/opends/server/core/AccessControlConfigManager.java b/opends/src/server/org/opends/server/core/AccessControlConfigManager.java
index a449933..dacc68b 100644
--- a/opends/src/server/org/opends/server/core/AccessControlConfigManager.java
+++ b/opends/src/server/org/opends/server/core/AccessControlConfigManager.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Portions Copyright 2006 Sun Microsystems, Inc.
+ *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
  */
 package org.opends.server.core;
 
@@ -31,13 +31,16 @@
 import static org.opends.server.loggers.Error.*;
 import static org.opends.server.messages.ConfigMessages.*;
 import static org.opends.server.messages.MessageHandler.*;
+import static org.opends.server.util.ServerConstants.*;
 import static org.opends.server.util.StaticUtils.*;
 
 import java.util.ArrayList;
+import java.util.LinkedHashMap;
 import java.util.concurrent.atomic.AtomicReference;
 
 import org.opends.server.api.AccessControlHandler;
 import org.opends.server.api.AccessControlProvider;
+import org.opends.server.api.AlertGenerator;
 import org.opends.server.api.ConfigChangeListener;
 import org.opends.server.config.BooleanConfigAttribute;
 import org.opends.server.config.ConfigEntry;
@@ -57,8 +60,9 @@
  * implementation is used, which permits all operations regardless of
  * the identity of the user.
  */
-public final class AccessControlConfigManager {
-
+public final class AccessControlConfigManager
+       implements AlertGenerator
+{
   // Fully qualified class name for debugging purposes.
   private static final String CLASS_NAME =
     "org.opends.server.core.AccessControlConfigManager";
@@ -255,11 +259,21 @@
         String message = getMessage(msgID);
         logError(ErrorLogCategory.CONFIGURATION,
             ErrorLogSeverity.SEVERE_WARNING, message, msgID);
+        if (currentConfiguration != null)
+        {
+          DirectoryServer.sendAlertNotification(this,
+              ALERT_TYPE_ACCESS_CONTROL_DISABLED, msgID, message);
+        }
       } else {
         int msgID = MSGID_CONFIG_AUTHZ_ENABLED;
         String message = getMessage(msgID, newHandlerClass.getName());
         logError(ErrorLogCategory.CONFIGURATION,
             ErrorLogSeverity.NOTICE, message, msgID);
+        if (currentConfiguration != null)
+        {
+          DirectoryServer.sendAlertNotification(this,
+              ALERT_TYPE_ACCESS_CONTROL_ENABLED, msgID, message);
+        }
       }
     }
 
@@ -536,4 +550,64 @@
       }
     }
   }
+
+
+
+  /**
+   * Retrieves the DN of the configuration entry with which this alert
+   * generator is associated.
+   *
+   * @return  The DN of the configuration entry with which this alert
+   *          generator is associated.
+   */
+  public DN getComponentEntryDN()
+  {
+    assert debugEnter(CLASS_NAME, "getComponentEntryDN");
+
+    return currentConfiguration.getConfigEntry().getDN();
+  }
+
+
+
+  /**
+   * Retrieves the fully-qualified name of the Java class for this
+   * alert generator implementation.
+   *
+   * @return  The fully-qualified name of the Java class for this
+   *          alert generator implementation.
+   */
+  public String getClassName()
+  {
+    assert debugEnter(CLASS_NAME, "getClassName");
+
+    return CLASS_NAME;
+  }
+
+
+
+  /**
+   * Retrieves information about the set of alerts that this generator
+   * may produce.  The map returned should be between the notification
+   * type for a particular notification and the human-readable
+   * description for that notification.  This alert generator must not
+   * generate any alerts with types that are not contained in this
+   * list.
+   *
+   * @return  Information about the set of alerts that this generator
+   *          may produce.
+   */
+  public LinkedHashMap<String,String> getAlerts()
+  {
+    assert debugEnter(CLASS_NAME, "getAlerts");
+
+    LinkedHashMap<String,String> alerts = new LinkedHashMap<String,String>();
+
+    alerts.put(ALERT_TYPE_ACCESS_CONTROL_DISABLED,
+               ALERT_DESCRIPTION_ACCESS_CONTROL_DISABLED);
+    alerts.put(ALERT_TYPE_ACCESS_CONTROL_ENABLED,
+               ALERT_DESCRIPTION_ACCESS_CONTROL_ENABLED);
+
+    return alerts;
+  }
 }
+
diff --git a/opends/src/server/org/opends/server/util/ServerConstants.java b/opends/src/server/org/opends/server/util/ServerConstants.java
index 2f13a5a..3fe29f0 100644
--- a/opends/src/server/org/opends/server/util/ServerConstants.java
+++ b/opends/src/server/org/opends/server/util/ServerConstants.java
@@ -1222,6 +1222,44 @@
 
   /**
    * The description for the alert type that will be used for the alert
+   * notification generated if the access control handler is disabled.
+   */
+  public static final String ALERT_DESCRIPTION_ACCESS_CONTROL_DISABLED =
+       "This alert type will be used to notify administrators that the " +
+       "access control handler has been disabled.";
+
+
+
+  /**
+   * The alert type string that will be used for the alert notification
+   * generated if the access control handler is disabled.
+   */
+  public static final String ALERT_TYPE_ACCESS_CONTROL_DISABLED =
+       "org.opends.server.AccessControlDisabled";
+
+
+
+  /**
+   * The description for the alert type that will be used for the alert
+   * notification generated if the access control handler is enabled.
+   */
+  public static final String ALERT_DESCRIPTION_ACCESS_CONTROL_ENABLED =
+       "This alert type will be used to notify administrators that the " +
+       "access control handler has been enabled.";
+
+
+
+  /**
+   * The alert type string that will be used for the alert notification
+   * generated if the access control handler is enabled.
+   */
+  public static final String ALERT_TYPE_ACCESS_CONTROL_ENABLED =
+       "org.opends.server.AccessControlEnabled";
+
+
+
+  /**
+   * The description for the alert type that will be used for the alert
    * notification generated if a recurring task cannot be found to schedule the
    * next iteration after the previous iteration has completed.
    */

--
Gitblit v1.10.0