From 79f651acc5946c9d42ae0bbd23540eec67e9dae5 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Sun, 24 Jun 2007 01:38:21 +0000
Subject: [PATCH] Update the set of plugins included with the server so that they will look for changes to the set of registered plugin types and reject the change if any of the new plugin types are not appropriate.
---
opendj-sdk/opends/src/server/org/opends/server/plugins/EntryUUIDPlugin.java | 51 ++++++++++++
opendj-sdk/opends/src/server/org/opends/server/plugins/PasswordPolicyImportPlugin.java | 49 ++++++++++++
opendj-sdk/opends/src/server/org/opends/server/plugins/LDAPADListPlugin.java | 52 +++++++++++++
opendj-sdk/opends/src/server/org/opends/server/plugins/profiler/ProfilerPlugin.java | 26 ++++++
opendj-sdk/opends/src/server/org/opends/server/plugins/LastModPlugin.java | 53 +++++++++++++
5 files changed, 231 insertions(+), 0 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/plugins/EntryUUIDPlugin.java b/opendj-sdk/opends/src/server/org/opends/server/plugins/EntryUUIDPlugin.java
index 861e7cf..3bc973d 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/plugins/EntryUUIDPlugin.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/plugins/EntryUUIDPlugin.java
@@ -36,6 +36,8 @@
import java.util.Set;
import java.util.UUID;
+import org.opends.server.admin.server.ConfigurationChangeListener;
+import org.opends.server.admin.std.meta.PluginCfgDefn;
import org.opends.server.admin.std.server.PluginCfg;
import org.opends.server.api.plugin.DirectoryServerPlugin;
import org.opends.server.api.plugin.LDIFPluginResult;
@@ -47,9 +49,11 @@
import org.opends.server.types.AttributeUsage;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.ByteStringFactory;
+import org.opends.server.types.ConfigChangeResult;
import org.opends.server.types.DirectoryConfig;
import org.opends.server.types.Entry;
import org.opends.server.types.LDIFImportConfig;
+import org.opends.server.types.ResultCode;
import org.opends.server.types.operation.PreOperationAddOperation;
import static org.opends.server.messages.MessageHandler.*;
@@ -69,6 +73,7 @@
*/
public final class EntryUUIDPlugin
extends DirectoryServerPlugin<PluginCfg>
+ implements ConfigurationChangeListener<PluginCfg>
{
/**
* The name of the entryUUID attribute type.
@@ -125,6 +130,8 @@
PluginCfg configuration)
throws ConfigException
{
+ configuration.addChangeListener(this);
+
// Make sure that the plugin has been enabled for the appropriate types.
for (PluginType t : pluginTypes)
{
@@ -219,5 +226,49 @@
addOperation.setAttribute(entryUUIDType, uuidList);
return PreOperationPluginResult.SUCCESS;
}
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isConfigurationChangeAcceptable(PluginCfg configuration,
+ List<String> unacceptableReasons)
+ {
+ boolean configAcceptable = true;
+
+ // Ensure that the set of plugin types contains only LDIF import and
+ // pre-operation add.
+ for (PluginCfgDefn.PluginType pluginType : configuration.getPluginType())
+ {
+ switch (pluginType)
+ {
+ case LDIFIMPORT:
+ case PREOPERATIONADD:
+ // These are acceptable.
+ break;
+
+
+ default:
+ int msgID = MSGID_PLUGIN_ENTRYUUID_INVALID_PLUGIN_TYPE;
+ String message = getMessage(msgID, pluginType.toString());
+ unacceptableReasons.add(message);
+ configAcceptable = false;
+ }
+ }
+
+ return configAcceptable;
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ConfigChangeResult applyConfigurationChange(PluginCfg configuration)
+ {
+ // No implementation is required.
+ return new ConfigChangeResult(ResultCode.SUCCESS, false);
+ }
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/plugins/LDAPADListPlugin.java b/opendj-sdk/opends/src/server/org/opends/server/plugins/LDAPADListPlugin.java
index 2e113ab..b971d2f 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/plugins/LDAPADListPlugin.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/plugins/LDAPADListPlugin.java
@@ -28,16 +28,21 @@
import java.util.LinkedHashSet;
+import java.util.List;
import java.util.Set;
+import org.opends.server.admin.server.ConfigurationChangeListener;
+import org.opends.server.admin.std.meta.PluginCfgDefn;
import org.opends.server.admin.std.server.PluginCfg;
import org.opends.server.api.plugin.DirectoryServerPlugin;
import org.opends.server.api.plugin.PluginType;
import org.opends.server.api.plugin.PreParsePluginResult;
import org.opends.server.config.ConfigException;
import org.opends.server.types.AttributeType;
+import org.opends.server.types.ConfigChangeResult;
import org.opends.server.types.DirectoryConfig;
import org.opends.server.types.ObjectClass;
+import org.opends.server.types.ResultCode;
import org.opends.server.types.operation.PreParseSearchOperation;
import static org.opends.server.loggers.debug.DebugLogger.*;
@@ -57,6 +62,7 @@
*/
public final class LDAPADListPlugin
extends DirectoryServerPlugin<PluginCfg>
+ implements ConfigurationChangeListener<PluginCfg>
{
/**
* The tracer object for the debug logger.
@@ -85,6 +91,8 @@
PluginCfg configuration)
throws ConfigException
{
+ configuration.addChangeListener(this);
+
// The set of plugin types must contain only the pre-parse search element.
if (pluginTypes.isEmpty())
{
@@ -182,5 +190,49 @@
return PreParsePluginResult.SUCCESS;
}
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isConfigurationChangeAcceptable(PluginCfg configuration,
+ List<String> unacceptableReasons)
+ {
+ boolean configAcceptable = true;
+
+ // Ensure that the set of plugin types contains only pre-parse search.
+ for (PluginCfgDefn.PluginType pluginType : configuration.getPluginType())
+ {
+ switch (pluginType)
+ {
+ case PREPARSESEARCH:
+ // This is acceptable.
+ break;
+
+
+ default:
+ int msgID = MSGID_PLUGIN_ADLIST_INVALID_PLUGIN_TYPE;
+ String message = getMessage(msgID,
+ String.valueOf(configuration.dn()),
+ String.valueOf(pluginType));
+ unacceptableReasons.add(message);
+ configAcceptable = false;
+ }
+ }
+
+ return configAcceptable;
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ConfigChangeResult applyConfigurationChange(PluginCfg configuration)
+ {
+ // No implementation is required.
+ return new ConfigChangeResult(ResultCode.SUCCESS, false);
+ }
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/plugins/LastModPlugin.java b/opendj-sdk/opends/src/server/org/opends/server/plugins/LastModPlugin.java
index 7cf0213..e3cf203 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/plugins/LastModPlugin.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/plugins/LastModPlugin.java
@@ -30,8 +30,11 @@
import java.util.ArrayList;
import java.util.LinkedHashSet;
+import java.util.List;
import java.util.Set;
+import org.opends.server.admin.server.ConfigurationChangeListener;
+import org.opends.server.admin.std.meta.PluginCfgDefn;
import org.opends.server.admin.std.server.PluginCfg;
import org.opends.server.api.plugin.DirectoryServerPlugin;
import org.opends.server.api.plugin.PluginType;
@@ -41,11 +44,13 @@
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.ByteStringFactory;
+import org.opends.server.types.ConfigChangeResult;
import org.opends.server.types.DirectoryConfig;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.DN;
import org.opends.server.types.Modification;
import org.opends.server.types.ModificationType;
+import org.opends.server.types.ResultCode;
import org.opends.server.types.operation.PreOperationAddOperation;
import org.opends.server.types.operation.PreOperationModifyOperation;
import org.opends.server.types.operation.PreOperationModifyDNOperation;
@@ -66,6 +71,7 @@
*/
public final class LastModPlugin
extends DirectoryServerPlugin<PluginCfg>
+ implements ConfigurationChangeListener<PluginCfg>
{
/**
* The tracer object for the debug logger.
@@ -121,6 +127,8 @@
PluginCfg configuration)
throws ConfigException
{
+ configuration.addChangeListener(this);
+
// Make sure that the plugin has been enabled for the appropriate types.
for (PluginType t : pluginTypes)
{
@@ -313,5 +321,50 @@
// We shouldn't ever need to return a non-success result.
return PreOperationPluginResult.SUCCESS;
}
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isConfigurationChangeAcceptable(PluginCfg configuration,
+ List<String> unacceptableReasons)
+ {
+ boolean configAcceptable = true;
+
+ // Ensure that the set of plugin types contains only pre-operation add,
+ // pre-operation modify, and pre-operation modify DN.
+ for (PluginCfgDefn.PluginType pluginType : configuration.getPluginType())
+ {
+ switch (pluginType)
+ {
+ case PREOPERATIONADD:
+ case PREOPERATIONMODIFY:
+ case PREOPERATIONMODIFYDN:
+ // These are acceptable.
+ break;
+
+
+ default:
+ int msgID = MSGID_PLUGIN_LASTMOD_INVALID_PLUGIN_TYPE;
+ String message = getMessage(msgID, pluginType.toString());
+ unacceptableReasons.add(message);
+ configAcceptable = false;
+ }
+ }
+
+ return configAcceptable;
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ConfigChangeResult applyConfigurationChange(PluginCfg configuration)
+ {
+ // No implementation is required.
+ return new ConfigChangeResult(ResultCode.SUCCESS, false);
+ }
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/plugins/PasswordPolicyImportPlugin.java b/opendj-sdk/opends/src/server/org/opends/server/plugins/PasswordPolicyImportPlugin.java
index 3925a4b..e35cd8b 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/plugins/PasswordPolicyImportPlugin.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/plugins/PasswordPolicyImportPlugin.java
@@ -36,6 +36,8 @@
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
+import org.opends.server.admin.server.ConfigurationChangeListener;
+import org.opends.server.admin.std.meta.PluginCfgDefn;
import org.opends.server.admin.std.server.PluginCfg;
import org.opends.server.api.PasswordStorageScheme;
import org.opends.server.api.plugin.DirectoryServerPlugin;
@@ -50,10 +52,12 @@
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.ByteString;
+import org.opends.server.types.ConfigChangeResult;
import org.opends.server.types.Entry;
import org.opends.server.types.ErrorLogCategory;
import org.opends.server.types.ErrorLogSeverity;
import org.opends.server.types.LDIFImportConfig;
+import org.opends.server.types.ResultCode;
import org.opends.server.types.DebugLogLevel;
import static org.opends.server.loggers.ErrorLogger.*;
@@ -72,6 +76,7 @@
*/
public final class PasswordPolicyImportPlugin
extends DirectoryServerPlugin<PluginCfg>
+ implements ConfigurationChangeListener<PluginCfg>
{
/**
* The tracer object for the debug logger.
@@ -180,6 +185,8 @@
PluginCfg configuration)
throws ConfigException
{
+ configuration.addChangeListener(this);
+
// Make sure that the plugin has been enabled for the appropriate types.
for (PluginType t : pluginTypes)
{
@@ -335,5 +342,47 @@
return LDIFPluginResult.SUCCESS;
}
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isConfigurationChangeAcceptable(PluginCfg configuration,
+ List<String> unacceptableReasons)
+ {
+ boolean configAcceptable = true;
+
+ // Ensure that the set of plugin types contains only LDIF import.
+ for (PluginCfgDefn.PluginType pluginType : configuration.getPluginType())
+ {
+ switch (pluginType)
+ {
+ case LDIFIMPORT:
+ // This is the only acceptable type.
+ break;
+
+
+ default:
+ int msgID = MSGID_PLUGIN_PWPIMPORT_INVALID_PLUGIN_TYPE;
+ String message = getMessage(msgID, pluginType.toString());
+ unacceptableReasons.add(message);
+ configAcceptable = false;
+ }
+ }
+
+ return configAcceptable;
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ConfigChangeResult applyConfigurationChange(PluginCfg configuration)
+ {
+ // No implementation is required.
+ return new ConfigChangeResult(ResultCode.SUCCESS, false);
+ }
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/plugins/profiler/ProfilerPlugin.java b/opendj-sdk/opends/src/server/org/opends/server/plugins/profiler/ProfilerPlugin.java
index bd54584..a798cd4 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/plugins/profiler/ProfilerPlugin.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/plugins/profiler/ProfilerPlugin.java
@@ -34,6 +34,7 @@
import java.util.Set;
import org.opends.server.admin.server.ConfigurationChangeListener;
+import org.opends.server.admin.std.meta.PluginCfgDefn;
import org.opends.server.admin.std.server.ProfilerPluginCfg;
import org.opends.server.api.plugin.DirectoryServerPlugin;
import org.opends.server.api.plugin.PluginType;
@@ -251,6 +252,31 @@
{
boolean configAcceptable = true;
+ // Make sure that the plugin is only registered as a startup plugin.
+ if (configuration.getPluginType().isEmpty())
+ {
+ int msgID = MSGID_PLUGIN_PROFILER_NO_PLUGIN_TYPES;
+ String message = getMessage(msgID, String.valueOf(configEntryDN));
+ unacceptableReasons.add(message);
+ configAcceptable = false;
+ }
+ else
+ {
+ for (PluginCfgDefn.PluginType t : configuration.getPluginType())
+ {
+ if (t != PluginCfgDefn.PluginType.STARTUP)
+ {
+ int msgID = MSGID_PLUGIN_PROFILER_INVALID_PLUGIN_TYPE;
+ String message = getMessage(msgID, String.valueOf(configEntryDN),
+ String.valueOf(t));
+ unacceptableReasons.add(message);
+ configAcceptable = false;
+ break;
+ }
+ }
+ }
+
+
// Make sure that the profile directory exists.
File profileDirectory = getFileForPath(configuration.getProfileDirectory());
if (! (profileDirectory.exists() && profileDirectory.isDirectory()))
--
Gitblit v1.10.0