From b671de6dbf50ca89cb0b9e4d7da6c81ae3017c82 Mon Sep 17 00:00:00 2001
From: Violette Roche-Montane <violette.roche-montane@forgerock.com>
Date: Tue, 18 Feb 2014 14:19:36 +0000
Subject: [PATCH] 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.

---
 opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java                                |   14 
 opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/GetPropSubCommandHandler.java                               |   10 
 opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java                                    |   72 ++
 opendj3-server-dev/src/server/org/opends/server/tools/InstallDS.java                                                       |   67 +
 opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/IndexPanel.java                                        |    2 
 opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ListSubCommandHandler.java                                  |   10 
 opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValueEditor.java                                    |   20 
 opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/NewBaseDNPanel.java                                    |    2 
 opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java                                |    8 
 opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/LocalPurgeHistorical.java                              |   14 
 opendj3-server-dev/src/server/org/opends/server/tools/ManageTasks.java                                                     |   20 
 opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ManagementContextFactory.java                               |    4 
 opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tools/dsconfig/DsconfigLdapConnectionTestCase.java |   32 
 opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/InternalManagementContextFactory.java                       |    4 
 opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java                                  |   16 
 opendj3-server-dev/src/server/org/opends/server/tools/WaitForFileDelete.java                                               |    4 
 opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java                                      |   14 
 opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleUserData.java                                      |    2 
 opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java                               |    6 
 opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DSConfig.java                                               |   28 
 opendj3-server-dev/src/server/org/opends/server/tools/InstallDSArgumentParser.java                                         |    9 
 opendj3-server-dev/src/server/org/opends/server/tools/JavaPropertiesTool.java                                              |   10 
 opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCli.java                                                |    8 
 opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ArgumentExceptionFactory.java                               |   18 
 opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleInteraction.java                                   |   30 
 opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java                           |    4 
 opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/task/Task.java                                            |    2 
 opendj3-server-dev/src/quicksetup/org/opends/quicksetup/CliUserInteraction.java                                            |    9 
 opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/VLVIndexPanel.java                                     |    2 
 /dev/null                                                                                                                  |   58 --
 opendj3-server-dev/src/server/org/opends/server/tools/upgrade/UpgradeCli.java                                              |   30 
 opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/NewIndexPanel.java                                     |    2 
 opendj3-server-dev/src/server/org/opends/server/util/cli/PointAdder.java                                                   |    6 
 opendj3-server-dev/src/server/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java                             |   63 +
 opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java                                |  951 ++++++++++++++++++++++++++----------
 35 files changed, 1,020 insertions(+), 531 deletions(-)

diff --git a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/task/Task.java b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/task/Task.java
index 97a1b6f..87dbb2c 100644
--- a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/task/Task.java
+++ b/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
diff --git a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/IndexPanel.java b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/IndexPanel.java
index bc63d33..f3979f1 100644
--- a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/IndexPanel.java
+++ b/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
diff --git a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/NewBaseDNPanel.java b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/NewBaseDNPanel.java
index 0099ec3..eb55b73 100644
--- a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/NewBaseDNPanel.java
+++ b/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'.
diff --git a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/NewIndexPanel.java b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/NewIndexPanel.java
index c4c3da1..2b066f9 100644
--- a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/NewIndexPanel.java
+++ b/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.
diff --git a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/VLVIndexPanel.java b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/VLVIndexPanel.java
index d450e63..2801901 100644
--- a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/VLVIndexPanel.java
+++ b/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
diff --git a/opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java b/opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
index 6e00492..2cda6cd 100644
--- a/opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
+++ b/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
diff --git a/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/CliUserInteraction.java b/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/CliUserInteraction.java
index 39b969a..0a1081d 100644
--- a/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/CliUserInteraction.java
+++ b/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();
   }
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/InstallDS.java b/opendj3-server-dev/src/server/org/opends/server/tools/InstallDS.java
index 6758322..482da72 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/InstallDS.java
+++ b/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 ++;
         }
       }
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/InstallDSArgumentParser.java b/opendj3-server-dev/src/server/org/opends/server/tools/InstallDSArgumentParser.java
index f1c2ebd..a95894a 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/InstallDSArgumentParser.java
+++ b/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;
   }
 
   /**
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/JavaPropertiesTool.java b/opendj3-server-dev/src/server/org/opends/server/tools/JavaPropertiesTool.java
index 2b191fe..432c1c4 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/JavaPropertiesTool.java
+++ b/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();
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/ManageTasks.java b/opendj3-server-dev/src/server/org/opends/server/tools/ManageTasks.java
index 7f5f26a..236d3ee 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/ManageTasks.java
+++ b/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));
   }
 
   /**
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/WaitForFileDelete.java b/opendj3-server-dev/src/server/org/opends/server/tools/WaitForFileDelete.java
index dcebe33..d2603db 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/WaitForFileDelete.java
+++ b/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);
   }
 
   /**
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ArgumentExceptionFactory.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ArgumentExceptionFactory.java
index 4c2d579..4d9dc73 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ArgumentExceptionFactory.java
+++ b/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);
+  }
 
 
   /**
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java
index 1cfbb37..4b21c96 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java
+++ b/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 =
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DSConfig.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DSConfig.java
index d7ed9f1..0f9ca72 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DSConfig.java
+++ 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();
 
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java
index da0b1a5..3f34864 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java
+++ b/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;
 
 
 
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/GetPropSubCommandHandler.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/GetPropSubCommandHandler.java
index ffe9609..412a0c4 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/GetPropSubCommandHandler.java
+++ b/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;
 
 
 
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java
index dec969c..c8aff02 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java
+++ b/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 {
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/InternalManagementContextFactory.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/InternalManagementContextFactory.java
index f492a6a..71529ca 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/InternalManagementContextFactory.java
+++ b/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;
 
 
 
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java
index d29f210..cc6f1e2 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java
+++ b/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;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ListSubCommandHandler.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ListSubCommandHandler.java
index 24c5759..fedb602 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ListSubCommandHandler.java
+++ b/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;
 
 
 
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ManagementContextFactory.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ManagementContextFactory.java
index e9bf272..09436ff 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ManagementContextFactory.java
+++ b/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;
 
 
 
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValueEditor.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValueEditor.java
index 2b439cf..c7f6424 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValueEditor.java
+++ b/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);
     }
   }
 
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java
index 26dda2d..a9b4951 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java
+++ b/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;
 
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java
index 459d4eb..433f083 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java
+++ b/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;
 
 
 
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/LocalPurgeHistorical.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/LocalPurgeHistorical.java
index d86dfb3..5c24073 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/LocalPurgeHistorical.java
+++ b/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))
     {
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java
index 79cb626..9a4d190 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java
+++ b/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())
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCli.java b/opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCli.java
index f24af1f..ef98bf2 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCli.java
+++ b/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);
   }
 
   /**
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleInteraction.java b/opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleInteraction.java
index a36c88d..090c453 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleInteraction.java
+++ b/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();
 
   }
 }
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleUserData.java b/opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleUserData.java
index 3cafc90..62b5f6e 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleUserData.java
+++ b/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
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/upgrade/UpgradeCli.java b/opendj3-server-dev/src/server/org/opends/server/tools/upgrade/UpgradeCli.java
index 6b426a6..c46c65b 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/upgrade/UpgradeCli.java
+++ b/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
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/cli/CommandBuilder.java b/opendj3-server-dev/src/server/org/opends/server/util/cli/CommandBuilder.java
deleted file mode 100644
index 33a1840..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/util/cli/CommandBuilder.java
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2008-2009 Sun Microsystems, Inc.
- *      Portions Copyright 2014 ForgeRock AS
- */
-
-package org.opends.server.util.cli;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-
-import org.opends.server.util.SetupUtils;
-import com.forgerock.opendj.cli.Argument;
-import com.forgerock.opendj.cli.BooleanArgument;
-import com.forgerock.opendj.cli.FileBasedArgument;
-
-/**
- * Class used to be able to generate the non interactive mode.
- *
- */
-public class CommandBuilder
-{
-  // The command name.
-  private String commandName;
-
-  // The subcommand name.
-  private String subcommandName;
-
-  private ArrayList<Argument> args = new ArrayList<Argument>();
-  private HashSet<Argument> obfuscatedArgs = new HashSet<Argument>();
-
-  /**
-   * The value used to display arguments that must be obfuscated (such as
-   * passwords).  This does not require localization (since the output of
-   * command builder by its nature is not localized).
-   */
-  public final static String OBFUSCATED_VALUE = "******";
-
-  /**
-   * The separator used to link the lines of the resulting command-lines.
-   */
-  public final static String LINE_SEPARATOR;
-  static
-  {
-    if (SetupUtils.isWindows())
-    {
-      LINE_SEPARATOR = " ";
-    }
-    else
-    {
-      LINE_SEPARATOR = " \\\n          ";
-    }
-  }
-
-  /**
-   * The separator used to link the lines of the resulting command-lines in
-   * HTML format.
-   */
-  public final static String HTML_LINE_SEPARATOR;
-  static
-  {
-    if (SetupUtils.isWindows())
-    {
-      HTML_LINE_SEPARATOR = "&nbsp;";
-    }
-    else
-    {
-      HTML_LINE_SEPARATOR =
-     "&nbsp;\\<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
-    }
-  }
-
-  /**
-   * The constructor for the CommandBuilder.
-   * @param commandName the command name.
-   */
-  public CommandBuilder(String commandName)
-  {
-    this(commandName, null);
-  }
-
-  /**
-   * The constructor for the CommandBuilder.
-   * @param commandName the command name.
-   * @param subcommandName the subcommand name.
-   */
-  public CommandBuilder(String commandName, String subcommandName)
-  {
-    this.commandName = commandName;
-    this.subcommandName = subcommandName;
-  }
-
-  /**
-   * Adds an argument to the list of the command builder.
-   * @param argument the argument to be added.
-   */
-  public void addArgument(Argument argument)
-  {
-    // We use an ArrayList to be able to provide the possibility of updating
-    // the position of the attributes.
-    if (!args.contains(argument))
-    {
-      args.add(argument);
-    }
-  }
-
-  /**
-   * Adds an argument whose values must be obfuscated (passwords for instance).
-   * @param argument the argument to be added.
-   */
-  public void addObfuscatedArgument(Argument argument)
-  {
-    addArgument(argument);
-    obfuscatedArgs.add(argument);
-  }
-
-  /**
-   * Removes the provided argument from this CommandBuilder.
-   * @param argument the argument to be removed.
-   * @return <CODE>true</CODE> if the attribute was present and removed and
-   * <CODE>false</CODE> otherwise.
-   */
-  public boolean removeArgument(Argument argument)
-  {
-    obfuscatedArgs.remove(argument);
-    return args.remove(argument);
-  }
-
-  /**
-   * Appends the arguments of another command builder to this command builder.
-   * @param builder the CommandBuilder to append.
-   */
-  public void append(CommandBuilder builder)
-  {
-    for (Argument arg : builder.args)
-    {
-      if (builder.isObfuscated(arg))
-      {
-        addObfuscatedArgument(arg);
-      }
-      else
-      {
-        addArgument(arg);
-      }
-    }
-  }
-
-  /**
-   * Returns the String representation of this command builder (i.e. what we
-   * want to show to the user).
-   * @return the String representation of this command builder (i.e. what we
-   * want to show to the user).
-   */
-  public String toString()
-  {
-    return toString(false, LINE_SEPARATOR);
-  }
-
-  /**
-   * Returns the String representation of this command builder (i.e. what we
-   * want to show to the user).
-   * @param lineSeparator the String to be used to separate lines of the
-   * command-builder.
-   * @return the String representation of this command builder (i.e. what we
-   * want to show to the user).
-   */
-  public String toString(String lineSeparator)
-  {
-    return toString(false, lineSeparator);
-  }
-
-  /**
-   * Returns the String representation of this command builder (i.e. what we
-   * want to show to the user).
-   * @param showObfuscated displays in clear the obfuscated values.
-   * @param lineSeparator the String to be used to separate lines of the
-   * command-builder.
-   * @return the String representation of this command builder (i.e. what we
-   * want to show to the user).
-   */
-  private String toString(boolean showObfuscated, String lineSeparator)
-  {
-    StringBuilder builder = new StringBuilder();
-    builder.append(commandName);
-    if (subcommandName != null)
-    {
-      builder.append(" "+subcommandName);
-    }
-    for (Argument arg : args)
-    {
-      // This CLI is always using SSL, and the argument has been removed from
-      // the user interface
-      if (arg.getName().equals("useSSL") ) {
-        continue;
-      }
-      String argName;
-      if (arg.getLongIdentifier() != null)
-      {
-        argName = "--"+arg.getLongIdentifier();
-      }
-      else
-      {
-        argName = "-"+arg.getShortIdentifier();
-      }
-
-      if (arg instanceof BooleanArgument)
-      {
-        builder.append(lineSeparator+argName);
-      }
-      else if (arg instanceof FileBasedArgument)
-      {
-        for (String value :
-          ((FileBasedArgument)arg).getNameToValueMap().keySet())
-        {
-          builder.append(lineSeparator+argName+" ");
-          if (isObfuscated(arg) && !showObfuscated)
-          {
-            value = OBFUSCATED_VALUE;
-          }
-          else
-          {
-            value = escapeValue(value);
-          }
-          builder.append(value);
-        }
-      }
-      else
-      {
-        for (String value : arg.getValues())
-        {
-          builder.append(lineSeparator+argName+" ");
-          if (isObfuscated(arg) && !showObfuscated)
-          {
-            value = OBFUSCATED_VALUE;
-          }
-          else
-          {
-            value = escapeValue(value);
-          }
-          builder.append(value);
-        }
-      }
-    }
-    return builder.toString();
-  }
-
-  /**
-   * Clears the arguments.
-   */
-  public void clearArguments()
-  {
-    args.clear();
-    obfuscatedArgs.clear();
-  }
-
-  /**
-   * Returns the list of arguments.
-   * @return the list of arguments.
-   */
-  public List<Argument> getArguments()
-  {
-    return args;
-  }
-
-  /**
-   * Tells whether the provided argument's values must be obfuscated or not.
-   * @param argument the argument to handle.
-   * @return <CODE>true</CODE> if the attribute's values must be obfuscated and
-   * <CODE>false</CODE> otherwise.
-   */
-  public boolean isObfuscated(Argument argument)
-  {
-    return obfuscatedArgs.contains(argument);
-  }
-
-  // Chars that require special treatment when passing them to command-line.
-  private final static char[] charsToEscape = {' ', '\t', '\n', '|', ';', '<',
-    '>', '(', ')', '$', '`', '\\', '"', '\''};
-  /**
-   * This method simply takes a value and tries to transform it (with escape or
-   * '"') characters so that it can be used in a command line.
-   * @param value the String to be treated.
-   * @return the transformed value.
-   */
-  public static String escapeValue(String value)
-  {
-    StringBuilder b = new StringBuilder();
-    if (SetupUtils.isUnix())
-    {
-      for (int i=0 ; i<value.length(); i++)
-      {
-        char c = value.charAt(i);
-        boolean charToEscapeFound = false;
-        for (int j=0; j<charsToEscape.length && !charToEscapeFound; j++)
-        {
-          charToEscapeFound = c == charsToEscape[j];
-        }
-        if (charToEscapeFound)
-        {
-          b.append('\\');
-        }
-        b.append(c);
-      }
-    }
-    else
-    {
-      b.append('"').append(value).append('"');
-    }
-
-    return b.toString();
-  }
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/cli/ConsoleApplication.java b/opendj3-server-dev/src/server/org/opends/server/util/cli/ConsoleApplication.java
deleted file mode 100644
index 857628c..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/util/cli/ConsoleApplication.java
+++ /dev/null
@@ -1,1467 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2008-2010 Sun Microsystems, Inc.
- *      Portions Copyright 2012-2014 ForgeRock AS
- */
-package org.opends.server.util.cli;
-
-import static org.opends.messages.AdminToolMessages.*;
-import static org.opends.messages.DSConfigMessages.*;
-import static org.opends.messages.QuickSetupMessages.*;
-import static org.opends.messages.UtilityMessages.*;
-import static org.opends.server.util.ServerConstants.*;
-import static org.opends.server.util.StaticUtils.*;
-
-import java.io.BufferedReader;
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.io.Reader;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-
-import javax.naming.NamingException;
-import javax.naming.NoPermissionException;
-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 org.opends.admin.ads.ServerDescriptor;
-import org.opends.admin.ads.util.ApplicationTrustManager;
-import org.opends.admin.ads.util.ConnectionUtils;
-import org.opends.admin.ads.util.OpendsCertificateException;
-import org.opends.quicksetup.util.Utils;
-import org.opends.server.types.NullOutputStream;
-import org.opends.server.util.PasswordReader;
-import org.opends.server.util.SetupUtils;
-import org.opends.server.util.StaticUtils;
-
-import com.forgerock.opendj.cli.ClientException;
-import com.forgerock.opendj.cli.ReturnCode;
-
-
-/**
- * This class provides an abstract base class which can be used as the basis of
- * a console-based application.
- */
-public abstract class ConsoleApplication
-{
-
-  /**
-   * A null reader.
-   */
-  private static final class NullReader extends Reader
-  {
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void close() throws IOException
-    {
-      // Do nothing.
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public int read(char[] cbuf, int off, int len) throws IOException
-    {
-      return -1;
-    }
-  }
-
-  /**
-   * Defines the different line styles for output.
-   */
-  public enum Style {
-    /**
-     * Defines a title.
-     */
-    TITLE,
-    /**
-     * Defines a subtitle.
-     */
-    SUBTITLE,
-    /**
-     * Defines a notice.
-     */
-    NOTICE,
-    /**
-     * Defines a normal line.
-     */
-    NORMAL,
-    /**
-     * Defines an error.
-     */
-    ERROR,
-    /**
-     * Defines a warning.
-     */
-    WARNING
-  }
-
-  // The error stream which this application should use.
-  private final PrintStream err;
-
-  // The input stream reader which this application should use.
-  private final BufferedReader in;
-
-  // The output stream which this application should use.
-  private final PrintStream out;
-
-  /**
-   * The maximum number of times we try to confirm.
-   */
-  protected final static int CONFIRMATION_MAX_TRIES = 5;
-
-  private static final String COMMENT_SHELL_UNIX = "# ";
-  private static final String COMMENT_BATCH_WINDOWS = "rem ";
-
-  /**
-   * The String used to write comments in a shell (or batch) script.
-   */
-  protected static final String SHELL_COMMENT_SEPARATOR = SetupUtils
-      .isWindows() ? COMMENT_BATCH_WINDOWS : COMMENT_SHELL_UNIX;
-
-  /**
-   * Creates a new console application instance.
-   *
-   * @param in
-   *          The application input stream.
-   * @param out
-   *          The application output stream.
-   * @param err
-   *          The application error stream.
-   */
-  protected ConsoleApplication(BufferedReader in, PrintStream out,
-      PrintStream err)
-  {
-    if (in != null)
-    {
-      this.in = in;
-    }
-    else
-    {
-      this.in = new BufferedReader(new NullReader());
-    }
-
-    this.out = NullOutputStream.wrapOrNullStream(out);
-    this.err = NullOutputStream.wrapOrNullStream(err);
-  }
-
-  /**
-   * Creates a new console application instance.
-   *
-   * @param in
-   *          The application input stream.
-   * @param out
-   *          The application output stream.
-   * @param err
-   *          The application error stream.
-   */
-  protected ConsoleApplication(InputStream in, OutputStream out,
-      OutputStream err)
-  {
-    if (in != null)
-    {
-      this.in = new BufferedReader(new InputStreamReader(in));
-    }
-    else
-    {
-      this.in = new BufferedReader(new NullReader());
-    }
-
-    this.out = NullOutputStream.wrapOrNullStream(out);
-    this.err = NullOutputStream.wrapOrNullStream(err);
-  }
-
-  /**
-   * Interactively confirms whether a user wishes to perform an action. If the
-   * application is non-interactive, then the provided default is returned
-   * automatically.
-   *
-   * @param prompt
-   *          The prompt describing the action.
-   * @param defaultValue
-   *          The default value for the confirmation message. This will be
-   *          returned if the application is non-interactive or if the user just
-   *          presses return.
-   * @return Returns <code>true</code> if the user wishes the action to be
-   *         performed, or <code>false</code> if they refused, or if an
-   *         exception occurred.
-   * @throws ClientException
-   *           If the user's response could not be read from the console for
-   *           some reason.
-   */
-  public final boolean confirmAction(LocalizableMessage prompt, final boolean defaultValue)
-      throws ClientException
-  {
-    if (!isInteractive())
-    {
-      return defaultValue;
-    }
-
-    final LocalizableMessage yes = INFO_GENERAL_YES.get();
-    final LocalizableMessage no = INFO_GENERAL_NO.get();
-    final LocalizableMessage errMsg = ERR_CONSOLE_APP_CONFIRM.get(yes, no);
-    prompt =
-        INFO_MENU_PROMPT_CONFIRM.get(prompt, yes, no, defaultValue ? yes : no);
-
-    ValidationCallback<Boolean> validator = new ValidationCallback<Boolean>()
-    {
-
-      @Override
-      public Boolean validate(ConsoleApplication app, String input)
-      {
-        String ninput = input.toLowerCase().trim();
-        if (ninput.length() == 0)
-        {
-          return defaultValue;
-        }
-        else if (no.toString().toLowerCase().startsWith(ninput))
-        {
-          return false;
-        }
-        else if (yes.toString().toLowerCase().startsWith(ninput))
-        {
-          return true;
-        }
-        else
-        {
-          // Try again...
-          app.println();
-          app.println(errMsg);
-          app.println();
-        }
-
-        return null;
-      }
-    };
-
-    return readValidatedInput(prompt, validator, CONFIRMATION_MAX_TRIES);
-  }
-
-  /**
-   * Gets the application error stream.
-   *
-   * @return Returns the application error stream.
-   */
-  public final PrintStream getErrorStream()
-  {
-    return err;
-  }
-
-  /**
-   * Gets the application input stream.
-   *
-   * @return Returns the application input stream.
-   */
-  public final BufferedReader getInputStream()
-  {
-    return in;
-  }
-
-  /**
-   * Gets the application output stream.
-   *
-   * @return Returns the application output stream.
-   */
-  public final PrintStream getOutputStream()
-  {
-    return out;
-  }
-
-  /**
-   * Indicates whether or not the user has requested advanced mode.
-   *
-   * @return Returns <code>true</code> if the user has requested advanced mode.
-   */
-  public abstract boolean isAdvancedMode();
-
-  /**
-   * Indicates whether or not the user has requested interactive behavior.
-   *
-   * @return Returns <code>true</code> if the user has requested interactive
-   *         behavior.
-   */
-  public abstract boolean isInteractive();
-
-  /**
-   * Indicates whether or not this console application is running in its
-   * menu-driven mode. This can be used to dictate whether output should go to
-   * the error stream or not. In addition, it may also dictate whether or not
-   * sub-menus should display a cancel option as well as a quit option.
-   *
-   * @return Returns <code>true</code> if this console application is running in
-   *         its menu-driven mode.
-   */
-  public abstract boolean isMenuDrivenMode();
-
-  /**
-   * Indicates whether or not the user has requested quiet output.
-   *
-   * @return Returns <code>true</code> if the user has requested quiet output.
-   */
-  public abstract boolean isQuiet();
-
-  /**
-   * Indicates whether or not the user has requested script-friendly output.
-   *
-   * @return Returns <code>true</code> if the user has requested script-friendly
-   *         output.
-   */
-  public abstract boolean isScriptFriendly();
-
-  /**
-   * Indicates whether or not the user has requested verbose output.
-   *
-   * @return Returns <code>true</code> if the user has requested verbose output.
-   */
-  public abstract boolean isVerbose();
-
-  /**
-   * Interactively prompts the user to press return to continue. This method
-   * should be called in situations where a user needs to be given a chance to
-   * read some documentation before continuing (continuing may cause the
-   * documentation to be scrolled out of view).
-   */
-  public final void pressReturnToContinue()
-  {
-    LocalizableMessage msg = INFO_MENU_PROMPT_RETURN_TO_CONTINUE.get();
-    try
-    {
-      readLineOfInput(msg);
-    }
-    catch (ClientException e)
-    {
-      // Ignore the exception - applications don't care.
-    }
-  }
-
-  /**
-   * Displays a blank line to the error stream.
-   */
-  public final void println()
-  {
-    err.println();
-  }
-
-  /**
-   * Displays a message to the error stream.
-   *
-   * @param msg
-   *          The message.
-   */
-  public final void println(LocalizableMessage msg)
-  {
-    err.println(wrapText(msg, MAX_LINE_WIDTH));
-  }
-
-  /**
-   * Displays a message to the error stream.
-   *
-   * @param msg
-   *          The message.
-   */
-  public final void print(LocalizableMessage msg)
-  {
-    err.print(wrapText(msg, MAX_LINE_WIDTH));
-  }
-
-  /**
-   * Print a line with EOL in the output stream.
-   *
-   * @param msg
-   *          The message to display in normal mode.
-   * @param indent
-   *          The indentation.
-   */
-  public final void println(final LocalizableMessage msg, final int indent)
-  {
-    println(Style.NORMAL, msg, indent);
-  }
-
-  /**
-   * Print a line with EOL in the output stream.
-   *
-   * @param msgStyle
-   *          The type of formatted output desired.
-   * @param msg
-   *          The message to display in normal mode.
-   * @param indent
-   *          The indentation.
-   */
-  public final void println(final Style msgStyle, final LocalizableMessage msg,
-      final int indent)
-  {
-    if (!isQuiet())
-    {
-      switch (msgStyle)
-      {
-      case TITLE:
-        out.println();
-        out.println(">>>> " + wrapText(msg, MAX_LINE_WIDTH, indent));
-        out.println();
-        break;
-      case SUBTITLE:
-        out.println(wrapText(msg, MAX_LINE_WIDTH, indent));
-        out.println();
-        break;
-      case NOTICE:
-        out.println(wrapText("* " + msg, MAX_LINE_WIDTH, indent));
-        break;
-      case ERROR:
-        out.println();
-        out.println(wrapText("** " + msg, MAX_LINE_WIDTH, indent));
-        out.println();
-        break;
-      case WARNING:
-        out.println(wrapText("[!] " + msg, MAX_LINE_WIDTH, indent));
-        break;
-      default:
-        out.println(wrapText(msg, MAX_LINE_WIDTH, indent));
-        break;
-      }
-    }
-  }
-
-  /**
-   * Displays a blank line to the output stream if we are not in quiet mode.
-   */
-  public final void printlnProgress()
-  {
-    if (!isQuiet())
-    {
-      out.println();
-    }
-  }
-
-  /**
-   * Displays a message to the output stream if we are not in quiet mode.
-   * LocalizableMessage is wrap to max line width.
-   *
-   * @param msg
-   *          The message.
-   */
-  public final void printlnProgress(LocalizableMessage msg)
-  {
-    if (!isQuiet())
-    {
-      out.println(wrapText(msg, MAX_LINE_WIDTH));
-    }
-  }
-
-  /**
-   * Displays a message to the output stream if we are not in quiet mode.
-   *
-   * @param msg
-   *          The message.
-   */
-  public final void printProgress(final LocalizableMessage msg)
-  {
-    if (!isQuiet())
-    {
-      out.print(msg);
-    }
-  }
-
-  /**
-   * Prints a progress bar on the same output stream line if not in quiet mode.
-   *
-   * <pre>
-   * Like
-   *   msg......   50%
-   *   if progress is up to 100 :
-   *   msg.....................  100%
-   *   if progress is < 0 :
-   *   msg....  FAIL
-   *   msg.....................  FAIL
-   * </pre>
-   *
-   * @param linePos
-   *          The progress bar starts at this position on the line.
-   * @param progress
-   *          The current percentage progress to print.
-   */
-  public final void printProgressBar(final int linePos, final int progress)
-  {
-    if (!isQuiet())
-    {
-      final int spacesLeft = MAX_LINE_WIDTH - linePos - 10;
-      StringBuilder bar = new StringBuilder();
-      if (progress != 0)
-      {
-        for (int i = 0; i < 50; i++)
-        {
-          if ((i < (Math.abs(progress) / 2)) && (bar.length() < spacesLeft))
-          {
-            bar.append(".");
-          }
-        }
-      }
-      bar.append(".   ");
-      if (progress >= 0)
-      {
-        bar.append(progress).append("%     ");
-      }
-      else
-      {
-        bar.append("FAIL");
-      }
-      final int endBuilder = linePos + bar.length();
-      for (int i = 0; i < endBuilder; i++)
-      {
-        bar.append("\b");
-      }
-      if (progress >= 100 || progress < 0)
-      {
-        bar.append(EOL);
-      }
-      out.print(bar.toString());
-    }
-  }
-
-  /**
-   * Display the batch progress string to the error stream, if we are not in
-   * quiet mode.
-   *
-   * @param s
-   *          The string to display
-   */
-  public final void printlnBatchProgress(String s)
-  {
-    if (!isQuiet())
-    {
-      err.println(s);
-    }
-  }
-
-  /**
-   * Displays a message to the error stream indented by the specified number of
-   * columns.
-   *
-   * @param msg
-   *          The message.
-   * @param indent
-   *          The number of columns to indent.
-   */
-  public final void printErrln(LocalizableMessage msg, int indent)
-  {
-    err.println(wrapText(msg, MAX_LINE_WIDTH, indent));
-  }
-
-  /**
-   * Displays a message to the error stream if verbose mode is enabled.
-   *
-   * @param msg
-   *          The verbose message.
-   */
-  public final void printVerboseMessage(LocalizableMessage msg)
-  {
-    if (isVerbose() || isInteractive())
-    {
-      err.println(wrapText(msg, MAX_LINE_WIDTH));
-    }
-  }
-
-  /**
-   * Interactively retrieves a line of input from the console.
-   *
-   * @param prompt
-   *          The prompt.
-   * @return Returns the line of input, or <code>null</code> if the end of input
-   *         has been reached.
-   * @throws ClientException
-   *           If the line of input could not be retrieved for some reason.
-   */
-  public final String readLineOfInput(LocalizableMessage prompt) throws ClientException
-  {
-    if (prompt != null)
-    {
-      err.print(wrapText(prompt, MAX_LINE_WIDTH));
-      err.print(" ");
-    }
-    try
-    {
-      String s = in.readLine();
-      if (s == null)
-      {
-        throw ClientException
-            .adaptInputException(new EOFException("End of input"));
-      }
-      else
-      {
-        return s;
-      }
-    }
-    catch (IOException e)
-    {
-      throw ClientException.adaptInputException(e);
-    }
-  }
-
-  /**
-   * Displays a message and read the user's input from output.
-   *
-   * @param prompt
-   *          The message to display.
-   * @param defaultValue
-   *          The default answer by default.
-   * @param msgStyle
-   *          The formatted style chosen.
-   * @return The user's input as a string.
-   * @throws ClientException
-   *           If an Exception occurs during the process.
-   */
-  public final String readInput(final LocalizableMessage prompt,
-      final String defaultValue, final Style msgStyle)
-      throws ClientException
-  {
-    String answer = null;
-    if (msgStyle == Style.TITLE)
-    {
-      println();
-    }
-    print(INFO_PROMPT_SINGLE_DEFAULT.get(prompt, defaultValue));
-    out.print(" ");
-
-    try
-    {
-      // Reads the user input.
-      answer = in.readLine();
-    }
-    catch (IOException e)
-    {
-      throw ClientException.adaptInputException(e);
-    }
-
-    if (msgStyle == Style.TITLE
-        || msgStyle == Style.SUBTITLE)
-    {
-      println();
-    }
-
-    if ("".equals(answer))
-    {
-      if (defaultValue == null)
-      {
-        println(INFO_ERROR_EMPTY_RESPONSE.get());
-      }
-      else
-      {
-        return defaultValue;
-      }
-    }
-    return answer;
-  }
-
-  /**
-   * Commodity method that interactively prompts (on error output) the user to
-   * provide a string value. Any non-empty string will be allowed (the empty
-   * string will indicate that the default should be used, if there is one).
-   *
-   * @param prompt
-   *          The prompt to present to the user.
-   * @param defaultValue
-   *          The default value to assume if the user presses ENTER without
-   *          typing anything, or <CODE>null</CODE> if there should not be a
-   *          default and the user must explicitly provide a value.
-   * @throws ClientException
-   *           If the line of input could not be retrieved for some reason.
-   * @return The string value read from the user.
-   */
-  public String readInput(LocalizableMessage prompt, String defaultValue)
-      throws ClientException
-  {
-    while (true)
-    {
-      if (defaultValue != null)
-      {
-        prompt = INFO_PROMPT_SINGLE_DEFAULT.get(prompt, defaultValue);
-      }
-      String response = readLineOfInput(prompt);
-
-      if ("".equals(response))
-      {
-        if (defaultValue == null)
-        {
-          println(INFO_ERROR_EMPTY_RESPONSE.get());
-        }
-        else
-        {
-          return defaultValue;
-        }
-      }
-      else
-      {
-        return response;
-      }
-    }
-  }
-
-  /**
-   * Commodity method that interactively prompts (on error output) the user to
-   * provide a string value. Any non-empty string will be allowed (the empty
-   * string will indicate that the default should be used, if there is one). If
-   * an error occurs a message will be logged to the provided logger.
-   *
-   * @param prompt
-   *          The prompt to present to the user.
-   * @param defaultValue
-   *          The default value to assume if the user presses ENTER without
-   *          typing anything, or <CODE>null</CODE> if there should not be a
-   *          default and the user must explicitly provide a value.
-   * @param logger
-   *          the Logger to be used to log the error message.
-   * @return The string value read from the user.
-   */
-  public String readInput(LocalizableMessage prompt, String defaultValue, LocalizedLogger logger)
-  {
-    String s = defaultValue;
-    try
-    {
-      s = readInput(prompt, defaultValue);
-    }
-    catch (ClientException ce)
-    {
-      logger.warn(LocalizableMessage.raw("Error reading input: " + ce, ce));
-    }
-    return s;
-  }
-
-  /**
-   * Interactively retrieves a password from the console.
-   *
-   * @param prompt
-   *          The password prompt.
-   * @return Returns the password.
-   * @throws ClientException
-   *           If the password could not be retrieved for some reason.
-   */
-  public final String readPassword(LocalizableMessage prompt) throws ClientException
-  {
-    err.print(wrapText(prompt + " ", MAX_LINE_WIDTH));
-    char[] pwChars;
-    try
-    {
-      pwChars = PasswordReader.readPassword();
-    }
-    catch (Exception e)
-    {
-      throw ClientException.adaptInputException(e);
-    }
-    return new String(pwChars);
-  }
-
-  /**
-   * Commodity method that interactively retrieves a password from the console.
-   * If there is an error an error message is logged to the provided Logger and
-   * <CODE>null</CODE> is returned.
-   *
-   * @param prompt
-   *          The password prompt.
-   * @param logger
-   *          the Logger to be used to log the error message.
-   * @return Returns the password.
-   */
-  protected final String readPassword(LocalizableMessage prompt, LocalizedLogger logger)
-  {
-    String pwd = null;
-    try
-    {
-      pwd = readPassword(prompt);
-    }
-    catch (ClientException ce)
-    {
-      logger.warn(LocalizableMessage.raw("Error reading input: " + ce, ce));
-    }
-    return pwd;
-  }
-
-  /**
-   * Interactively retrieves a port value from the console.
-   *
-   * @param prompt
-   *          The port prompt.
-   * @param defaultValue
-   *          The port default value.
-   * @return Returns the port.
-   * @throws ClientException
-   *           If the port could not be retrieved for some reason.
-   */
-  public final int readPort(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 || i > 65535)
-            {
-              throw new NumberFormatException();
-            }
-            return i;
-          }
-          catch (NumberFormatException e)
-          {
-            // Try again...
-            app.println();
-            app.println(ERR_LDAP_CONN_BAD_PORT_NUMBER.get(ninput));
-            app.println();
-            return null;
-          }
-        }
-      }
-
-    };
-
-    if (defaultValue != -1)
-    {
-      prompt = INFO_PROMPT_SINGLE_DEFAULT.get(prompt, defaultValue);
-    }
-
-    return readValidatedInput(prompt, callback, CONFIRMATION_MAX_TRIES);
-  }
-
-  /**
-   * Returns a message object for the given NamingException.
-   *
-   * @param ne
-   *          the NamingException.
-   * @param hostPort
-   *          the hostPort representation of the server we were contacting when
-   *          the NamingException occurred.
-   * @return a message object for the given NamingException.
-   */
-  protected LocalizableMessage getMessageForException(NamingException ne, String hostPort)
-  {
-    return Utils.getMessageForException(ne, hostPort);
-  }
-
-  /**
-   * Commodity method used to repeatidly ask the user to provide a port value.
-   *
-   * @param prompt
-   *          the prompt message.
-   * @param defaultValue
-   *          the default value of the port to be proposed to the user.
-   * @param logger
-   *          the logger where the errors will be written.
-   * @return the port value provided by the user.
-   */
-  protected int askPort(LocalizableMessage prompt, int defaultValue, LocalizedLogger logger)
-  {
-    int port = -1;
-    while (port == -1)
-    {
-      try
-      {
-        port = readPort(prompt, defaultValue);
-      }
-      catch (ClientException ce)
-      {
-        port = -1;
-        logger.warn(LocalizableMessage.raw("Error reading input: " + ce, ce));
-      }
-    }
-    return port;
-  }
-
-  /**
-   * Interactively prompts for user input and continues until valid input is
-   * provided.
-   *
-   * @param <T>
-   *          The type of decoded user input.
-   * @param prompt
-   *          The interactive prompt which should be displayed on each input
-   *          attempt.
-   * @param validator
-   *          An input validator responsible for validating and decoding the
-   *          user's response.
-   * @return Returns the decoded user's response.
-   * @throws ClientException
-   *           If an unexpected error occurred which prevented validation.
-   */
-  public final <T> T readValidatedInput(LocalizableMessage prompt,
-      ValidationCallback<T> validator) throws ClientException
-  {
-    while (true)
-    {
-      String response = readLineOfInput(prompt);
-      T value = validator.validate(this, response);
-      if (value != null)
-      {
-        return value;
-      }
-    }
-  }
-
-  /**
-   * Interactively prompts for user input and continues until valid input is
-   * provided.
-   *
-   * @param <T>
-   *          The type of decoded user input.
-   * @param prompt
-   *          The interactive prompt which should be displayed on each input
-   *          attempt.
-   * @param validator
-   *          An input validator responsible for validating and decoding the
-   *          user's response.
-   * @param maxTries
-   *          The maximum number of tries that we can make.
-   * @return Returns the decoded user's response.
-   * @throws ClientException
-   *           If an unexpected error occurred which prevented validation or if
-   *           the maximum number of tries was reached.
-   */
-  public final <T> T readValidatedInput(LocalizableMessage prompt,
-      ValidationCallback<T> validator, int maxTries) throws ClientException
-  {
-    int nTries = 0;
-    while (nTries < maxTries)
-    {
-      String response = readLineOfInput(prompt);
-      T value = validator.validate(this, response);
-      if (value != null)
-      {
-        return value;
-      }
-      nTries++;
-    }
-    throw new ClientException(ReturnCode.TODO, ERR_TRIES_LIMIT_REACHED.get(maxTries));
-  }
-
-  /**
-   * Commodity method that interactively confirms whether a user wishes to
-   * perform an action. If the application is non-interactive, then the provided
-   * default is returned automatically. If there is an error an error message is
-   * logged to the provided Logger and the defaul value is returned.
-   *
-   * @param prompt
-   *          The prompt describing the action.
-   * @param defaultValue
-   *          The default value for the confirmation message. This will be
-   *          returned if the application is non-interactive or if the user just
-   *          presses return.
-   * @param logger
-   *          the Logger to be used to log the error message.
-   * @return Returns <code>true</code> if the user wishes the action to be
-   *         performed, or <code>false</code> if they refused.
-   * @throws ClientException
-   *           if the user did not provide valid answer after a certain number
-   *           of tries (ConsoleApplication.CONFIRMATION_MAX_TRIES)
-   */
-  protected final boolean askConfirmation(LocalizableMessage prompt, boolean defaultValue,
-      LocalizedLogger logger) throws ClientException
-  {
-    boolean v = defaultValue;
-
-    boolean done = false;
-    int nTries = 0;
-
-    while (!done && (nTries < CONFIRMATION_MAX_TRIES))
-    {
-      nTries++;
-      try
-      {
-        v = confirmAction(prompt, defaultValue);
-        done = true;
-      }
-      catch (ClientException ce)
-      {
-        if (StaticUtils.hasDescriptor(ce.getMessageObject(),
-            ERR_CONFIRMATION_TRIES_LIMIT_REACHED)
-            || StaticUtils.hasDescriptor(ce.getMessageObject(),
-                ERR_TRIES_LIMIT_REACHED))
-        {
-          throw ce;
-        }
-        logger.warn(LocalizableMessage.raw("Error reading input: " + ce, ce));
-        //      Try again...
-        println();
-      }
-    }
-
-    if (!done)
-    {
-      // This means we reached the maximum number of tries
-      throw new ClientException(ReturnCode.TODO, ERR_CONFIRMATION_TRIES_LIMIT_REACHED
-          .get(CONFIRMATION_MAX_TRIES));
-    }
-    return v;
-  }
-
-  /**
-   * 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.
-   */
-  protected 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;
-  }
-
-  /**
-   * 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());
-  }
-
-  /**
-   * 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 = Utils.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;
-  }
-
-  /**
-   * Returns the message to be displayed in the file with the equivalent
-   * command-line with information about the current time.
-   *
-   * @return the message to be displayed in the file with the equivalent
-   *         command-line with information about the current time.
-   */
-  protected String getCurrentOperationDateMessage()
-  {
-    String date = formatDateTimeStringForEquivalentCommand(new Date());
-    return INFO_OPERATION_START_TIME_MESSAGE.get(date).toString();
-  }
-
-  /**
-   * Formats a Date to String representation in "dd/MMM/yyyy:HH:mm:ss Z".
-   *
-   * @param date
-   *          to format; null if <code>date</code> is null
-   * @return string representation of the date
-   */
-  protected String formatDateTimeStringForEquivalentCommand(Date date)
-  {
-    String timeStr = null;
-    if (date != null)
-    {
-      SimpleDateFormat dateFormat =
-          new SimpleDateFormat(DATE_FORMAT_LOCAL_TIME);
-      dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
-      timeStr = dateFormat.format(date);
-    }
-    return timeStr;
-  }
-
-  /**
-   * 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 = readPassword(INFO_ADMINISTRATOR_PWD_PROMPT.get(), logger);
-    return pwd;
-  }
-
-  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;
-  }
-
-  /**
-   * 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_LDAP_CONN_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);
-  }
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/cli/ErrorStreamConsoleApplication.java b/opendj3-server-dev/src/server/org/opends/server/util/cli/ErrorStreamConsoleApplication.java
deleted file mode 100644
index d4cb1e6..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/util/cli/ErrorStreamConsoleApplication.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2008 Sun Microsystems, Inc.
- */
-package org.opends.server.util.cli;
-
-
-
-/**
- * A console application decorator which redirects all output to the
- * underlying application's error stream.
- */
-public class ErrorStreamConsoleApplication extends ConsoleApplication {
-
-  // The underlying console application.
-  private final ConsoleApplication app;
-
-
-
-  /**
-   * Creates a new console application instance which redirects all
-   * output to the underlying application's error stream.
-   *
-   * @param app
-   *          The underlying application console.
-   */
-  public ErrorStreamConsoleApplication(ConsoleApplication app) {
-    super(app.getInputStream(), app.getErrorStream(), app.getErrorStream());
-
-    this.app = app;
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public boolean isAdvancedMode() {
-    return app.isAdvancedMode();
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public boolean isInteractive() {
-    return app.isInteractive();
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public boolean isMenuDrivenMode() {
-    return app.isMenuDrivenMode();
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public boolean isQuiet() {
-    return app.isQuiet();
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public boolean isScriptFriendly() {
-    return app.isScriptFriendly();
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public boolean isVerbose() {
-    return app.isVerbose();
-  }
-
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/cli/HelpCallback.java b/opendj3-server-dev/src/server/org/opends/server/util/cli/HelpCallback.java
deleted file mode 100644
index 3e176ce..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/util/cli/HelpCallback.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2008 Sun Microsystems, Inc.
- */
-package org.opends.server.util.cli;
-
-
-
-/**
- * An interface for displaying help interactively.
- */
-public interface HelpCallback {
-
-  /**
-   * Displays help to the provided application console.
-   *
-   * @param app
-   *          The console application.
-   */
-  void display(ConsoleApplication app);
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java b/opendj3-server-dev/src/server/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java
index de12ee7..256a93f 100644
--- a/opendj3-server-dev/src/server/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java
+++ b/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);
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/cli/Menu.java b/opendj3-server-dev/src/server/org/opends/server/util/cli/Menu.java
deleted file mode 100644
index 485f7d0..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/util/cli/Menu.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2008 Sun Microsystems, Inc.
- *      Portions Copyright 2014 ForgeRock AS
- */
-package org.opends.server.util.cli;
-
-import com.forgerock.opendj.cli.ClientException;
-
-
-
-/**
- * An interactive console-based menu.
- *
- * @param <T>
- *          The type of success result value(s) returned by the
- *          call-back. Use <code>Void</code> if the call-backs do
- *          not return any values.
- */
-public interface Menu<T> {
-
-  /**
-   * Displays the menu and waits for the user to select a valid
-   * option. When the user selects an option, the call-back associated
-   * with the option will be invoked and its result returned.
-   *
-   * @return Returns the result of invoking the chosen menu call-back.
-   * @throws ClientException
-   *           If an I/O exception occurred or if one of the menu
-   *           option call-backs failed for some reason.
-   */
-  MenuResult<T> run() throws ClientException;
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/cli/MenuBuilder.java b/opendj3-server-dev/src/server/org/opends/server/util/cli/MenuBuilder.java
deleted file mode 100644
index 2eb605d..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/util/cli/MenuBuilder.java
+++ /dev/null
@@ -1,838 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2007-2008 Sun Microsystems, Inc.
- *      Portions Copyright 2014 ForgeRock AS
- */
-package org.opends.server.util.cli;
-
-
-
-import static org.opends.messages.UtilityMessages.*;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.forgerock.i18n.LocalizableMessage;
-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.ClientException;
-
-
-
-/**
- * An interface for incrementally building a command-line menu.
- *
- * @param <T>
- *          The type of value returned by the call-backs. Use
- *          <code>Void</code> if the call-backs do not return a
- *          value.
- */
-public final class MenuBuilder<T> {
-
-  /**
-   * A simple menu option call-back which is a composite of zero or
-   * more underlying call-backs.
-   *
-   * @param <T>
-   *          The type of value returned by the call-back.
-   */
-  private static final class CompositeCallback<T> implements MenuCallback<T> {
-
-    // The list of underlying call-backs.
-    private final Collection<MenuCallback<T>> callbacks;
-
-
-
-    /**
-     * Creates a new composite call-back with the specified set of
-     * call-backs.
-     *
-     * @param callbacks
-     *          The set of call-backs.
-     */
-    public CompositeCallback(Collection<MenuCallback<T>> callbacks) {
-      this.callbacks = callbacks;
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public MenuResult<T> invoke(ConsoleApplication app) throws ClientException {
-      List<T> values = new ArrayList<T>();
-      for (MenuCallback<T> callback : callbacks) {
-        MenuResult<T> result = callback.invoke(app);
-
-        if (!result.isSuccess()) {
-          // Throw away all the other results.
-          return result;
-        } else {
-          values.addAll(result.getValues());
-        }
-      }
-      return MenuResult.success(values);
-    }
-  }
-
-
-
-  /**
-   * Underlying menu implementation generated by this menu builder.
-   *
-   * @param <T>
-   *          The type of value returned by the call-backs. Use
-   *          <code>Void</code> if the call-backs do not return a
-   *          value.
-   */
-  private static final class MenuImpl<T> implements Menu<T> {
-
-    // Indicates whether the menu will allow selection of multiple
-    // numeric options.
-    private final boolean allowMultiSelect;
-
-    // The application console.
-    private final ConsoleApplication app;
-
-    // The call-back lookup table.
-    private final Map<String, MenuCallback<T>> callbacks;
-
-    // The char options table builder.
-    private final TableBuilder cbuilder;
-
-    // The call-back for the optional default action.
-    private final MenuCallback<T> defaultCallback;
-
-    // The description of the optional default action.
-    private final LocalizableMessage defaultDescription;
-
-    // The numeric options table builder.
-    private final TableBuilder nbuilder;
-
-    // The table printer.
-    private final TablePrinter printer;
-
-    // The menu prompt.
-    private final LocalizableMessage prompt;
-
-    // The menu title.
-    private final LocalizableMessage title;
-
-    // The maximum number of times we display the menu if the user provides
-    // bad input (-1 for unlimited).
-    private int nMaxTries;
-
-    // Private constructor.
-    private MenuImpl(ConsoleApplication app, LocalizableMessage title, LocalizableMessage prompt,
-        TableBuilder ntable, TableBuilder ctable, TablePrinter printer,
-        Map<String, MenuCallback<T>> callbacks, boolean allowMultiSelect,
-        MenuCallback<T> defaultCallback, LocalizableMessage defaultDescription,
-        int nMaxTries) {
-      this.app = app;
-      this.title = title;
-      this.prompt = prompt;
-      this.nbuilder = ntable;
-      this.cbuilder = ctable;
-      this.printer = printer;
-      this.callbacks = callbacks;
-      this.allowMultiSelect = allowMultiSelect;
-      this.defaultCallback = defaultCallback;
-      this.defaultDescription = defaultDescription;
-      this.nMaxTries = nMaxTries;
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public MenuResult<T> run() throws ClientException {
-      // The validation call-back which will be used to determine the
-      // action call-back.
-      ValidationCallback<MenuCallback<T>> validator =
-        new ValidationCallback<MenuCallback<T>>() {
-
-        public MenuCallback<T> validate(ConsoleApplication app, String input) {
-          String ninput = input.trim();
-
-          if (ninput.length() == 0) {
-            if (defaultCallback != null) {
-              return defaultCallback;
-            } else if (allowMultiSelect) {
-              app.println();
-              app.println(ERR_MENU_BAD_CHOICE_MULTI.get());
-              app.println();
-              return null;
-            } else {
-              app.println();
-              app.println(ERR_MENU_BAD_CHOICE_SINGLE.get());
-              app.println();
-              return null;
-            }
-          } else if (allowMultiSelect) {
-            // Use a composite call-back to collect all the results.
-            List<MenuCallback<T>> cl = new ArrayList<MenuCallback<T>>();
-            for (String value : ninput.split(",")) {
-              // Make sure that there are no duplicates.
-              String nvalue = value.trim();
-              Set<String> choices = new HashSet<String>();
-
-              if (choices.contains(nvalue)) {
-                app.println();
-                app.println(ERR_MENU_BAD_CHOICE_MULTI_DUPE.get(value));
-                app.println();
-                return null;
-              } else if (!callbacks.containsKey(nvalue)) {
-                app.println();
-                app.println(ERR_MENU_BAD_CHOICE_MULTI.get());
-                app.println();
-                return null;
-              } else {
-                cl.add(callbacks.get(nvalue));
-                choices.add(nvalue);
-              }
-            }
-
-            return new CompositeCallback<T>(cl);
-          } else if (!callbacks.containsKey(ninput)) {
-            app.println();
-            app.println(ERR_MENU_BAD_CHOICE_SINGLE.get());
-            app.println();
-            return null;
-          } else {
-            return callbacks.get(ninput);
-          }
-        }
-      };
-
-      // Determine the correct choice prompt.
-      LocalizableMessage promptMsg;
-      if (allowMultiSelect) {
-        if (defaultDescription != null) {
-          promptMsg = INFO_MENU_PROMPT_MULTI_DEFAULT.get(defaultDescription);
-        } else {
-          promptMsg = INFO_MENU_PROMPT_MULTI.get();
-        }
-      } else {
-        if (defaultDescription != null) {
-          promptMsg = INFO_MENU_PROMPT_SINGLE_DEFAULT.get(defaultDescription);
-        } else {
-          promptMsg = INFO_MENU_PROMPT_SINGLE.get();
-        }
-      }
-
-      // If the user selects help then we need to loop around and
-      // display the menu again.
-      while (true) {
-        // Display the menu.
-        if (title != null) {
-          app.println(title);
-          app.println();
-        }
-
-        if (prompt != null) {
-          app.println(prompt);
-          app.println();
-        }
-
-        if (nbuilder.getTableHeight() > 0) {
-          nbuilder.print(printer);
-          app.println();
-        }
-
-        if (cbuilder.getTableHeight() > 0) {
-          TextTablePrinter cprinter =
-            new TextTablePrinter(app.getErrorStream());
-          cprinter.setDisplayHeadings(false);
-          int sz = String.valueOf(nbuilder.getTableHeight()).length() + 1;
-          cprinter.setIndentWidth(4);
-          cprinter.setColumnWidth(0, sz);
-          cprinter.setColumnWidth(1, 0);
-          cbuilder.print(cprinter);
-          app.println();
-        }
-
-        // Get the user's choice.
-        MenuCallback<T> choice;
-
-        if (nMaxTries != -1)
-        {
-          choice = app.readValidatedInput(promptMsg, validator, nMaxTries);
-        }
-        else
-        {
-          choice = app.readValidatedInput(promptMsg, validator);
-        }
-
-        // Invoke the user's selected choice.
-        MenuResult<T> result = choice.invoke(app);
-
-        // Determine if the help needs to be displayed, display it and
-        // start again.
-        if (!result.isAgain()) {
-          return result;
-        } else {
-          app.println();
-          app.println();
-        }
-      }
-    }
-  }
-
-
-
-  /**
-   * A simple menu option call-back which does nothing but return the
-   * provided menu result.
-   *
-   * @param <T>
-   *          The type of result returned by the call-back.
-   */
-  private static final class ResultCallback<T> implements MenuCallback<T> {
-
-    // The result to be returned by this call-back.
-    private final MenuResult<T> result;
-
-
-
-    // Private constructor.
-    private ResultCallback(MenuResult<T> result) {
-      this.result = result;
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public MenuResult<T> invoke(ConsoleApplication app) throws ClientException {
-      return result;
-    }
-
-  }
-
-  // The multiple column display threshold.
-  private int threshold = -1;
-
-  // Indicates whether the menu will allow selection of multiple
-  // numeric options.
-  private boolean allowMultiSelect = false;
-
-  // The application console.
-  private final ConsoleApplication app;
-
-  // The char option call-backs.
-  private final List<MenuCallback<T>> charCallbacks =
-    new ArrayList<MenuCallback<T>>();
-
-  // The char option keys (must be single-character messages).
-  private final List<LocalizableMessage> charKeys = new ArrayList<LocalizableMessage>();
-
-  // The synopsis of char options.
-  private final List<LocalizableMessage> charSynopsis = new ArrayList<LocalizableMessage>();
-
-  // Optional column headings.
-  private final List<LocalizableMessage> columnHeadings = new ArrayList<LocalizableMessage>();
-
-  // Optional column widths.
-  private final List<Integer> columnWidths = new ArrayList<Integer>();
-
-  // The call-back for the optional default action.
-  private MenuCallback<T> defaultCallback = null;
-
-  // The description of the optional default action.
-  private LocalizableMessage defaultDescription = null;
-
-  // The numeric option call-backs.
-  private final List<MenuCallback<T>> numericCallbacks =
-    new ArrayList<MenuCallback<T>>();
-
-  // The numeric option fields.
-  private final List<List<LocalizableMessage>> numericFields =
-    new ArrayList<List<LocalizableMessage>>();
-
-  // The menu title.
-  private LocalizableMessage title = null;
-
-  // The menu prompt.
-  private LocalizableMessage prompt = null;
-
-  // The maximum number of times that we allow the user to provide an invalid
-  // answer (-1 if unlimited).
-  private int nMaxTries = -1;
-
-  /**
-   * Creates a new menu.
-   *
-   * @param app
-   *          The application console.
-   */
-  public MenuBuilder(ConsoleApplication app) {
-    this.app = app;
-  }
-
-
-
-  /**
-   * Creates a "back" menu option. When invoked, this option will
-   * return a {@code MenuResult.cancel()} result.
-   *
-   * @param isDefault
-   *          Indicates whether this option should be made the menu
-   *          default.
-   */
-  public void addBackOption(boolean isDefault) {
-    addCharOption(INFO_MENU_OPTION_BACK_KEY.get(), INFO_MENU_OPTION_BACK.get(),
-        MenuResult.<T> cancel());
-
-    if (isDefault) {
-      setDefault(INFO_MENU_OPTION_BACK_KEY.get(), MenuResult.<T> cancel());
-    }
-  }
-
-
-
-  /**
-   * Creates a "cancel" menu option. When invoked, this option will
-   * return a {@code MenuResult.cancel()} result.
-   *
-   * @param isDefault
-   *          Indicates whether this option should be made the menu
-   *          default.
-   */
-  public void addCancelOption(boolean isDefault) {
-    addCharOption(INFO_MENU_OPTION_CANCEL_KEY.get(), INFO_MENU_OPTION_CANCEL
-        .get(), MenuResult.<T> cancel());
-
-    if (isDefault) {
-      setDefault(INFO_MENU_OPTION_CANCEL_KEY.get(), MenuResult.<T> cancel());
-    }
-  }
-
-
-
-  /**
-   * Adds a menu choice to the menu which will have a single letter as
-   * its key.
-   *
-   * @param c
-   *          The single-letter message which will be used as the key
-   *          for this option.
-   * @param description
-   *          The menu option description.
-   * @param callback
-   *          The call-back associated with this option.
-   */
-  public void addCharOption(LocalizableMessage c, LocalizableMessage description,
-      MenuCallback<T> callback) {
-    charKeys.add(c);
-    charSynopsis.add(description);
-    charCallbacks.add(callback);
-  }
-
-
-
-  /**
-   * Adds a menu choice to the menu which will have a single letter as
-   * its key and which returns the provided result.
-   *
-   * @param c
-   *          The single-letter message which will be used as the key
-   *          for this option.
-   * @param description
-   *          The menu option description.
-   * @param result
-   *          The menu result which should be returned by this menu
-   *          choice.
-   */
-  public void addCharOption(LocalizableMessage c, LocalizableMessage description,
-      MenuResult<T> result) {
-    addCharOption(c, description, new ResultCallback<T>(result));
-  }
-
-
-
-  /**
-   * Creates a "help" menu option which will use the provided help
-   * call-back to display help relating to the other menu options.
-   * When the help menu option is selected help will be displayed and
-   * then the user will be shown the menu again and prompted to enter
-   * a choice.
-   *
-   * @param callback
-   *          The help call-back.
-   */
-  public void addHelpOption(final HelpCallback callback) {
-    MenuCallback<T> wrapper = new MenuCallback<T>() {
-
-      public MenuResult<T> invoke(ConsoleApplication app) throws ClientException {
-        app.println();
-        callback.display(app);
-        return MenuResult.again();
-      }
-
-    };
-
-    addCharOption(INFO_MENU_OPTION_HELP_KEY.get(), INFO_MENU_OPTION_HELP.get(),
-        wrapper);
-  }
-
-
-
-  /**
-   * Adds a menu choice to the menu which will have a numeric key.
-   *
-   * @param description
-   *          The menu option description.
-   * @param callback
-   *          The call-back associated with this option.
-   * @param extraFields
-   *          Any additional fields associated with this menu option.
-   * @return Returns the number associated with menu choice.
-   */
-  public int addNumberedOption(LocalizableMessage description, MenuCallback<T> callback,
-      LocalizableMessage... extraFields) {
-    List<LocalizableMessage> fields = new ArrayList<LocalizableMessage>();
-    fields.add(description);
-    if (extraFields != null) {
-      fields.addAll(Arrays.asList(extraFields));
-    }
-
-    numericFields.add(fields);
-    numericCallbacks.add(callback);
-
-    return numericCallbacks.size();
-  }
-
-
-
-  /**
-   * Adds a menu choice to the menu which will have a numeric key and
-   * which returns the provided result.
-   *
-   * @param description
-   *          The menu option description.
-   * @param result
-   *          The menu result which should be returned by this menu
-   *          choice.
-   * @param extraFields
-   *          Any additional fields associated with this menu option.
-   * @return Returns the number associated with menu choice.
-   */
-  public int addNumberedOption(LocalizableMessage description, MenuResult<T> result,
-      LocalizableMessage... extraFields) {
-    return addNumberedOption(description, new ResultCallback<T>(result),
-        extraFields);
-  }
-
-
-
-  /**
-   * Creates a "quit" menu option. When invoked, this option will
-   * return a {@code MenuResult.quit()} result.
-   */
-  public void addQuitOption() {
-    addCharOption(INFO_MENU_OPTION_QUIT_KEY.get(), INFO_MENU_OPTION_QUIT.get(),
-        MenuResult.<T> quit());
-  }
-
-
-
-  /**
-   * Sets the flag which indicates whether or not the menu will permit
-   * multiple numeric options to be selected at once. Users specify
-   * multiple choices by separating them with a comma. The default is
-   * <code>false</code>.
-   *
-   * @param allowMultiSelect
-   *          Indicates whether or not the menu will permit multiple
-   *          numeric options to be selected at once.
-   */
-  public void setAllowMultiSelect(boolean allowMultiSelect) {
-    this.allowMultiSelect = allowMultiSelect;
-  }
-
-
-
-  /**
-   * Sets the optional column headings. The column headings will be
-   * displayed above the menu options.
-   *
-   * @param headings
-   *          The optional column headings.
-   */
-  public void setColumnHeadings(LocalizableMessage... headings) {
-    this.columnHeadings.clear();
-    if (headings != null) {
-      this.columnHeadings.addAll(Arrays.asList(headings));
-    }
-  }
-
-
-
-  /**
-   * Sets the optional column widths. A value of zero indicates that
-   * the column should be expandable, a value of <code>null</code>
-   * indicates that the column should use its default width.
-   *
-   * @param widths
-   *          The optional column widths.
-   */
-  public void setColumnWidths(Integer... widths) {
-    this.columnWidths.clear();
-    if (widths != null) {
-      this.columnWidths.addAll(Arrays.asList(widths));
-    }
-  }
-
-
-
-  /**
-   * Sets the optional default action for this menu. The default
-   * action call-back will be invoked if the user does not specify an
-   * option and just presses enter.
-   *
-   * @param description
-   *          A short description of the default action.
-   * @param callback
-   *          The call-back associated with the default action.
-   */
-  public void setDefault(LocalizableMessage description, MenuCallback<T> callback) {
-    defaultCallback = callback;
-    defaultDescription = description;
-  }
-
-
-
-  /**
-   * Sets the optional default action for this menu. The default
-   * action call-back will be invoked if the user does not specify an
-   * option and just presses enter.
-   *
-   * @param description
-   *          A short description of the default action.
-   * @param result
-   *          The menu result which should be returned by default.
-   */
-  public void setDefault(LocalizableMessage description, MenuResult<T> result) {
-    setDefault(description, new ResultCallback<T>(result));
-  }
-
-
-
-  /**
-   * Sets the number of numeric options required to trigger
-   * multiple-column display. A negative value (the default) indicates
-   * that the numeric options will always be displayed in a single
-   * column. A value of 0 indicates that numeric options will always
-   * be displayed in multiple columns.
-   *
-   * @param threshold
-   *          The number of numeric options required to trigger
-   *          multiple-column display.
-   */
-  public void setMultipleColumnThreshold(int threshold) {
-    this.threshold = threshold;
-  }
-
-
-
-  /**
-   * Sets the optional menu prompt. The prompt will be displayed above
-   * the menu. Menus do not have a prompt by default.
-   *
-   * @param prompt
-   *          The menu prompt, or <code>null</code> if there is not
-   *          prompt.
-   */
-  public void setPrompt(LocalizableMessage prompt) {
-    this.prompt = prompt;
-  }
-
-
-
-  /**
-   * Sets the optional menu title. The title will be displayed above
-   * the menu prompt. Menus do not have a title by default.
-   *
-   * @param title
-   *          The menu title, or <code>null</code> if there is not
-   *          title.
-   */
-  public void setTitle(LocalizableMessage title) {
-    this.title = title;
-  }
-
-
-
-  /**
-   * Creates a menu from this menu builder.
-   *
-   * @return Returns the new menu.
-   */
-  public Menu<T> toMenu() {
-    TableBuilder nbuilder = new TableBuilder();
-    Map<String, MenuCallback<T>> callbacks =
-      new HashMap<String, MenuCallback<T>>();
-
-    // Determine whether multiple columns should be used for numeric
-    // options.
-    boolean useMultipleColumns = false;
-    if (threshold >= 0 && numericCallbacks.size() >= threshold) {
-      useMultipleColumns = true;
-    }
-
-    // Create optional column headers.
-    if (!columnHeadings.isEmpty()) {
-      nbuilder.appendHeading();
-      for (LocalizableMessage heading : columnHeadings) {
-        if (heading != null) {
-          nbuilder.appendHeading(heading);
-        } else {
-          nbuilder.appendHeading();
-        }
-      }
-
-      if (useMultipleColumns) {
-        nbuilder.appendHeading();
-        for (LocalizableMessage heading : columnHeadings) {
-          if (heading != null) {
-            nbuilder.appendHeading(heading);
-          } else {
-            nbuilder.appendHeading();
-          }
-        }
-      }
-    }
-
-    // Add the numeric options first.
-    int sz = numericCallbacks.size();
-    int rows = sz;
-
-    if (useMultipleColumns) {
-      // Display in two columns the first column should contain half
-      // the options. If there are an odd number of columns then the
-      // first column should contain an additional option (e.g. if
-      // there are 23 options, the first column should contain 12
-      // options and the second column 11 options).
-      rows /= 2;
-      rows += sz % 2;
-    }
-
-    for (int i = 0, j = rows; i < rows; i++, j++) {
-      nbuilder.startRow();
-      nbuilder.appendCell(INFO_MENU_NUMERIC_OPTION.get(i + 1));
-
-      for (LocalizableMessage field : numericFields.get(i)) {
-        if (field != null) {
-          nbuilder.appendCell(field);
-        } else {
-          nbuilder.appendCell();
-        }
-      }
-
-      callbacks.put(String.valueOf(i + 1), numericCallbacks.get(i));
-
-      // Second column.
-      if (useMultipleColumns && (j < sz)) {
-        nbuilder.appendCell(INFO_MENU_NUMERIC_OPTION.get(j + 1));
-
-        for (LocalizableMessage field : numericFields.get(j)) {
-          if (field != null) {
-            nbuilder.appendCell(field);
-          } else {
-            nbuilder.appendCell();
-          }
-        }
-
-        callbacks.put(String.valueOf(j + 1), numericCallbacks.get(j));
-      }
-    }
-
-    // Add the char options last.
-    TableBuilder cbuilder = new TableBuilder();
-    for (int i = 0; i < charCallbacks.size(); i++) {
-      char c = charKeys.get(i).charAt(0);
-      LocalizableMessage option = INFO_MENU_CHAR_OPTION.get(c);
-
-      cbuilder.startRow();
-      cbuilder.appendCell(option);
-      cbuilder.appendCell(charSynopsis.get(i));
-
-      callbacks.put(String.valueOf(c), charCallbacks.get(i));
-    }
-
-    // Configure the table printer.
-    TextTablePrinter printer = new TextTablePrinter(app.getErrorStream());
-
-    if (columnHeadings.isEmpty()) {
-      printer.setDisplayHeadings(false);
-    } else {
-      printer.setDisplayHeadings(true);
-      printer.setHeadingSeparatorStartColumn(1);
-    }
-
-    printer.setIndentWidth(4);
-    if (columnWidths.isEmpty()) {
-      printer.setColumnWidth(1, 0);
-      if (useMultipleColumns) {
-        printer.setColumnWidth(3, 0);
-      }
-    } else {
-      for (int i = 0; i < columnWidths.size(); i++) {
-        Integer j = columnWidths.get(i);
-        if (j != null) {
-          // Skip the option key column.
-          printer.setColumnWidth(i + 1, j);
-
-          if (useMultipleColumns) {
-            printer.setColumnWidth(i + 2 + columnWidths.size(), j);
-          }
-        }
-      }
-    }
-
-    return new MenuImpl<T>(app, title, prompt, nbuilder, cbuilder, printer,
-        callbacks, allowMultiSelect, defaultCallback, defaultDescription,
-        nMaxTries);
-  }
-
-  /**
-   * Sets the maximum number of tries that the user can provide an invalid
-   * value in the menu. -1 for unlimited tries (the default).  If this limit is
-   * reached a ClientException will be thrown.
-   * @param nTries the maximum number of tries.
-   */
-  public void setMaxTries(int nTries)
-  {
-    nMaxTries = nTries;
-  }
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/cli/MenuCallback.java b/opendj3-server-dev/src/server/org/opends/server/util/cli/MenuCallback.java
deleted file mode 100644
index 608c3b0..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/util/cli/MenuCallback.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2008 Sun Microsystems
- *      Portions Copyright 2014 ForgeRock AS
- */
-package org.opends.server.util.cli;
-
-import com.forgerock.opendj.cli.ClientException;
-
-
-/**
- * A menu call-back which should be associated with each menu option.
- * When an option is selected the call-back is invoked.
- *
- * @param <T>
- *          The type of success result value(s) returned by the
- *          call-back. Use <code>Void</code> if the call-backs do
- *          not return any values.
- */
-public interface MenuCallback<T> {
-
-  /**
-   * Invoke the menu call-back.
-   *
-   * @param app
-   *          The application console.
-   * @return Returns the result of invoking the menu call-back.
-   * @throws ClientException
-   *           If the menu call-back fails for some reason.
-   */
-  MenuResult<T> invoke(ConsoleApplication app) throws ClientException;
-}
\ No newline at end of file
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/cli/MenuResult.java b/opendj3-server-dev/src/server/org/opends/server/util/cli/MenuResult.java
deleted file mode 100644
index b4c6a97..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/util/cli/MenuResult.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2008 Sun Microsystems, Inc.
- */
-package org.opends.server.util.cli;
-
-
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-
-
-
-/**
- * The result of running a {@link Menu}. The result indicates to the
- * application how it should proceed:
- * <ul>
- * <li>{@link #again()} - the menu should be displayed again. A good
- * example of this is when a user chooses to view some help. Normally,
- * after the help is displayed, the user is allowed to select another
- * option
- * <li>{@link #cancel()} - the user chose to cancel any task
- * currently in progress and go back to the previous main menu if
- * applicable
- * <li>{@link #success()} - the user chose to apply any task
- * currently in progress and go back to the previous menu if
- * applicable. Any result values applicable to the chosen option can
- * be retrieved using {@link #getValue()} or {@link #getValues()}
- * <li>{@link #quit()} - the user chose to quit the application and
- * cancel all outstanding tasks.
- * </ul>
- *
- * @param <T>
- *          The type of result value(s) contained in success results.
- *          Use <code>Void</code> if success results should not
- *          contain values.
- */
-public final class MenuResult<T> {
-
-  /**
-   * The type of result returned from the menu.
-   */
-  private static enum Type {
-    /**
-     * The user selected an option which did not return a result, so
-     * the menu should be displayed again.
-     */
-    AGAIN,
-
-    /**
-     * The user did not select an option and instead chose to cancel
-     * the current task.
-     */
-    CANCEL,
-
-    /**
-     * The user did not select an option and instead chose to quit the
-     * entire application.
-     */
-    QUIT,
-
-    /**
-     * The user selected an option which succeeded and returned one or
-     * more result values.
-     */
-    SUCCESS
-  }
-
-
-
-  /**
-   * Creates a new menu result indicating that the menu should be
-   * displayed again. A good example of this is when a user chooses to
-   * view some help. Normally, after the help is displayed, the user
-   * is allowed to select another option.
-   *
-   * @param <T>
-   *          The type of result value(s) contained in success
-   *          results. Use <code>Void</code> if success results
-   *          should not contain values.
-   * @return Returns a new menu result indicating that the menu should
-   *         be displayed again.
-   */
-  public static <T> MenuResult<T> again() {
-    return new MenuResult<T>(Type.AGAIN, Collections.<T> emptyList());
-  }
-
-
-
-  /**
-   * Creates a new menu result indicating that the user chose to
-   * cancel any task currently in progress and go back to the previous
-   * main menu if applicable.
-   *
-   * @param <T>
-   *          The type of result value(s) contained in success
-   *          results. Use <code>Void</code> if success results
-   *          should not contain values.
-   * @return Returns a new menu result indicating that the user chose
-   *         to cancel any task currently in progress and go back to
-   *         the previous main menu if applicable.
-   */
-  public static <T> MenuResult<T> cancel() {
-    return new MenuResult<T>(Type.CANCEL, Collections.<T> emptyList());
-  }
-
-
-
-  /**
-   * Creates a new menu result indicating that the user chose to quit
-   * the application and cancel all outstanding tasks.
-   *
-   * @param <T>
-   *          The type of result value(s) contained in success
-   *          results. Use <code>Void</code> if success results
-   *          should not contain values.
-   * @return Returns a new menu result indicating that the user chose
-   *         to quit the application and cancel all outstanding tasks.
-   */
-  public static <T> MenuResult<T> quit() {
-    return new MenuResult<T>(Type.QUIT, Collections.<T> emptyList());
-  }
-
-
-
-  /**
-   * Creates a new menu result indicating that the user chose to apply
-   * any task currently in progress and go back to the previous menu
-   * if applicable. The menu result will not contain any result
-   * values.
-   *
-   * @param <T>
-   *          The type of result value(s) contained in success
-   *          results. Use <code>Void</code> if success results
-   *          should not contain values.
-   * @return Returns a new menu result indicating that the user chose
-   *         to apply any task currently in progress and go back to
-   *         the previous menu if applicable.The menu result will not
-   *         contain any result values.
-   */
-  public static <T> MenuResult<T> success() {
-    return success(Collections.<T> emptySet());
-  }
-
-
-
-  /**
-   * Creates a new menu result indicating that the user chose to apply
-   * any task currently in progress and go back to the previous menu
-   * if applicable. The menu result will contain the provided values,
-   * which can be retrieved using {@link #getValue()} or
-   * {@link #getValues()}.
-   *
-   * @param <T>
-   *          The type of the result values.
-   * @param values
-   *          The result values.
-   * @return Returns a new menu result indicating that the user chose
-   *         to apply any task currently in progress and go back to
-   *         the previous menu if applicable. The menu result will
-   *         contain the provided values, which can be retrieved using
-   *         {@link #getValue()} or {@link #getValues()}.
-   */
-  public static <T> MenuResult<T> success(Collection<T> values) {
-    return new MenuResult<T>(Type.SUCCESS, new ArrayList<T>(values));
-  }
-
-
-
-  /**
-   * Creates a new menu result indicating that the user chose to apply
-   * any task currently in progress and go back to the previous menu
-   * if applicable. The menu result will contain the provided value,
-   * which can be retrieved using {@link #getValue()} or
-   * {@link #getValues()}.
-   *
-   * @param <T>
-   *          The type of the result value.
-   * @param value
-   *          The result value.
-   * @return Returns a new menu result indicating that the user chose
-   *         to apply any task currently in progress and go back to
-   *         the previous menu if applicable. The menu result will
-   *         contain the provided value, which can be retrieved using
-   *         {@link #getValue()} or {@link #getValues()}.
-   */
-  public static <T> MenuResult<T> success(T value) {
-    return success(Collections.singleton(value));
-  }
-
-  // The type of result returned from the menu.
-  private final Type type;
-
-  // The menu result value(s).
-  private final Collection<T> values;
-
-
-
-  // Private constructor.
-  private MenuResult(Type type, Collection<T> values) {
-    this.type = type;
-    this.values = values;
-  }
-
-
-
-  /**
-   * Gets the menu result value if this is a menu result indicating
-   * success.
-   *
-   * @return Returns the menu result value, or <code>null</code> if
-   *         there was no result value or if this is not a success
-   *         menu result.
-   * @see #isSuccess()
-   */
-  public T getValue() {
-    if (values.isEmpty()) {
-      return null;
-    } else {
-      return values.iterator().next();
-    }
-  }
-
-
-
-  /**
-   * Gets the menu result values if this is a menu result indicating
-   * success.
-   *
-   * @return Returns the menu result values, which may be empty if
-   *         there were no result values or if this is not a success
-   *         menu result.
-   * @see #isSuccess()
-   */
-  public Collection<T> getValues() {
-    return new ArrayList<T>(values);
-  }
-
-
-
-  /**
-   * Determines if this menu result indicates that the menu should be
-   * displayed again. A good example of this is when a user chooses to
-   * view some help. Normally, after the help is displayed, the user
-   * is allowed to select another option.
-   *
-   * @return Returns <code>true</code> if this menu result indicates
-   *         that the menu should be displayed again.
-   */
-  public boolean isAgain() {
-    return type == Type.AGAIN;
-  }
-
-
-
-  /**
-   * Determines if this menu result indicates that the user chose to
-   * cancel any task currently in progress and go back to the previous
-   * main menu if applicable.
-   *
-   * @return Returns <code>true</code> if this menu result indicates
-   *         that the user chose to cancel any task currently in
-   *         progress and go back to the previous main menu if
-   *         applicable.
-   */
-  public boolean isCancel() {
-    return type == Type.CANCEL;
-  }
-
-
-
-  /**
-   * Determines if this menu result indicates that the user chose to
-   * quit the application and cancel all outstanding tasks.
-   *
-   * @return Returns <code>true</code> if this menu result indicates
-   *         that the user chose to quit the application and cancel
-   *         all outstanding tasks.
-   */
-  public boolean isQuit() {
-    return type == Type.QUIT;
-  }
-
-
-
-  /**
-   * Determines if this menu result indicates that the user chose to
-   * apply any task currently in progress and go back to the previous
-   * menu if applicable. Any result values can be retrieved using the
-   * {@link #getValue()} or {@link #getValues()} methods.
-   *
-   * @return Returns <code>true</code> if this menu result indicates
-   *         that the user chose to apply any task currently in
-   *         progress and go back to the previous menu if applicable.
-   * @see #getValue()
-   * @see #getValues()
-   */
-  public boolean isSuccess() {
-    return type == Type.SUCCESS;
-  }
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/cli/OutputStreamConsoleApplication.java b/opendj3-server-dev/src/server/org/opends/server/util/cli/OutputStreamConsoleApplication.java
deleted file mode 100644
index 36ea51f..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/util/cli/OutputStreamConsoleApplication.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2008 Sun Microsystems, Inc.
- */
-package org.opends.server.util.cli;
-
-
-
-/**
- * A console application decorator which redirects all output to the
- * underlying application's output stream.
- */
-public class OutputStreamConsoleApplication extends ConsoleApplication {
-
-  // The underlying console application.
-  private final ConsoleApplication app;
-
-
-
-  /**
-   * Creates a new console application instance which redirects all
-   * output to the underlying application's output stream.
-   *
-   * @param app
-   *          The underlying application console.
-   */
-  public OutputStreamConsoleApplication(ConsoleApplication app) {
-    super(app.getInputStream(), app.getOutputStream(), app.getOutputStream());
-
-    this.app = app;
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public boolean isAdvancedMode() {
-    return app.isAdvancedMode();
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public boolean isInteractive() {
-    return app.isInteractive();
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public boolean isMenuDrivenMode() {
-    return app.isMenuDrivenMode();
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public boolean isQuiet() {
-    return app.isQuiet();
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public boolean isScriptFriendly() {
-    return app.isScriptFriendly();
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public boolean isVerbose() {
-    return app.isVerbose();
-  }
-
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/cli/PointAdder.java b/opendj3-server-dev/src/server/org/opends/server/util/cli/PointAdder.java
index dfd834d..93d9489 100644
--- a/opendj3-server-dev/src/server/org/opends/server/util/cli/PointAdder.java
+++ b/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)
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/cli/ValidationCallback.java b/opendj3-server-dev/src/server/org/opends/server/util/cli/ValidationCallback.java
deleted file mode 100644
index c6ead77..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/util/cli/ValidationCallback.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2008 Sun Microsystems, Inc.
- *      Portions Copyright 2014 ForgeRock AS
- */
-package org.opends.server.util.cli;
-
-import com.forgerock.opendj.cli.ClientException;
-
-
-/**
- * An interface for validating user input.
- *
- * @param <T>
- *          The type of the decoded input.
- */
-public interface ValidationCallback<T> {
-
-  /**
-   * Validates and decodes the user-provided input. Implementations
-   * must validate <code>input</code> and return the decoded value
-   * if the input is acceptable. If the input is unacceptable,
-   * implementations must return <code>null</code> and output a user
-   * friendly error message to the provided application console.
-   *
-   * @param app
-   *          The console application.
-   * @param input
-   *          The user input to be validated.
-   * @return Returns the decoded input if the input is valid, or
-   *         <code>null</code> if it is not.
-   * @throws ClientException
-   *           If an unexpected error occurred which prevented
-   *           validation.
-   */
-  T validate(ConsoleApplication app, String input) throws ClientException;
-}
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tools/dsconfig/DsconfigLdapConnectionTestCase.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tools/dsconfig/DsconfigLdapConnectionTestCase.java
index e1e6f71..d5a8779 100644
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tools/dsconfig/DsconfigLdapConnectionTestCase.java
+++ b/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());
   }
 }
 

--
Gitblit v1.10.0