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/AccountStatusNotificationHandlerConfigManager.java | 49 +++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 41 insertions(+), 8 deletions(-)
diff --git a/opends/src/server/org/opends/server/core/AccountStatusNotificationHandlerConfigManager.java b/opends/src/server/org/opends/server/core/AccountStatusNotificationHandlerConfigManager.java
index bde3356..6d2fc87 100644
--- a/opends/src/server/org/opends/server/core/AccountStatusNotificationHandlerConfigManager.java
+++ b/opends/src/server/org/opends/server/core/AccountStatusNotificationHandlerConfigManager.java
@@ -34,6 +34,7 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
@@ -159,7 +160,7 @@
try
{
// Load the class but don't initialize it.
- loadNotificationHandler(className, null);
+ loadNotificationHandler(className, configuration, true);
}
catch (InitializationException ie)
{
@@ -267,7 +268,7 @@
try
{
// Load the class but don't initialize it.
- loadNotificationHandler (className, null);
+ loadNotificationHandler (className, configuration, false);
}
catch (InitializationException ie)
{
@@ -373,7 +374,7 @@
// Load the notification handler class...
AccountStatusNotificationHandler
<? extends AccountStatusNotificationHandlerCfg> handlerClass;
- handlerClass = loadNotificationHandler (className, configuration);
+ handlerClass = loadNotificationHandler (className, configuration, true);
// ... and install the entry cache in the server.
DN configEntryDN = configuration.dn();
@@ -392,8 +393,9 @@
* @param className The fully-qualified name of the notification handler
* class to load, instantiate, and initialize.
* @param configuration The configuration to use to initialize the
- * notification handler, or {@code null} if the
- * notification handler should not be initialized.
+ * notification handler. It must not be {@code null}.
+ * @param initialize Indicates whether the key manager provider instance
+ * should be initialized.
*
* @return The possibly initialized notification handler.
*
@@ -405,8 +407,8 @@
<? extends AccountStatusNotificationHandlerCfg>
loadNotificationHandler(
String className,
- AccountStatusNotificationHandlerCfg configuration
- )
+ AccountStatusNotificationHandlerCfg configuration,
+ boolean initialize)
throws InitializationException
{
try
@@ -429,7 +431,7 @@
<? extends AccountStatusNotificationHandlerCfg>)
handlerClass.newInstance();
- if (configuration != null)
+ if (initialize)
{
Method method = notificationHandler.getClass().getMethod(
"initializeStatusNotificationHandler",
@@ -437,6 +439,37 @@
);
method.invoke(notificationHandler, configuration);
}
+ else
+ {
+ Method method =
+ notificationHandler.getClass().getMethod(
+ "isConfigurationAcceptable",
+ AccountStatusNotificationHandlerCfg.class, List.class);
+
+ List<String> unacceptableReasons = new ArrayList<String>();
+ Boolean acceptable = (Boolean) method.invoke(notificationHandler,
+ configuration,
+ unacceptableReasons);
+ if (! acceptable)
+ {
+ StringBuilder buffer = new StringBuilder();
+ if (! unacceptableReasons.isEmpty())
+ {
+ Iterator<String> iterator = unacceptableReasons.iterator();
+ buffer.append(iterator.next());
+ while (iterator.hasNext())
+ {
+ buffer.append(". ");
+ buffer.append(iterator.next());
+ }
+ }
+
+ int msgID = MSGID_CONFIG_ACCTNOTHANDLER_CONFIG_NOT_ACCEPTABLE;
+ String message = getMessage(msgID, String.valueOf(configuration.dn()),
+ buffer.toString());
+ throw new InitializationException(msgID, message);
+ }
+ }
return notificationHandler;
}
--
Gitblit v1.10.0