From d737629521c16e5e8b9e36ad6dd11c976e9385e0 Mon Sep 17 00:00:00 2001
From: coulbeck <coulbeck@localhost>
Date: Mon, 09 Apr 2007 18:52:45 +0000
Subject: [PATCH] Migrate the ExtendedOperationConfigManager to the new configuration framework.
---
opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/PasswordModifyExtendedOperationHandlerConfiguration.xml | 48 +
opendj-sdk/opends/src/server/org/opends/server/core/DirectoryServer.java | 2
opendj-sdk/opends/resource/admin/metaMO.xsl | 8
opendj-sdk/opends/src/server/org/opends/server/extensions/PasswordModifyExtendedOperation.java | 203 +----
opendj-sdk/opends/src/server/org/opends/server/core/ExtendedOperationConfigManager.java | 1120 +++++++++----------------------------
opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/ExtendedOperationHandlerConfiguration.xml | 59 +
opendj-sdk/opends/src/server/org/opends/server/extensions/CancelExtendedOperation.java | 18
opendj-sdk/opends/src/server/org/opends/server/messages/ConfigMessages.java | 122 ---
opendj-sdk/opends/src/server/org/opends/server/extensions/WhoAmIExtendedOperation.java | 18
opendj-sdk/opends/src/server/org/opends/server/messages/ExtensionsMessages.java | 21
opendj-sdk/opends/src/server/org/opends/server/extensions/StartTLSExtendedOperation.java | 18
opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/RootConfiguration.xml | 8
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/PasswordModifyExtendedOperationTestCase.java | 30
opendj-sdk/opends/src/server/org/opends/server/api/ExtendedOperationHandler.java | 89 ++
14 files changed, 595 insertions(+), 1,169 deletions(-)
diff --git a/opendj-sdk/opends/resource/admin/metaMO.xsl b/opendj-sdk/opends/resource/admin/metaMO.xsl
index 1074ab0..1774eac 100644
--- a/opendj-sdk/opends/resource/admin/metaMO.xsl
+++ b/opendj-sdk/opends/resource/admin/metaMO.xsl
@@ -324,7 +324,7 @@
$this-java-class,
'CfgClient> impl) {
',
' this.impl = impl;
',
- ' };
')" />
+ ' }
')" />
<!--
Getters/Setters for all properties.
-->
@@ -428,7 +428,7 @@
$this-java-class,
'CfgServerImpl(ServerManagedObject<? extends ', $this-java-class, 'Cfg> impl) {
',
' this.impl = impl;
',
- ' };
')" />
+ ' }
')" />
<!--
Generate all the change listener methods - one for each managed
object in the hierarchy.
@@ -958,7 +958,7 @@
<xsl:when test="string(@multi-valued) != 'true'">
<xsl:choose>
<xsl:when test="adm:default-behavior/adm:defined">
- <!--
+ <!--
The method is guaranteed to return a value since there is a
well-defined default value.
-->
@@ -966,7 +966,7 @@
</xsl:when>
<xsl:when
test="$interface = 'server' and @mandatory = 'true'">
- <!--
+ <!--
The method is guaranteed to return a value in the server interface, but
not necessarily in the client, since the mandatory property might not
have been created yet.
diff --git a/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/ExtendedOperationHandlerConfiguration.xml b/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/ExtendedOperationHandlerConfiguration.xml
new file mode 100644
index 0000000..5a808d1
--- /dev/null
+++ b/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/ExtendedOperationHandlerConfiguration.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+<adm:managed-object
+ name="extended-operation-handler"
+ plural-name="extended-operation-handlers"
+ package="org.opends.server.admin.std"
+ abstract="false"
+ xmlns:adm="http://www.opends.org/admin"
+ xmlns:ldap="http://www.opends.org/admin-ldap">
+ <adm:synopsis>
+ <adm:user-friendly-plural-name />
+ are responsible for all processing of different types of extended
+ operations in the server.
+ </adm:synopsis>
+ <adm:profile name="ldap">
+ <ldap:object-class>
+ <ldap:oid>1.3.6.1.4.1.26027.1.2.18</ldap:oid>
+ <ldap:name>ds-cfg-extended-operation-handler</ldap:name>
+ <ldap:superior>top</ldap:superior>
+ </ldap:object-class>
+ </adm:profile>
+ <adm:property name="enabled" mandatory="true">
+ <adm:synopsis>
+ Indicates whether the
+ <adm:user-friendly-name />
+ is enabled for use (i.e. whether the types of extended operations that
+ it defines will be allowed in the server). Changes to this property
+ will take effect immediately.
+ </adm:synopsis>
+ <adm:syntax>
+ <adm:boolean />
+ </adm:syntax>
+ <adm:profile name="ldap">
+ <ldap:attribute>
+ <ldap:oid>1.3.6.1.4.1.26027.1.1.37</ldap:oid>
+ <ldap:name>ds-cfg-extended-operation-handler-enabled</ldap:name>
+ </ldap:attribute>
+ </adm:profile>
+ </adm:property>
+ <adm:property name="java-implementation-class" mandatory="true">
+ <adm:synopsis>
+ The fully-qualified name of the Java class that provides the
+ <adm:user-friendly-name />
+ implementation.
+ </adm:synopsis>
+ <adm:syntax>
+ <adm:java-class>
+ <adm:instance-of>
+ org.opends.server.api.ExtendedOperationHandler
+ </adm:instance-of>
+ </adm:java-class>
+ </adm:syntax>
+ <adm:profile name="ldap">
+ <ldap:attribute>
+ <ldap:oid>1.3.6.1.4.1.26027.1.1.36</ldap:oid>
+ <ldap:name>ds-cfg-extended-operation-handler-class</ldap:name>
+ </ldap:attribute>
+ </adm:profile>
+ </adm:property>
+</adm:managed-object>
diff --git a/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/PasswordModifyExtendedOperationHandlerConfiguration.xml b/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/PasswordModifyExtendedOperationHandlerConfiguration.xml
new file mode 100644
index 0000000..d0686e7
--- /dev/null
+++ b/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/PasswordModifyExtendedOperationHandlerConfiguration.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<adm:managed-object
+ name="password-modify-extended-operation-handler"
+ plural-name="password-modify-extended-operation-handlers"
+ package="org.opends.server.admin.std"
+ extends="extended-operation-handler"
+ xmlns:adm="http://www.opends.org/admin"
+ xmlns:ldap="http://www.opends.org/admin-ldap">
+ <adm:synopsis>
+ The <adm:user-friendly-name /> provides the ability for end users to change
+ their own passwords, or for administrators to reset user passwords.
+ </adm:synopsis>
+ <adm:description>
+ The password modify extended operation is defined in RFC 3062. It includes
+ the ability for users to provide their current password for further
+ confirmation of their identity when changing the password, and it also
+ includes the ability to generate a new password if the user doesn't provide
+ one.
+ </adm:description>
+ <adm:profile name="ldap">
+ <ldap:object-class>
+ <ldap:oid>1.3.6.1.4.1.26027.1.2.74</ldap:oid>
+ <ldap:name>ds-cfg-password-modify-extended-operation-handler</ldap:name>
+ <ldap:superior>ds-cfg-extended-operation-handler</ldap:superior>
+ </ldap:object-class>
+ </adm:profile>
+ <adm:property name="identity-mapper-dn" mandatory="true">
+ <adm:synopsis>
+ Specifies the DN of the configuration entry for the identity mapper that
+ should be used in conjunction with the password modify extended
+ operation.
+ </adm:synopsis>
+ <adm:description>
+ This property will be used to identify a user based on an
+ authorization ID in the 'u:' form. Changes to this property will take
+ effect immediately.
+ </adm:description>
+ <adm:syntax>
+ <adm:dn />
+ </adm:syntax>
+ <adm:profile name="ldap">
+ <ldap:attribute>
+ <ldap:oid>1.3.6.1.4.1.26027.1.1.148</ldap:oid>
+ <ldap:name>ds-cfg-identity-mapper-dn</ldap:name>
+ </ldap:attribute>
+ </adm:profile>
+ </adm:property>
+</adm:managed-object>
diff --git a/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/RootConfiguration.xml b/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/RootConfiguration.xml
index 5cd4a1e..42a9cc8 100644
--- a/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/RootConfiguration.xml
+++ b/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/RootConfiguration.xml
@@ -77,5 +77,13 @@
</ldap:rdn-sequence>
</adm:profile>
</adm:relation>
+ <adm:relation name="extended-operation-handler">
+ <adm:one-to-many />
+ <adm:profile name="ldap">
+ <ldap:rdn-sequence>
+ cn=Extended Operations,cn=config
+ </ldap:rdn-sequence>
+ </adm:profile>
+ </adm:relation>
<adm:product-name>OpenDS Directory Server</adm:product-name>
</adm:root-managed-object>
diff --git a/opendj-sdk/opends/src/server/org/opends/server/api/ExtendedOperationHandler.java b/opendj-sdk/opends/src/server/org/opends/server/api/ExtendedOperationHandler.java
index 109d6fd..ae48759 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/api/ExtendedOperationHandler.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/api/ExtendedOperationHandler.java
@@ -31,12 +31,11 @@
import java.util.HashSet;
import java.util.Set;
-import org.opends.server.config.ConfigEntry;
import org.opends.server.config.ConfigException;
import org.opends.server.core.ExtendedOperation;
+import org.opends.server.core.DirectoryServer;
import org.opends.server.types.InitializationException;
-
-
+import org.opends.server.admin.std.server.ExtendedOperationHandlerCfg;
/**
@@ -44,19 +43,26 @@
* implemented by a Directory Server module that implements the
* functionality required for one or more types of extended
* operations.
+ *
+ * @param <T> The configuration class that will be provided to
+ * initialize the handler.
*/
-public abstract class ExtendedOperationHandler
+public abstract class
+ ExtendedOperationHandler<T extends ExtendedOperationHandlerCfg>
{
+ /**
+ * The default set of supported control OIDs for this extended
+ * operation.
+ */
+ protected Set<String> supportedControlOIDs = new HashSet<String>(0);
- // The default set of supported control OIDs for this extended
- // operation.
- private Set<String> supportedControlOIDs = new HashSet<String>(0);
-
- // The default set of supported feature OIDs for this extended
- // operation.
- private Set<String> supportedFeatureOIDs = new HashSet<String>(0);
+ /**
+ * The default set of supported feature OIDs for this extended
+ * operation.
+ */
+ protected Set<String> supportedFeatureOIDs = new HashSet<String>(0);
@@ -66,9 +72,9 @@
* register itself with the Directory Server for the particular
* kinds of extended operations that it will process.
*
- * @param configEntry The configuration entry that contains the
- * information to use to initialize this
- * extended operation handler.
+ * @param config The extended operation handler configuration that
+ * contains the information to use to initialize
+ * this extended operation handler.
*
* @throws ConfigException If an unrecoverable problem arises in
* the process of performing the
@@ -80,7 +86,7 @@
* configuration.
*/
public abstract void
- initializeExtendedOperationHandler(ConfigEntry configEntry)
+ initializeExtendedOperationHandler(T config)
throws ConfigException, InitializationException;
@@ -167,5 +173,58 @@
{
return getSupportedFeatures().contains(featureOID);
}
+
+ /**
+ * If the extended operation handler defines any supported controls
+ * and/or features, then register them with the server.
+ *
+ */
+ protected void registerControlsAndFeatures()
+ {
+ Set<String> controlOIDs = getSupportedControls();
+ if (controlOIDs != null)
+ {
+ for (String oid : controlOIDs)
+ {
+ DirectoryServer.registerSupportedControl(oid);
+ }
+ }
+
+ Set<String> featureOIDs = getSupportedFeatures();
+ if (featureOIDs != null)
+ {
+ for (String oid : featureOIDs)
+ {
+ DirectoryServer.registerSupportedFeature(oid);
+ }
+ }
+ }
+
+
+ /**
+ * If the extended operation handler defines any supported controls
+ * and/or features, then deregister them with the server.
+ */
+ protected void deregisterControlsAndFeatures()
+ {
+ Set<String> controlOIDs = getSupportedControls();
+ if (controlOIDs != null)
+ {
+ for (String oid : controlOIDs)
+ {
+ DirectoryServer.deregisterSupportedControl(oid);
+ }
+ }
+
+ Set<String> featureOIDs = getSupportedFeatures();
+ if (featureOIDs != null)
+ {
+ for (String oid : featureOIDs)
+ {
+ DirectoryServer.deregisterSupportedFeature(oid);
+ }
+ }
+ }
+
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/core/DirectoryServer.java b/opendj-sdk/opends/src/server/org/opends/server/core/DirectoryServer.java
index 0bb1d84..07ec1bb 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/core/DirectoryServer.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/core/DirectoryServer.java
@@ -4154,7 +4154,7 @@
baseName + "s\"");
lines.add(" package=\"org.opends.server.admin.std\"");
lines.add(" xmlns:adm=\"http://www.opends.org/admin\"");
- lines.add(" xmlns:ldap=\"http://www.opends.org/admin-ldap\"");
+ lines.add(" xmlns:ldap=\"http://www.opends.org/admin-ldap\">");
lines.add(" <adm:synopsis>");
lines.add(" ___SYNOPSIS___");
lines.add(" </adm:synopsis>");
diff --git a/opendj-sdk/opends/src/server/org/opends/server/core/ExtendedOperationConfigManager.java b/opendj-sdk/opends/src/server/org/opends/server/core/ExtendedOperationConfigManager.java
index 2b71695..4351d91 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/core/ExtendedOperationConfigManager.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/core/ExtendedOperationConfigManager.java
@@ -29,39 +29,31 @@
import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedList;
import java.util.List;
-import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+import java.lang.reflect.Method;
-import org.opends.server.api.ConfigAddListener;
-import org.opends.server.api.ConfigChangeListener;
-import org.opends.server.api.ConfigDeleteListener;
-import org.opends.server.api.ConfigHandler;
-import org.opends.server.api.ConfigurableComponent;
import org.opends.server.api.ExtendedOperationHandler;
-import org.opends.server.config.BooleanConfigAttribute;
-import org.opends.server.config.ConfigEntry;
import org.opends.server.config.ConfigException;
-import org.opends.server.config.StringConfigAttribute;
import org.opends.server.types.ConfigChangeResult;
import org.opends.server.types.DN;
-import org.opends.server.types.ErrorLogCategory;
-import org.opends.server.types.ErrorLogSeverity;
import org.opends.server.types.InitializationException;
import org.opends.server.types.ResultCode;
-import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.loggers.debug.DebugLogger.debugCaught;
import static org.opends.server.loggers.debug.DebugLogger.debugEnabled;
import org.opends.server.types.DebugLogLevel;
-import static org.opends.server.loggers.Error.*;
import static org.opends.server.messages.ConfigMessages.*;
-import static org.opends.server.messages.MessageHandler.*;
-import static org.opends.server.util.ServerConstants.*;
-import static org.opends.server.util.StaticUtils.*;
-
+import static org.opends.server.messages.MessageHandler.getMessage;
+import org.opends.server.admin.server.ConfigurationChangeListener;
+import org.opends.server.admin.server.ConfigurationAddListener;
+import org.opends.server.admin.server.ConfigurationDeleteListener;
+import org.opends.server.admin.server.ServerManagementContext;
+import org.opends.server.admin.std.server.ExtendedOperationHandlerCfg;
+import org.opends.server.admin.std.server.RootCfg;
+import org.opends.server.admin.std.meta.ExtendedOperationHandlerCfgDefn;
+import org.opends.server.admin.ClassPropertyDefinition;
+import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString;
/**
@@ -71,8 +63,10 @@
* removals, or modifications of any extended operation handlers while the
* server is running.
*/
-public class ExtendedOperationConfigManager
- implements ConfigChangeListener, ConfigAddListener, ConfigDeleteListener
+public class ExtendedOperationConfigManager implements
+ ConfigurationChangeListener<ExtendedOperationHandlerCfg>,
+ ConfigurationAddListener<ExtendedOperationHandlerCfg>,
+ ConfigurationDeleteListener<ExtendedOperationHandlerCfg>
{
@@ -81,9 +75,6 @@
// operation handlers.
private ConcurrentHashMap<DN,ExtendedOperationHandler> handlers;
- // The configuration handler for the Directory Server.
- private ConfigHandler configHandler;
-
/**
@@ -91,7 +82,6 @@
*/
public ExtendedOperationConfigManager()
{
- configHandler = DirectoryServer.getConfigHandler();
handlers = new ConcurrentHashMap<DN,ExtendedOperationHandler>();
}
@@ -112,432 +102,199 @@
public void initializeExtendedOperationHandlers()
throws ConfigException, InitializationException
{
- // First, get the configuration base entry.
- ConfigEntry baseEntry;
- try
+ // Create an internal server management context and retrieve
+ // the root configuration which has the extended operation handler relation.
+ ServerManagementContext context = ServerManagementContext.getInstance();
+ RootCfg root = context.getRootConfiguration();
+
+ // Register add and delete listeners.
+ root.addExtendedOperationHandlerAddListener(this);
+ root.addExtendedOperationHandlerDeleteListener(this);
+
+ // Initialize existing handlers.
+ for (String name : root.listExtendedOperationHandlers())
{
- DN extendedOpBaseDN = DN.decode(DN_EXTENDED_OP_CONFIG_BASE);
- baseEntry = configHandler.getConfigEntry(extendedOpBaseDN);
- }
- catch (Exception e)
- {
- if (debugEnabled())
+ // Get the handler's configuration.
+ // This will decode and validate its properties.
+ ExtendedOperationHandlerCfg config =
+ root.getExtendedOperationHandler(name);
+
+ // Register as a change listener for this handler so that we can be
+ // notified when it is disabled or enabled.
+ config.addChangeListener(this);
+
+ // Ignore this handler if it is disabled.
+ if (config.isEnabled())
{
- debugCaught(DebugLogLevel.ERROR, e);
- }
+ // Load the handler's implementation class and initialize it.
+ ExtendedOperationHandler handler = getHandler(config);
- int msgID = MSGID_CONFIG_EXTOP_CANNOT_GET_BASE;
- String message = getMessage(msgID, String.valueOf(e));
- throw new ConfigException(msgID, message, e);
- }
-
- if (baseEntry == null)
- {
- // The extended operation handler base entry does not exist. This is not
- // acceptable, so throw an exception.
- int msgID = MSGID_CONFIG_EXTOP_BASE_DOES_NOT_EXIST;
- String message = getMessage(msgID);
- throw new ConfigException(msgID, message);
- }
-
-
- // Register add and delete listeners with the extended operation base entry.
- // We don't care about modifications to it.
- baseEntry.registerAddListener(this);
- baseEntry.registerDeleteListener(this);
-
-
- // See if the base entry has any children. If not, then we don't need to do
- // anything else.
- if (! baseEntry.hasChildren())
- {
- return;
- }
-
-
- // Iterate through the child entries and process them as extended operation
- // handler configuration entries.
- for (ConfigEntry childEntry : baseEntry.getChildren().values())
- {
- childEntry.registerChangeListener(this);
-
- StringBuilder unacceptableReason = new StringBuilder();
- if (! configAddIsAcceptable(childEntry, unacceptableReason))
- {
- logError(ErrorLogCategory.CONFIGURATION, ErrorLogSeverity.SEVERE_ERROR,
- MSGID_CONFIG_EXTOP_ENTRY_UNACCEPTABLE,
- childEntry.getDN().toString(), unacceptableReason.toString());
- continue;
- }
-
- try
- {
- ConfigChangeResult result = applyConfigurationAdd(childEntry);
- if (result.getResultCode() != ResultCode.SUCCESS)
- {
- StringBuilder buffer = new StringBuilder();
-
- List<String> resultMessages = result.getMessages();
- if ((resultMessages == null) || (resultMessages.isEmpty()))
- {
- buffer.append(getMessage(MSGID_CONFIG_UNKNOWN_UNACCEPTABLE_REASON));
- }
- else
- {
- Iterator<String> iterator = resultMessages.iterator();
-
- buffer.append(iterator.next());
- while (iterator.hasNext())
- {
- buffer.append(EOL);
- buffer.append(iterator.next());
- }
- }
-
- logError(ErrorLogCategory.CONFIGURATION,
- ErrorLogSeverity.SEVERE_ERROR,
- MSGID_CONFIG_EXTOP_CANNOT_CREATE_HANDLER,
- childEntry.getDN().toString(), buffer.toString());
- }
- }
- catch (Exception e)
- {
- logError(ErrorLogCategory.CONFIGURATION, ErrorLogSeverity.SEVERE_ERROR,
- MSGID_CONFIG_EXTOP_CANNOT_CREATE_HANDLER,
- childEntry.getDN().toString(), String.valueOf(e));
+ // Put this handler in the hash map so that we will be able to find
+ // it if it is deleted or disabled.
+ handlers.put(config.dn(), handler);
}
}
}
-
-
/**
- * Indicates whether the configuration entry that will result from a proposed
- * modification is acceptable to this change listener.
- *
- * @param configEntry The configuration entry that will result from
- * the requested update.
- * @param unacceptableReason A buffer to which this method can append a
- * human-readable message explaining why the
- * proposed change is not acceptable.
- *
- * @return <CODE>true</CODE> if the proposed entry contains an acceptable
- * configuration, or <CODE>false</CODE> if it does not.
+ * {@inheritDoc}
*/
- public boolean configChangeIsAcceptable(ConfigEntry configEntry,
- StringBuilder unacceptableReason)
+ public ConfigChangeResult applyConfigurationDelete(
+ ExtendedOperationHandlerCfg configuration)
{
- // Make sure that the entry has an appropriate objectclass for an extended
- // operation handler.
- if (! configEntry.hasObjectClass(OC_EXTENDED_OPERATION_HANDLER))
- {
- int msgID = MSGID_CONFIG_EXTOP_INVALID_OBJECTCLASS;
- String message = getMessage(msgID, configEntry.getDN().toString());
- unacceptableReason.append(message);
- return false;
- }
+ ResultCode resultCode = ResultCode.SUCCESS;
+ boolean adminActionRequired = false;
- // Make sure that the entry specifies the handler class name.
- StringConfigAttribute classNameAttr;
- try
- {
- StringConfigAttribute classStub =
- new StringConfigAttribute(ATTR_EXTOP_CLASS,
- getMessage(MSGID_CONFIG_EXTOP_DESCRIPTION_CLASS_NAME),
- true, false, true);
- classNameAttr = (StringConfigAttribute)
- configEntry.getConfigAttribute(classStub);
-
- if (classNameAttr == null)
- {
- int msgID = MSGID_CONFIG_EXTOP_NO_CLASS_NAME;
- String message = getMessage(msgID, configEntry.getDN().toString());
- unacceptableReason.append(message);
- return false;
- }
- }
- catch (Exception e)
- {
- if (debugEnabled())
- {
- debugCaught(DebugLogLevel.ERROR, e);
- }
-
- int msgID = MSGID_CONFIG_EXTOP_INVALID_CLASS_NAME;
- String message = getMessage(msgID, configEntry.getDN().toString(),
- String.valueOf(e));
- unacceptableReason.append(message);
- return false;
- }
-
- Class handlerClass;
- try
- {
- handlerClass = DirectoryServer.loadClass(classNameAttr.pendingValue());
- }
- catch (Exception e)
- {
- if (debugEnabled())
- {
- debugCaught(DebugLogLevel.ERROR, e);
- }
-
- int msgID = MSGID_CONFIG_EXTOP_INVALID_CLASS_NAME;
- String message = getMessage(msgID, configEntry.getDN().toString(),
- String.valueOf(e));
- unacceptableReason.append(message);
- return false;
- }
-
- try
- {
- ExtendedOperationHandler handler =
- (ExtendedOperationHandler) handlerClass.newInstance();
- }
- catch(Exception e)
- {
- if (debugEnabled())
- {
- debugCaught(DebugLogLevel.ERROR, e);
- }
-
- int msgID = MSGID_CONFIG_EXTOP_INVALID_CLASS;
- String message = getMessage(msgID, handlerClass.getName(),
- String.valueOf(configEntry.getDN()),
- String.valueOf(e));
- unacceptableReason.append(message);
- return false;
- }
-
-
- // See if this extended operation handler should be enabled.
- BooleanConfigAttribute enabledAttr;
- try
- {
- BooleanConfigAttribute enabledStub =
- new BooleanConfigAttribute(ATTR_EXTOP_ENABLED,
- getMessage(MSGID_CONFIG_EXTOP_DESCRIPTION_ENABLED),
- false);
- enabledAttr = (BooleanConfigAttribute)
- configEntry.getConfigAttribute(enabledStub);
-
- if (enabledAttr == null)
- {
- int msgID = MSGID_CONFIG_EXTOP_NO_ENABLED_ATTR;
- String message = getMessage(msgID, configEntry.getDN().toString());
- unacceptableReason.append(message);
- return false;
- }
- }
- catch (Exception e)
- {
- if (debugEnabled())
- {
- debugCaught(DebugLogLevel.ERROR, e);
- }
-
- int msgID = MSGID_CONFIG_EXTOP_INVALID_ENABLED_VALUE;
- String message = getMessage(msgID, configEntry.getDN().toString(),
- String.valueOf(e));
- unacceptableReason.append(message);
- return false;
- }
-
-
- // If we've gotten here then the extended operation handler entry appears to
- // be acceptable.
- return true;
- }
-
-
-
- /**
- * Attempts to apply a new configuration to this Directory Server component
- * based on the provided changed entry.
- *
- * @param configEntry The configuration entry that containing the updated
- * configuration for this component.
- *
- * @return Information about the result of processing the configuration
- * change.
- */
- public ConfigChangeResult applyConfigurationChange(ConfigEntry configEntry)
- {
- DN configEntryDN = configEntry.getDN();
- ResultCode resultCode = ResultCode.SUCCESS;
- boolean adminActionRequired = false;
- ArrayList<String> messages = new ArrayList<String>();
-
-
- // Make sure that the entry has an appropriate objectclass for an extended
- // operation handler.
- if (! configEntry.hasObjectClass(OC_EXTENDED_OPERATION_HANDLER))
- {
- int msgID = MSGID_CONFIG_EXTOP_INVALID_OBJECTCLASS;
- messages.add(getMessage(msgID, String.valueOf(configEntryDN)));
- resultCode = ResultCode.UNWILLING_TO_PERFORM;
- return new ConfigChangeResult(resultCode, adminActionRequired, messages);
- }
-
-
- // Get the corresponding extended operation handler if it is active.
- ExtendedOperationHandler handler = handlers.get(configEntryDN);
-
-
- // See if this handler should be enabled or disabled.
- boolean needsEnabled = false;
- BooleanConfigAttribute enabledAttr;
- try
- {
- BooleanConfigAttribute enabledStub =
- new BooleanConfigAttribute(ATTR_EXTOP_ENABLED,
- getMessage(MSGID_CONFIG_EXTOP_DESCRIPTION_ENABLED),
- false);
- enabledAttr = (BooleanConfigAttribute)
- configEntry.getConfigAttribute(enabledStub);
-
- if (enabledAttr == null)
- {
- int msgID = MSGID_CONFIG_EXTOP_NO_ENABLED_ATTR;
- messages.add(getMessage(msgID, String.valueOf(configEntryDN)));
- resultCode = ResultCode.UNWILLING_TO_PERFORM;
- return new ConfigChangeResult(resultCode, adminActionRequired,
- messages);
- }
-
- if (enabledAttr.activeValue())
- {
- if (handler == null)
- {
- needsEnabled = true;
- }
- else
- {
- // The handler is already active, so no action is required.
- }
- }
- else
- {
- if (handler == null)
- {
- // The handler is already disabled, so no action is required and we
- // can short-circuit out of this processing.
- return new ConfigChangeResult(resultCode, adminActionRequired,
- messages);
- }
- else
- {
- // The handler is active, so it needs to be disabled. Do this and
- // return that we were successful.
- handlers.remove(configEntryDN);
- handler.finalizeExtendedOperationHandler();
- return new ConfigChangeResult(resultCode, adminActionRequired,
- messages);
- }
- }
- }
- catch (Exception e)
- {
- if (debugEnabled())
- {
- debugCaught(DebugLogLevel.ERROR, e);
- }
-
- int msgID = MSGID_CONFIG_EXTOP_INVALID_ENABLED_VALUE;
- messages.add(getMessage(msgID, String.valueOf(configEntryDN),
- String.valueOf(e)));
- resultCode = DirectoryServer.getServerErrorResultCode();
- return new ConfigChangeResult(resultCode, adminActionRequired, messages);
- }
-
-
- // Make sure that the entry specifies the handler class name. If it has
- // changed, then we will not try to dynamically apply it.
- String className;
- try
- {
- StringConfigAttribute classStub =
- new StringConfigAttribute(ATTR_EXTOP_CLASS,
- getMessage(MSGID_CONFIG_EXTOP_DESCRIPTION_CLASS_NAME),
- true, false, true);
- StringConfigAttribute classNameAttr =
- (StringConfigAttribute) configEntry.getConfigAttribute(classStub);
-
- if (classNameAttr == null)
- {
- int msgID = MSGID_CONFIG_EXTOP_NO_CLASS_NAME;
- messages.add(getMessage(msgID, String.valueOf(configEntryDN)));
- resultCode = ResultCode.OBJECTCLASS_VIOLATION;
- return new ConfigChangeResult(resultCode, adminActionRequired,
- messages);
- }
-
- className = classNameAttr.pendingValue();
- }
- catch (Exception e)
- {
- if (debugEnabled())
- {
- debugCaught(DebugLogLevel.ERROR, e);
- }
-
- int msgID = MSGID_CONFIG_EXTOP_INVALID_CLASS_NAME;
- messages.add(getMessage(msgID, String.valueOf(configEntryDN),
- String.valueOf(e)));
- resultCode = DirectoryServer.getServerErrorResultCode();
- return new ConfigChangeResult(resultCode, adminActionRequired, messages);
- }
-
-
- boolean classChanged = false;
- String oldClassName = null;
+ // See if the entry is registered as an extended operation handler. If so,
+ // deregister it and finalize the handler.
+ ExtendedOperationHandler handler = handlers.remove(configuration.dn());
if (handler != null)
{
- oldClassName = handler.getClass().getName();
- classChanged = (! className.equals(oldClassName));
+ handler.finalizeExtendedOperationHandler();
}
- if (classChanged)
- {
- // This will not be applied dynamically. Add a message to the response
- // and indicate that admin action is required.
- adminActionRequired = true;
- messages.add(getMessage(MSGID_CONFIG_EXTOP_CLASS_ACTION_REQUIRED,
- String.valueOf(oldClassName),
- String.valueOf(className),
- String.valueOf(configEntryDN)));
- return new ConfigChangeResult(resultCode, adminActionRequired, messages);
+ return new ConfigChangeResult(resultCode, adminActionRequired);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isConfigurationChangeAcceptable(
+ ExtendedOperationHandlerCfg configuration,
+ List<String> unacceptableReasons)
+ {
+ if (configuration.isEnabled()) {
+ // It's enabled so always validate the class.
+ return isJavaClassAcceptable(configuration, unacceptableReasons);
+ } else {
+ // It's disabled so ignore it.
+ return true;
}
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public ConfigChangeResult applyConfigurationChange(
+ ExtendedOperationHandlerCfg configuration)
+ {
+ // Attempt to get the existing handler. This will only
+ // succeed if it was enabled.
+ DN dn = configuration.dn();
+ ExtendedOperationHandler handler = handlers.get(dn);
- if (needsEnabled)
- {
- try
- {
- Class handlerClass = DirectoryServer.loadClass(className);
- handler = (ExtendedOperationHandler) handlerClass.newInstance();
+ // Default result code.
+ ResultCode resultCode = ResultCode.SUCCESS;
+ boolean adminActionRequired = false;
+ ArrayList<String> messages = new ArrayList<String>();
+
+ // See whether the handler should be enabled.
+ if (handler == null) {
+ if (configuration.isEnabled()) {
+ // The handler needs to be enabled.
+ try {
+ handler = getHandler(configuration);
+
+ // Put this handler in the hash so that we will
+ // be able to find it if it is altered.
+ handlers.put(dn, handler);
+
+ } catch (ConfigException e) {
+ if (debugEnabled())
+ {
+ debugCaught(DebugLogLevel.ERROR, e);
+ }
+
+ messages.add(e.getMessage());
+ resultCode = DirectoryServer.getServerErrorResultCode();
+ } catch (Exception e) {
+ if (debugEnabled())
+ {
+ debugCaught(DebugLogLevel.ERROR, e);
+ }
+
+ int msgID = MSGID_CONFIG_EXTOP_INITIALIZATION_FAILED;
+ messages.add(getMessage(msgID, String.valueOf(configuration
+ .getJavaImplementationClass()), String.valueOf(dn),
+ stackTraceToSingleLineString(e)));
+ resultCode = DirectoryServer.getServerErrorResultCode();
+ }
}
- catch (Exception e)
+ } else {
+ if (configuration.isEnabled()) {
+ // The handler is currently active, so we don't
+ // need to do anything. Changes to the class name cannot be
+ // applied dynamically, so if the class name did change then
+ // indicate that administrative action is required for that
+ // change to take effect.
+ String className = configuration.getJavaImplementationClass();
+ if (!className.equals(handler.getClass().getName())) {
+ adminActionRequired = true;
+ }
+ } else {
+ // We need to disable the connection handler.
+
+ handlers.remove(dn);
+
+ handler.finalizeExtendedOperationHandler();
+ }
+ }
+
+ // Return the configuration result.
+ return new ConfigChangeResult(resultCode, adminActionRequired,
+ messages);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isConfigurationAddAcceptable(
+ ExtendedOperationHandlerCfg configuration,
+ List<String> unacceptableReasons)
+ {
+ return isConfigurationChangeAcceptable(configuration, unacceptableReasons);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ConfigChangeResult applyConfigurationAdd(
+ ExtendedOperationHandlerCfg configuration)
+ {
+ // Default result code.
+ ResultCode resultCode = ResultCode.SUCCESS;
+ boolean adminActionRequired = false;
+ ArrayList<String> messages = new ArrayList<String>();
+
+ // Register as a change listener for this connection handler entry
+ // so that we will be notified of any changes that may be made to
+ // it.
+ configuration.addChangeListener(this);
+
+ // Ignore this connection handler if it is disabled.
+ if (configuration.isEnabled())
+ {
+ // The connection handler needs to be enabled.
+ DN dn = configuration.dn();
+ try {
+ ExtendedOperationHandler handler = getHandler(configuration);
+
+ // Put this connection handler in the hash so that we will be
+ // able to find it if it is altered.
+ handlers.put(dn, handler);
+
+ }
+ catch (ConfigException e)
{
if (debugEnabled())
{
debugCaught(DebugLogLevel.ERROR, e);
}
- int msgID = MSGID_CONFIG_EXTOP_INVALID_CLASS;
- messages.add(getMessage(msgID, className,
- String.valueOf(configEntryDN),
- String.valueOf(e)));
+ messages.add(e.getMessage());
resultCode = DirectoryServer.getServerErrorResultCode();
- return new ConfigChangeResult(resultCode, adminActionRequired,
- messages);
- }
-
- try
- {
- handler.initializeExtendedOperationHandler(configEntry);
}
catch (Exception e)
{
@@ -547,452 +304,117 @@
}
int msgID = MSGID_CONFIG_EXTOP_INITIALIZATION_FAILED;
- messages.add(getMessage(msgID, className,
- String.valueOf(configEntryDN),
- String.valueOf(e)));
+ messages.add(getMessage(msgID, String.valueOf(configuration
+ .getJavaImplementationClass()), String.valueOf(dn),
+ stackTraceToSingleLineString(e)));
resultCode = DirectoryServer.getServerErrorResultCode();
- return new ConfigChangeResult(resultCode, adminActionRequired,
- messages);
}
-
-
- // If the extended operation handler defines any supported controls and/or
- // features, then register them with the server.
- Set<String> controlOIDs = handler.getSupportedControls();
- if (controlOIDs != null)
- {
- for (String oid : controlOIDs)
- {
- DirectoryServer.registerSupportedControl(oid);
- }
- }
-
- Set<String> featureOIDs = handler.getSupportedFeatures();
- if (featureOIDs != null)
- {
- for (String oid : featureOIDs)
- {
- DirectoryServer.registerSupportedFeature(oid);
- }
- }
-
-
- handlers.put(configEntryDN, handler);
- return new ConfigChangeResult(resultCode, adminActionRequired, messages);
}
-
- // If we've gotten here, then there haven't been any changes to anything
- // that we care about.
- return new ConfigChangeResult(resultCode, adminActionRequired, messages);
+ // Return the configuration result.
+ return new ConfigChangeResult(resultCode, adminActionRequired,
+ messages);
}
-
-
/**
- * Indicates whether the configuration entry that will result from a proposed
- * add is acceptable to this add listener.
- *
- * @param configEntry The configuration entry that will result from
- * the requested add.
- * @param unacceptableReason A buffer to which this method can append a
- * human-readable message explaining why the
- * proposed entry is not acceptable.
- *
- * @return <CODE>true</CODE> if the proposed entry contains an acceptable
- * configuration, or <CODE>false</CODE> if it does not.
+ * {@inheritDoc}
*/
- public boolean configAddIsAcceptable(ConfigEntry configEntry,
- StringBuilder unacceptableReason)
- {
- // Make sure that no entry already exists with the specified DN.
- DN configEntryDN = configEntry.getDN();
- if (handlers.containsKey(configEntryDN))
- {
- int msgID = MSGID_CONFIG_EXTOP_EXISTS;
- String message = getMessage(msgID, String.valueOf(configEntryDN));
- unacceptableReason.append(message);
- return false;
- }
-
-
- // Make sure that the entry has an appropriate objectclass for an extended
- // operation handler.
- if (! configEntry.hasObjectClass(OC_EXTENDED_OPERATION_HANDLER))
- {
- int msgID = MSGID_CONFIG_EXTOP_INVALID_OBJECTCLASS;
- String message = getMessage(msgID, configEntry.getDN().toString());
- unacceptableReason.append(message);
- return false;
- }
-
-
- // Make sure that the entry specifies the extended operation handler class.
- StringConfigAttribute classNameAttr;
- try
- {
- StringConfigAttribute classStub =
- new StringConfigAttribute(ATTR_EXTOP_CLASS,
- getMessage(MSGID_CONFIG_EXTOP_DESCRIPTION_CLASS_NAME),
- true, false, true);
- classNameAttr = (StringConfigAttribute)
- configEntry.getConfigAttribute(classStub);
-
- if (classNameAttr == null)
- {
- int msgID = MSGID_CONFIG_EXTOP_NO_CLASS_NAME;
- String message = getMessage(msgID, configEntry.getDN().toString());
- unacceptableReason.append(message);
- return false;
- }
- }
- catch (Exception e)
- {
- if (debugEnabled())
- {
- debugCaught(DebugLogLevel.ERROR, e);
- }
-
- int msgID = MSGID_CONFIG_EXTOP_INVALID_CLASS_NAME;
- String message = getMessage(msgID, configEntry.getDN().toString(),
- String.valueOf(e));
- unacceptableReason.append(message);
- return false;
- }
-
- Class handlerClass;
- try
- {
- handlerClass = DirectoryServer.loadClass(classNameAttr.pendingValue());
- }
- catch (Exception e)
- {
- if (debugEnabled())
- {
- debugCaught(DebugLogLevel.ERROR, e);
- }
-
- int msgID = MSGID_CONFIG_EXTOP_INVALID_CLASS_NAME;
- String message = getMessage(msgID, configEntry.getDN().toString(),
- String.valueOf(e));
- unacceptableReason.append(message);
- return false;
- }
-
- ExtendedOperationHandler handler;
- try
- {
- handler = (ExtendedOperationHandler) handlerClass.newInstance();
- }
- catch (Exception e)
- {
- if (debugEnabled())
- {
- debugCaught(DebugLogLevel.ERROR, e);
- }
-
- int msgID = MSGID_CONFIG_EXTOP_INVALID_CLASS;
- String message = getMessage(msgID, handlerClass.getName(),
- String.valueOf(configEntryDN),
- String.valueOf(e));
- unacceptableReason.append(message);
- return false;
- }
-
-
- // If the handler is a configurable component, then make sure that its
- // configuration is valid.
- if (handler instanceof ConfigurableComponent)
- {
- ConfigurableComponent cc = (ConfigurableComponent) handler;
- LinkedList<String> errorMessages = new LinkedList<String>();
- if (! cc.hasAcceptableConfiguration(configEntry, errorMessages))
- {
- if (errorMessages.isEmpty())
- {
- int msgID = MSGID_CONFIG_EXTOP_UNACCEPTABLE_CONFIG;
- unacceptableReason.append(getMessage(msgID,
- String.valueOf(configEntryDN)));
- }
- else
- {
- Iterator<String> iterator = errorMessages.iterator();
- unacceptableReason.append(iterator.next());
- while (iterator.hasNext())
- {
- unacceptableReason.append(" ");
- unacceptableReason.append(iterator.next());
- }
- }
-
- return false;
- }
- }
-
-
- // See if this handler should be enabled.
- BooleanConfigAttribute enabledAttr;
- try
- {
- BooleanConfigAttribute enabledStub =
- new BooleanConfigAttribute(ATTR_EXTOP_ENABLED,
- getMessage(MSGID_CONFIG_EXTOP_DESCRIPTION_ENABLED),
- false);
- enabledAttr = (BooleanConfigAttribute)
- configEntry.getConfigAttribute(enabledStub);
-
- if (enabledAttr == null)
- {
- int msgID = MSGID_CONFIG_EXTOP_NO_ENABLED_ATTR;
- String message = getMessage(msgID, configEntry.getDN().toString());
- unacceptableReason.append(message);
- return false;
- }
- }
- catch (Exception e)
- {
- if (debugEnabled())
- {
- debugCaught(DebugLogLevel.ERROR, e);
- }
-
- int msgID = MSGID_CONFIG_EXTOP_INVALID_ENABLED_VALUE;
- String message = getMessage(msgID, configEntry.getDN().toString(),
- String.valueOf(e));
- unacceptableReason.append(message);
- return false;
- }
-
-
- // If we've gotten here then the handler entry appears to be acceptable.
- return true;
- }
-
-
-
- /**
- * Attempts to apply a new configuration based on the provided added entry.
- *
- * @param configEntry The new configuration entry that contains the
- * configuration to apply.
- *
- * @return Information about the result of processing the configuration
- * change.
- */
- public ConfigChangeResult applyConfigurationAdd(ConfigEntry configEntry)
- {
- DN configEntryDN = configEntry.getDN();
- ResultCode resultCode = ResultCode.SUCCESS;
- boolean adminActionRequired = false;
- ArrayList<String> messages = new ArrayList<String>();
-
-
- // Make sure that the entry has an appropriate objectclass for an extended
- // operation handler.
- if (! configEntry.hasObjectClass(OC_EXTENDED_OPERATION_HANDLER))
- {
- int msgID = MSGID_CONFIG_EXTOP_INVALID_OBJECTCLASS;
- messages.add(getMessage(msgID, String.valueOf(configEntryDN)));
- resultCode = ResultCode.UNWILLING_TO_PERFORM;
- return new ConfigChangeResult(resultCode, adminActionRequired, messages);
- }
-
-
- // See if this handler should be enabled or disabled.
- BooleanConfigAttribute enabledAttr;
- try
- {
- BooleanConfigAttribute enabledStub =
- new BooleanConfigAttribute(ATTR_EXTOP_ENABLED,
- getMessage(MSGID_CONFIG_EXTOP_DESCRIPTION_ENABLED),
- false);
- enabledAttr = (BooleanConfigAttribute)
- configEntry.getConfigAttribute(enabledStub);
-
- if (enabledAttr == null)
- {
- // The attribute doesn't exist, so it will be disabled by default.
- int msgID = MSGID_CONFIG_EXTOP_NO_ENABLED_ATTR;
- messages.add(getMessage(msgID, String.valueOf(configEntryDN)));
- resultCode = ResultCode.SUCCESS;
- return new ConfigChangeResult(resultCode, adminActionRequired,
- messages);
- }
- else if (! enabledAttr.activeValue())
- {
- // It is explicitly configured as disabled, so we don't need to do
- // anything.
- return new ConfigChangeResult(resultCode, adminActionRequired,
- messages);
- }
- }
- catch (Exception e)
- {
- if (debugEnabled())
- {
- debugCaught(DebugLogLevel.ERROR, e);
- }
-
- int msgID = MSGID_CONFIG_EXTOP_INVALID_ENABLED_VALUE;
- messages.add(getMessage(msgID, String.valueOf(configEntryDN),
- String.valueOf(e)));
- resultCode = DirectoryServer.getServerErrorResultCode();
- return new ConfigChangeResult(resultCode, adminActionRequired, messages);
- }
-
-
- // Make sure that the entry specifies the handler class name.
- String className;
- try
- {
- StringConfigAttribute classStub =
- new StringConfigAttribute(ATTR_EXTOP_CLASS,
- getMessage(MSGID_CONFIG_EXTOP_DESCRIPTION_CLASS_NAME),
- true, false, true);
- StringConfigAttribute classNameAttr =
- (StringConfigAttribute) configEntry.getConfigAttribute(classStub);
-
- if (classNameAttr == null)
- {
- int msgID = MSGID_CONFIG_EXTOP_NO_CLASS_NAME;
- messages.add(getMessage(msgID, String.valueOf(configEntryDN)));
- resultCode = ResultCode.OBJECTCLASS_VIOLATION;
- return new ConfigChangeResult(resultCode, adminActionRequired,
- messages);
- }
-
- className = classNameAttr.pendingValue();
- }
- catch (Exception e)
- {
- if (debugEnabled())
- {
- debugCaught(DebugLogLevel.ERROR, e);
- }
-
- int msgID = MSGID_CONFIG_EXTOP_INVALID_CLASS_NAME;
- messages.add(getMessage(msgID, String.valueOf(configEntryDN),
- String.valueOf(e)));
- resultCode = DirectoryServer.getServerErrorResultCode();
- return new ConfigChangeResult(resultCode, adminActionRequired, messages);
- }
-
-
- // Load and initialize the handler class, and register it with the Directory
- // Server.
- ExtendedOperationHandler handler;
- try
- {
- Class handlerClass = DirectoryServer.loadClass(className);
- handler = (ExtendedOperationHandler) handlerClass.newInstance();
- }
- catch (Exception e)
- {
- if (debugEnabled())
- {
- debugCaught(DebugLogLevel.ERROR, e);
- }
-
- int msgID = MSGID_CONFIG_EXTOP_INVALID_CLASS;
- messages.add(getMessage(msgID, className, String.valueOf(configEntryDN),
- String.valueOf(e)));
- resultCode = DirectoryServer.getServerErrorResultCode();
- return new ConfigChangeResult(resultCode, adminActionRequired, messages);
- }
-
- try
- {
- handler.initializeExtendedOperationHandler(configEntry);
- }
- catch (Exception e)
- {
- if (debugEnabled())
- {
- debugCaught(DebugLogLevel.ERROR, e);
- }
-
- int msgID = MSGID_CONFIG_EXTOP_INITIALIZATION_FAILED;
- messages.add(getMessage(msgID, className, String.valueOf(configEntryDN),
- String.valueOf(e)));
- resultCode = DirectoryServer.getServerErrorResultCode();
- return new ConfigChangeResult(resultCode, adminActionRequired, messages);
- }
-
-
- // If the extended operation handler defines any supported controls and/or
- // features, then register them with the server.
- Set<String> controlOIDs = handler.getSupportedControls();
- if (controlOIDs != null)
- {
- for (String oid : controlOIDs)
- {
- DirectoryServer.registerSupportedControl(oid);
- }
- }
-
- Set<String> featureOIDs = handler.getSupportedFeatures();
- if (featureOIDs != null)
- {
- for (String oid : featureOIDs)
- {
- DirectoryServer.registerSupportedFeature(oid);
- }
- }
-
-
- handlers.put(configEntryDN, handler);
- return new ConfigChangeResult(resultCode, adminActionRequired, messages);
- }
-
-
-
- /**
- * Indicates whether it is acceptable to remove the provided configuration
- * entry.
- *
- * @param configEntry The configuration entry that will be removed
- * from the configuration.
- * @param unacceptableReason A buffer to which this method can append a
- * human-readable message explaining why the
- * proposed delete is not acceptable.
- *
- * @return <CODE>true</CODE> if the proposed entry may be removed from the
- * configuration, or <CODE>false</CODE> if not.
- */
- public boolean configDeleteIsAcceptable(ConfigEntry configEntry,
- StringBuilder unacceptableReason)
+ public boolean isConfigurationDeleteAcceptable(
+ ExtendedOperationHandlerCfg configuration,
+ List<String> unacceptableReasons)
{
// A delete should always be acceptable, so just return true.
return true;
}
-
-
- /**
- * Attempts to apply a new configuration based on the provided deleted entry.
- *
- * @param configEntry The new configuration entry that has been deleted.
- *
- * @return Information about the result of processing the configuration
- * change.
- */
- public ConfigChangeResult applyConfigurationDelete(ConfigEntry configEntry)
+ // Load and initialize the handler named in the config.
+ private ExtendedOperationHandler getHandler(
+ ExtendedOperationHandlerCfg config) throws ConfigException
{
- DN configEntryDN = configEntry.getDN();
- ResultCode resultCode = ResultCode.SUCCESS;
- boolean adminActionRequired = false;
+ String className = config.getJavaImplementationClass();
+ ExtendedOperationHandlerCfgDefn d =
+ ExtendedOperationHandlerCfgDefn.getInstance();
+ ClassPropertyDefinition pd = d
+ .getJavaImplementationClassPropertyDefinition();
+ // Load the class and cast it to an extended operation handler.
+ Class<? extends ExtendedOperationHandler> theClass;
+ ExtendedOperationHandler extendedOperationHandler;
- // See if the entry is registered as an extended operation handler. If so,
- // deregister it and stop the handler.
- ExtendedOperationHandler handler = handlers.remove(configEntryDN);
- if (handler != null)
+ try
{
- handler.finalizeExtendedOperationHandler();
+ theClass = pd.loadClass(className, ExtendedOperationHandler.class);
+ extendedOperationHandler = theClass.newInstance();
+
+ // Determine the initialization method to use: it must take a
+ // single parameter which is the exact type of the configuration
+ // object.
+ Method method = theClass.getMethod(
+ "initializeExtendedOperationHandler",
+ config.definition().getServerConfigurationClass());
+
+ method.invoke(extendedOperationHandler, config);
+ }
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ debugCaught(DebugLogLevel.ERROR, e);
+ }
+
+ int msgID = MSGID_CONFIG_EXTOP_INVALID_CLASS;
+ String message = getMessage(msgID, String.valueOf(className),
+ String.valueOf(config.dn()),
+ String.valueOf(e));
+ throw new ConfigException(msgID, message, e);
}
+ // The handler has been successfully initialized.
+ return extendedOperationHandler;
+ }
- return new ConfigChangeResult(resultCode, adminActionRequired);
+
+
+ // Determines whether or not the new configuration's implementation
+ // class is acceptable.
+ private boolean isJavaClassAcceptable(
+ ExtendedOperationHandlerCfg config,
+ List<String> unacceptableReasons)
+ {
+ String className = config.getJavaImplementationClass();
+ ExtendedOperationHandlerCfgDefn d =
+ ExtendedOperationHandlerCfgDefn.getInstance();
+ ClassPropertyDefinition pd = d
+ .getJavaImplementationClassPropertyDefinition();
+
+ // Load the class and cast it to an extended operation handler.
+ Class<? extends ExtendedOperationHandler> theClass;
+ try {
+ theClass = pd.loadClass(className, ExtendedOperationHandler.class);
+ theClass.newInstance();
+
+ // Determine the initialization method to use: it must take a
+ // single parameter which is the exact type of the configuration
+ // object.
+ theClass.getMethod("initializeExtendedOperationHandler",
+ config.definition().getServerConfigurationClass());
+ }
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ debugCaught(DebugLogLevel.ERROR, e);
+ }
+
+ int msgID = MSGID_CONFIG_EXTOP_INVALID_CLASS;
+ unacceptableReasons.add(getMessage(msgID, className,
+ String.valueOf(config.dn()),
+ String.valueOf(e)));
+ return false;
+ }
+
+ // The class is valid as far as we can tell.
+ return true;
}
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/extensions/CancelExtendedOperation.java b/opendj-sdk/opends/src/server/org/opends/server/extensions/CancelExtendedOperation.java
index a976ebe..a60733a 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/extensions/CancelExtendedOperation.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/extensions/CancelExtendedOperation.java
@@ -30,7 +30,6 @@
import org.opends.server.api.ClientConnection;
import org.opends.server.api.ExtendedOperationHandler;
-import org.opends.server.config.ConfigEntry;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ExtendedOperation;
@@ -48,7 +47,7 @@
import static org.opends.server.messages.MessageHandler.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
-
+import org.opends.server.admin.std.server.ExtendedOperationHandlerCfg;
/**
@@ -59,7 +58,7 @@
* successful the abandoned operation won't get one either).
*/
public class CancelExtendedOperation
- extends ExtendedOperationHandler
+ extends ExtendedOperationHandler<ExtendedOperationHandlerCfg>
{
@@ -76,15 +75,13 @@
}
-
-
/**
* Initializes this extended operation handler based on the information in the
* provided configuration entry. It should also register itself with the
* Directory Server for the particular kinds of extended operations that it
* will process.
*
- * @param configEntry The configuration entry that contains the information
+ * @param config The configuration that contains the information
* to use to initialize this extended operation handler.
*
* @throws ConfigException If an unrecoverable problem arises in the
@@ -94,12 +91,15 @@
* that is not related to the server
* configuration.
*/
- public void initializeExtendedOperationHandler(ConfigEntry configEntry)
- throws ConfigException, InitializationException
+ public void initializeExtendedOperationHandler(
+ ExtendedOperationHandlerCfg config)
+ throws ConfigException, InitializationException
{
// No special configuration is required.
DirectoryServer.registerSupportedExtension(OID_CANCEL_REQUEST, this);
+
+ registerControlsAndFeatures();
}
@@ -111,6 +111,8 @@
public void finalizeExtendedOperationHandler()
{
DirectoryServer.deregisterSupportedExtension(OID_CANCEL_REQUEST);
+
+ deregisterControlsAndFeatures();
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/extensions/PasswordModifyExtendedOperation.java b/opendj-sdk/opends/src/server/org/opends/server/extensions/PasswordModifyExtendedOperation.java
index 2853b65..431f2e2 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/extensions/PasswordModifyExtendedOperation.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/extensions/PasswordModifyExtendedOperation.java
@@ -31,21 +31,15 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashSet;
-import java.util.LinkedList;
import java.util.List;
import java.util.HashSet;
-import java.util.Set;
import java.util.concurrent.locks.Lock;
import org.opends.server.api.ClientConnection;
-import org.opends.server.api.ConfigurableComponent;
import org.opends.server.api.ExtendedOperationHandler;
import org.opends.server.api.IdentityMapper;
import org.opends.server.api.PasswordStorageScheme;
-import org.opends.server.config.ConfigAttribute;
-import org.opends.server.config.ConfigEntry;
import org.opends.server.config.ConfigException;
-import org.opends.server.config.DNConfigAttribute;
import org.opends.server.controls.PasswordPolicyResponseControl;
import org.opends.server.controls.PasswordPolicyWarningType;
import org.opends.server.controls.PasswordPolicyErrorType;
@@ -77,7 +71,6 @@
import org.opends.server.types.Privilege;
import org.opends.server.types.ResultCode;
-import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.extensions.ExtensionsConstants.*;
import static org.opends.server.loggers.debug.DebugLogger.debugCaught;
import static org.opends.server.loggers.debug.DebugLogger.debugEnabled;
@@ -86,7 +79,9 @@
import static org.opends.server.messages.MessageHandler.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
-
+import org.opends.server.admin.std.server.
+ PasswordModifyExtendedOperationHandlerCfg;
+import org.opends.server.admin.server.ConfigurationChangeListener;
/**
@@ -95,14 +90,16 @@
* as for generating a new password if none was provided.
*/
public class PasswordModifyExtendedOperation
- extends ExtendedOperationHandler
- implements ConfigurableComponent
+ extends ExtendedOperationHandler<
+ PasswordModifyExtendedOperationHandlerCfg>
+ implements ConfigurationChangeListener<
+ PasswordModifyExtendedOperationHandlerCfg>
{
- // The DN of the configuration entry.
- private DN configEntryDN;
+ // The current configuration state.
+ private PasswordModifyExtendedOperationHandlerCfg currentConfig;
// The DN of the identity mapper.
private DN identityMapperDN;
@@ -110,9 +107,6 @@
// The reference to the identity mapper.
private IdentityMapper identityMapper;
- // The set of OIDs for the supported controls.
- private Set<String> supportedControlOIDs;
-
/**
@@ -131,11 +125,11 @@
/**
* Initializes this extended operation handler based on the information in the
- * provided configuration entry. It should also register itself with the
+ * provided configuration. It should also register itself with the
* Directory Server for the particular kinds of extended operations that it
* will process.
*
- * @param configEntry The configuration entry that contains the information
+ * @param config The configuration that contains the information
* to use to initialize this extended operation handler.
*
* @throws ConfigException If an unrecoverable problem arises in the
@@ -145,37 +139,21 @@
* that is not related to the server
* configuration.
*/
- public void initializeExtendedOperationHandler(ConfigEntry configEntry)
+ public void initializeExtendedOperationHandler(
+ PasswordModifyExtendedOperationHandlerCfg config)
throws ConfigException, InitializationException
{
- configEntryDN = configEntry.getDN();
-
- int msgID = MSGID_EXTOP_PASSMOD_DESCRIPTION_ID_MAPPER;
- DNConfigAttribute mapperStub =
- new DNConfigAttribute(ATTR_IDMAPPER_DN, getMessage(msgID), true, false,
- false);
try
{
- DNConfigAttribute mapperAttr =
- (DNConfigAttribute) configEntry.getConfigAttribute(mapperStub);
- if (mapperAttr == null)
+ identityMapperDN = config.getIdentityMapperDN();
+ identityMapper = DirectoryServer.getIdentityMapper(identityMapperDN);
+ if (identityMapper == null)
{
- msgID = MSGID_EXTOP_PASSMOD_NO_ID_MAPPER;
- String message = getMessage(msgID, String.valueOf(configEntryDN));
+ int msgID = MSGID_EXTOP_PASSMOD_NO_SUCH_ID_MAPPER;
+ String message = getMessage(msgID, String.valueOf(identityMapperDN),
+ String.valueOf(config.dn()));
throw new ConfigException(msgID, message);
}
- else
- {
- identityMapperDN = mapperAttr.activeValue();
- identityMapper = DirectoryServer.getIdentityMapper(identityMapperDN);
- if (identityMapper == null)
- {
- msgID = MSGID_EXTOP_PASSMOD_NO_SUCH_ID_MAPPER;
- String message = getMessage(msgID, String.valueOf(identityMapperDN),
- String.valueOf(configEntryDN));
- throw new ConfigException(msgID, message);
- }
- }
}
catch (Exception e)
{
@@ -183,8 +161,8 @@
{
debugCaught(DebugLogLevel.ERROR, e);
}
- msgID = MSGID_EXTOP_PASSMOD_CANNOT_DETERMINE_ID_MAPPER;
- String message = getMessage(msgID, String.valueOf(configEntryDN),
+ int msgID = MSGID_EXTOP_PASSMOD_CANNOT_DETERMINE_ID_MAPPER;
+ String message = getMessage(msgID, String.valueOf(config.dn()),
stackTraceToSingleLineString(e));
throw new InitializationException(msgID, message, e);
}
@@ -195,10 +173,16 @@
supportedControlOIDs.add(OID_PASSWORD_POLICY_CONTROL);
- DirectoryServer.registerConfigurableComponent(this);
+ // Save this configuration for future reference.
+ currentConfig = config;
+
+ // Register this as a change listener.
+ config.addPasswordModifyChangeListener(this);
DirectoryServer.registerSupportedExtension(OID_PASSWORD_MODIFY_REQUEST,
this);
+
+ registerControlsAndFeatures();
}
@@ -209,9 +193,11 @@
*/
public void finalizeExtendedOperationHandler()
{
- DirectoryServer.deregisterConfigurableComponent(this);
+ currentConfig.removePasswordModifyChangeListener(this);
DirectoryServer.deregisterSupportedExtension(OID_PASSWORD_MODIFY_REQUEST);
+
+ deregisterControlsAndFeatures();
}
@@ -311,7 +297,7 @@
// See if a user identity was provided. If so, then try to resolve it to
// an actual user.
DN userDN = null;
- Entry userEntry = null;
+ Entry userEntry;
Lock userLock = null;
try
@@ -1277,55 +1263,11 @@
/**
- * {@inheritDoc}
- */
- public Set<String> getSupportedControls()
- {
- return supportedControlOIDs;
- }
-
-
-
- /**
- * Retrieves the DN of the configuration entry with which this component is
- * associated.
- *
- * @return The DN of the configuration entry with which this component is
- * associated.
- */
- public DN getConfigurableComponentEntryDN()
- {
- return configEntryDN;
- }
-
-
-
- /**
- * Retrieves the set of configuration attributes that are associated with this
- * configurable component.
- *
- * @return The set of configuration attributes that are associated with this
- * configurable component.
- */
- public List<ConfigAttribute> getConfigurationAttributes()
- {
- List<ConfigAttribute> attrList = new LinkedList<ConfigAttribute>();
-
- int msgID = MSGID_EXTOP_PASSMOD_DESCRIPTION_ID_MAPPER;
- attrList.add(new DNConfigAttribute(ATTR_IDMAPPER_DN, getMessage(msgID),
- true, false, false, identityMapperDN));
-
- return attrList;
- }
-
-
-
- /**
* Indicates whether the provided configuration entry has an acceptable
* configuration for this component. If it does not, then detailed
* information about the problem(s) should be added to the provided list.
*
- * @param configEntry The configuration entry for which to make the
+ * @param config The configuration entry for which to make the
* determination.
* @param unacceptableReasons A list that can be used to hold messages about
* why the provided entry does not have an
@@ -1334,38 +1276,23 @@
* @return <CODE>true</CODE> if the provided entry has an acceptable
* configuration for this component, or <CODE>false</CODE> if not.
*/
- public boolean hasAcceptableConfiguration(ConfigEntry configEntry,
- List<String> unacceptableReasons)
+ public boolean isConfigurationChangeAcceptable(
+ PasswordModifyExtendedOperationHandlerCfg config,
+ List<String> unacceptableReasons)
{
// Make sure that the specified identity mapper is OK.
- int msgID = MSGID_EXTOP_PASSMOD_DESCRIPTION_ID_MAPPER;
- DNConfigAttribute mapperStub =
- new DNConfigAttribute(ATTR_IDMAPPER_DN, getMessage(msgID), true, false,
- false);
try
{
- DNConfigAttribute mapperAttr =
- (DNConfigAttribute) configEntry.getConfigAttribute(mapperStub);
- if (mapperAttr == null)
+ DN mapperDN = config.getIdentityMapperDN();
+ IdentityMapper mapper = DirectoryServer.getIdentityMapper(mapperDN);
+ if (mapper == null)
{
- msgID = MSGID_EXTOP_PASSMOD_NO_ID_MAPPER;
- String message = getMessage(msgID, String.valueOf(configEntry.getDN()));
+ int msgID = MSGID_EXTOP_PASSMOD_NO_SUCH_ID_MAPPER;
+ String message = getMessage(msgID, String.valueOf(mapperDN),
+ String.valueOf(config.dn()));
unacceptableReasons.add(message);
return false;
}
- else
- {
- DN mapperDN = mapperAttr.pendingValue();
- IdentityMapper mapper = DirectoryServer.getIdentityMapper(mapperDN);
- if (mapper == null)
- {
- msgID = MSGID_EXTOP_PASSMOD_NO_SUCH_ID_MAPPER;
- String message = getMessage(msgID, String.valueOf(mapperDN),
- String.valueOf(configEntry.getDN()));
- unacceptableReasons.add(message);
- return false;
- }
- }
}
catch (Exception e)
{
@@ -1374,8 +1301,8 @@
debugCaught(DebugLogLevel.ERROR, e);
}
- msgID = MSGID_EXTOP_PASSMOD_CANNOT_DETERMINE_ID_MAPPER;
- String message = getMessage(msgID, String.valueOf(configEntry.getDN()),
+ int msgID = MSGID_EXTOP_PASSMOD_CANNOT_DETERMINE_ID_MAPPER;
+ String message = getMessage(msgID, String.valueOf(config.dn()),
stackTraceToSingleLineString(e));
unacceptableReasons.add(message);
return false;
@@ -1397,15 +1324,13 @@
* successfully (and optionally about parameters that were not changed) should
* also be included.
*
- * @param configEntry The entry containing the new configuration to
+ * @param config The entry containing the new configuration to
* apply for this component.
- * @param detailedResults Indicates whether detailed information about the
- * processing should be added to the list.
*
* @return Information about the result of the configuration update.
*/
- public ConfigChangeResult applyNewConfiguration(ConfigEntry configEntry,
- boolean detailedResults)
+ public ConfigChangeResult applyConfigurationChange(
+ PasswordModifyExtendedOperationHandlerCfg config)
{
ResultCode resultCode = ResultCode.SUCCESS;
boolean adminActionRequired = false;
@@ -1415,33 +1340,17 @@
// Make sure that the specified identity mapper is OK.
DN mapperDN = null;
IdentityMapper mapper = null;
- int msgID = MSGID_EXTOP_PASSMOD_DESCRIPTION_ID_MAPPER;
- DNConfigAttribute mapperStub =
- new DNConfigAttribute(ATTR_IDMAPPER_DN, getMessage(msgID), true, false,
- false);
try
{
- DNConfigAttribute mapperAttr =
- (DNConfigAttribute) configEntry.getConfigAttribute(mapperStub);
- if (mapperAttr == null)
+ mapperDN = config.getIdentityMapperDN();
+ mapper = DirectoryServer.getIdentityMapper(mapperDN);
+ if (mapper == null)
{
- resultCode = ResultCode.OBJECTCLASS_VIOLATION;
+ resultCode = ResultCode.CONSTRAINT_VIOLATION;
- msgID = MSGID_EXTOP_PASSMOD_NO_ID_MAPPER;
- messages.add(getMessage(msgID, String.valueOf(configEntry.getDN())));
- }
- else
- {
- mapperDN = mapperAttr.pendingValue();
- mapper = DirectoryServer.getIdentityMapper(mapperDN);
- if (mapper == null)
- {
- resultCode = ResultCode.CONSTRAINT_VIOLATION;
-
- msgID = MSGID_EXTOP_PASSMOD_NO_SUCH_ID_MAPPER;
- messages.add(getMessage(msgID, String.valueOf(mapperDN),
- String.valueOf(configEntry.getDN())));
- }
+ int msgID = MSGID_EXTOP_PASSMOD_NO_SUCH_ID_MAPPER;
+ messages.add(getMessage(msgID, String.valueOf(mapperDN),
+ String.valueOf(config.dn())));
}
}
catch (Exception e)
@@ -1453,8 +1362,8 @@
resultCode = DirectoryServer.getServerErrorResultCode();
- msgID = MSGID_EXTOP_PASSMOD_CANNOT_DETERMINE_ID_MAPPER;
- messages.add(getMessage(msgID, String.valueOf(configEntry.getDN()),
+ int msgID = MSGID_EXTOP_PASSMOD_CANNOT_DETERMINE_ID_MAPPER;
+ messages.add(getMessage(msgID, String.valueOf(config.dn()),
stackTraceToSingleLineString(e)));
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/extensions/StartTLSExtendedOperation.java b/opendj-sdk/opends/src/server/org/opends/server/extensions/StartTLSExtendedOperation.java
index 00d2fc4..42c29af 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/extensions/StartTLSExtendedOperation.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/extensions/StartTLSExtendedOperation.java
@@ -30,7 +30,6 @@
import org.opends.server.api.ClientConnection;
import org.opends.server.api.ExtendedOperationHandler;
-import org.opends.server.config.ConfigEntry;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ExtendedOperation;
@@ -49,7 +48,7 @@
import static org.opends.server.messages.MessageHandler.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
-
+import org.opends.server.admin.std.server.ExtendedOperationHandlerCfg;
/**
@@ -59,7 +58,7 @@
* client.
*/
public class StartTLSExtendedOperation
- extends ExtendedOperationHandler
+ extends ExtendedOperationHandler<ExtendedOperationHandlerCfg>
{
@@ -76,15 +75,13 @@
}
-
-
/**
* Initializes this extended operation handler based on the information in the
* provided configuration entry. It should also register itself with the
* Directory Server for the particular kinds of extended operations that it
* will process.
*
- * @param configEntry The configuration entry that contains the information
+ * @param config The configuration that contains the information
* to use to initialize this extended operation handler.
*
* @throws ConfigException If an unrecoverable problem arises in the
@@ -94,11 +91,14 @@
* that is not related to the server
* configuration.
*/
- public void initializeExtendedOperationHandler(ConfigEntry configEntry)
- throws ConfigException, InitializationException
+ public void initializeExtendedOperationHandler(
+ ExtendedOperationHandlerCfg config)
+ throws ConfigException, InitializationException
{
// FIXME -- Are there any configurable options that we should support?
DirectoryServer.registerSupportedExtension(OID_START_TLS_REQUEST, this);
+
+ registerControlsAndFeatures();
}
@@ -110,6 +110,8 @@
public void finalizeExtendedOperationHandler()
{
DirectoryServer.deregisterSupportedExtension(OID_START_TLS_REQUEST);
+
+ deregisterControlsAndFeatures();
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/extensions/WhoAmIExtendedOperation.java b/opendj-sdk/opends/src/server/org/opends/server/extensions/WhoAmIExtendedOperation.java
index 29fa150..763a50b 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/extensions/WhoAmIExtendedOperation.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/extensions/WhoAmIExtendedOperation.java
@@ -30,7 +30,6 @@
import org.opends.server.api.ClientConnection;
import org.opends.server.api.ExtendedOperationHandler;
-import org.opends.server.config.ConfigEntry;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ExtendedOperation;
@@ -42,7 +41,7 @@
import static org.opends.server.messages.ExtensionsMessages.*;
import static org.opends.server.messages.MessageHandler.*;
import static org.opends.server.util.ServerConstants.*;
-
+import org.opends.server.admin.std.server.ExtendedOperationHandlerCfg;
/**
@@ -50,7 +49,7 @@
* It simply returns the authorized ID of the currently-authenticated user.
*/
public class WhoAmIExtendedOperation
- extends ExtendedOperationHandler
+ extends ExtendedOperationHandler<ExtendedOperationHandlerCfg>
{
@@ -67,15 +66,13 @@
}
-
-
/**
* Initializes this extended operation handler based on the information in the
* provided configuration entry. It should also register itself with the
* Directory Server for the particular kinds of extended operations that it
* will process.
*
- * @param configEntry The configuration entry that contains the information
+ * @param config The configuration that contains the information
* to use to initialize this extended operation handler.
*
* @throws ConfigException If an unrecoverable problem arises in the
@@ -85,12 +82,15 @@
* that is not related to the server
* configuration.
*/
- public void initializeExtendedOperationHandler(ConfigEntry configEntry)
- throws ConfigException, InitializationException
+ public void initializeExtendedOperationHandler(
+ ExtendedOperationHandlerCfg config)
+ throws ConfigException, InitializationException
{
// No special configuration is required.
DirectoryServer.registerSupportedExtension(OID_WHO_AM_I_REQUEST, this);
+
+ registerControlsAndFeatures();
}
@@ -102,6 +102,8 @@
public void finalizeExtendedOperationHandler()
{
DirectoryServer.deregisterSupportedExtension(OID_WHO_AM_I_REQUEST);
+
+ deregisterControlsAndFeatures();
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/messages/ConfigMessages.java b/opendj-sdk/opends/src/server/org/opends/server/messages/ConfigMessages.java
index 751e211..4bdaed6 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/messages/ConfigMessages.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/messages/ConfigMessages.java
@@ -2734,8 +2734,8 @@
* configuration. This takes a single argument, which is a string
* representation of the exception that was caught.
*/
- public static final int MSGID_CONFIG_EXTOP_CANNOT_GET_BASE =
- CATEGORY_MASK_CONFIG | SEVERITY_MASK_FATAL_ERROR | 248;
+// public static final int MSGID_CONFIG_EXTOP_CANNOT_GET_BASE =
+// CATEGORY_MASK_CONFIG | SEVERITY_MASK_FATAL_ERROR | 248;
@@ -2744,8 +2744,8 @@
* handler base entry does not exist in the Directory Server configuration.
* This does not take any arguments.
*/
- public static final int MSGID_CONFIG_EXTOP_BASE_DOES_NOT_EXIST =
- CATEGORY_MASK_CONFIG | SEVERITY_MASK_SEVERE_WARNING | 249;
+// public static final int MSGID_CONFIG_EXTOP_BASE_DOES_NOT_EXIST =
+// CATEGORY_MASK_CONFIG | SEVERITY_MASK_SEVERE_WARNING | 249;
@@ -2755,8 +2755,8 @@
* configuration. This takes two arguments, which are the DN of the
* configuration entry and the reason that it is not acceptable.
*/
- public static final int MSGID_CONFIG_EXTOP_ENTRY_UNACCEPTABLE =
- CATEGORY_MASK_CONFIG | SEVERITY_MASK_SEVERE_ERROR | 250;
+// public static final int MSGID_CONFIG_EXTOP_ENTRY_UNACCEPTABLE =
+// CATEGORY_MASK_CONFIG | SEVERITY_MASK_SEVERE_ERROR | 250;
@@ -2766,8 +2766,8 @@
* This takes two arguments, which are the DN of the configuration entry and a
* message that explains the problem that occurred.
*/
- public static final int MSGID_CONFIG_EXTOP_CANNOT_CREATE_HANDLER =
- CATEGORY_MASK_CONFIG | SEVERITY_MASK_SEVERE_ERROR | 251;
+// public static final int MSGID_CONFIG_EXTOP_CANNOT_CREATE_HANDLER =
+// CATEGORY_MASK_CONFIG | SEVERITY_MASK_SEVERE_ERROR | 251;
@@ -2776,8 +2776,8 @@
* extended operation does not contain a valid objectclass. This takes a
* single argument, which is the DN of the configuration entry.
*/
- public static final int MSGID_CONFIG_EXTOP_INVALID_OBJECTCLASS =
- CATEGORY_MASK_CONFIG | SEVERITY_MASK_SEVERE_ERROR | 252;
+// public static final int MSGID_CONFIG_EXTOP_INVALID_OBJECTCLASS =
+// CATEGORY_MASK_CONFIG | SEVERITY_MASK_SEVERE_ERROR | 252;
@@ -2785,8 +2785,8 @@
* The message ID for the description of the extended operation handler class
* name configuration attribute. This does not take any arguments.
*/
- public static final int MSGID_CONFIG_EXTOP_DESCRIPTION_CLASS_NAME =
- CATEGORY_MASK_CONFIG | SEVERITY_MASK_INFORMATIONAL | 253;
+// public static final int MSGID_CONFIG_EXTOP_DESCRIPTION_CLASS_NAME =
+// CATEGORY_MASK_CONFIG | SEVERITY_MASK_INFORMATIONAL | 253;
@@ -2795,8 +2795,8 @@
* extended operation base does not contain a value for the class name. This
* takes a single argument, which is the DN of the configuration entry.
*/
- public static final int MSGID_CONFIG_EXTOP_NO_CLASS_NAME =
- CATEGORY_MASK_CONFIG | SEVERITY_MASK_SEVERE_ERROR | 254;
+// public static final int MSGID_CONFIG_EXTOP_NO_CLASS_NAME =
+// CATEGORY_MASK_CONFIG | SEVERITY_MASK_SEVERE_ERROR | 254;
@@ -2806,8 +2806,8 @@
* takes two arguments, which are the DN of the configuration entry and a
* string representation of the exception that was caught.
*/
- public static final int MSGID_CONFIG_EXTOP_INVALID_CLASS_NAME =
- CATEGORY_MASK_CONFIG | SEVERITY_MASK_SEVERE_ERROR | 255;
+// public static final int MSGID_CONFIG_EXTOP_INVALID_CLASS_NAME =
+// CATEGORY_MASK_CONFIG | SEVERITY_MASK_SEVERE_ERROR | 255;
@@ -2827,8 +2827,8 @@
* The message ID for the description of the extended operation handler
* enabled configuration attribute. This does not take any arguments.
*/
- public static final int MSGID_CONFIG_EXTOP_DESCRIPTION_ENABLED =
- CATEGORY_MASK_CONFIG | SEVERITY_MASK_INFORMATIONAL | 257;
+// public static final int MSGID_CONFIG_EXTOP_DESCRIPTION_ENABLED =
+// CATEGORY_MASK_CONFIG | SEVERITY_MASK_INFORMATIONAL | 257;
@@ -2837,8 +2837,8 @@
* extended operation base does not contain a value for the enabled attribute.
* This takes a single argument, which is the DN of the configuration entry.
*/
- public static final int MSGID_CONFIG_EXTOP_NO_ENABLED_ATTR =
- CATEGORY_MASK_CONFIG | SEVERITY_MASK_SEVERE_ERROR | 258;
+// public static final int MSGID_CONFIG_EXTOP_NO_ENABLED_ATTR =
+// CATEGORY_MASK_CONFIG | SEVERITY_MASK_SEVERE_ERROR | 258;
@@ -2848,8 +2848,8 @@
* This takes two arguments, which are the DN of the configuration entry and a
* string representation of the exception that was caught.
*/
- public static final int MSGID_CONFIG_EXTOP_INVALID_ENABLED_VALUE =
- CATEGORY_MASK_CONFIG | SEVERITY_MASK_SEVERE_ERROR | 259;
+// public static final int MSGID_CONFIG_EXTOP_INVALID_ENABLED_VALUE =
+// CATEGORY_MASK_CONFIG | SEVERITY_MASK_SEVERE_ERROR | 259;
@@ -2859,8 +2859,8 @@
* effect. This takes three arguments, which are the old class name, the new
* class name, and the DN of the associated configuration entry.
*/
- public static final int MSGID_CONFIG_EXTOP_CLASS_ACTION_REQUIRED =
- CATEGORY_MASK_CONFIG | SEVERITY_MASK_INFORMATIONAL | 260;
+// public static final int MSGID_CONFIG_EXTOP_CLASS_ACTION_REQUIRED =
+// CATEGORY_MASK_CONFIG | SEVERITY_MASK_INFORMATIONAL | 260;
@@ -2882,8 +2882,8 @@
* handler that already exists. This takes a single argument, which is the DN
* of the handler configuration entry.
*/
- public static final int MSGID_CONFIG_EXTOP_EXISTS =
- CATEGORY_MASK_CONFIG | SEVERITY_MASK_MILD_ERROR | 262;
+// public static final int MSGID_CONFIG_EXTOP_EXISTS =
+// CATEGORY_MASK_CONFIG | SEVERITY_MASK_MILD_ERROR | 262;
@@ -2893,8 +2893,8 @@
* any specific details about the nature of the problem. This takes a single
* argument, which is the DN of the configuration entry.
*/
- public static final int MSGID_CONFIG_EXTOP_UNACCEPTABLE_CONFIG =
- CATEGORY_MASK_CONFIG | SEVERITY_MASK_SEVERE_ERROR | 263;
+// public static final int MSGID_CONFIG_EXTOP_UNACCEPTABLE_CONFIG =
+// CATEGORY_MASK_CONFIG | SEVERITY_MASK_SEVERE_ERROR | 263;
@@ -8122,78 +8122,14 @@
"Server is restarted.");
- registerMessage(MSGID_CONFIG_EXTOP_CANNOT_GET_BASE,
- "An error occurred while attempting to retrieve the " +
- "extended operation handler base entry " +
- DN_EXTENDED_OP_CONFIG_BASE +
- " from the Directory Server configuration: %s.");
- registerMessage(MSGID_CONFIG_EXTOP_BASE_DOES_NOT_EXIST,
- "The extended operation configuration base " +
- DN_EXTENDED_OP_CONFIG_BASE + " does not exist in the " +
- "Directory Server configuration. This entry must be " +
- "present for the server to function properly.");
- registerMessage(MSGID_CONFIG_EXTOP_ENTRY_UNACCEPTABLE,
- "Configuration entry %s does not contain a valid " +
- "extended operation handler configuration: %s. It will " +
- "be ignored.");
- registerMessage(MSGID_CONFIG_EXTOP_CANNOT_CREATE_HANDLER,
- "An error occurred while attempting to create a " +
- "Directory Server extended operation handler from the " +
- "information in configuration entry %s: %s.");
- registerMessage(MSGID_CONFIG_EXTOP_INVALID_OBJECTCLASS,
- "Configuration entry %s does not contain the " +
- OC_EXTENDED_OPERATION_HANDLER + " objectclass, which is " +
- "required for extended operation handler definitions.");
- registerMessage(MSGID_CONFIG_EXTOP_DESCRIPTION_CLASS_NAME,
- "The fully-qualified name of the Java class that defines " +
- "the Directory Server extended operation handler. If " +
- "this is altered while the associated handler is " +
- "enabled, then that handler must be disabled and " +
- "re-enabled for the change to take effect.");
- registerMessage(MSGID_CONFIG_EXTOP_NO_CLASS_NAME,
- "Configuration entry %s does not contain a valid value " +
- "for configuration attribute " + ATTR_EXTOP_CLASS +
- " which specifies the fully-qualified class name for " +
- "the associated extended operation handler.");
- registerMessage(MSGID_CONFIG_EXTOP_INVALID_CLASS_NAME,
- "Configuration entry %s has an invalid value for " +
- "attribute " + ATTR_EXTOP_CLASS + ": %s.");
registerMessage(MSGID_CONFIG_EXTOP_INVALID_CLASS,
"Class %s specified in configuration entry %s does not " +
"contain a valid extended operation handler " +
"implementation: %s.");
- registerMessage(MSGID_CONFIG_EXTOP_DESCRIPTION_ENABLED,
- "Indicates whether this Directory Server extended " +
- "operation handler should be enabled. Changes to this " +
- "attribute will take effect immediately.");
- registerMessage(MSGID_CONFIG_EXTOP_NO_ENABLED_ATTR,
- "Configuration entry %s does not contain a valid value " +
- "for configuration attribute " + ATTR_EXTOP_ENABLED +
- " which indicates whether the extended operation handler " +
- "should be enabled for use in the Directory Server.");
- registerMessage(MSGID_CONFIG_EXTOP_INVALID_ENABLED_VALUE,
- "Configuration entry %s has an invalid value for " +
- "attribute " + ATTR_EXTOP_ENABLED + ": %s.");
- registerMessage(MSGID_CONFIG_EXTOP_CLASS_ACTION_REQUIRED,
- "The requested change in the extended operation handler " +
- "class name from %s to %s in configuration entry %s " +
- "cannot be dynamically applied. This change will not " +
- "take effect until the handler is disabled and " +
- "re-enabled or the Directory Server is restarted.");
registerMessage(MSGID_CONFIG_EXTOP_INITIALIZATION_FAILED,
"An error occurred while trying to initialize an " +
"instance of class %s as an extended operation handler " +
"as defined in configuration entry %s: %s.");
- registerMessage(MSGID_CONFIG_EXTOP_EXISTS,
- "Unable to add a new extended operation handler entry " +
- "with DN %s because there is already a handler " +
- "registered with that DN.");
- registerMessage(MSGID_CONFIG_EXTOP_UNACCEPTABLE_CONFIG,
- "The configuration for the extended operation handler " +
- "defined in configuration entry %s was not acceptable " +
- "according to its internal validation. However, no " +
- "specific information is available regarding the " +
- "problem(s) with the entry.");
registerMessage(MSGID_CONFIG_SASL_CANNOT_GET_BASE,
@@ -9329,7 +9265,7 @@
registerMessage(MSGID_CONFIG_GROUP_CANNOT_GET_BASE,
"An error occurred while attempting to retrieve the " +
"group implementation base entry " +
- DN_EXTENDED_OP_CONFIG_BASE +
+ DN_GROUP_IMPLEMENTATION_CONFIG_BASE +
" from the Directory Server configuration: %s.");
registerMessage(MSGID_CONFIG_GROUP_BASE_DOES_NOT_EXIST,
"The group implementation configuration base " +
diff --git a/opendj-sdk/opends/src/server/org/opends/server/messages/ExtensionsMessages.java b/opendj-sdk/opends/src/server/org/opends/server/messages/ExtensionsMessages.java
index 7866cc2..b4e867c 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/messages/ExtensionsMessages.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/messages/ExtensionsMessages.java
@@ -3861,8 +3861,8 @@
* identity mapper DN configuration attribute. This does not take any
* arguments.
*/
- public static final int MSGID_EXTOP_PASSMOD_DESCRIPTION_ID_MAPPER =
- CATEGORY_MASK_EXTENSIONS | SEVERITY_MASK_INFORMATIONAL | 366;
+// public static final int MSGID_EXTOP_PASSMOD_DESCRIPTION_ID_MAPPER =
+// CATEGORY_MASK_EXTENSIONS | SEVERITY_MASK_INFORMATIONAL | 366;
@@ -3871,8 +3871,8 @@
* is provided for the password modify extended operation. This takes a
* single argument, which is the DN of the configuration entry.
*/
- public static final int MSGID_EXTOP_PASSMOD_NO_ID_MAPPER =
- CATEGORY_MASK_EXTENSIONS | SEVERITY_MASK_MILD_ERROR | 367;
+// public static final int MSGID_EXTOP_PASSMOD_NO_ID_MAPPER =
+// CATEGORY_MASK_EXTENSIONS | SEVERITY_MASK_MILD_ERROR | 367;
@@ -5020,19 +5020,6 @@
"updated.");
- registerMessage(MSGID_EXTOP_PASSMOD_DESCRIPTION_ID_MAPPER,
- "Specifies the DN of the configuration entry for the " +
- "identity mapper that should be used in conjunction with " +
- "the password modify extended operation. This will be " +
- "used to identify a user based on an authorization ID " +
- "in the 'u:' form. Changes to this configuration " +
- "attribute will take effect immediately.");
- registerMessage(MSGID_EXTOP_PASSMOD_NO_ID_MAPPER,
- "No identity mapper DN was specified in the " +
- ATTR_IDMAPPER_DN + " attribute of the password modify " +
- "extended operation configuration entry %s. This is a " +
- "required attribute, and the password modify extended " +
- "operation will not be enabled.");
registerMessage(MSGID_EXTOP_PASSMOD_NO_SUCH_ID_MAPPER,
"The identity mapper with configuration entry DN %s as " +
"specified for use with the password modify extended " +
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/PasswordModifyExtendedOperationTestCase.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/PasswordModifyExtendedOperationTestCase.java
index 65de147..91a0e3f 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/PasswordModifyExtendedOperationTestCase.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/PasswordModifyExtendedOperationTestCase.java
@@ -36,7 +36,9 @@
import org.testng.annotations.Test;
import org.opends.server.TestCaseUtils;
-import org.opends.server.config.ConfigEntry;
+import org.opends.server.admin.server.AdminTestCaseUtils;
+import org.opends.server.admin.std.server.PasswordModifyExtendedOperationHandlerCfg;
+import org.opends.server.admin.std.meta.PasswordModifyExtendedOperationHandlerCfgDefn;
import org.opends.server.config.ConfigException;
import org.opends.server.core.AddOperation;
import org.opends.server.core.BindOperation;
@@ -45,17 +47,11 @@
import org.opends.server.core.ModifyOperation;
import org.opends.server.protocols.asn1.ASN1Element;
import org.opends.server.protocols.asn1.ASN1OctetString;
-import org.opends.server.protocols.asn1.ASN1Reader;
import org.opends.server.protocols.asn1.ASN1Sequence;
-import org.opends.server.protocols.asn1.ASN1Writer;
import org.opends.server.protocols.internal.InternalClientConnection;
-import org.opends.server.protocols.ldap.LDAPControl;
-import org.opends.server.protocols.ldap.LDAPMessage;
-import org.opends.server.protocols.ldap.UnbindRequestProtocolOp;
import org.opends.server.tools.LDAPPasswordModify;
import org.opends.server.types.Attribute;
import org.opends.server.types.AuthenticationInfo;
-import org.opends.server.types.Control;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.InitializationException;
@@ -91,8 +87,9 @@
/**
- * Retrieves a set of invvalid configuration entries.
+ * Retrieves a set of invalid configuration entries.
*
+ * @return The set of invalid configuration entries.
* @throws Exception If an unexpected problem occurs.
*/
@DataProvider(name = "invalidConfigs")
@@ -143,7 +140,7 @@
/**
* Tests the process of initializing the server with invalid configurations.
*
- * @param entry The configuration entry to use for the initialization.
+ * @param e The configuration entry to use for the initialization.
*
* @throws Exception If an unexpected problem occurs.
*/
@@ -153,13 +150,14 @@
public void testInitializeWithInvalidConfigs(Entry e)
throws Exception
{
- DN parentDN = DN.decode("cn=Extended Operations,cn=config");
- ConfigEntry parentEntry = DirectoryServer.getConfigEntry(parentDN);
- ConfigEntry configEntry = new ConfigEntry(e, parentEntry);
+ PasswordModifyExtendedOperationHandlerCfg configuration =
+ AdminTestCaseUtils.getConfiguration(
+ PasswordModifyExtendedOperationHandlerCfgDefn.getInstance(),
+ e);
PasswordModifyExtendedOperation handler =
new PasswordModifyExtendedOperation();
- handler.initializeExtendedOperationHandler(configEntry);
+ handler.initializeExtendedOperationHandler(configuration);
}
@@ -1237,8 +1235,6 @@
/**
* Tests the password modify extended operation over an internal connection
* with a request whose value isn't a valid encoded sequence.
- *
- * @throws Exception If an unexpected error occurs.
*/
@Test()
public void testFailureInvalidRequestValueFormat()
@@ -1258,8 +1254,6 @@
/**
* Tests the password modify extended operation over an internal connection
* with a request that contain an invalid sequence element type.
- *
- * @throws Exception If an unexpected error occurs.
*/
@Test()
public void testFailureInvalidSequenceElementType()
@@ -1284,8 +1278,6 @@
/**
* Tests the password modify extended operation over an unauthenticated
* internal connection and without providing an authorization ID.
- *
- * @throws Exception If an unexpected error occurs.
*/
@Test()
public void testFailureCompletelyAnonymous()
--
Gitblit v1.10.0