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/PasswordStorageSchemeConfigManager.java | 48 ++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 40 insertions(+), 8 deletions(-)
diff --git a/opends/src/server/org/opends/server/core/PasswordStorageSchemeConfigManager.java b/opends/src/server/org/opends/server/core/PasswordStorageSchemeConfigManager.java
index 1081d4d..36a8c5d 100644
--- a/opends/src/server/org/opends/server/core/PasswordStorageSchemeConfigManager.java
+++ b/opends/src/server/org/opends/server/core/PasswordStorageSchemeConfigManager.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;
@@ -150,7 +151,7 @@
try
{
// Load the class but don't initialize it.
- loadPasswordStorageScheme (className, null);
+ loadPasswordStorageScheme (className, configuration, false);
}
catch (InitializationException ie)
{
@@ -259,7 +260,7 @@
try
{
// Load the class but don't initialize it.
- loadPasswordStorageScheme (className, null);
+ loadPasswordStorageScheme (className, configuration, false);
}
catch (InitializationException ie)
{
@@ -367,7 +368,7 @@
// Load the password storage scheme class...
PasswordStorageScheme
<? extends PasswordStorageSchemeCfg> schemeClass;
- schemeClass = loadPasswordStorageScheme (className, configuration);
+ schemeClass = loadPasswordStorageScheme (className, configuration, true);
// ... and install the password storage scheme in the server.
DN configEntryDN = configuration.dn();
@@ -383,8 +384,9 @@
* @param className The fully-qualified name of the class
* to load, instantiate, and initialize.
* @param configuration The configuration to use to initialize the
- * class, or {@code null} if the
- * class should not be initialized.
+ * class. It must not be {@code null}.
+ * @param initialize Indicates whether the password storage scheme
+ * instance should be initialized.
*
* @return The possibly initialized password storage scheme.
*
@@ -394,8 +396,8 @@
private PasswordStorageScheme <? extends PasswordStorageSchemeCfg>
loadPasswordStorageScheme(
String className,
- PasswordStorageSchemeCfg configuration
- )
+ PasswordStorageSchemeCfg configuration,
+ boolean initialize)
throws InitializationException
{
try
@@ -416,7 +418,7 @@
(PasswordStorageScheme<? extends PasswordStorageSchemeCfg>)
schemeClass.newInstance();
- if (configuration != null)
+ if (initialize)
{
Method method = passwordStorageScheme.getClass().getMethod(
"initializePasswordStorageScheme",
@@ -424,6 +426,36 @@
);
method.invoke(passwordStorageScheme, configuration);
}
+ else
+ {
+ Method method = passwordStorageScheme.getClass().getMethod(
+ "isConfigurationAcceptable",
+ PasswordStorageSchemeCfg.class, List.class);
+
+ List<String> unacceptableReasons = new ArrayList<String>();
+ Boolean acceptable = (Boolean) method.invoke(passwordStorageScheme,
+ 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_PWSCHEME_CONFIG_NOT_ACCEPTABLE;
+ String message = getMessage(msgID, String.valueOf(configuration.dn()),
+ buffer.toString());
+ throw new InitializationException(msgID, message);
+ }
+ }
return passwordStorageScheme;
}
--
Gitblit v1.10.0