From 4990dd6175a8d5a931c413d6091f0ec5c8331d45 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Tue, 13 Mar 2012 11:16:22 +0000
Subject: [PATCH] Fix OPENDJ-436: Inconsistency between hostname specified in setup and DIGEST-MD5 fqdn of server.
---
opends/src/server/org/opends/server/tools/ConfigureDS.java | 54 +++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 49 insertions(+), 5 deletions(-)
diff --git a/opends/src/server/org/opends/server/tools/ConfigureDS.java b/opends/src/server/org/opends/server/tools/ConfigureDS.java
index b596376..611cb95 100644
--- a/opends/src/server/org/opends/server/tools/ConfigureDS.java
+++ b/opends/src/server/org/opends/server/tools/ConfigureDS.java
@@ -23,12 +23,14 @@
*
*
* Copyright 2006-2009 Sun Microsystems, Inc.
+ * Portions copyright 2012 ForgeRock AS.
*/
package org.opends.server.tools;
import org.opends.messages.Message;
+import java.net.InetAddress;
import java.security.GeneralSecurityException;
import java.util.Collection;
import java.util.HashSet;
@@ -152,6 +154,11 @@
*/
public static final String DN_CRYPTO_MANAGER = "cn=Crypto Manager,cn=config";
+ /**
+ * The DN of the DIGEST-MD5 SASL mechanism handler.
+ */
+ public static final String DN_DIGEST_MD5_SASL_MECHANISM =
+ "cn=DIGEST-MD5,cn=SASL Mechanisms,cn=config";
/**
@@ -189,6 +196,7 @@
BooleanArgument showUsage;
BooleanArgument enableStartTLS;
FileBasedArgument rootPasswordFile;
+ StringArgument hostName;
IntegerArgument ldapPort;
IntegerArgument adminConnectorPort;
IntegerArgument ldapsPort;
@@ -237,6 +245,25 @@
configClass.setHidden(true);
argParser.addArgument(configClass);
+ String defaultHostName;
+ try
+ {
+ defaultHostName = InetAddress.getLocalHost().getHostName();
+ }
+ catch (Exception e)
+ {
+ // Not much we can do here.
+ defaultHostName = "localhost";
+ }
+ hostName = new StringArgument(OPTION_LONG_HOST.toLowerCase(),
+ OPTION_SHORT_HOST,
+ OPTION_LONG_HOST, false, false, true,
+ INFO_HOST_PLACEHOLDER.get(),
+ defaultHostName,
+ null,
+ INFO_INSTALLDS_DESCRIPTION_HOST_NAME.get());
+ argParser.addArgument(hostName);
+
ldapPort = new IntegerArgument("ldapport", OPTION_SHORT_PORT,
"ldapPort", false, false,
true, INFO_LDAPPORT_PLACEHOLDER.get(), 389,
@@ -471,11 +498,11 @@
// Initialize the Directory Server configuration handler using the
// information that was provided.
DirectoryServer directoryServer = DirectoryServer.getInstance();
- directoryServer.bootstrapClient();
+ DirectoryServer.bootstrapClient();
try
{
- directoryServer.initializeJMX();
+ DirectoryServer.initializeJMX();
}
catch (Exception e)
{
@@ -593,7 +620,7 @@
// Get the Directory Server configuration handler and use it to make the
// appropriate configuration changes.
- ConfigHandler configHandler = directoryServer.getConfigHandler();
+ ConfigHandler configHandler = DirectoryServer.getConfigHandler();
// Check that the key manager provided is valid.
@@ -1202,6 +1229,23 @@
}
}
+ // Set the FQDN for the DIGEST-MD5 SASL mechanism.
+ try
+ {
+ DN digestMD5DN = DN.decode(DN_DIGEST_MD5_SASL_MECHANISM);
+ ConfigEntry configEntry = configHandler.getConfigEntry(digestMD5DN);
+ StringConfigAttribute fqdnAttr = new StringConfigAttribute(
+ "ds-cfg-server-fqdn", Message.EMPTY, false, false, false,
+ hostName.getValue());
+ configEntry.putConfigAttribute(fqdnAttr);
+ }
+ catch (Exception e)
+ {
+ Message message = ERR_CONFIGDS_CANNOT_UPDATE_DIGEST_MD5_FQDN.get(String
+ .valueOf(e));
+ err.println(wrapText(message, MAX_LINE_WIDTH));
+ return 1;
+ }
// Check that the cipher specified is supported. This is intended to
// fix issues with JVM that do not support the default cipher (see
@@ -1210,11 +1254,11 @@
StringPropertyDefinition prop =
cryptoManager.getKeyWrappingTransformationPropertyDefinition();
String defaultCipher = null;
- DefaultBehaviorProvider p = prop.getDefaultBehaviorProvider();
+ DefaultBehaviorProvider<?> p = prop.getDefaultBehaviorProvider();
if (p instanceof DefinedDefaultBehaviorProvider)
{
Collection<?> defaultValues =
- ((DefinedDefaultBehaviorProvider)p).getDefaultValues();
+ ((DefinedDefaultBehaviorProvider<?>)p).getDefaultValues();
if (!defaultValues.isEmpty())
{
defaultCipher = defaultValues.iterator().next().toString();
--
Gitblit v1.10.0