mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Matthew Swift
13.16.2012 4990dd6175a8d5a931c413d6091f0ec5c8331d45
Fix OPENDJ-436: Inconsistency between hostname specified in setup and DIGEST-MD5 fqdn of server.

Pass hostname to ConfigureDS and use it to set the FQDN for the DIGEST-MD5 mechanism.
3 files modified
60 ■■■■■ changed files
opends/src/messages/messages/tools.properties 2 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java 4 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/ConfigureDS.java 54 ●●●●● patch | view | raw | blame | history
opends/src/messages/messages/tools.properties
@@ -2593,3 +2593,5 @@
 specified with the "--rebuildDegraded" option
SEVERE_ERR_REBUILDINDEX_REBUILD_ALL_DEGRADED_ERROR_1722=Option "--rebuildAll" \
 cannot be specified with the "--rebuildDegraded" option
SEVERE_ERR_CONFIGDS_CANNOT_UPDATE_DIGEST_MD5_FQDN_1733=An error occurred while \
 attempting to update the FQDN for the DIGEST-MD5 SASL mechanism:  %s
opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
@@ -23,7 +23,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011 ForgeRock AS
 *      Portions Copyright 2011-2012 ForgeRock AS
 */
package org.opends.quicksetup.installer;
@@ -913,6 +913,8 @@
    argList.add("-c");
    argList.add(getConfigurationFile());
    argList.add("-h");
    argList.add(String.valueOf(getUserData().getHostName()));
    argList.add("-p");
    argList.add(String.valueOf(getUserData().getServerPort()));
    argList.add("--adminConnectorPort");
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();