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/SynchronizationProviderConfigManager.java |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/opends/src/server/org/opends/server/core/SynchronizationProviderConfigManager.java b/opends/src/server/org/opends/server/core/SynchronizationProviderConfigManager.java
index bdfcb9e..b0383b2 100644
--- a/opends/src/server/org/opends/server/core/SynchronizationProviderConfigManager.java
+++ b/opends/src/server/org/opends/server/core/SynchronizationProviderConfigManager.java
@@ -34,6 +34,7 @@
 import static org.opends.server.messages.MessageHandler.getMessage;
 import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString;
 
+import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.ConcurrentHashMap;
@@ -440,11 +441,12 @@
       d.getJavaImplementationClassPropertyDefinition();
 
     // Load the class and cast it to a synchronizationProvider.
+    SynchronizationProvider provider = null;
     Class<? extends SynchronizationProvider> theClass;
     try
     {
        theClass = pd.loadClass(className, SynchronizationProvider.class);
-       theClass.newInstance();
+       provider = theClass.newInstance();
     } catch (Exception e)
     {
        // Handle the exception: put a message in the unacceptable reasons.
@@ -461,8 +463,16 @@
       // Determine the initialization method to use: it must take a
       // single parameter which is the exact type of the configuration
       // object.
-      theClass.getMethod("initializeSynchronizationProvider",
-                     configuration.definition().getServerConfigurationClass());
+      Method method = theClass.getMethod("isConfigurationAcceptable",
+                                         SynchronizationProviderCfg.class,
+                                         List.class);
+      Boolean acceptable = (Boolean) method.invoke(provider, configuration,
+                                                   unacceptableReasons);
+
+      if (! acceptable)
+      {
+        return false;
+      }
     } catch (Exception e)
     {
       // Handle the exception: put a message in the unacceptable reasons.

--
Gitblit v1.10.0