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/GroupManager.java | 52 +++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 41 insertions(+), 11 deletions(-)
diff --git a/opends/src/server/org/opends/server/core/GroupManager.java b/opends/src/server/org/opends/server/core/GroupManager.java
index c7a0416..94bcf8a 100644
--- a/opends/src/server/org/opends/server/core/GroupManager.java
+++ b/opends/src/server/org/opends/server/core/GroupManager.java
@@ -35,7 +35,6 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-
import org.opends.server.workflowelement.localbackend.*;
import org.opends.server.admin.ClassPropertyDefinition;
import org.opends.server.admin.server.ConfigurationAddListener;
@@ -80,6 +79,7 @@
import static org.opends.server.util.StaticUtils.*;
+
/**
* This class provides a mechanism for interacting with all groups defined in
* the Directory Server. It will handle all necessary processing at server
@@ -105,7 +105,6 @@
-
// A mapping between the DNs of the config entries and the associated
// group implementations.
private ConcurrentHashMap<DN,Group> groupImplementations;
@@ -170,7 +169,7 @@
String className = groupConfiguration.getGroupClass();
try
{
- Group group = loadGroup(className, groupConfiguration);
+ Group group = loadGroup(className, groupConfiguration, true);
groupImplementations.put(groupConfiguration.dn(), group);
}
catch (InitializationException ie)
@@ -200,7 +199,7 @@
String className = configuration.getGroupClass();
try
{
- loadGroup(className, null);
+ loadGroup(className, configuration, false);
}
catch (InitializationException ie)
{
@@ -239,7 +238,7 @@
String className = configuration.getGroupClass();
try
{
- group = loadGroup(className, configuration);
+ group = loadGroup(className, configuration, true);
}
catch (InitializationException ie)
{
@@ -323,7 +322,7 @@
String className = configuration.getGroupClass();
try
{
- loadGroup(className, null);
+ loadGroup(className, configuration, false);
}
catch (InitializationException ie)
{
@@ -399,7 +398,7 @@
Group group = null;
try
{
- group = loadGroup(className, configuration);
+ group = loadGroup(className, configuration, true);
}
catch (InitializationException ie)
{
@@ -431,8 +430,9 @@
* @param className The fully-qualified name of the group implementation
* class to load, instantiate, and initialize.
* @param configuration The configuration to use to initialize the group
- * implementation, or {@code null} if the group
- * implementation should not be initialized.
+ * implementation. It must not be {@code null}.
+ * @param initialize Indicates whether the key manager provider instance
+ * should be initialized.
*
* @return The possibly initialized group implementation.
*
@@ -440,7 +440,8 @@
* initialize the group implementation.
*/
private Group loadGroup(String className,
- GroupImplementationCfg configuration)
+ GroupImplementationCfg configuration,
+ boolean initialize)
throws InitializationException
{
try
@@ -453,13 +454,42 @@
propertyDefinition.loadClass(className, Group.class);
Group group = groupClass.newInstance();
- if (configuration != null)
+ if (initialize)
{
Method method =
group.getClass().getMethod("initializeGroupImplementation",
configuration.definition().getServerConfigurationClass());
method.invoke(group, configuration);
}
+ else
+ {
+ Method method = group.getClass().getMethod("isConfigurationAcceptable",
+ GroupImplementationCfg.class,
+ List.class);
+
+ List<String> unacceptableReasons = new ArrayList<String>();
+ Boolean acceptable = (Boolean) method.invoke(group, 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_GROUP_CONFIG_NOT_ACCEPTABLE;
+ String message = getMessage(msgID, String.valueOf(configuration.dn()),
+ buffer.toString());
+ throw new InitializationException(msgID, message);
+ }
+ }
return group;
}
--
Gitblit v1.10.0