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

Violette Roche-Montane
18.19.2014 b671de6dbf50ca89cb0b9e4d7da6c81ae3017c82
Checkpoint OPENDJ-1343 Migrate dsconfig / OPENDJ-1303 "opendj-cli"
- org.opends.server.util.cli.[*] calls replaced by equivalent CLI sdk's classes.
- fixed upgrade cli -> <string<.equals(LocalizedMessaged)
- moved methods from console application to ReplicationMainCli.

10 files deleted
34 files modified
4890 ■■■■ changed files
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/task/Task.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/IndexPanel.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/NewBaseDNPanel.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/NewIndexPanel.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/VLVIndexPanel.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java 72 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/quicksetup/org/opends/quicksetup/CliUserInteraction.java 9 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/InstallDS.java 67 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/InstallDSArgumentParser.java 9 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/JavaPropertiesTool.java 10 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/ManageTasks.java 20 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/WaitForFileDelete.java 4 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ArgumentExceptionFactory.java 18 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java 14 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DSConfig.java 28 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java 8 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/GetPropSubCommandHandler.java 10 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java 16 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/InternalManagementContextFactory.java 4 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java 4 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ListSubCommandHandler.java 10 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ManagementContextFactory.java 4 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValueEditor.java 20 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java 6 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java 14 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/LocalPurgeHistorical.java 14 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java 951 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCli.java 8 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleInteraction.java 30 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleUserData.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/upgrade/UpgradeCli.java 30 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/util/cli/CommandBuilder.java 334 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/util/cli/ConsoleApplication.java 1467 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/util/cli/ErrorStreamConsoleApplication.java 114 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/util/cli/HelpCallback.java 42 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java 63 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/util/cli/Menu.java 54 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/util/cli/MenuBuilder.java 838 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/util/cli/MenuCallback.java 53 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/util/cli/MenuResult.java 323 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/util/cli/OutputStreamConsoleApplication.java 114 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/util/cli/PointAdder.java 6 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/util/cli/ValidationCallback.java 58 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tools/dsconfig/DsconfigLdapConnectionTestCase.java 32 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/task/Task.java
@@ -63,7 +63,7 @@
import org.opends.server.types.Schema;
import org.opends.server.util.Base64;
import org.opends.server.util.SetupUtils;
import org.opends.server.util.cli.CommandBuilder;
import com.forgerock.opendj.cli.CommandBuilder;
/**
 * The class used to define a number of common methods and mechanisms for the
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/IndexPanel.java
@@ -84,7 +84,7 @@
import org.opends.server.types.OpenDsException;
import org.opends.server.util.LDIFReader;
import org.opends.server.util.ServerConstants;
import org.opends.server.util.cli.CommandBuilder;
import com.forgerock.opendj.cli.CommandBuilder;
/**
 * The panel that displays an existing index (it appears on the right of the
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/NewBaseDNPanel.java
@@ -108,7 +108,7 @@
import org.opends.server.types.OpenDsException;
import org.opends.server.util.LDIFReader;
import org.opends.server.util.SetupUtils;
import org.opends.server.util.cli.CommandBuilder;
import com.forgerock.opendj.cli.CommandBuilder;
/**
 * The class that appears when the user clicks on 'New Base DN'.
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/NewIndexPanel.java
@@ -77,7 +77,7 @@
import org.opends.server.types.Schema;
import org.opends.server.util.LDIFReader;
import org.opends.server.util.ServerConstants;
import org.opends.server.util.cli.CommandBuilder;
import com.forgerock.opendj.cli.CommandBuilder;
/**
 * Panel that appears when the user defines a new index.
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/VLVIndexPanel.java
@@ -86,7 +86,7 @@
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.OpenDsException;
import org.opends.server.util.LDIFReader;
import org.opends.server.util.cli.CommandBuilder;
import com.forgerock.opendj.cli.CommandBuilder;
/**
 * The panel that displays an existing VLV index (it appears on the right of the
opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
@@ -37,6 +37,7 @@
import java.util.Set;
import javax.naming.NamingException;
import javax.naming.NoPermissionException;
import javax.naming.ldap.InitialLdapContext;
import javax.net.ssl.TrustManager;
@@ -48,6 +49,7 @@
import org.opends.admin.ads.TopologyCache;
import org.opends.admin.ads.TopologyCacheException;
import org.opends.admin.ads.util.ApplicationTrustManager;
import org.opends.admin.ads.util.ConnectionUtils;
import org.opends.guitools.controlpanel.datamodel.ConnectionProtocolPolicy;
import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
import org.opends.quicksetup.*;
@@ -61,14 +63,21 @@
import org.opends.server.tools.ToolConstants;
import org.opends.server.tools.dsconfig.LDAPManagementContextFactory;
import org.opends.server.util.StaticUtils;
import org.opends.server.util.cli.*;
import com.forgerock.opendj.cli.ConsoleApplication;
import org.opends.server.util.cli.LDAPConnectionConsoleInteraction;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.ClientException;
import com.forgerock.opendj.cli.Menu;
import com.forgerock.opendj.cli.MenuBuilder;
import com.forgerock.opendj.cli.MenuResult;
import static org.forgerock.util.Utils.*;
import static org.opends.messages.AdminToolMessages.*;
import static org.opends.messages.QuickSetupMessages.*;
import static com.forgerock.opendj.cli.Utils.CONFIRMATION_MAX_TRIES;
/**
 * The class used to provide some CLI interface in the uninstall.
@@ -102,7 +111,7 @@
   */
  public UninstallCliHelper()
  {
    super(System.in, System.out, System.err);
    // Nothing to do.
  }
  /**
@@ -1091,12 +1100,12 @@
    {
      if (!supressOutput)
      {
        printlnProgress();
        println();
      }
      controller.startServer(supressOutput);
      if (!supressOutput)
      {
        printlnProgress();
        println();
      }
      serverStarted = Installation.getLocal().getStatus().isServerRunning();
      logger.info(LocalizableMessage.raw("server started successfully. serverStarted: "+
@@ -1119,6 +1128,61 @@
  }
  /**
   * Returns an InitialLdapContext using the provided parameters. We try to
   * guarantee that the connection is able to read the configuration.
   *
   * @param host
   *          the host name.
   * @param port
   *          the port to connect.
   * @param useSSL
   *          whether to use SSL or not.
   * @param useStartTLS
   *          whether to use StartTLS or not.
   * @param bindDn
   *          the bind dn to be used.
   * @param pwd
   *          the password.
   * @param connectTimeout
   *          the timeout in milliseconds to connect to the server.
   * @param trustManager
   *          the trust manager.
   * @return an InitialLdapContext connected.
   * @throws NamingException
   *           if there was an error establishing the connection.
   */
  private InitialLdapContext createAdministrativeContext(String host,
      int port, boolean useSSL, boolean useStartTLS, String bindDn, String pwd,
      int connectTimeout, ApplicationTrustManager trustManager)
      throws NamingException
  {
    InitialLdapContext ctx;
    String ldapUrl = ConnectionUtils.getLDAPUrl(host, port, useSSL);
    if (useSSL)
    {
      ctx =
          Utils.createLdapsContext(ldapUrl, bindDn, pwd, connectTimeout, null,
              trustManager);
    }
    else if (useStartTLS)
    {
      ctx =
          Utils.createStartTLSContext(ldapUrl, bindDn, pwd, connectTimeout,
              null, trustManager, null);
    }
    else
    {
      ctx = Utils.createLdapContext(ldapUrl, bindDn, pwd, connectTimeout, null);
    }
    if (!ConnectionUtils.connectedAsAdministrativeUser(ctx))
    {
      throw new NoPermissionException(ERR_NOT_ADMINISTRATIVE_USER.get()
          .toString());
    }
    return ctx;
  }
  /**
   * Updates the contents of the UninstallUserData while trying to connect
   * to the remote servers.  It returns <CODE>true</CODE> if we could connect
   * to the remote servers and all the presented certificates were accepted and
opendj3-server-dev/src/quicksetup/org/opends/quicksetup/CliUserInteraction.java
@@ -35,10 +35,10 @@
import org.opends.quicksetup.util.Utils;
import org.opends.server.util.StaticUtils;
import com.forgerock.opendj.cli.ClientException;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.cli.Menu;
import org.opends.server.util.cli.MenuBuilder;
import org.opends.server.util.cli.MenuResult;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.Menu;
import com.forgerock.opendj.cli.MenuBuilder;
import com.forgerock.opendj.cli.MenuResult;
import java.util.List;
@@ -60,7 +60,6 @@
   * @param ud The CLI arguments.
   */
  public CliUserInteraction(UserData ud) {
    super(System.in, System.out, System.err);
    isInteractive = ud == null || ud.isInteractive();
    isForceOnError = ud != null && ud.isForceOnError();
  }
opendj3-server-dev/src/server/org/opends/server/tools/InstallDS.java
@@ -32,11 +32,13 @@
import static org.opends.messages.QuickSetupMessages.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.messages.UtilityMessages.*;
import static com.forgerock.opendj.cli.Utils.CONFIRMATION_MAX_TRIES;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.security.KeyStoreException;
@@ -70,14 +72,15 @@
import org.opends.server.util.CertificateManager;
import org.opends.server.util.SetupUtils;
import org.opends.server.util.StaticUtils;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.IntegerArgument;
import com.forgerock.opendj.cli.StringArgument;
import com.forgerock.opendj.cli.ClientException;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.cli.Menu;
import org.opends.server.util.cli.MenuBuilder;
import org.opends.server.util.cli.MenuResult;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.Menu;
import com.forgerock.opendj.cli.MenuBuilder;
import com.forgerock.opendj.cli.MenuResult;
/**
 * This class provides a very simple mechanism for installing the OpenDS
@@ -247,7 +250,7 @@
   */
  public InstallDS(PrintStream out, PrintStream err, InputStream in)
  {
    super(in, out, err);
    super(out, err);
  }
  /**
@@ -411,7 +414,8 @@
        println(QuickSetupMessages.
            INFO_LICENSE_DETAILS_CLI_LABEL.get());
        BufferedReader in = getInputStream();
        BufferedReader in = new BufferedReader(new InputStreamReader(getInputStream()));
        // No-prompt arg automatically rejects the license.
        if (!argParser.noPromptArg.isPresent())
        {
@@ -478,6 +482,18 @@
          initializeUserDataWithParser(uData);
        }
      }
      catch (ClientException ce)
      {
        println(ce.getMessageObject());
        if (isPasswordTriesError(ce.getMessageObject()))
        {
          return ErrorReturnCode.ERROR_PASSWORD_LIMIT.getReturnCode();
        }
        else
        {
          return ErrorReturnCode.ERROR_USER_DATA.getReturnCode();
        }
      }
      catch (UserDataException ude)
      {
        println(ude.getMessageObject());
@@ -544,11 +560,11 @@
          public void progressUpdate(ProgressUpdateEvent ev) {
            if (ev.getNewLogs() != null)
            {
              printProgress(ev.getNewLogs());
              print(ev.getNewLogs());
            }
          }
        });
    printlnProgress();
    println();
    installer.run();
@@ -570,9 +586,9 @@
          Installation.UNIX_BINARIES_PATH_RELATIVE);
      cmd = Utils.getPath(binDir, Installation.UNIX_STATUSCLI_FILE_NAME);
    }
    printlnProgress();
    printProgress(INFO_INSTALLDS_STATUS_COMMAND_LINE.get(cmd));
    printlnProgress();
    println();
    println(INFO_INSTALLDS_STATUS_COMMAND_LINE.get(cmd));
    println();
    if (ue != null)
    {
@@ -706,7 +722,7 @@
      errorMessages.add(message);
    }
    uData.setDirectoryManagerDn(dmDN);
    uData.setDirectoryManagerPwd(argParser.getDirectoryManagerPassword());
    uData.setDirectoryManagerPwd(String.valueOf(argParser.getDirectoryManagerPassword()));
    // Check the validity of the base DNs
    List<String> baseDNs = argParser.baseDNArg.getValues();
@@ -929,8 +945,9 @@
   * @param uData the UserData object to be updated.
   * @throws UserDataException if the user did not manage to provide the
   * keystore password after a certain number of tries.
   * @throws ClientException if something went wrong when reading inputs.
   */
  private void promptIfRequired(UserData uData) throws UserDataException
  private void promptIfRequired(UserData uData) throws UserDataException, ClientException
  {
    uData.setQuiet(isQuiet());
    uData.setVerbose(isVerbose());
@@ -951,16 +968,17 @@
   * not valid, it prompts the user to provide it.
   * @param uData the UserData object to be updated.
   * @throws UserDataException if something went wrong checking the data.
   * @throws ClientException if something went wrong checking passwords.
   */
  private void promptIfRequiredForDirectoryManager(UserData uData)
  throws UserDataException
  throws UserDataException, ClientException
  {
    LinkedList<String> dns = promptIfRequiredForDNs(
        argParser.directoryManagerDNArg, INFO_INSTALLDS_PROMPT_ROOT_DN.get(),
        true);
    uData.setDirectoryManagerDn(dns.getFirst());
    String pwd = argParser.getDirectoryManagerPassword();
    char[] pwd = argParser.getDirectoryManagerPassword();
    int nTries = 0;
    while (pwd == null)
    {
@@ -969,12 +987,12 @@
        throw new UserDataException(null,
            ERR_TRIES_LIMIT_REACHED.get(CONFIRMATION_MAX_TRIES));
      }
      String pwd1 = null;
      char[] pwd1 = null;
      // Prompt for password and confirm.
      while (pwd1 == null)
      {
        pwd1 = readPassword(INFO_INSTALLDS_PROMPT_ROOT_PASSWORD.get(), logger);
        pwd1 = readPassword(INFO_INSTALLDS_PROMPT_ROOT_PASSWORD.get());
        if ((pwd1 == null) || "".equals(pwd1))
        {
          pwd1 = null;
@@ -983,8 +1001,8 @@
          println();
        }
      }
      String pwd2 =
        readPassword(INFO_INSTALLDS_PROMPT_CONFIRM_ROOT_PASSWORD.get(), logger);
      char[] pwd2 =
        readPassword(INFO_INSTALLDS_PROMPT_CONFIRM_ROOT_PASSWORD.get());
      if (pwd1.equals(pwd2))
      {
@@ -998,7 +1016,7 @@
      nTries++;
    }
    uData.setDirectoryManagerPwd(pwd);
    uData.setDirectoryManagerPwd(String.valueOf(pwd));
  }
  /**
@@ -1558,9 +1576,10 @@
   * @throws UserDataException
   *           if the user did not manage to provide the keystore password after
   *           a certain number of tries.
   * @throws ClientException If an error occurs when reading inputs.
   */
  private SecurityOptions promptIfRequiredForSecurityData(UserData uData)
  throws UserDataException
  throws UserDataException, ClientException
  {
    // Check that the security data provided is valid.
    boolean enableSSL = false;
@@ -2008,10 +2027,11 @@
   * parameters (or to what the user provided after being prompted).
   * @throws UserDataException if the user did not manage to provide the
   * keystore password after a certain number of tries.
   * @throws ClientException
   */
  private SecurityOptions createSecurityOptionsPrompting(
      SecurityOptions.CertificateType type, boolean enableSSL,
      boolean enableStartTLS, int ldapsPort) throws UserDataException
      boolean enableStartTLS, int ldapsPort) throws UserDataException, ClientException
  {
    SecurityOptions securityOptions;
    String path;
@@ -2125,8 +2145,7 @@
            throw new UserDataException(null,
                ERR_INSTALLDS_TOO_MANY_KEYSTORE_PASSWORD_TRIES.get(LIMIT_KEYSTORE_PASSWORD_PROMPT));
          }
          pwd = readPassword(
                INFO_INSTALLDS_PROMPT_KEYSTORE_PASSWORD.get(), logger);
          pwd = String.valueOf(readPassword(INFO_INSTALLDS_PROMPT_KEYSTORE_PASSWORD.get()));
          nPasswordPrompts ++;
        }
      }
opendj3-server-dev/src/server/org/opends/server/tools/InstallDSArgumentParser.java
@@ -464,18 +464,17 @@
   * should be called after a call to parseArguments.
   * @return the directory manager password provided by the user.
   */
  public String getDirectoryManagerPassword()
  public char[] getDirectoryManagerPassword()
  {
    String pwd = null;
    if (directoryManagerPwdStringArg.isPresent())
    {
      pwd = directoryManagerPwdStringArg.getValue();
      return directoryManagerPwdStringArg.getValue().toCharArray();
    }
    else if (directoryManagerPwdFileArg.isPresent())
    {
      pwd = directoryManagerPwdFileArg.getValue();
      return directoryManagerPwdFileArg.getValue().toCharArray();
    }
    return pwd;
    return null;
  }
  /**
opendj3-server-dev/src/server/org/opends/server/tools/JavaPropertiesTool.java
@@ -37,7 +37,7 @@
import org.opends.quicksetup.util.Utils;
import org.opends.server.loggers.JDKLogging;
import org.opends.server.types.NullOutputStream;
import org.opends.server.util.cli.ConsoleApplication;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.ArgumentException;
@@ -121,7 +121,7 @@
   */
  public JavaPropertiesTool(PrintStream out, PrintStream err, InputStream in)
  {
    super(in, out, err);
    super(out, err);
  }
  /**
@@ -335,17 +335,17 @@
    File f2 = new File(argParser.destinationFileArg.getDefaultValue());
    if (f1.equals(f2))
    {
      printProgress(INFO_JAVAPROPERTIES_SUCCESSFUL.get(
      print(INFO_JAVAPROPERTIES_SUCCESSFUL.get(
          argParser.propertiesFileArg.getValue()));
    }
    else
    {
      printProgress(INFO_JAVAPROPERTIES_SUCCESSFUL_NON_DEFAULT.get(
      print(INFO_JAVAPROPERTIES_SUCCESSFUL_NON_DEFAULT.get(
          argParser.destinationFileArg.getValue(),
          argParser.propertiesFileArg.getValue(),
          argParser.destinationFileArg.getDefaultValue()));
    }
    printlnProgress();
    println();
    return ErrorReturnCode.SUCCESSFUL.getReturnCode();
opendj3-server-dev/src/server/org/opends/server/tools/ManageTasks.java
@@ -52,18 +52,23 @@
import com.forgerock.opendj.cli.StringArgument;
import org.opends.server.util.args.LDAPConnectionArgumentParser;
import org.opends.server.util.cli.ConsoleApplication;
import com.forgerock.opendj.cli.ConsoleApplication;
import org.opends.server.util.cli.LDAPConnectionConsoleInteraction;
import org.opends.server.util.cli.Menu;
import org.opends.server.util.cli.MenuBuilder;
import org.opends.server.util.cli.MenuCallback;
import org.opends.server.util.cli.MenuResult;
import com.forgerock.opendj.cli.Menu;
import com.forgerock.opendj.cli.MenuBuilder;
import com.forgerock.opendj.cli.MenuCallback;
import com.forgerock.opendj.cli.MenuResult;
import org.opends.server.util.table.TableBuilder;
import org.opends.server.util.table.TextTablePrinter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
@@ -180,8 +185,9 @@
   * @param err              The output stream to use for standard error, or
   *                         {@code null} if standard error is not needed.
   */
  public ManageTasks(InputStream in, OutputStream out, OutputStream err) {
    super(in, out, err);
  public ManageTasks(InputStream in, OutputStream out, OutputStream err)
  {
    super(new PrintStream(out), new PrintStream(err));
  }
  /**
opendj3-server-dev/src/server/org/opends/server/tools/WaitForFileDelete.java
@@ -32,7 +32,7 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.loggers.JDKLogging;
import org.opends.server.types.NullOutputStream;
import org.opends.server.util.cli.ConsoleApplication;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.*;
@@ -88,7 +88,7 @@
   */
  public WaitForFileDelete(PrintStream out, PrintStream err, InputStream in)
  {
    super(in, out, err);
    super(out, err);
  }
  /**
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ArgumentExceptionFactory.java
@@ -47,9 +47,9 @@
import com.forgerock.opendj.cli.ClientException;
import com.forgerock.opendj.cli.ReturnCode;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.table.TableBuilder;
import org.opends.server.util.table.TextTablePrinter;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.TableBuilder;
import com.forgerock.opendj.cli.TextTablePrinter;
@@ -293,6 +293,18 @@
    return new ArgumentException(msg);
  }
  /**
   * Creates an argument exception which should be used when the
   * client has not specified a bind password.
   *
   * @param bindDN
   *          The name of the user requiring a password.
   * @return Returns an argument exception.
   */
  public static ArgumentException missingBindPassword(char[] bindDN) {
    LocalizableMessage msg = ERR_DSCFG_ERROR_NO_PASSWORD.get(bindDN);
    return new ArgumentException(msg);
  }
  /**
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java
@@ -87,11 +87,11 @@
import com.forgerock.opendj.cli.SubCommandArgumentParser;
import com.forgerock.opendj.cli.ClientException;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.cli.HelpCallback;
import org.opends.server.util.cli.MenuBuilder;
import org.opends.server.util.cli.MenuResult;
import org.opends.server.util.cli.ValidationCallback;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.HelpCallback;
import com.forgerock.opendj.cli.MenuBuilder;
import com.forgerock.opendj.cli.MenuResult;
import com.forgerock.opendj.cli.ValidationCallback;
import org.opends.server.util.table.TableBuilder;
import org.opends.server.util.table.TextTablePrinter;
@@ -908,11 +908,11 @@
      app.println(INFO_DSCFG_CREATE_NAME_PROMPT_NAMING.get(ufn, pd.getName()));
      app.println();
      app.printErrln(pd.getSynopsis(), 4);
      app.errPrintln(pd.getSynopsis(), 4);
      if (pd.getDescription() != null) {
        app.println();
        app.printErrln(pd.getDescription(), 4);
        app.errPrintln(pd.getDescription(), 4);
      }
      PropertyDefinitionUsageBuilder b =
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DSConfig.java
@@ -36,6 +36,9 @@
import static org.opends.server.tools.dsconfig.ArgumentExceptionFactory.*;
import static org.opends.server.util.ServerConstants.PROPERTY_SCRIPT_NAME;
import static org.opends.server.util.StaticUtils.*;
import static com.forgerock.opendj.cli.Utils.formatDateTimeStringForEquivalentCommand;
import static com.forgerock.opendj.cli.Utils.SHELL_COMMENT_SEPARATOR;
import static com.forgerock.opendj.cli.Utils.getCurrentOperationDateMessage;
import java.io.BufferedWriter;
import java.io.File;
@@ -44,6 +47,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -74,6 +78,7 @@
import org.opends.server.util.EmbeddedUtils;
import org.opends.server.util.ServerConstants;
import org.opends.server.util.StaticUtils;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.BooleanArgument;
import com.forgerock.opendj.cli.StringArgument;
@@ -81,13 +86,12 @@
import com.forgerock.opendj.cli.SubCommandArgumentParser;
import com.forgerock.opendj.cli.ArgumentGroup;
import com.forgerock.opendj.cli.ClientException;
import org.opends.server.util.cli.CommandBuilder;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.cli.Menu;
import org.opends.server.util.cli.MenuBuilder;
import org.opends.server.util.cli.MenuCallback;
import org.opends.server.util.cli.MenuResult;
import org.opends.server.util.cli.OutputStreamConsoleApplication;
import com.forgerock.opendj.cli.CommandBuilder;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.Menu;
import com.forgerock.opendj.cli.MenuBuilder;
import com.forgerock.opendj.cli.MenuCallback;
import com.forgerock.opendj.cli.MenuResult;
@@ -430,7 +434,7 @@
   */
  private DSConfig(InputStream in, OutputStream out, OutputStream err,
      ManagementContextFactory factory) {
    super(in, out, err);
    super(new PrintStream(out), new PrintStream(err));
    this.parser = new SubCommandArgumentParser(this.getClass().getName(),
        INFO_CONFIGDS_TOOL_DESCRIPTION.get(), false);
@@ -862,8 +866,8 @@
  // Run the top-level interactive console.
  private int runInteractiveMode() {
    // In interactive mode, redirect all output to stdout.
    ConsoleApplication app = new OutputStreamConsoleApplication(this);
    ConsoleApplication app = this;
    // Build menu structure.
    Comparator<RelationDefinition<?, ?>> c =
@@ -1256,7 +1260,7 @@
          fileArguments[ii] = fileArguments[ii].replace("##", " ");
        }
        printlnBatchProgress(displayCommand);
        errPrintln(LocalizableMessage.raw(displayCommand));
        // Append initial arguments to the file line
        List<String> allArguments = new ArrayList<String>();
@@ -1270,7 +1274,7 @@
          reader.close();
          System.exit(filterExitCode(exitCode));
        }
        printlnBatchProgress("");
        errPrintln();
      }
      reader.close();
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java
@@ -58,10 +58,10 @@
import com.forgerock.opendj.cli.SubCommandArgumentParser;
import com.forgerock.opendj.cli.ClientException;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.cli.MenuResult;
import org.opends.server.util.table.TableBuilder;
import org.opends.server.util.table.TextTablePrinter;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.MenuResult;
import com.forgerock.opendj.cli.TableBuilder;
import com.forgerock.opendj.cli.TextTablePrinter;
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/GetPropSubCommandHandler.java
@@ -70,11 +70,11 @@
import com.forgerock.opendj.cli.SubCommandArgumentParser;
import com.forgerock.opendj.cli.ClientException;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.cli.MenuResult;
import org.opends.server.util.table.TableBuilder;
import org.opends.server.util.table.TablePrinter;
import org.opends.server.util.table.TextTablePrinter;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.MenuResult;
import com.forgerock.opendj.cli.TableBuilder;
import com.forgerock.opendj.cli.TablePrinter;
import com.forgerock.opendj.cli.TextTablePrinter;
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java
@@ -70,12 +70,11 @@
import com.forgerock.opendj.cli.SubCommand;
import com.forgerock.opendj.cli.SubCommandArgumentParser;
import com.forgerock.opendj.cli.ClientException;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.cli.MenuResult;
import org.opends.server.util.cli.OutputStreamConsoleApplication;
import org.opends.server.util.table.TableBuilder;
import org.opends.server.util.table.TablePrinter;
import org.opends.server.util.table.TextTablePrinter;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.MenuResult;
import com.forgerock.opendj.cli.TableBuilder;
import com.forgerock.opendj.cli.TablePrinter;
import com.forgerock.opendj.cli.TextTablePrinter;
@@ -507,11 +506,11 @@
    // Display the property synopsis and description.
    app.println();
    app.printErrln(pd.getSynopsis(), 4);
    app.errPrintln(pd.getSynopsis(), 4);
    if (pd.getDescription() != null) {
      app.println();
      app.printErrln(pd.getDescription(), 4);
      app.errPrintln(pd.getDescription(), 4);
    }
    if (pd instanceof AggregationPropertyDefinition) {
@@ -922,7 +921,6 @@
    }
    // Output everything to the output stream.
    app = new OutputStreamConsoleApplication(app);
    if (!app.isVerbose()) {
      displayNonVerbose(app, categoryName, typeName, tag, propertyNames);
    } else {
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/InternalManagementContextFactory.java
@@ -32,8 +32,8 @@
import com.forgerock.opendj.cli.ClientException;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.SubCommandArgumentParser;
import org.opends.server.util.cli.CommandBuilder;
import org.opends.server.util.cli.ConsoleApplication;
import com.forgerock.opendj.cli.CommandBuilder;
import com.forgerock.opendj.cli.ConsoleApplication;
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java
@@ -45,8 +45,8 @@
import org.opends.server.tools.JavaPropertiesTool.ErrorReturnCode;
import org.opends.server.tools.ToolConstants;
import org.opends.server.util.cli.CommandBuilder;
import org.opends.server.util.cli.ConsoleApplication;
import com.forgerock.opendj.cli.CommandBuilder;
import com.forgerock.opendj.cli.ConsoleApplication;
import org.opends.server.util.cli.LDAPConnectionConsoleInteraction;
import com.forgerock.opendj.cli.Argument;
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ListSubCommandHandler.java
@@ -62,11 +62,11 @@
import com.forgerock.opendj.cli.SubCommandArgumentParser;
import com.forgerock.opendj.cli.ClientException;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.cli.MenuResult;
import org.opends.server.util.table.TableBuilder;
import org.opends.server.util.table.TablePrinter;
import org.opends.server.util.table.TextTablePrinter;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.MenuResult;
import com.forgerock.opendj.cli.TableBuilder;
import com.forgerock.opendj.cli.TablePrinter;
import com.forgerock.opendj.cli.TextTablePrinter;
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ManagementContextFactory.java
@@ -32,8 +32,8 @@
import com.forgerock.opendj.cli.ClientException;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.SubCommandArgumentParser;
import org.opends.server.util.cli.CommandBuilder;
import org.opends.server.util.cli.ConsoleApplication;
import com.forgerock.opendj.cli.CommandBuilder;
import com.forgerock.opendj.cli.ConsoleApplication;
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValueEditor.java
@@ -74,14 +74,14 @@
import com.forgerock.opendj.cli.ClientException;
import com.forgerock.opendj.cli.ReturnCode;
import org.opends.server.util.cli.HelpCallback;
import org.opends.server.util.cli.Menu;
import org.opends.server.util.cli.MenuBuilder;
import org.opends.server.util.cli.MenuCallback;
import org.opends.server.util.cli.MenuResult;
import org.opends.server.util.table.TableBuilder;
import org.opends.server.util.table.TextTablePrinter;
import org.opends.server.util.cli.ConsoleApplication;
import com.forgerock.opendj.cli.HelpCallback;
import com.forgerock.opendj.cli.Menu;
import com.forgerock.opendj.cli.MenuBuilder;
import com.forgerock.opendj.cli.MenuCallback;
import com.forgerock.opendj.cli.MenuResult;
import com.forgerock.opendj.cli.TableBuilder;
import com.forgerock.opendj.cli.TextTablePrinter;
import com.forgerock.opendj.cli.ConsoleApplication;
@@ -2001,10 +2001,10 @@
    app.println();
    app.println(INFO_EDITOR_HEADING_CONFIGURE_PROPERTY.get(pd.getName()));
    app.println();
    app.printErrln(pd.getSynopsis(), 4);
    app.errPrintln(pd.getSynopsis(), 4);
    if (pd.getDescription() != null) {
      app.println();
      app.printErrln(pd.getDescription(), 4);
      app.errPrintln(pd.getDescription(), 4);
    }
  }
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java
@@ -73,9 +73,9 @@
import com.forgerock.opendj.cli.SubCommandArgumentParser;
import com.forgerock.opendj.cli.ClientException;
import org.opends.server.util.cli.CommandBuilder;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.cli.MenuResult;
import com.forgerock.opendj.cli.CommandBuilder;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.MenuResult;
import com.forgerock.opendj.util.Pair;
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java
@@ -82,13 +82,13 @@
import com.forgerock.opendj.cli.SubCommand;
import com.forgerock.opendj.cli.ClientException;
import org.opends.server.util.cli.CommandBuilder;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.cli.Menu;
import org.opends.server.util.cli.MenuBuilder;
import org.opends.server.util.cli.MenuResult;
import org.opends.server.util.table.TabSeparatedTablePrinter;
import org.opends.server.util.table.TablePrinter;
import com.forgerock.opendj.cli.CommandBuilder;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.Menu;
import com.forgerock.opendj.cli.MenuBuilder;
import com.forgerock.opendj.cli.MenuResult;
import com.forgerock.opendj.cli.TabSeparatedTablePrinter;
import com.forgerock.opendj.cli.TablePrinter;
opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/LocalPurgeHistorical.java
@@ -44,7 +44,7 @@
import org.opends.server.util.EmbeddedUtils;
import org.opends.server.util.StaticUtils;
import org.opends.server.util.TimeThread;
import org.opends.server.util.cli.ConsoleApplication;
import com.forgerock.opendj.cli.ConsoleApplication;
import org.opends.server.util.cli.PointAdder;
/**
@@ -99,7 +99,7 @@
    long endMaxTime = startTime + purgeMaxTime;
    app.printProgress(formatter.getFormattedProgress(
    app.print(formatter.getFormattedProgress(
        INFO_REPLICATION_PURGE_HISTORICAL_LOCAL_ENVIRONMENT.get()));
    PointAdder pointAdder = new PointAdder(app);
@@ -145,12 +145,12 @@
      return ReplicationCliReturnCode.ERROR_LOCAL_PURGE_HISTORICAL_SERVER_START;
    }
    pointAdder.stop();
    app.printProgress(formatter.getFormattedDone());
    app.printlnProgress();
    app.printlnProgress();
    app.printProgress(formatter.getFormattedProgress(
    app.print(formatter.getFormattedDone());
    app.println();
    app.println();
    app.print(formatter.getFormattedProgress(
        INFO_REPLICATION_PURGE_HISTORICAL_LOCAL_STARTING.get()));
    app.printlnProgress();
    app.println();
    if (applyTimeout && timeoutOccurred(endMaxTime))
    {
opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java
@@ -35,6 +35,7 @@
import org.opends.admin.ads.ADSContext.ServerProperty;
import org.opends.admin.ads.util.ApplicationTrustManager;
import org.opends.admin.ads.util.ConnectionUtils;
import org.opends.admin.ads.util.OpendsCertificateException;
import org.opends.admin.ads.util.PreferredConnection;
import org.opends.admin.ads.util.ServerLoader;
import org.opends.guitools.controlpanel.datamodel.BackendDescriptor;
@@ -45,7 +46,6 @@
import org.opends.quicksetup.ApplicationException;
import org.opends.quicksetup.Constants;
import org.opends.quicksetup.Installation;
import org.opends.quicksetup.ReturnCode;
import org.opends.quicksetup.event.ProgressUpdateEvent;
import org.opends.quicksetup.event.ProgressUpdateListener;
import org.opends.quicksetup.installer.Installer;
@@ -53,7 +53,16 @@
import org.opends.quicksetup.installer.PeerNotFoundException;
import org.opends.quicksetup.installer.offline.OfflineInstaller;
import org.opends.quicksetup.util.PlainTextProgressMessageFormatter;
import org.opends.quicksetup.util.Utils;
import static org.opends.quicksetup.util.Utils.createLdapsContext;
import static org.opends.quicksetup.util.Utils.createStartTLSContext;
import static org.opends.quicksetup.util.Utils.areDnsEqual;
import static org.opends.quicksetup.util.Utils.isLocalHost;
import static org.opends.quicksetup.util.Utils.isCertificateException;
import static org.opends.quicksetup.util.Utils.getMessage;
import static org.opends.quicksetup.util.Utils.getMessageFromCollection;
import static org.opends.quicksetup.util.Utils.getServerClock;
import org.opends.server.admin.*;
import org.opends.server.admin.client.ManagementContext;
import org.opends.server.admin.client.ldap.JNDIDirContextAdaptor;
@@ -86,33 +95,52 @@
import com.forgerock.opendj.cli.ClientException;
import com.forgerock.opendj.cli.FileBasedArgument;
import com.forgerock.opendj.cli.IntegerArgument;
import com.forgerock.opendj.cli.CommandBuilder;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.ReturnCode;
import com.forgerock.opendj.cli.MenuBuilder;
import com.forgerock.opendj.cli.TabSeparatedTablePrinter;
import com.forgerock.opendj.cli.TableBuilder;
import com.forgerock.opendj.cli.TablePrinter;
import com.forgerock.opendj.cli.TextTablePrinter;
import com.forgerock.opendj.cli.MenuResult;
import com.forgerock.opendj.cli.ValidationCallback;
import org.opends.server.util.cli.CommandBuilder;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.cli.LDAPConnectionConsoleInteraction;
import org.opends.server.util.cli.MenuBuilder;
import org.opends.server.util.table.TabSeparatedTablePrinter;
import org.opends.server.util.table.TableBuilder;
import org.opends.server.util.table.TablePrinter;
import org.opends.server.util.table.TextTablePrinter;
import static com.forgerock.opendj.cli.CliMessages.ERR_BAD_INTEGER;
import static com.forgerock.opendj.cli.CliMessages.INFO_ADMINISTRATOR_PWD_PROMPT;
import static com.forgerock.opendj.cli.CliMessages.INFO_ADMINISTRATOR_UID_PROMPT;
import static com.forgerock.opendj.cli.CliMessages.INFO_PROMPT_SINGLE_DEFAULT;
import static com.forgerock.opendj.cli.Utils.CONFIRMATION_MAX_TRIES;
import static com.forgerock.opendj.cli.Utils.getCurrentOperationDateMessage;
import static com.forgerock.opendj.cli.Utils.getMessageForException;
import static com.forgerock.opendj.cli.Utils.SHELL_COMMENT_SEPARATOR;
import static org.forgerock.util.Utils.joinAsString;
import org.opends.server.util.cli.PointAdder;
import org.opends.server.util.cli.MenuResult;
import org.opends.server.util.cli.LDAPConnectionConsoleInteraction;
import javax.naming.NameAlreadyBoundException;
import javax.naming.NameNotFoundException;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.NoPermissionException;
import javax.naming.directory.*;
import javax.naming.ldap.InitialLdapContext;
import javax.net.ssl.KeyManager;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.TrustManager;
import java.io.*;
import java.util.*;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import static org.forgerock.util.Utils.*;
import static org.opends.admin.ads.ServerDescriptor.*;
import static org.opends.messages.AdminToolMessages.*;
import static org.opends.messages.DSConfigMessages.ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT;
import static org.opends.messages.DSConfigMessages.ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT_NOT_TRUSTED;
import static org.opends.messages.DSConfigMessages.ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT_WRONG_PORT;
import static org.opends.messages.QuickSetupMessages.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.messages.UtilityMessages.
@@ -237,7 +265,7 @@
   */
  public ReplicationCliMain(PrintStream out, PrintStream err, InputStream in)
  {
    super(in, out, err);
    super(out, err);
  }
  /**
@@ -582,6 +610,140 @@
    return returnValue.getReturnCode();
  }
  /**
   * Prompts the user to give the Global Administrator UID.
   *
   * @param defaultValue
   *          the default value that will be proposed in the prompt message.
   * @param logger
   *          the Logger to be used to log the error message.
   * @return the Global Administrator UID as provided by the user.
   */
  protected String askForAdministratorUID(String defaultValue,
      LocalizedLogger logger)
  {
    String s = defaultValue;
    try
    {
      s = readInput(INFO_ADMINISTRATOR_UID_PROMPT.get(), defaultValue);
    }
    catch (ClientException ce)
    {
      logger.warn(LocalizableMessage.raw("Error reading input: " + ce, ce));
    }
    return s;
  }
  /**
   * Prompts the user to give the Global Administrator password.
   *
   * @param logger
   *          the Logger to be used to log the error message.
   * @return the Global Administrator password as provided by the user.
   */
  protected String askForAdministratorPwd(LocalizedLogger logger)
  {
    String pwd = null;
    try
    {
      readPassword(INFO_ADMINISTRATOR_PWD_PROMPT.get());
    }
    catch (ClientException ex)
    {
      logger.warn(LocalizableMessage.raw("Error reading input: " + ex, ex));
    }
    return pwd;
  }
  /**
   * Commodity method used to repeatidly ask the user to provide an integer
   * value.
   *
   * @param prompt
   *          the prompt message.
   * @param defaultValue
   *          the default value to be proposed to the user.
   * @param logger
   *          the logger where the errors will be written.
   * @return the value provided by the user.
   */
  protected int askInteger(LocalizableMessage prompt, int defaultValue,
      LocalizedLogger logger)
  {
    int newInt = -1;
    while (newInt == -1)
    {
      try
      {
        newInt = readInteger(prompt, defaultValue);
      }
      catch (ClientException ce)
      {
        newInt = -1;
        logger.warn(LocalizableMessage.raw("Error reading input: " + ce, ce));
      }
    }
    return newInt;
  }
  /**
   * Interactively retrieves an integer value from the console.
   *
   * @param prompt
   *          The message prompt.
   * @param defaultValue
   *          The default value.
   * @return Returns the value.
   * @throws ClientException
   *           If the value could not be retrieved for some reason.
   */
  public final int readInteger(
      LocalizableMessage prompt, final int defaultValue) throws ClientException
  {
    ValidationCallback<Integer> callback = new ValidationCallback<Integer>()
    {
      @Override
      public Integer validate(ConsoleApplication app, String input)
          throws ClientException
      {
        String ninput = input.trim();
        if (ninput.length() == 0)
        {
          return defaultValue;
        }
        else
        {
          try
          {
            int i = Integer.parseInt(ninput);
            if (i < 1)
            {
              throw new NumberFormatException();
            }
            return i;
          }
          catch (NumberFormatException e)
          {
            // Try again...
            app.println();
            app.println(ERR_BAD_INTEGER.get(ninput));
            app.println();
            return null;
          }
        }
      }
    };
    if (defaultValue != -1)
    {
      prompt = INFO_PROMPT_SINGLE_DEFAULT.get(prompt, defaultValue);
    }
    return readValidatedInput(prompt, callback, CONFIRMATION_MAX_TRIES);
  }
  private boolean isFirstCallFromScript()
  {
    return FIRST_SCRIPT_CALL.equals(System.getProperty(SCRIPT_CALL_STATUS));
@@ -889,12 +1051,12 @@
  {
    String separator =  formatter.getLineBreak().toString() +
    formatter.getTab().toString();
    printlnProgress();
    println();
    LocalizableMessage msg = formatter.getFormattedProgress(
        INFO_PROGRESS_PURGE_HISTORICAL.get(separator,
            joinAsString(separator, uData.getBaseDNs())));
    printProgress(msg);
    printlnProgress();
    print(msg);
    println();
  }
@@ -988,6 +1150,278 @@
    }
  }
  /**
   * Returns an InitialLdapContext using the provided parameters. We try to
   * guarantee that the connection is able to read the configuration.
   *
   * @param host
   *          the host name.
   * @param port
   *          the port to connect.
   * @param useSSL
   *          whether to use SSL or not.
   * @param useStartTLS
   *          whether to use StartTLS or not.
   * @param bindDn
   *          the bind dn to be used.
   * @param pwd
   *          the password.
   * @param connectTimeout
   *          the timeout in milliseconds to connect to the server.
   * @param trustManager
   *          the trust manager.
   * @return an InitialLdapContext connected.
   * @throws NamingException
   *           if there was an error establishing the connection.
   */
  private InitialLdapContext createAdministrativeContext(String host,
      int port, boolean useSSL, boolean useStartTLS, String bindDn, String pwd,
      int connectTimeout, ApplicationTrustManager trustManager)
      throws NamingException
  {
    InitialLdapContext ctx;
    String ldapUrl = ConnectionUtils.getLDAPUrl(host, port, useSSL);
    if (useSSL)
    {
      ctx =
          createLdapsContext(ldapUrl, bindDn, pwd, connectTimeout, null,
              trustManager);
    }
    else if (useStartTLS)
    {
      ctx =
          createStartTLSContext(ldapUrl, bindDn, pwd, connectTimeout,
              null, trustManager, null);
    }
    else
    {
      ctx = ConnectionUtils.createLdapContext(ldapUrl, bindDn, pwd, connectTimeout, null);
    }
    if (!ConnectionUtils.connectedAsAdministrativeUser(ctx))
    {
      throw new NoPermissionException(ERR_NOT_ADMINISTRATIVE_USER.get()
          .toString());
    }
    return ctx;
  }
  /**
   * Creates an Initial LDAP Context interacting with the user if the
   * application is interactive.
   *
   * @param ci
   *          the LDAPConnectionConsoleInteraction object that is assumed to
   *          have been already run.
   * @return the initial LDAP context or <CODE>null</CODE> if the user did not
   *         accept to trust the certificates.
   * @throws ClientException
   *           if there was an error establishing the connection.
   */
  protected InitialLdapContext createInitialLdapContextInteracting(
      LDAPConnectionConsoleInteraction ci) throws ClientException
  {
    return createInitialLdapContextInteracting(ci, isInteractive()
        && ci.isTrustStoreInMemory());
  }
  private OpendsCertificateException getCertificateRootException(Throwable t)
  {
    OpendsCertificateException oce = null;
    while (t != null && oce == null)
    {
      t = t.getCause();
      if (t instanceof OpendsCertificateException)
      {
        oce = (OpendsCertificateException) t;
      }
    }
    return oce;
  }
  /**
   * Creates an Initial LDAP Context interacting with the user if the
   * application is interactive.
   *
   * @param ci
   *          the LDAPConnectionConsoleInteraction object that is assumed to
   *          have been already run.
   * @param promptForCertificate
   *          whether we should prompt for the certificate or not.
   * @return the initial LDAP context or <CODE>null</CODE> if the user did not
   *         accept to trust the certificates.
   * @throws ClientException
   *           if there was an error establishing the connection.
   */
  protected InitialLdapContext createInitialLdapContextInteracting(
      LDAPConnectionConsoleInteraction ci, boolean promptForCertificate)
      throws ClientException
  {
    // Interact with the user though the console to get
    // LDAP connection information
    String hostName = ConnectionUtils.getHostNameForLdapUrl(ci.getHostName());
    Integer portNumber = ci.getPortNumber();
    String bindDN = ci.getBindDN();
    String bindPassword = ci.getBindPassword();
    TrustManager trustManager = ci.getTrustManager();
    KeyManager keyManager = ci.getKeyManager();
    InitialLdapContext ctx;
    if (ci.useSSL())
    {
      String ldapsUrl = "ldaps://" + hostName + ":" + portNumber;
      while (true)
      {
        try
        {
          ctx =
              ConnectionUtils.createLdapsContext(ldapsUrl, bindDN,
                  bindPassword, ci.getConnectTimeout(), null, trustManager,
                  keyManager);
          ctx.reconnect(null);
          break;
        }
        catch (NamingException e)
        {
          if (promptForCertificate)
          {
            OpendsCertificateException oce = getCertificateRootException(e);
            if (oce != null)
            {
              String authType = null;
              if (trustManager instanceof ApplicationTrustManager)
              {
                ApplicationTrustManager appTrustManager =
                    (ApplicationTrustManager) trustManager;
                authType = appTrustManager.getLastRefusedAuthType();
              }
              if (ci.checkServerCertificate(oce.getChain(), authType, hostName))
              {
                // If the certificate is trusted, update the trust manager.
                trustManager = ci.getTrustManager();
                // Try to connect again.
                continue;
              }
              else
              {
                // Assume user canceled.
                return null;
              }
            }
          }
          if (e.getCause() != null)
          {
            if (!isInteractive() && !ci.isTrustAll())
            {
              if (getCertificateRootException(e) != null
                  || (e.getCause() instanceof SSLHandshakeException))
              {
                LocalizableMessage message =
                    ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT_NOT_TRUSTED.get(hostName, portNumber);
                throw new ClientException(
                    ReturnCode.CLIENT_SIDE_CONNECT_ERROR, message);
              }
            }
            if (e.getCause() instanceof SSLException)
            {
              LocalizableMessage message =
                  ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT_WRONG_PORT.get(hostName, portNumber);
              throw new ClientException(
                  ReturnCode.CLIENT_SIDE_CONNECT_ERROR, message);
            }
          }
          String hostPort =
              ServerDescriptor.getServerRepresentation(hostName, portNumber);
          LocalizableMessage message = getMessageForException(e, hostPort);
          throw new ClientException(ReturnCode.CLIENT_SIDE_CONNECT_ERROR,
              message);
        }
      }
    }
    else if (ci.useStartTLS())
    {
      String ldapUrl = "ldap://" + hostName + ":" + portNumber;
      while (true)
      {
        try
        {
          ctx =
              ConnectionUtils.createStartTLSContext(ldapUrl, bindDN,
                  bindPassword, ConnectionUtils.getDefaultLDAPTimeout(), null,
                  trustManager, keyManager, null);
          ctx.reconnect(null);
          break;
        }
        catch (NamingException e)
        {
          if (promptForCertificate)
          {
            OpendsCertificateException oce = getCertificateRootException(e);
            if (oce != null)
            {
              String authType = null;
              if (trustManager instanceof ApplicationTrustManager)
              {
                ApplicationTrustManager appTrustManager =
                    (ApplicationTrustManager) trustManager;
                authType = appTrustManager.getLastRefusedAuthType();
              }
              if (ci.checkServerCertificate(oce.getChain(), authType, hostName))
              {
                // If the certificate is trusted, update the trust manager.
                trustManager = ci.getTrustManager();
                // Try to connect again.
                continue;
              }
              else
              {
                // Assume user cancelled.
                return null;
              }
            }
            else
            {
              LocalizableMessage message =
                  ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT.get(hostName, portNumber);
              throw new ClientException(
                  ReturnCode.CLIENT_SIDE_CONNECT_ERROR, message);
            }
          }
          LocalizableMessage message =
              ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT.get(hostName, portNumber);
          throw new ClientException(ReturnCode.CLIENT_SIDE_CONNECT_ERROR,
              message);
        }
      }
    }
    else
    {
      String ldapUrl = "ldap://" + hostName + ":" + portNumber;
      while (true)
      {
        try
        {
          ctx =
              ConnectionUtils.createLdapContext(ldapUrl, bindDN, bindPassword,
                  ConnectionUtils.getDefaultLDAPTimeout(), null);
          ctx.reconnect(null);
          break;
        }
        catch (NamingException e)
        {
          LocalizableMessage message =
              ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT.get(hostName, portNumber);
          throw new ClientException(ReturnCode.CLIENT_SIDE_CONNECT_ERROR,
              message);
        }
      }
    }
    return ctx;
  }
  private ReplicationCliReturnCode purgeHistoricalRemotely(
      PurgeHistoricalUserData uData)
  {
@@ -1048,21 +1482,21 @@
  private void printSuccessMessage(PurgeHistoricalUserData uData, String taskID)
  {
    printlnProgress();
    println();
    if (!uData.isOnline())
    {
      printProgress(
      print(
          INFO_PROGRESS_PURGE_HISTORICAL_FINISHED_PROCEDURE.get());
    }
    else if (uData.getTaskSchedule().isStartNow())
    {
      printProgress(INFO_TASK_TOOL_TASK_SUCESSFULL.get(
      print(INFO_TASK_TOOL_TASK_SUCESSFULL.get(
          INFO_PURGE_HISTORICAL_TASK_NAME.get(),
          taskID));
    }
    else if (uData.getTaskSchedule().getStartDate() != null)
    {
      printProgress(INFO_TASK_TOOL_TASK_SCHEDULED_FUTURE.get(
      print(INFO_TASK_TOOL_TASK_SCHEDULED_FUTURE.get(
          INFO_PURGE_HISTORICAL_TASK_NAME.get(),
          taskID,
          StaticUtils.formatDateTimeString(
@@ -1070,12 +1504,12 @@
    }
    else
    {
      printProgress(INFO_TASK_TOOL_RECURRING_TASK_SCHEDULED.get(
      print(INFO_TASK_TOOL_RECURRING_TASK_SCHEDULED.get(
          INFO_PURGE_HISTORICAL_TASK_NAME.get(),
          taskID));
    }
    printlnProgress();
    println();
  }
  /**
@@ -1347,7 +1781,7 @@
        boolean found = false;
        for (String dn1 : availableSuffixes)
        {
          if (Utils.areDnsEqual(dn, dn1))
          if (areDnsEqual(dn, dn1))
          {
            found = true;
            break;
@@ -1358,7 +1792,7 @@
          boolean notReplicated = false;
          for (String s : notReplicatedSuffixes)
          {
            if (Utils.areDnsEqual(s, dn))
            if (areDnsEqual(s, dn))
            {
              notReplicated = true;
              break;
@@ -1390,9 +1824,9 @@
          boolean noSchemaOrAds = false;
          for (String s: availableSuffixes)
          {
            if (!Utils.areDnsEqual(s, ADSContext.getAdministrationSuffixDN()) &&
                !Utils.areDnsEqual(s, Constants.SCHEMA_DN) &&
                !Utils.areDnsEqual(s, Constants.REPLICATION_CHANGES_DN))
            if (!areDnsEqual(s, ADSContext.getAdministrationSuffixDN()) &&
                !areDnsEqual(s, Constants.SCHEMA_DN) &&
                !areDnsEqual(s, Constants.REPLICATION_CHANGES_DN))
            {
              noSchemaOrAds = true;
            }
@@ -1411,10 +1845,10 @@
            println(ERR_NO_SUFFIXES_SELECTED_TO_PURGE_HISTORICAL.get());
            for (String dn : availableSuffixes)
            {
              if (!Utils.areDnsEqual(dn,
              if (!areDnsEqual(dn,
                  ADSContext.getAdministrationSuffixDN()) &&
                  !Utils.areDnsEqual(dn, Constants.SCHEMA_DN) &&
                  !Utils.areDnsEqual(dn, Constants.REPLICATION_CHANGES_DN))
                  !areDnsEqual(dn, Constants.SCHEMA_DN) &&
                  !areDnsEqual(dn, Constants.REPLICATION_CHANGES_DN))
              {
                try
                {
@@ -1510,7 +1944,7 @@
        {
          try
          {
            printlnProgress();
            println();
            promptForConnection =
              !askConfirmation(
                  INFO_REPLICATION_PURGE_HISTORICAL_LOCAL_PROMPT.get(),
@@ -1583,7 +2017,7 @@
      /* Prompt for maximum duration */
      if (!argParser.maximumDurationArg.isPresent())
      {
        printlnProgress();
        println();
        maximumDuration = askInteger(
            INFO_REPLICATION_PURGE_HISTORICAL_MAXIMUM_DURATION_PROMPT.get(),
            argParser.getDefaultMaximumDuration(), logger);
@@ -1825,7 +2259,7 @@
                argParser.getDefaultReplicationPort1(), logger);
            println();
          }
          if (!argParser.skipReplicationPortCheck() && Utils.isLocalHost(host1))
          if (!argParser.skipReplicationPortCheck() && isLocalHost(host1))
          {
            if (!SetupUtils.canUseAsPort(replicationPort1))
            {
@@ -1906,7 +2340,7 @@
    uData.setSecureReplication1(secureReplication1);
    uData.setConfigureReplicationServer1(configureReplicationServer1);
    uData.setConfigureReplicationDomain1(configureReplicationDomain1);
    firstServerCommandBuilder = new CommandBuilder(null);
    firstServerCommandBuilder = new CommandBuilder(null, null);
    if (mustPrintCommandBuilder())
    {
      firstServerCommandBuilder.append(ci.getCommandBuilder());
@@ -2115,7 +2549,7 @@
              println();
            }
            if (!argParser.skipReplicationPortCheck() &&
                Utils.isLocalHost(host2))
                isLocalHost(host2))
            {
              if (!SetupUtils.canUseAsPort(replicationPort2))
              {
@@ -2257,8 +2691,18 @@
        String adminPwdConfirm = null;
        while (adminPwdConfirm == null)
        {
          adminPwdConfirm =
          readPassword(INFO_ADMINISTRATOR_PWD_CONFIRM_PROMPT.get(), logger);
          try
          {
            adminPwdConfirm =
                String
                    .valueOf(readPassword(INFO_ADMINISTRATOR_PWD_CONFIRM_PROMPT
                        .get()));
          }
          catch (ClientException ex)
          {
            logger.warn(LocalizableMessage
                .raw("Error reading input: " + ex, ex));
          }
          println();
        }
        if (!adminPwd.equals(adminPwdConfirm))
@@ -2471,11 +2915,11 @@
      boolean disableSchema = false;
      for (String dn : uData.getBaseDNs())
      {
        if (Utils.areDnsEqual(ADSContext.getAdministrationSuffixDN(), dn))
        if (areDnsEqual(ADSContext.getAdministrationSuffixDN(), dn))
        {
          disableADS = true;
        }
        else if (Utils.areDnsEqual(Constants.SCHEMA_DN, dn))
        else if (areDnsEqual(Constants.SCHEMA_DN, dn))
        {
          disableSchema = true;
        }
@@ -2620,7 +3064,7 @@
      boolean initializeADS = false;
      for (String dn : uData.getBaseDNs())
      {
        if (Utils.areDnsEqual(ADSContext.getAdministrationSuffixDN(), dn))
        if (areDnsEqual(ADSContext.getAdministrationSuffixDN(), dn))
        {
          initializeADS = true;
        }
@@ -2999,7 +3443,7 @@
      uData.setAdminPwd(adminPwd);
    }
    firstServerCommandBuilder = new CommandBuilder(null);
    firstServerCommandBuilder = new CommandBuilder(null, null);
    if (mustPrintCommandBuilder())
    {
      firstServerCommandBuilder.append(ci.getCommandBuilder());
@@ -3094,7 +3538,7 @@
      boolean initializeADS = false;
      for (String dn : uData.getBaseDNs())
      {
        if (Utils.areDnsEqual(ADSContext.getAdministrationSuffixDN(), dn))
        if (areDnsEqual(ADSContext.getAdministrationSuffixDN(), dn))
        {
          initializeADS = true;
          break;
@@ -3684,7 +4128,7 @@
              break;
            case GENERIC_CREATING_CONNECTION:
              if ((e.getCause() != null) &&
                  Utils.isCertificateException(e.getCause()))
                  isCertificateException(e.getCause()))
              {
                reloadTopology = true;
                cancelled = !ci.promptForCertificateConfirmation(e.getCause(),
@@ -3692,11 +4136,11 @@
              }
              else
              {
                exceptionMsgs.add(Utils.getMessage(e));
                exceptionMsgs.add(getMessage(e));
              }
              break;
            default:
              exceptionMsgs.add(Utils.getMessage(e));
              exceptionMsgs.add(getMessage(e));
            }
          }
        }
@@ -3706,7 +4150,7 @@
          {
            println(
                ERR_REPLICATION_STATUS_READING_REGISTERED_SERVERS.get(
                    Utils.getMessageFromCollection(exceptionMsgs,
                    getMessageFromCollection(exceptionMsgs,
                        Constants.LINE_SEPARATOR)));
            println();
          }
@@ -3716,7 +4160,7 @@
            {
              cancelled = !askConfirmation(
              ERR_REPLICATION_READING_REGISTERED_SERVERS_CONFIRM_UPDATE_REMOTE.
                  get(Utils.getMessageFromCollection(exceptionMsgs,
                  get(getMessageFromCollection(exceptionMsgs,
                      Constants.LINE_SEPARATOR)), true, logger);
            }
            catch (ClientException ce)
@@ -3859,7 +4303,7 @@
          {
          case NOT_REPLICATED:
            if (!areReplicated(rep1, rep2) &&
                Utils.areDnsEqual(rep1.getSuffix().getDN(),
                areDnsEqual(rep1.getSuffix().getDN(),
                    rep2.getSuffix().getDN()))
            {
              suffixes.add(rep1.getSuffix().getDN());
@@ -3879,14 +4323,14 @@
            break;
          case NOT_FULLY_REPLICATED:
            if (!areFullyReplicated(rep1, rep2) &&
                Utils.areDnsEqual(rep1.getSuffix().getDN(),
                areDnsEqual(rep1.getSuffix().getDN(),
                    rep2.getSuffix().getDN()))
            {
              suffixes.add(rep1.getSuffix().getDN());
            }
            break;
          case ALL:
            if (Utils.areDnsEqual(rep1.getSuffix().getDN(),
            if (areDnsEqual(rep1.getSuffix().getDN(),
                rep2.getSuffix().getDN()))
            {
              suffixes.add(rep1.getSuffix().getDN());
@@ -3921,7 +4365,7 @@
      ReplicaDescriptor rep2)
  {
    boolean areFullyReplicated = false;
    if (Utils.areDnsEqual(rep1.getSuffix().getDN(), rep2.getSuffix().getDN()) &&
    if (areDnsEqual(rep1.getSuffix().getDN(), rep2.getSuffix().getDN()) &&
        rep1.isReplicated() && rep2.isReplicated() &&
        rep1.getServer().isReplicationServer() &&
        rep2.getServer().isReplicationServer())
@@ -3948,7 +4392,7 @@
  private boolean areReplicated(ReplicaDescriptor rep1, ReplicaDescriptor rep2)
  {
    boolean areReplicated = false;
    if (Utils.areDnsEqual(rep1.getSuffix().getDN(), rep2.getSuffix().getDN()) &&
    if (areDnsEqual(rep1.getSuffix().getDN(), rep2.getSuffix().getDN()) &&
        rep1.isReplicated() && rep2.isReplicated())
    {
      Set<String> servers1 = rep1.getReplicationServers();
@@ -4007,8 +4451,8 @@
    LinkedList<LocalizableMessage> errorMessages = new LinkedList<LocalizableMessage>();
    printlnProgress();
    printProgress(
    println();
    print(
        formatter.getFormattedWithPoints(INFO_REPLICATION_CONNECTING.get()));
    try
    {
@@ -4045,8 +4489,8 @@
    if (errorMessages.isEmpty())
    {
      // This done is for the message informing that we are connecting.
      printProgress(formatter.getFormattedDone());
      printlnProgress();
      print(formatter.getFormattedDone());
      println();
//    If we are not in interactive mode do some checks...
      if (!argParser.isInteractive())
@@ -4069,7 +4513,7 @@
        {
          if (!argParser.skipReplicationPortCheck() &&
              uData.configureReplicationServer1() &&
              Utils.isLocalHost(host1) &&
              isLocalHost(host1) &&
              !SetupUtils.canUseAsPort(replPort1))
          {
            errorMessages.add(getCannotBindToPortError(replPort1));
@@ -4079,7 +4523,7 @@
        {
          if (!argParser.skipReplicationPortCheck() &&
              uData.configureReplicationServer2() &&
              Utils.isLocalHost(host2) &&
              isLocalHost(host2) &&
              !SetupUtils.canUseAsPort(replPort2))
          {
            errorMessages.add(getCannotBindToPortError(replPort2));
@@ -4187,8 +4631,8 @@
    if (returnValue == SUCCESSFUL)
    {
      long time1 = Utils.getServerClock(ctx1);
      long time2 = Utils.getServerClock(ctx2);
      long time1 = getServerClock(ctx1);
      long time2 = getServerClock(ctx2);
      if ((time1 != -1) && (time2 != -1))
      {
        if (Math.abs(time1 - time2) >
@@ -4200,10 +4644,10 @@
              Installer.THRESHOLD_CLOCK_DIFFERENCE_WARNING));
        }
      }
      printlnProgress();
      printProgress(INFO_REPLICATION_POST_ENABLE_INFO.get("dsreplication",
      println();
      println(INFO_REPLICATION_POST_ENABLE_INFO.get("dsreplication",
          ReplicationCliArgumentParser.INITIALIZE_REPLICATION_SUBCMD_NAME));
      printlnProgress();
      println();
    }
    close(ctx1, ctx2);
@@ -4223,7 +4667,7 @@
  {
    ReplicationCliReturnCode returnValue;
    InitialLdapContext ctx = null;
    printProgress(
    print(
        formatter.getFormattedWithPoints(INFO_REPLICATION_CONNECTING.get()));
    String bindDn = uData.getAdminUid() == null ? uData.getBindDn() :
      ADSContext.getAdministratorDN(uData.getAdminUid());
@@ -4245,8 +4689,8 @@
    if (ctx != null)
    {
      // This done is for the message informing that we are connecting.
      printProgress(formatter.getFormattedDone());
      printlnProgress();
      print(formatter.getFormattedDone());
      println();
      List<String> suffixes = uData.getBaseDNs();
      checkSuffixesForDisableReplication(suffixes, ctx, false,
          !uData.disableReplicationServer(), !uData.disableReplicationServer());
@@ -4437,12 +4881,12 @@
        {
          try
          {
            printlnProgress();
            println();
            LocalizableMessage msg = formatter.getFormattedProgress(
                INFO_PROGRESS_INITIALIZING_SUFFIX.get(baseDN,
                    ConnectionUtils.getHostPort(ctxSource)));
            printProgress(msg);
            printlnProgress();
            print(msg);
            println();
            initializeSuffix(baseDN, ctxSource, ctxDestination, true);
            returnValue = SUCCESSFUL;
          }
@@ -4491,7 +4935,7 @@
    {
      final String hostPort = getServerRepresentation(host, port);
      println();
      println(Utils.getMessageForException(ne, hostPort));
      println(getMessageForException(ne, hostPort));
      logger.error(LocalizableMessage.raw("Complete error stack:"), ne);
    }
    return context;
@@ -4552,11 +4996,11 @@
        {
          try
          {
            printlnProgress();
            println();
            LocalizableMessage msg = formatter.getFormattedProgress(
                INFO_PROGRESS_INITIALIZING_SUFFIX.get(baseDN,
                    ConnectionUtils.getHostPort(ctx)));
            printProgress(msg);
            print(msg);
            println();
            initializeAllSuffix(baseDN, ctx, true);
            returnValue = SUCCESSFUL;
@@ -4640,13 +5084,13 @@
        {
          try
          {
            printlnProgress();
            println();
            LocalizableMessage msg = formatter.getFormattedWithPoints(
                INFO_PROGRESS_PRE_EXTERNAL_INITIALIZATION.get(baseDN));
            printProgress(msg);
            print(msg);
            preExternalInitialization(baseDN, ctx, false);
            printProgress(formatter.getFormattedDone());
            printlnProgress();
            print(formatter.getFormattedDone());
            println();
          }
          catch (ReplicationCliException rce)
          {
@@ -4656,12 +5100,12 @@
            logger.error(LocalizableMessage.raw("Complete error stack:"), rce);
          }
        }
        printlnProgress();
        printProgress(
        println();
        print(
          INFO_PROGRESS_PRE_INITIALIZATION_FINISHED_PROCEDURE.get(
              ReplicationCliArgumentParser.
              POST_EXTERNAL_INITIALIZATION_SUBCMD_NAME));
        printlnProgress();
        println();
      }
      else
      {
@@ -4729,13 +5173,13 @@
        {
          try
          {
            printlnProgress();
            println();
            LocalizableMessage msg = formatter.getFormattedWithPoints(
                INFO_PROGRESS_POST_EXTERNAL_INITIALIZATION.get(baseDN));
            printProgress(msg);
            print(msg);
            postExternalInitialization(baseDN, ctx, false);
            printProgress(formatter.getFormattedDone());
            printlnProgress();
            println(formatter.getFormattedDone());
            println();
          }
          catch (ReplicationCliException rce)
          {
@@ -4745,10 +5189,10 @@
            logger.error(LocalizableMessage.raw("Complete error stack:"), rce);
          }
        }
        printlnProgress();
        printProgress(
        println();
        print(
            INFO_PROGRESS_POST_INITIALIZATION_FINISHED_PROCEDURE.get());
        printlnProgress();
        println();
      }
      else
      {
@@ -4840,7 +5284,7 @@
      {
        for (String s2 : alreadyReplicatedSuffixes)
        {
          if (Utils.areDnsEqual(s1, s2))
          if (areDnsEqual(s1, s2))
          {
            userProvidedReplicatedSuffixes.add(s1);
          }
@@ -4864,7 +5308,7 @@
        boolean found = false;
        for (String dn1 : availableSuffixes)
        {
          if (Utils.areDnsEqual(dn, dn1))
          if (areDnsEqual(dn, dn1))
          {
            found = true;
            break;
@@ -4875,7 +5319,7 @@
          boolean isReplicated = false;
          for (String s : alreadyReplicatedSuffixes)
          {
            if (Utils.areDnsEqual(s, dn))
            if (areDnsEqual(s, dn))
            {
              isReplicated = true;
              break;
@@ -4913,9 +5357,9 @@
          boolean noSchemaOrAds = false;
          for (String s: availableSuffixes)
          {
            if (!Utils.areDnsEqual(s, ADSContext.getAdministrationSuffixDN()) &&
                !Utils.areDnsEqual(s, Constants.SCHEMA_DN) &&
                !Utils.areDnsEqual(s, Constants.REPLICATION_CHANGES_DN))
            if (!areDnsEqual(s, ADSContext.getAdministrationSuffixDN()) &&
                !areDnsEqual(s, Constants.SCHEMA_DN) &&
                !areDnsEqual(s, Constants.REPLICATION_CHANGES_DN))
            {
              noSchemaOrAds = true;
            }
@@ -4935,10 +5379,10 @@
            println(ERR_NO_SUFFIXES_SELECTED_TO_REPLICATE.get());
            for (String dn : availableSuffixes)
            {
              if (!Utils.areDnsEqual(dn,
              if (!areDnsEqual(dn,
                  ADSContext.getAdministrationSuffixDN()) &&
                  !Utils.areDnsEqual(dn, Constants.SCHEMA_DN) &&
                  !Utils.areDnsEqual(dn, Constants.REPLICATION_CHANGES_DN))
                  !areDnsEqual(dn, Constants.SCHEMA_DN) &&
                  !areDnsEqual(dn, Constants.REPLICATION_CHANGES_DN))
              {
                try
                {
@@ -5015,7 +5459,7 @@
      {
        for (String s2 : notReplicatedSuffixes)
        {
          if (Utils.areDnsEqual(s1, s2))
          if (areDnsEqual(s1, s2))
          {
            userProvidedNotReplicatedSuffixes.add(s1);
          }
@@ -5039,7 +5483,7 @@
        boolean found = false;
        for (String dn1 : availableSuffixes)
        {
          if (Utils.areDnsEqual(dn, dn1))
          if (areDnsEqual(dn, dn1))
          {
            found = true;
            break;
@@ -5050,7 +5494,7 @@
          boolean notReplicated = false;
          for (String s : notReplicatedSuffixes)
          {
            if (Utils.areDnsEqual(s, dn))
            if (areDnsEqual(s, dn))
            {
              notReplicated = true;
              break;
@@ -5088,9 +5532,9 @@
          boolean noSchemaOrAds = false;
          for (String s: availableSuffixes)
          {
            if (!Utils.areDnsEqual(s, ADSContext.getAdministrationSuffixDN()) &&
                !Utils.areDnsEqual(s, Constants.SCHEMA_DN) &&
                !Utils.areDnsEqual(s, Constants.REPLICATION_CHANGES_DN))
            if (!areDnsEqual(s, ADSContext.getAdministrationSuffixDN()) &&
                !areDnsEqual(s, Constants.SCHEMA_DN) &&
                !areDnsEqual(s, Constants.REPLICATION_CHANGES_DN))
            {
              noSchemaOrAds = true;
            }
@@ -5115,10 +5559,10 @@
            }
            for (String dn : availableSuffixes)
            {
              if (!Utils.areDnsEqual(dn,
              if (!areDnsEqual(dn,
                  ADSContext.getAdministrationSuffixDN()) &&
                  !Utils.areDnsEqual(dn, Constants.SCHEMA_DN) &&
                  !Utils.areDnsEqual(dn, Constants.REPLICATION_CHANGES_DN))
                  !areDnsEqual(dn, Constants.SCHEMA_DN) &&
                  !areDnsEqual(dn, Constants.REPLICATION_CHANGES_DN))
              {
                try
                {
@@ -5200,7 +5644,7 @@
      {
        for (String s2 : notReplicatedSuffixes)
        {
          if (Utils.areDnsEqual(s1, s2))
          if (areDnsEqual(s1, s2))
          {
            userProvidedNotReplicatedSuffixes.add(s1);
          }
@@ -5224,7 +5668,7 @@
        boolean found = false;
        for (String dn1 : availableSuffixes)
        {
          if (Utils.areDnsEqual(dn, dn1))
          if (areDnsEqual(dn, dn1))
          {
            found = true;
            break;
@@ -5235,7 +5679,7 @@
          boolean notReplicated = false;
          for (String s : notReplicatedSuffixes)
          {
            if (Utils.areDnsEqual(s, dn))
            if (areDnsEqual(s, dn))
            {
              notReplicated = true;
              break;
@@ -5273,9 +5717,9 @@
          boolean noSchemaOrAds = false;
          for (String s: availableSuffixes)
          {
            if (!Utils.areDnsEqual(s, ADSContext.getAdministrationSuffixDN()) &&
                !Utils.areDnsEqual(s, Constants.SCHEMA_DN) &&
                !Utils.areDnsEqual(s, Constants.REPLICATION_CHANGES_DN))
            if (!areDnsEqual(s, ADSContext.getAdministrationSuffixDN()) &&
                !areDnsEqual(s, Constants.SCHEMA_DN) &&
                !areDnsEqual(s, Constants.REPLICATION_CHANGES_DN))
            {
              noSchemaOrAds = true;
            }
@@ -5316,10 +5760,10 @@
            }
            for (String dn : availableSuffixes)
            {
              if (!Utils.areDnsEqual(dn,
              if (!areDnsEqual(dn,
                  ADSContext.getAdministrationSuffixDN()) &&
                  !Utils.areDnsEqual(dn, Constants.SCHEMA_DN) &&
                  !Utils.areDnsEqual(dn, Constants.REPLICATION_CHANGES_DN))
                  !areDnsEqual(dn, Constants.SCHEMA_DN) &&
                  !areDnsEqual(dn, Constants.REPLICATION_CHANGES_DN))
              {
                boolean addSuffix;
                try
@@ -5399,7 +5843,7 @@
        boolean found = false;
        for (String dn1 : availableSuffixes)
        {
          if (Utils.areDnsEqual(dn, dn1))
          if (areDnsEqual(dn, dn1))
          {
            found = true;
            break;
@@ -5425,9 +5869,9 @@
          boolean noSchemaOrAds = false;
          for (String s: availableSuffixes)
          {
            if (!Utils.areDnsEqual(s, ADSContext.getAdministrationSuffixDN()) &&
                !Utils.areDnsEqual(s, Constants.SCHEMA_DN) &&
                !Utils.areDnsEqual(s, Constants.REPLICATION_CHANGES_DN))
            if (!areDnsEqual(s, ADSContext.getAdministrationSuffixDN()) &&
                !areDnsEqual(s, Constants.SCHEMA_DN) &&
                !areDnsEqual(s, Constants.REPLICATION_CHANGES_DN))
            {
              noSchemaOrAds = true;
            }
@@ -5447,10 +5891,10 @@
            for (String dn : availableSuffixes)
            {
              if (!Utils.areDnsEqual(dn,
              if (!areDnsEqual(dn,
                  ADSContext.getAdministrationSuffixDN()) &&
                  !Utils.areDnsEqual(dn, Constants.SCHEMA_DN) &&
                  !Utils.areDnsEqual(dn, Constants.REPLICATION_CHANGES_DN))
                  !areDnsEqual(dn, Constants.SCHEMA_DN) &&
                  !areDnsEqual(dn, Constants.REPLICATION_CHANGES_DN))
              {
                try
                {
@@ -5589,7 +6033,7 @@
      if (!messages.isEmpty())
      {
        println(ERR_REPLICATION_READING_REGISTERED_SERVERS_WARNING.get(
                Utils.getMessageFromCollection(messages,
                getMessageFromCollection(messages,
                    Constants.LINE_SEPARATOR)));
      }
    }
@@ -5651,7 +6095,7 @@
    boolean adsAlreadyReplicated = false;
    boolean adsMergeDone = false;
    printProgress(formatter.getFormattedWithPoints(
    print(formatter.getFormattedWithPoints(
        INFO_REPLICATION_ENABLE_UPDATING_ADS_CONTENTS.get()));
    try
    {
@@ -5700,8 +6144,8 @@
        }
        else if (!areEqual(registry1, registry2))
        {
          printProgress(formatter.getFormattedDone());
          printlnProgress();
          print(formatter.getFormattedDone());
          println();
          boolean isFirstSource = mergeRegistries(adsCtx1, adsCtx2);
          if (isFirstSource)
@@ -5731,8 +6175,8 @@
            if (isADS1Replicated && isADS2Replicated)
            {
              // Merge
              printProgress(formatter.getFormattedDone());
              printlnProgress();
              print(formatter.getFormattedDone());
              println();
              boolean isFirstSource = mergeRegistries(adsCtx1, adsCtx2);
              if (isFirstSource)
@@ -5876,8 +6320,8 @@
    }
    if (!adsMergeDone)
    {
      printProgress(formatter.getFormattedDone());
      printlnProgress();
      print(formatter.getFormattedDone());
      println();
    }
    List<String> baseDNs = uData.getBaseDNs();
    if (!adsAlreadyReplicated)
@@ -5885,7 +6329,7 @@
      boolean found = false;
      for (String dn : baseDNs)
      {
        if (Utils.areDnsEqual(dn, ADSContext.getAdministrationSuffixDN()))
        if (areDnsEqual(dn, ADSContext.getAdministrationSuffixDN()))
        {
          found = true;
          break;
@@ -6106,7 +6550,7 @@
      Set<String> alreadyConfiguredServers = new HashSet<String>();
      if (uData.configureReplicationDomain1() ||
          Utils.areDnsEqual(baseDN, ADSContext.getAdministrationSuffixDN()))
          areDnsEqual(baseDN, ADSContext.getAdministrationSuffixDN()))
      {
        try
        {
@@ -6123,7 +6567,7 @@
      alreadyConfiguredServers.add(server1.getId());
      if (uData.configureReplicationDomain2() ||
          Utils.areDnsEqual(baseDN, ADSContext.getAdministrationSuffixDN()))
          areDnsEqual(baseDN, ADSContext.getAdministrationSuffixDN()))
      {
        try
        {
@@ -6160,7 +6604,7 @@
    if (adsMergeDone)
    {
      PointAdder pointAdder = new PointAdder(this);
      printProgress(
      print(
          INFO_ENABLE_REPLICATION_INITIALIZING_ADS_ALL.get(
              ConnectionUtils.getHostPort(ctxSource)));
      pointAdder.start();
@@ -6173,21 +6617,21 @@
      {
        pointAdder.stop();
      }
      printProgress(formatter.getSpace());
      printProgress(formatter.getFormattedDone());
      printlnProgress();
      print(formatter.getSpace());
      print(formatter.getFormattedDone());
      println();
    }
    else if ((ctxSource != null) && (ctxDestination != null))
    {
      printProgress(formatter.getFormattedWithPoints(
      print(formatter.getFormattedWithPoints(
          INFO_ENABLE_REPLICATION_INITIALIZING_ADS.get(
              ConnectionUtils.getHostPort(ctxDestination),
              ConnectionUtils.getHostPort(ctxSource))));
      initializeSuffix(ADSContext.getAdministrationSuffixDN(), ctxSource,
          ctxDestination, false);
      printProgress(formatter.getFormattedDone());
      printlnProgress();
      print(formatter.getFormattedDone());
      println();
    }
    // If we must initialize the schema do so.
@@ -6206,7 +6650,7 @@
      if (adsMergeDone)
      {
        PointAdder pointAdder = new PointAdder(this);
        printProgress(
        println(
            INFO_ENABLE_REPLICATION_INITIALIZING_SCHEMA.get(
                ConnectionUtils.getHostPort(ctxDestination),
                ConnectionUtils.getHostPort(ctxSource)));
@@ -6219,19 +6663,19 @@
        {
          pointAdder.stop();
        }
        printProgress(formatter.getSpace());
        print(formatter.getSpace());
      }
      else
      {
        printProgress(formatter.getFormattedWithPoints(
        print(formatter.getFormattedWithPoints(
            INFO_ENABLE_REPLICATION_INITIALIZING_SCHEMA.get(
                ConnectionUtils.getHostPort(ctxDestination),
                ConnectionUtils.getHostPort(ctxSource))));
        initializeSuffix(Constants.SCHEMA_DN, ctxSource,
          ctxDestination, false);
      }
      printProgress(formatter.getFormattedDone());
      printlnProgress();
      print(formatter.getFormattedDone());
      println();
    }
  }
@@ -6317,7 +6761,7 @@
      {
        println(
            ERR_REPLICATION_READING_REGISTERED_SERVERS_WARNING.get(
                Utils.getMessageFromCollection(messages,
                getMessageFromCollection(messages,
                    Constants.LINE_SEPARATOR)));
      }
    }
@@ -6343,9 +6787,9 @@
      for (SuffixDescriptor suffix : cache.getSuffixes())
      {
        if (Utils.areDnsEqual(suffix.getDN(),
        if (areDnsEqual(suffix.getDN(),
            ADSContext.getAdministrationSuffixDN()) ||
            Utils.areDnsEqual(suffix.getDN(), Constants.SCHEMA_DN))
            areDnsEqual(suffix.getDN(), Constants.SCHEMA_DN))
        {
          // Do not display these suffixes.
          continue;
@@ -6384,9 +6828,9 @@
        Set<String> baseDNs = new LinkedHashSet<String>();
        for (SuffixDescriptor suffix : beforeLastRepServer)
        {
          if (!Utils.areDnsEqual(suffix.getDN(),
          if (!areDnsEqual(suffix.getDN(),
              ADSContext.getAdministrationSuffixDN()) &&
              !Utils.areDnsEqual(suffix.getDN(), Constants.SCHEMA_DN))
              !areDnsEqual(suffix.getDN(), Constants.SCHEMA_DN))
          {
            // Do not display these suffixes.
            baseDNs.add(suffix.getDN());
@@ -6432,14 +6876,14 @@
          boolean baseDNSpecified = false;
          for (String baseDN : uData.getBaseDNs())
          {
            if (Utils.areDnsEqual(baseDN,
            if (areDnsEqual(baseDN,
                ADSContext.getAdministrationSuffixDN()) ||
                Utils.areDnsEqual(baseDN, Constants.SCHEMA_DN))
                areDnsEqual(baseDN, Constants.SCHEMA_DN))
            {
              // Do not display these suffixes.
              continue;
            }
            if (Utils.areDnsEqual(baseDN, suffix.getDN()))
            if (areDnsEqual(baseDN, suffix.getDN()))
            {
              baseDNSpecified = true;
              break;
@@ -6526,11 +6970,11 @@
      String dn = rep.getSuffix().getDN();
      if (rep.isReplicated())
      {
        if (Utils.areDnsEqual(ADSContext.getAdministrationSuffixDN(), dn))
        if (areDnsEqual(ADSContext.getAdministrationSuffixDN(), dn))
        {
          adsReplicated = true;
        }
        else if (Utils.areDnsEqual(Constants.SCHEMA_DN, dn))
        else if (areDnsEqual(Constants.SCHEMA_DN, dn))
        {
          schemaReplicated = true;
        }
@@ -6593,12 +7037,12 @@
      }
      for (String dn : uData.getBaseDNs())
      {
        if (Utils.areDnsEqual(ADSContext.getAdministrationSuffixDN(), dn))
        if (areDnsEqual(ADSContext.getAdministrationSuffixDN(), dn))
        {
          // The user already asked this to be explicitly disabled
          forceDisableADS = false;
        }
        else if (Utils.areDnsEqual(Constants.SCHEMA_DN, dn))
        else if (areDnsEqual(Constants.SCHEMA_DN, dn))
        {
          // The user already asked this to be explicitly disabled
          forceDisableSchema = false;
@@ -6715,11 +7159,11 @@
      try
      {
        // Delete all contents from ADSContext.
        printProgress(formatter.getFormattedWithPoints(
        print(formatter.getFormattedWithPoints(
            INFO_REPLICATION_REMOVE_ADS_CONTENTS.get()));
        adsCtx.removeAdminData(false /* avoid self-disconnect */);
        printProgress(formatter.getFormattedDone());
        printlnProgress();
        print(formatter.getFormattedDone());
        println();
      }
      catch (ADSContextException adce)
      {
@@ -6817,7 +7261,7 @@
      {
        LocalizableMessage msg =
            ERR_REPLICATION_STATUS_READING_REGISTERED_SERVERS.get(
                Utils.getMessageFromCollection(messages,
                getMessageFromCollection(messages,
                    Constants.LINE_SEPARATOR));
        println(msg);
      }
@@ -6837,12 +7281,12 @@
      // If no base DNs where specified display all the base DNs but the schema
      // and cn=admin data.
      boolean found = displayAll &&
      !Utils.areDnsEqual(dn, ADSContext.getAdministrationSuffixDN()) &&
      !Utils.areDnsEqual(dn, Constants.SCHEMA_DN) &&
      !Utils.areDnsEqual(dn, Constants.REPLICATION_CHANGES_DN);
      !areDnsEqual(dn, ADSContext.getAdministrationSuffixDN()) &&
      !areDnsEqual(dn, Constants.SCHEMA_DN) &&
      !areDnsEqual(dn, Constants.REPLICATION_CHANGES_DN);
      for (String baseDN : userBaseDNs)
      {
        found = Utils.areDnsEqual(baseDN, dn);
        found = areDnsEqual(baseDN, dn);
        if (found)
        {
          break;
@@ -6872,7 +7316,7 @@
          {
            ReplicaDescriptor replica = replicas.iterator().next();
            if (!replica.isReplicated() &&
                Utils.areDnsEqual(dn, replica.getSuffix().getDN()))
                areDnsEqual(dn, replica.getSuffix().getDN()))
            {
              replicas.addAll(suffix.getReplicas());
              found = true;
@@ -6945,21 +7389,21 @@
      if (oneReplicated && !uData.isScriptFriendly())
      {
        printlnProgress();
        printProgress(INFO_REPLICATION_STATUS_REPLICATED_LEGEND.get());
        println();
        print(INFO_REPLICATION_STATUS_REPLICATED_LEGEND.get());
        if (!replicasWithNoReplicationServer.isEmpty() ||
            !serversWithNoReplica.isEmpty())
        {
          printlnProgress();
          printProgress(
          println();
          print(
              INFO_REPLICATION_STATUS_NOT_A_REPLICATION_SERVER_LEGEND.get());
          printlnProgress();
          printProgress(
          println();
          print(
              INFO_REPLICATION_STATUS_NOT_A_REPLICATION_DOMAIN_LEGEND.get());
        }
        printlnProgress();
        println();
        somethingDisplayed = true;
      }
    }
@@ -6967,13 +7411,13 @@
    {
      if (displayAll)
      {
        printProgress(INFO_REPLICATION_STATUS_NO_REPLICATION_INFORMATION.get());
        printlnProgress();
        print(INFO_REPLICATION_STATUS_NO_REPLICATION_INFORMATION.get());
        println();
      }
      else
      {
        printProgress(INFO_REPLICATION_STATUS_NO_BASEDNS.get());
        printlnProgress();
        print(INFO_REPLICATION_STATUS_NO_BASEDNS.get());
        println();
      }
    }
  }
@@ -7322,25 +7766,25 @@
    if (scriptFriendly)
    {
      printProgress(
      print(
          INFO_REPLICATION_STATUS_INDEPENDENT_REPLICATION_SERVERS.get());
      printlnProgress();
      println();
      printer = new TabSeparatedTablePrinter(out);
    }
    else
    {
      LocalizableMessage msg =
        INFO_REPLICATION_STATUS_INDEPENDENT_REPLICATION_SERVERS.get();
      printProgressMessageNoWrap(msg);
      printlnProgress();
      print(msg);
      println();
      int length = msg.length();
      StringBuilder buf = new StringBuilder();
      for (int i=0; i<length; i++)
      {
        buf.append("=");
      }
      printProgressMessageNoWrap(LocalizableMessage.raw(buf.toString()));
      printlnProgress();
      print(LocalizableMessage.raw(buf.toString()));
      println();
      printer = new TextTablePrinter(getOutputStream());
      ((TextTablePrinter)printer).setColumnSeparator(
@@ -7368,7 +7812,7 @@
    Set<String> servers = new LinkedHashSet<String>();
    for (ReplicaDescriptor replica : server.getReplicas())
    {
      if (Utils.areDnsEqual(replica.getSuffix().getDN(), baseDN))
      if (areDnsEqual(replica.getSuffix().getDN(), baseDN))
      {
        servers.addAll(replica.getReplicationServers());
        break;
@@ -7379,7 +7823,7 @@
      Set<SuffixDescriptor> suffixes = cache.getSuffixes();
      for (SuffixDescriptor suffix : suffixes)
      {
        if (Utils.areDnsEqual(suffix.getDN(), baseDN))
        if (areDnsEqual(suffix.getDN(), baseDN))
        {
          Set<String> s = suffix.getReplicationServers();
          // Test that at least we share one of the replication servers.
@@ -7443,7 +7887,7 @@
    Set<String> servers = new LinkedHashSet<String>();
    for (ReplicaDescriptor replica : server.getReplicas())
    {
      if (Utils.areDnsEqual(replica.getSuffix().getDN(), baseDN))
      if (areDnsEqual(replica.getSuffix().getDN(), baseDN))
      {
        servers.addAll(replica.getReplicationServers());
        break;
@@ -7453,7 +7897,7 @@
    Set<SuffixDescriptor> suffixes = cache.getSuffixes();
    for (SuffixDescriptor suffix : suffixes)
    {
      if (Utils.areDnsEqual(suffix.getDN(), baseDN))
      if (areDnsEqual(suffix.getDN(), baseDN))
      {
        Set<String> s = suffix.getReplicationServers();
        // Test that at least we share one of the replication servers.
@@ -7499,7 +7943,7 @@
    for (ReplicaDescriptor replica : server.getReplicas())
    {
      if ((replica.isReplicated()) &&
      Utils.areDnsEqual(replica.getSuffix().getDN(), baseDN))
      areDnsEqual(replica.getSuffix().getDN(), baseDN))
      {
        ids.add(replica.getReplicationId());
        break;
@@ -7528,7 +7972,7 @@
      Set<String> replicationServers,
      Set<Integer> usedReplicationServerIds) throws OpenDsException
  {
    printProgress(formatter.getFormattedWithPoints(
    print(formatter.getFormattedWithPoints(
        INFO_REPLICATION_ENABLE_CONFIGURING_REPLICATION_SERVER.get(
            ConnectionUtils.getHostPort(ctx))));
@@ -7619,8 +8063,8 @@
      replicationServer.commit();
    }
    printProgress(formatter.getFormattedDone());
    printlnProgress();
    print(formatter.getFormattedDone());
    println();
  }
  /**
@@ -7634,7 +8078,7 @@
  private void updateReplicationServer(InitialLdapContext ctx,
      Set<String> replicationServers) throws OpenDsException
  {
    printProgress(formatter.getFormattedWithPoints(
    print(formatter.getFormattedWithPoints(
        INFO_REPLICATION_ENABLE_UPDATING_REPLICATION_SERVER.get(
            ConnectionUtils.getHostPort(ctx))));
@@ -7665,8 +8109,8 @@
      replicationServer.commit();
    }
    printProgress(formatter.getFormattedDone());
    printlnProgress();
    print(formatter.getFormattedDone());
    println();
  }
  /**
@@ -7712,23 +8156,23 @@
    {
      for (String dn : l)
      {
        if (Utils.areDnsEqual(dn, ADSContext.getAdministrationSuffixDN()))
        if (areDnsEqual(dn, ADSContext.getAdministrationSuffixDN()))
        {
          userSpecifiedAdminBaseDN = true;
          break;
        }
      }
    }
    if (!userSpecifiedAdminBaseDN && Utils.areDnsEqual(baseDN,
    if (!userSpecifiedAdminBaseDN && areDnsEqual(baseDN,
        ADSContext.getAdministrationSuffixDN()))
    {
      printProgress(formatter.getFormattedWithPoints(
      print(formatter.getFormattedWithPoints(
          INFO_REPLICATION_ENABLE_CONFIGURING_ADS.get(
              ConnectionUtils.getHostPort(ctx))));
    }
    else
    {
      printProgress(formatter.getFormattedWithPoints(
      print(formatter.getFormattedWithPoints(
          INFO_REPLICATION_ENABLE_CONFIGURING_BASEDN.get(baseDN,
              ConnectionUtils.getHostPort(ctx))));
    }
@@ -7754,7 +8198,7 @@
    ReplicationDomainCfgClient domain = null;
    for (ReplicationDomainCfgClient domain2 : domains)
    {
      if (Utils.areDnsEqual(baseDN, domain2.getBaseDN().toString()))
      if (areDnsEqual(baseDN, domain2.getBaseDN().toString()))
      {
        domain = domain2;
        break;
@@ -7796,8 +8240,8 @@
      domain.commit();
    }
    printProgress(formatter.getFormattedDone());
    printlnProgress();
    print(formatter.getFormattedDone());
    println();
  }
  /**
@@ -7945,7 +8389,7 @@
          filter);
      for (ReplicaDescriptor replica : source.getReplicas())
      {
        if (Utils.areDnsEqual(replica.getSuffix().getDN(), baseDN))
        if (areDnsEqual(replica.getSuffix().getDN(), baseDN))
        {
          replicationId = replica.getReplicationId();
          break;
@@ -7978,8 +8422,8 @@
        if ((newLogDetails != null) &&
            !newLogDetails.toString().trim().equals(""))
        {
          printProgress(newLogDetails);
          printlnProgress();
          print(newLogDetails);
          println();
        }
      }
    });
@@ -8069,7 +8513,7 @@
        {
        }
      }
      catch (ApplicationException ae)
      catch (ClientException ae)
      {
        throw new ReplicationCliException(ae.getMessageObject(),
            ERROR_INITIALIZING_BASEDN_GENERIC, ae);
@@ -8277,13 +8721,13 @@
   * initialization is.
   * @param baseDN the dn of the suffix.
   * @param displayProgress whether we want to display progress or not.
   * @throws ApplicationException if an unexpected error occurs.
   * @throws ClientException if an unexpected error occurs.
   * @throws PeerNotFoundException if the replication mechanism cannot find
   * a peer.
   */
  public void initializeAllSuffixTry(String baseDN, InitialLdapContext ctx,
      boolean displayProgress)
  throws ApplicationException, PeerNotFoundException
  throws ClientException, PeerNotFoundException
  {
    boolean taskCreated = false;
    int i = 1;
@@ -8319,7 +8763,7 @@
      catch (NamingException ne)
      {
        logger.error(LocalizableMessage.raw("Error creating task "+attrs, ne));
        throw new ApplicationException(
        throw new ClientException(
            ReturnCode.APPLICATION_ERROR,
                getThrowableMsg(INFO_ERROR_LAUNCHING_INITIALIZATION.get(
                        serverDisplay), ne), ne);
@@ -8445,9 +8889,9 @@
            if (((currentTime - minRefreshPeriod) > lastTimeMsgDisplayed) &&
                !msg.equals(lastDisplayedMsg))
            {
              printProgress(msg);
              print(msg);
              lastDisplayedMsg = msg;
              printlnProgress();
              println();
              lastTimeMsgDisplayed = currentTime;
            }
          }
@@ -8472,9 +8916,9 @@
          logger.info(LocalizableMessage.raw("Last task entry: "+sr));
          if (displayProgress && (msg != null) && !msg.equals(lastDisplayedMsg))
          {
            printProgress(msg);
            print(msg);
            lastDisplayedMsg = msg;
            printlnProgress();
            println();
          }
          if (lastLogMsg == null)
          {
@@ -8499,7 +8943,7 @@
              helper.isStoppedByError(state))
          {
            logger.warn(LocalizableMessage.raw("Processed errorMsg: "+errorMsg));
            ApplicationException ae = new ApplicationException(
            ClientException ce = new ClientException(
                ReturnCode.APPLICATION_ERROR, errorMsg,
                null);
            if ((lastLogMsg == null) ||
@@ -8513,15 +8957,15 @@
            else
            {
              logger.error(LocalizableMessage.raw("Throwing ApplicationException."));
              throw ae;
              throw ce;
            }
          }
          else
          {
            if (displayProgress)
            {
              printProgress(INFO_SUFFIX_INITIALIZED_SUCCESSFULLY.get());
              printlnProgress();
              print(INFO_SUFFIX_INITIALIZED_SUCCESSFULLY.get());
              println();
            }
            logger.info(LocalizableMessage.raw("Processed msg: "+errorMsg));
            logger.info(LocalizableMessage.raw("Initialization completed successfully."));
@@ -8534,13 +8978,13 @@
        logger.info(LocalizableMessage.raw("Initialization entry not found."));
        if (displayProgress)
        {
          printProgress(INFO_SUFFIX_INITIALIZED_SUCCESSFULLY.get());
          printlnProgress();
          print(INFO_SUFFIX_INITIALIZED_SUCCESSFULLY.get());
          println();
        }
      }
      catch (NamingException ne)
      {
        throw new ApplicationException(
        throw new ClientException(
            ReturnCode.APPLICATION_ERROR,
                getThrowableMsg(INFO_ERROR_POOLING_INITIALIZATION.get(
                    serverDisplay), ne), ne);
@@ -8611,10 +9055,10 @@
            for (String baseDN : baseDNs)
            {
              lastBaseDN = baseDN;
              if (Utils.areDnsEqual(domain.getBaseDN().toString(),
              if (areDnsEqual(domain.getBaseDN().toString(),
                  baseDN))
              {
                printProgress(formatter.getFormattedWithPoints(
                print(formatter.getFormattedWithPoints(
                    INFO_REPLICATION_REMOVING_REFERENCES_ON_REMOTE.get(baseDN,
                        hostPort)));
                Set<String> replServers = domain.getReplicationServer();
@@ -8646,8 +9090,8 @@
                    }
                  }
                }
                printProgress(formatter.getFormattedDone());
                printlnProgress();
                print(formatter.getFormattedDone());
                println();
              }
            }
          }
@@ -8751,16 +9195,16 @@
          {
            ReplicationDomainCfgClient domain =
              sync.getReplicationDomain(domainName);
            if (Utils.areDnsEqual(domain.getBaseDN().toString(), baseDN))
            if (areDnsEqual(domain.getBaseDN().toString(), baseDN))
            {
              printProgress(formatter.getFormattedWithPoints(
              print(formatter.getFormattedWithPoints(
                  INFO_REPLICATION_DISABLING_BASEDN.get(baseDN,
                      hostPort)));
              sync.removeReplicationDomain(domainName);
              sync.commit();
              printProgress(formatter.getFormattedDone());
              printlnProgress();
              print(formatter.getFormattedDone());
              println();
            }
          }
        }
@@ -8809,14 +9253,14 @@
      if (replicationServer != null)
      {
        String s = String.valueOf(replicationServer.getReplicationPort());
        printProgress(formatter.getFormattedWithPoints(
        print(formatter.getFormattedWithPoints(
            INFO_REPLICATION_DISABLING_REPLICATION_SERVER.get(s,
                hostPort)));
        sync.removeReplicationServer();
        sync.commit();
        printProgress(formatter.getFormattedDone());
        printlnProgress();
        print(formatter.getFormattedDone());
        println();
      }
    }
    catch (OpenDsException ode)
@@ -9111,19 +9555,6 @@
  }
  /**
   * Prints a message to the output with no wrapping if we are not in quiet
   * mode.
   * @param msg the message to be displayed.
   */
  private void printProgressMessageNoWrap(LocalizableMessage msg)
  {
    if (!isQuiet())
    {
      getOutputStream().print(msg.toString());
    }
  }
  /**
   * Forces the initialization of the trust manager in the
   * LDAPConnectionInteraction object.
   */
@@ -9233,13 +9664,13 @@
    for (String dn1 : replicatedSuffixes)
    {
      if (!Utils.areDnsEqual(ADSContext.getAdministrationSuffixDN(), dn1) &&
          !Utils.areDnsEqual(Constants.SCHEMA_DN, dn1))
      if (!areDnsEqual(ADSContext.getAdministrationSuffixDN(), dn1) &&
          !areDnsEqual(Constants.SCHEMA_DN, dn1))
      {
        boolean found = false;
        for (String dn2 : uData.getBaseDNs())
        {
          if (Utils.areDnsEqual(dn1, dn2))
          if (areDnsEqual(dn1, dn2))
          {
            found = true;
            break;
@@ -9650,7 +10081,7 @@
        String adminUID = uData.getAdminUid();
        if (bindDN1 != null && adminUID != null)
        {
          if (!Utils.areDnsEqual(ADSContext.getAdministratorDN(adminUID),
          if (!areDnsEqual(ADSContext.getAdministratorDN(adminUID),
              bindDN1))
          {
            forceAddBindDN1 = true;
@@ -9824,7 +10255,7 @@
        String adminUID = uData.getAdminUid();
        if (bindDN2 != null && adminUID != null)
        {
          if (!Utils.areDnsEqual(ADSContext.getAdministratorDN(adminUID),
          if (!areDnsEqual(ADSContext.getAdministratorDN(adminUID),
              bindDN2))
          {
            forceAddBindDN2 = true;
@@ -10385,7 +10816,7 @@
          boolean isFirstReplicated = false;
          for (SuffixDescriptor suffix2 : cache2.getSuffixes())
          {
            if (Utils.areDnsEqual(suffix.getDN(), suffix2.getDN()))
            if (areDnsEqual(suffix.getDN(), suffix2.getDN()))
            {
              for (String rServer2 : suffix2.getReplicationServers())
              {
@@ -10482,7 +10913,7 @@
      int nReplicationServers = 0;
      for (SuffixDescriptor suffix : suffixes)
      {
        if (Utils.areDnsEqual(suffix.getDN(), baseDN))
        if (areDnsEqual(suffix.getDN(), baseDN))
        {
          Set<String> replicationServers = suffix.getReplicationServers();
          nReplicationServers += replicationServers.size();
@@ -10651,7 +11082,7 @@
        println();
      }
      printProgress(INFO_REPLICATION_MERGING_REGISTRIES_PROGRESS.get());
      print(INFO_REPLICATION_MERGING_REGISTRIES_PROGRESS.get());
      pointAdder.start();
      Collection<LocalizableMessage> cache1Errors = cache1.getErrorMessages();
@@ -10660,7 +11091,7 @@
        throw new ReplicationCliException(
            ERR_REPLICATION_CANNOT_MERGE_WITH_ERRORS.get(
                ConnectionUtils.getHostPort(adsCtx1.getDirContext()),
                Utils.getMessageFromCollection(cache1Errors,
                getMessageFromCollection(cache1Errors,
                    Constants.LINE_SEPARATOR)),
                    ERROR_READING_ADS, null);
      }
@@ -10671,7 +11102,7 @@
        throw new ReplicationCliException(
            ERR_REPLICATION_CANNOT_MERGE_WITH_ERRORS.get(
                ConnectionUtils.getHostPort(adsCtx2.getDirContext()),
                Utils.getMessageFromCollection(cache2Errors,
                getMessageFromCollection(cache2Errors,
                    Constants.LINE_SEPARATOR)),
                    ERROR_READING_ADS, null);
      }
@@ -10719,7 +11150,7 @@
            boolean found = false;
            for (SuffixDescriptor suffix2 : cache2.getSuffixes())
            {
              if (!Utils.areDnsEqual(suffix2.getDN(),
              if (!areDnsEqual(suffix2.getDN(),
                  replica1.getSuffix().getDN()))
              {
                // Conflicting domain names must apply to same suffix.
@@ -10757,7 +11188,7 @@
        if (!commonRepServerIDErrors.isEmpty())
        {
          mb.append(ERR_REPLICATION_ENABLE_COMMON_REPLICATION_SERVER_ID.get(
            Utils.getMessageFromCollection(commonRepServerIDErrors,
            getMessageFromCollection(commonRepServerIDErrors,
                Constants.LINE_SEPARATOR)));
        }
        if (!commonDomainIDErrors.isEmpty())
@@ -10767,7 +11198,7 @@
            mb.append(Constants.LINE_SEPARATOR);
          }
          mb.append(ERR_REPLICATION_ENABLE_COMMON_DOMAIN_ID.get(
            Utils.getMessageFromCollection(commonDomainIDErrors,
            getMessageFromCollection(commonDomainIDErrors,
                Constants.LINE_SEPARATOR)));
        }
        throw new ReplicationCliException(mb.toMessage(),
@@ -10851,9 +11282,9 @@
                    ERROR_SEEDING_TRUSTORE, t);
      }
      pointAdder.stop();
      printProgress(formatter.getSpace());
      printProgress(formatter.getFormattedDone());
      printlnProgress();
      print(formatter.getSpace());
      print(formatter.getFormattedDone());
      println();
      return adsCtxSource == adsCtx1;
    }
@@ -10892,7 +11323,7 @@
    boolean isReplicated = false;
    for (ReplicaDescriptor replica : server.getReplicas())
    {
      if (Utils.areDnsEqual(replica.getSuffix().getDN(), baseDN))
      if (areDnsEqual(replica.getSuffix().getDN(), baseDN))
      {
        isReplicated = replica.isReplicated();
        break;
@@ -10918,7 +11349,7 @@
    ReplicaDescriptor replica2;
    for (ReplicaDescriptor replica : server1.getReplicas())
    {
      if (Utils.areDnsEqual(replica.getSuffix().getDN(), baseDN))
      if (areDnsEqual(replica.getSuffix().getDN(), baseDN))
      {
        replica1 = replica;
        break;
@@ -10928,7 +11359,7 @@
    {
      for (ReplicaDescriptor replica : server2.getReplicas())
      {
        if (Utils.areDnsEqual(replica.getSuffix().getDN(), baseDN))
        if (areDnsEqual(replica.getSuffix().getDN(), baseDN))
        {
          replica2 = replica;
          if (replica2.isReplicated())
opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCli.java
@@ -68,10 +68,10 @@
import org.opends.server.types.OpenDsException;
import org.opends.server.util.BuildVersion;
import org.opends.server.util.StaticUtils;
import org.opends.server.util.cli.ConsoleApplication;
import com.forgerock.opendj.cli.ConsoleApplication;
import org.opends.server.util.cli.LDAPConnectionConsoleInteraction;
import org.opends.server.util.table.TableBuilder;
import org.opends.server.util.table.TextTablePrinter;
import com.forgerock.opendj.cli.TableBuilder;
import com.forgerock.opendj.cli.TextTablePrinter;
import com.forgerock.opendj.cli.ArgumentException;
@@ -175,7 +175,7 @@
   */
  public StatusCli(PrintStream out, PrintStream err, InputStream in)
  {
    super(in, out, err);
    super(out, err);
  }
  /**
opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleInteraction.java
@@ -48,9 +48,9 @@
import com.forgerock.opendj.cli.ClientException;
import com.forgerock.opendj.cli.ReturnCode;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.cli.MenuBuilder;
import org.opends.server.util.cli.MenuResult;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.MenuBuilder;
import com.forgerock.opendj.cli.MenuResult;
/**
 * A class that is in charge of interacting with the user to ask about
@@ -286,10 +286,10 @@
      sb.append(separator);
      sb.append(entry.getId());
    }
    app.printlnProgress();
    app.printProgress(INFO_AVAILABLE_DEFINED_TASKS.get(sb));
    app.printlnProgress();
    app.printlnProgress();
    app.println();
    app.print(INFO_AVAILABLE_DEFINED_TASKS.get(sb));
    app.println();
    app.println();
  }
@@ -463,9 +463,9 @@
        Date currentDate = new Date(System.currentTimeMillis());
        if (currentDate.after(startDate))
        {
          app.printProgress(ERR_START_DATETIME_ALREADY_PASSED.get(sDate));
          app.printlnProgress();
          app.printlnProgress();
          app.print(ERR_START_DATETIME_ALREADY_PASSED.get(sDate));
          app.println();
          app.println();
          startDate = null;
        }
      } catch (ParseException pe) {
@@ -489,7 +489,7 @@
      try
      {
        RecurringTask.parseTaskTab(schedule);
        app.printlnProgress();
        app.println();
      }
      catch (DirectoryException de)
      {
@@ -506,12 +506,12 @@
  {
    if (!headerDisplayed)
    {
      app.printlnProgress();
      app.printProgress(INFO_TASK_SCHEDULE_PROMPT_HEADER.get());
      app.printlnProgress();
      app.println();
      app.print(INFO_TASK_SCHEDULE_PROMPT_HEADER.get());
      app.println();
      headerDisplayed = true;
    }
    app.printlnProgress();
    app.println();
  }
}
opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleUserData.java
@@ -37,7 +37,7 @@
import org.opends.server.util.StaticUtils;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.StringArgument;
import org.opends.server.util.cli.CommandBuilder;
import com.forgerock.opendj.cli.CommandBuilder;
/**
 * A generic data structure that contains the data that the user provided to
opendj3-server-dev/src/server/org/opends/server/tools/upgrade/UpgradeCli.java
@@ -26,7 +26,6 @@
package org.opends.server.tools.upgrade;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.tools.ToolConstants.*;
import static org.opends.server.util.StaticUtils.filterExitCode;
import static org.opends.server.tools.upgrade.FormattedNotificationCallback.*;
@@ -36,6 +35,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
@@ -51,12 +51,13 @@
import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.util.ServerConstants;
import org.opends.server.util.StaticUtils;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.BooleanArgument;
import com.forgerock.opendj.cli.StringArgument;
import com.forgerock.opendj.cli.SubCommandArgumentParser;
import com.forgerock.opendj.cli.ClientException;
import org.opends.server.util.cli.ConsoleApplication;
import com.forgerock.opendj.cli.ConsoleApplication;
/**
 * This class provides the CLI used for upgrading the OpenDJ product.
@@ -96,8 +97,7 @@
  private UpgradeCli(InputStream in, OutputStream out, OutputStream err)
  {
    super(in, out, err);
    super(new PrintStream(out), new PrintStream(err));
    this.parser =
        new SubCommandArgumentParser(this.getClass().getName(),
            INFO_UPGRADE_DESCRIPTION_CLI.get(), false);
@@ -388,7 +388,7 @@
        final ProgressNotificationCallback pnc =
            (ProgressNotificationCallback) c;
        final LocalizableMessage msg = LocalizableMessage.raw("  " + pnc.getMessage());
        printProgress(msg);
        print(msg);
        printProgressBar(msg.length(), pnc.getProgress());
      }
      else if (c instanceof FormattedNotificationCallback)
@@ -430,8 +430,8 @@
        // Usual output text.
        final TextOutputCallback toc = (TextOutputCallback) c;
        if(toc.getMessageType() == TextOutputCallback.INFORMATION) {
          logger.debug(LocalizableMessage.raw(toc.getMessage()));
          printlnProgress(LocalizableMessage.raw(toc.getMessage()));
          logger.info(LocalizableMessage.raw(toc.getMessage()));
          println(LocalizableMessage.raw(toc.getMessage()));
        } else {
          logger.error(LocalizableMessage.raw("Unsupported message type: "
            + toc.getMessage()));
@@ -480,7 +480,7 @@
        }
        prompt.append(")");
        logger.debug(LocalizableMessage.raw(cc.getPrompt()));
        logger.info(LocalizableMessage.raw(cc.getPrompt()));
        // Displays the output and
        // while it hasn't a valid response, question is repeated.
@@ -502,27 +502,27 @@
            }
            String valueLC = value.toLowerCase();
            if ((valueLC.equals(INFO_PROMPT_YES_FIRST_LETTER_ANSWER.get())
                || valueLC.equals(INFO_PROMPT_YES_COMPLETE_ANSWER.get()))
            if ((valueLC.equals(INFO_PROMPT_YES_FIRST_LETTER_ANSWER.get().toString())
                || valueLC.equals(INFO_PROMPT_YES_COMPLETE_ANSWER.get().toString()))
                && choices.contains(value))
            {
              cc.setSelectedIndex(ConfirmationCallback.YES);
              break;
            }
            else if ((valueLC.equals(INFO_PROMPT_NO_FIRST_LETTER_ANSWER.get())
                || valueLC.equals(INFO_PROMPT_NO_COMPLETE_ANSWER.get()))
            else if ((valueLC.equals(INFO_PROMPT_NO_FIRST_LETTER_ANSWER.get().toString())
                || valueLC.equals(INFO_PROMPT_NO_COMPLETE_ANSWER.get().toString()))
                && choices.contains(value))
            {
              cc.setSelectedIndex(ConfirmationCallback.NO);
              break;
            }
            else if (valueLC.equals(INFO_TASKINFO_CMD_CANCEL_CHAR.get())
            else if (valueLC.equals(INFO_TASKINFO_CMD_CANCEL_CHAR.get().toString())
                && choices.contains(value))
            {
              cc.setSelectedIndex(ConfirmationCallback.CANCEL);
              break;
            }
            logger.debug(LocalizableMessage.raw(value));
            logger.info(LocalizableMessage.raw(value));
          }
        }
        else // Non interactive mode :
@@ -539,7 +539,7 @@
          // Displays the prompt
          prompt.append(" ").append(getDefaultOption(cc.getSelectedIndex()));
          println(Style.SUBTITLE, LocalizableMessage.raw(prompt), 0);
          logger.debug(LocalizableMessage.raw(getDefaultOption(cc.getSelectedIndex())));
          logger.info(LocalizableMessage.raw(getDefaultOption(cc.getSelectedIndex())));
        }
      }
      else
opendj3-server-dev/src/server/org/opends/server/util/cli/CommandBuilder.java
File was deleted
opendj3-server-dev/src/server/org/opends/server/util/cli/ConsoleApplication.java
File was deleted
opendj3-server-dev/src/server/org/opends/server/util/cli/ErrorStreamConsoleApplication.java
File was deleted
opendj3-server-dev/src/server/org/opends/server/util/cli/HelpCallback.java
File was deleted
opendj3-server-dev/src/server/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java
@@ -42,6 +42,13 @@
import org.opends.server.admin.client.cli.SecureConnectionCliArgs;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.ClientException;
import com.forgerock.opendj.cli.CommandBuilder;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.Menu;
import com.forgerock.opendj.cli.MenuBuilder;
import com.forgerock.opendj.cli.MenuResult;
import com.forgerock.opendj.cli.ValidationCallback;
import org.opends.server.util.SelectableCertificateKeyManager;
import org.opends.admin.ads.ADSContext;
import org.opends.admin.ads.util.ApplicationTrustManager;
@@ -77,7 +84,7 @@
  private String providedBindDN;
  private String adminUID;
  private String providedAdminUID;
  private String bindPassword;
  private char[] bindPassword;
  private KeyManager keyManager;
  private ApplicationTrustManager trustManager;
  // Boolean that tells if we ask for bind DN or admin UID in the same prompt.
@@ -109,13 +116,13 @@
  private String keystorePath;
  private String keystorePassword;
  private char[] keystorePassword;
  private String certifNickname;
  private String truststorePath;
  private String truststorePassword;
  private char[] truststorePassword;
  // The timeout to be used to connect
  private int connectTimeout;
@@ -288,7 +295,7 @@
                                          SecureConnectionCliArgs secureArgs) {
    this.app = app;
    this.secureArgsList = secureArgs;
    this.commandBuilder = new CommandBuilder(null);
    this.commandBuilder = new CommandBuilder(null, null);
    this.useSSL = secureArgs.useSSL();
    this.useStartTLS = secureArgs.useStartTLS();
    this.trustAll = secureArgs.trustAllArg.isPresent();
@@ -728,13 +735,16 @@
    }
    boolean addedPasswordFileArgument = false;
    bindPassword = secureArgsList.bindPasswordArg.getValue();
    if (secureArgsList.bindPasswordArg.isPresent())
    {
      bindPassword = secureArgsList.bindPasswordArg.getValue().toCharArray();
    }
    if (keyManager == null)
    {
      if (secureArgsList.bindPasswordFileArg.isPresent())
      {
        // Read from file if it exists.
        bindPassword = secureArgsList.bindPasswordFileArg.getValue();
        bindPassword = secureArgsList.bindPasswordFileArg.getValue().toCharArray();
        if (bindPassword == null)
        {
@@ -793,7 +803,7 @@
        }
      }
      copySecureArgsList.bindPasswordArg.clearValues();
      copySecureArgsList.bindPasswordArg.addValue(bindPassword);
      copySecureArgsList.bindPasswordArg.addValue(String.valueOf(bindPassword));
      if (!addedPasswordFileArgument)
      {
        commandBuilder.addObfuscatedArgument(
@@ -982,14 +992,16 @@
    // Then the truststore password.
    //  As the most common case is to have no password for truststore,
    // we don't ask it in the interactive mode.
    truststorePassword = secureArgsList.trustStorePasswordArg
        .getValue();
    if (secureArgsList.trustStorePasswordArg.isPresent())
    {
      truststorePassword =
          secureArgsList.trustStorePasswordArg.getValue().toCharArray();
    }
    if (secureArgsList.trustStorePasswordFileArg.isPresent())
    {
      // Read from file if it exists.
      truststorePassword = secureArgsList.trustStorePasswordFileArg
          .getValue();
          .getValue().toCharArray();
    }
    if ((truststorePassword !=  null) && (truststorePassword.equals("-")))
    {
@@ -1025,7 +1037,7 @@
        FileInputStream fos = new FileInputStream(truststorePath);
        if (truststorePassword != null)
        {
          truststore.load(fos, truststorePassword.toCharArray());
          truststore.load(fos, truststorePassword);
        }
        else
        {
@@ -1052,7 +1064,7 @@
        // Only add the trust store password if there is one AND if the user
        // specified a trust store path.
        copySecureArgsList.trustStorePasswordArg.clearValues();
        copySecureArgsList.trustStorePasswordArg.addValue(truststorePassword);
        copySecureArgsList.trustStorePasswordArg.addValue(String.valueOf(truststorePassword));
        commandBuilder.addObfuscatedArgument(
            copySecureArgsList.trustStorePasswordArg);
      }
@@ -1161,12 +1173,12 @@
    }
    // Then the keystore password.
    keystorePassword = secureArgsList.keyStorePasswordArg.getValue();
    keystorePassword = secureArgsList.keyStorePasswordArg.getValue().toCharArray();
    if (secureArgsList.keyStorePasswordFileArg.isPresent())
    {
      // Read from file if it exists.
      keystorePassword = secureArgsList.keyStorePasswordFileArg.getValue();
      keystorePassword = secureArgsList.keyStorePasswordFileArg.getValue().toCharArray();
      if (keystorePassword == null)
      {
@@ -1204,7 +1216,7 @@
    {
      FileInputStream fos = new FileInputStream(keystorePath);
      keystore = KeyStore.getInstance(KeyStore.getDefaultType());
      keystore.load(fos, keystorePassword.toCharArray());
      keystore.load(fos, keystorePassword);
      fos.close();
      aliasesEnum = keystore.aliases();
    }
@@ -1272,7 +1284,7 @@
    // We'we got all the information to get the keys manager
    ApplicationKeyManager akm = new ApplicationKeyManager(keystore,
        keystorePassword.toCharArray());
        keystorePassword);
    if (secureArgsList.keyStorePasswordFileArg.isPresent())
@@ -1286,7 +1298,7 @@
    else if (keystorePassword != null)
    {
      copySecureArgsList.keyStorePasswordArg.clearValues();
      copySecureArgsList.keyStorePasswordArg.addValue(keystorePassword);
      copySecureArgsList.keyStorePasswordArg.addValue(String.valueOf(keystorePassword));
      commandBuilder.addObfuscatedArgument(
          copySecureArgsList.keyStorePasswordArg);
    }
@@ -1416,7 +1428,7 @@
   * @return bind password for connections
   */
  public String getBindPassword() {
    return this.bindPassword;
    return String.valueOf(this.bindPassword);
  }
  /**
@@ -1655,7 +1667,7 @@
            }
            // Read the password from the stdin.
            String truststorePassword;
            char[] truststorePassword;
            try
            {
              app.println();
@@ -1679,7 +1691,7 @@
              {
                fis = null;
              }
              ts.load(fis, truststorePassword.toCharArray());
              ts.load(fis, truststorePassword);
              if (fis != null)
              {
                fis.close();
@@ -1690,7 +1702,7 @@
                ts.setCertificateEntry(alias, chain[i]);
              }
              FileOutputStream fos = new FileOutputStream(truststorePath);
              ts.store(fos, truststorePassword.toCharArray());
              ts.store(fos, truststorePassword);
              if (fos != null)
              {
                fos.close();
@@ -1737,9 +1749,10 @@
   if (this.useSSL) {
     options.setUseSSL(true);
     SSLConnectionFactory sslConnectionFactory = new SSLConnectionFactory();
     sslConnectionFactory.init(getTrustManager() == null, keystorePath,
                               keystorePassword, certifNickname,
                               truststorePath, truststorePassword);
      sslConnectionFactory.init(getTrustManager() == null, String
          .valueOf(keystorePath), String.valueOf(keystorePassword), String
          .valueOf(certifNickname), String.valueOf(truststorePath), String
          .valueOf(truststorePassword));
     options.setSSLConnectionFactory(sslConnectionFactory);
   } else {
     options.setUseSSL(false);
opendj3-server-dev/src/server/org/opends/server/util/cli/Menu.java
File was deleted
opendj3-server-dev/src/server/org/opends/server/util/cli/MenuBuilder.java
File was deleted
opendj3-server-dev/src/server/org/opends/server/util/cli/MenuCallback.java
File was deleted
opendj3-server-dev/src/server/org/opends/server/util/cli/MenuResult.java
File was deleted
opendj3-server-dev/src/server/org/opends/server/util/cli/OutputStreamConsoleApplication.java
File was deleted
opendj3-server-dev/src/server/org/opends/server/util/cli/PointAdder.java
@@ -30,6 +30,8 @@
import org.opends.quicksetup.util.PlainTextProgressMessageFormatter;
import org.opends.quicksetup.util.ProgressMessageFormatter;
import com.forgerock.opendj.cli.ConsoleApplication;
/**
 * Class used to add points periodically to the end of the output.
 *
@@ -98,7 +100,7 @@
    }
    else
    {
      app.printProgress(mb.toMessage());
      app.print(mb.toMessage());
    }
    t = new Thread(this);
    t.start();
@@ -141,7 +143,7 @@
        }
        else
        {
          app.printProgress(formatter.getFormattedPoint());
          app.print(formatter.getFormattedPoint());
        }
      }
      catch (Throwable t)
opendj3-server-dev/src/server/org/opends/server/util/cli/ValidationCallback.java
File was deleted
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tools/dsconfig/DsconfigLdapConnectionTestCase.java
@@ -36,11 +36,11 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.opends.server.tools.JavaPropertiesTool.ErrorReturnCode.*;
import static com.forgerock.opendj.cli.ReturnCode.*;
import static org.testng.Assert.*;
/**
 * A set of test cases for the dsservice tool.
 * A set of test cases for the DS service tool.
 */
public class DsconfigLdapConnectionTestCase extends DirectoryServerTestCase {
  // The path to a file containing an invalid bind password.
@@ -106,8 +106,8 @@
      "-X"
    };
    assertFalse(DSConfig.main(args, false, null, null)
        == SUCCESSFUL.getReturnCode());
    assertFalse(DSConfig.main(args, false, System.out, System.err)
        == SUCCESS.get());
  }
  /**
@@ -129,7 +129,7 @@
    };
    assertFalse(DSConfig.main(args, false, System.out, System.err)
        == SUCCESSFUL.getReturnCode());
        == SUCCESS.get());
  }
  /**
@@ -151,7 +151,7 @@
    };
    assertFalse(DSConfig.main(args, false, System.out, System.err)
        == SUCCESSFUL.getReturnCode());
        == SUCCESS.get());
  }
@@ -179,7 +179,7 @@
    };
    assertEquals(DSConfig.main(args, false, System.out,
        System.err), SUCCESSFUL.getReturnCode());
        System.err), SUCCESS.get());
  }
  /**
@@ -204,7 +204,7 @@
    };
    assertFalse(DSConfig.main(args, false, System.out, System.err)
        == SUCCESSFUL.getReturnCode());
        == SUCCESS.get());
  }
@@ -229,7 +229,7 @@
    };
    assertEquals(DSConfig.main(args, false, System.out,
        System.err), SUCCESSFUL.getReturnCode());
        System.err), SUCCESS.get());
  }
@@ -239,17 +239,17 @@
  @Test()
  public void testHelp()
  {
    String[] args = {"--noPropertiesFile","--help" };
    assertEquals(DSConfig.main(args, false, null, null),
        SUCCESSFUL.getReturnCode());
    String[] args = { "--noPropertiesFile", "--help" };
    assertEquals(DSConfig.main(args, false, System.out, System.err),
        SUCCESS.get());
    args = new String[] { "--noPropertiesFile", "-H" };
    assertEquals(DSConfig.main(args, false, null, null),
        SUCCESSFUL.getReturnCode());
    assertEquals(DSConfig.main(args, false, System.out, System.err),
        SUCCESS.get());
    args = new String[] { "--noPropertiesFile", "-?" };
    assertEquals(DSConfig.main(args, false, null, null),
        SUCCESSFUL.getReturnCode());
    assertEquals(DSConfig.main(args, false, System.out, System.err),
        SUCCESS.get());
  }
}