From 959c9ded0c297d00500678a0c80d7d6d8a5265fe Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Tue, 10 Jul 2007 16:03:42 +0000
Subject: [PATCH] Fix a set of problems with the configuration interface in which there were a number of cases in which insufficient validation was performed.  In particular, if a new configuration object was added over protocol or an existing configuration object was changed from disabled to enabled, then the server would only perform generic validation for that component and would not have any way to perform more detailed validation that could detect larger numbers of problems.

---
 opends/src/server/org/opends/server/core/ExtendedOperationConfigManager.java |   49 ++++++++++++++++++++++++++++---------------------
 1 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/opends/src/server/org/opends/server/core/ExtendedOperationConfigManager.java b/opends/src/server/org/opends/server/core/ExtendedOperationConfigManager.java
index 2dc1ad8..2f546ec 100644
--- a/opends/src/server/org/opends/server/core/ExtendedOperationConfigManager.java
+++ b/opends/src/server/org/opends/server/core/ExtendedOperationConfigManager.java
@@ -33,18 +33,7 @@
 import java.util.concurrent.ConcurrentHashMap;
 import java.lang.reflect.Method;
 
-import org.opends.server.api.ExtendedOperationHandler;
-import org.opends.server.config.ConfigException;
-import org.opends.server.types.ConfigChangeResult;
-import org.opends.server.types.DN;
-import org.opends.server.types.InitializationException;
-import org.opends.server.types.ResultCode;
-
-import static org.opends.server.loggers.debug.DebugLogger.*;
-import org.opends.server.loggers.debug.DebugTracer;
-import org.opends.server.types.DebugLogLevel;
-import static org.opends.server.messages.ConfigMessages.*;
-import static org.opends.server.messages.MessageHandler.getMessage;
+import org.opends.server.admin.ClassPropertyDefinition;
 import org.opends.server.admin.server.ConfigurationChangeListener;
 import org.opends.server.admin.server.ConfigurationAddListener;
 import org.opends.server.admin.server.ConfigurationDeleteListener;
@@ -52,10 +41,22 @@
 import org.opends.server.admin.std.server.ExtendedOperationHandlerCfg;
 import org.opends.server.admin.std.server.RootCfg;
 import org.opends.server.admin.std.meta.ExtendedOperationHandlerCfgDefn;
-import org.opends.server.admin.ClassPropertyDefinition;
+import org.opends.server.api.ExtendedOperationHandler;
+import org.opends.server.config.ConfigException;
+import org.opends.server.loggers.debug.DebugTracer;
+import org.opends.server.types.ConfigChangeResult;
+import org.opends.server.types.DebugLogLevel;
+import org.opends.server.types.DN;
+import org.opends.server.types.InitializationException;
+import org.opends.server.types.ResultCode;
+
+import static org.opends.server.loggers.debug.DebugLogger.*;
+import static org.opends.server.messages.ConfigMessages.*;
+import static org.opends.server.messages.MessageHandler.*;
 import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString;
 
 
+
 /**
  * This class defines a utility that will be used to manage the set of extended
  * operation handlers defined in the Directory Server.  It will initialize the
@@ -75,7 +76,6 @@
 
 
 
-
   // A mapping between the DNs of the config entries and the associated extended
   // operation handlers.
   private ConcurrentHashMap<DN,ExtendedOperationHandler> handlers;
@@ -87,7 +87,7 @@
    */
   public ExtendedOperationConfigManager()
   {
-    handlers      = new ConcurrentHashMap<DN,ExtendedOperationHandler>();
+    handlers = new ConcurrentHashMap<DN,ExtendedOperationHandler>();
   }
 
 
@@ -382,9 +382,8 @@
 
   // Determines whether or not the new configuration's implementation
   // class is acceptable.
-  private boolean isJavaClassAcceptable(
-      ExtendedOperationHandlerCfg config,
-      List<String> unacceptableReasons)
+  private boolean isJavaClassAcceptable(ExtendedOperationHandlerCfg config,
+                                        List<String> unacceptableReasons)
   {
     String className = config.getJavaImplementationClass();
     ExtendedOperationHandlerCfgDefn d =
@@ -396,13 +395,21 @@
     Class<? extends ExtendedOperationHandler> theClass;
     try {
       theClass = pd.loadClass(className, ExtendedOperationHandler.class);
-      theClass.newInstance();
+      ExtendedOperationHandler extOpHandler = theClass.newInstance();
 
       // Determine the initialization method to use: it must take a
       // single parameter which is the exact type of the configuration
       // object.
-      theClass.getMethod("initializeExtendedOperationHandler",
-                         config.definition().getServerConfigurationClass());
+      Method method = theClass.getMethod("isConfigurationAcceptable",
+                                         ExtendedOperationHandlerCfg.class,
+                                         List.class);
+      Boolean acceptable = (Boolean) method.invoke(extOpHandler, config,
+                                                   unacceptableReasons);
+
+      if (! acceptable)
+      {
+        return false;
+      }
     }
     catch (Exception e)
     {

--
Gitblit v1.10.0