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

Gaetan Boismal
25.30.2016 6ea56ecde3d05b84f42a7338d7c2c159817d00d0
Code cleanup

Uses new com.forgerock.opendj.cli.Utils methods to handle command line
arguments conflicts.
16 files modified
397 ■■■■ changed files
opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/DSConfig.java 15 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ControlPanelArgumentParser.java 11 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/uninstaller/UninstallerArgumentParser.java 32 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/admin/client/cli/SecureConnectionCliArgs.java 28 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/admin/client/cli/SecureConnectionCliParser.java 17 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/EncodePassword.java 35 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java 4 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/InstallDSArgumentParser.java 65 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPCompare.java 6 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPDelete.java 6 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPModify.java 6 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPPasswordModify.java 51 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPSearch.java 29 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/ListBackends.java 3 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java 70 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/util/cli/LDAPConnectionArgumentParser.java 19 ●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/DSConfig.java
@@ -1136,15 +1136,15 @@
    }
    private void checkForConflictingArguments() throws ArgumentException {
        throwIfConflictingArgsSet(quietArgument, verboseArgument);
        throwIfConflictingArgsSet(batchArgument, batchFileArgument);
        throwIfArgumentsConflict(quietArgument, verboseArgument);
        throwIfArgumentsConflict(batchArgument, batchFileArgument);
        throwIfSetInInteractiveMode(batchFileArgument);
        throwIfSetInInteractiveMode(batchArgument);
        throwIfSetInInteractiveMode(quietArgument);
        throwIfConflictingArgsSet(scriptFriendlyArgument, verboseArgument);
        throwIfConflictingArgsSet(noPropertiesFileArgument, propertiesFileArgument);
        throwIfArgumentsConflict(scriptFriendlyArgument, verboseArgument);
        throwIfArgumentsConflict(noPropertiesFileArgument, propertiesFileArgument);
    }
    private void throwIfSetInInteractiveMode(Argument arg) throws ArgumentException {
@@ -1154,13 +1154,6 @@
        }
    }
    private void throwIfConflictingArgsSet(Argument arg1, Argument arg2) throws ArgumentException {
        if (arg1.isPresent() && arg2.isPresent()) {
            throw new ArgumentException(ERR_TOOL_CONFLICTING_ARGS.get(
                    arg1.getLongIdentifier(), arg2.getLongIdentifier()));
        }
    }
    /** Run the top-level interactive console. */
    private int runInteractiveMode() {
        ConsoleApplication app = this;
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ControlPanelArgumentParser.java
@@ -16,10 +16,10 @@
 */
package org.opends.guitools.controlpanel;
import static com.forgerock.opendj.cli.Utils.addErrorMessageIfArgumentsConflict;
import static org.opends.messages.ToolMessages.*;
import static com.forgerock.opendj.cli.CommonArguments.*;
import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS;
import java.util.LinkedHashSet;
@@ -145,14 +145,7 @@
    {
      errorMessages.add(ae.getMessageObject());
    }
    if (bindPasswordArg.isPresent() && bindPasswordFileArg.isPresent())
    {
      LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get(
          bindPasswordArg.getLongIdentifier(),
          bindPasswordFileArg.getLongIdentifier());
      errorMessages.add(message);
    }
    addErrorMessageIfArgumentsConflict(errorMessages, bindPasswordArg, bindPasswordArg);
    if (!errorMessages.isEmpty())
    {
opendj-server-legacy/src/main/java/org/opends/guitools/uninstaller/UninstallerArgumentParser.java
@@ -365,31 +365,13 @@
      }
      buf.append(message);
    }
    if (removeAllArg.isPresent())
    {
      BooleanArgument[] removeArgs = {
          removeServerLibrariesArg,
          removeDatabasesArg,
          removeLogFilesArg,
          removeConfigurationFilesArg,
          removeBackupFilesArg,
          removeLDIFFilesArg
      };
      for (BooleanArgument removeArg : removeArgs)
      {
        if (removeArg.isPresent())
        {
          LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get(
              removeAllArg.getLongIdentifier(),
              removeArg.getLongIdentifier());
          if (buf.length() > 0)
          {
            buf.append(LINE_SEPARATOR);
          }
          buf.append(message);
        }
      }
    }
    appendErrorMessageIfArgumentsConflict(buf, removeAllArg, removeServerLibrariesArg);
    appendErrorMessageIfArgumentsConflict(buf, removeAllArg, removeDatabasesArg);
    appendErrorMessageIfArgumentsConflict(buf, removeAllArg, removeLogFilesArg);
    appendErrorMessageIfArgumentsConflict(buf, removeAllArg, removeConfigurationFilesArg);
    appendErrorMessageIfArgumentsConflict(buf, removeAllArg, removeBackupFilesArg);
    appendErrorMessageIfArgumentsConflict(buf, removeAllArg, removeLDIFFilesArg);
    super.validateGlobalOptions(buf);
    if (buf.length() > 0)
    {
opendj-server-legacy/src/main/java/org/opends/server/admin/client/cli/SecureConnectionCliArgs.java
@@ -19,7 +19,6 @@
import static com.forgerock.opendj.cli.ReturnCode.*;
import static com.forgerock.opendj.cli.Utils.*;
import static com.forgerock.opendj.cli.CommonArguments.*;
import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS;
import static org.opends.messages.ToolMessages.*;
import static org.opends.messages.AdminToolMessages.*;
@@ -298,22 +297,17 @@
   */
  public int validateGlobalOptions(LocalizableMessageBuilder buf)
  {
    List<LocalizableMessage> errors = new ArrayList<>();
    addIfArgsAreConflicting(errors, bindPasswordArg, bindPasswordFileArg);
    // Couldn't have at the same time trustAll and trustStore related args
    addIfArgsAreConflicting(errors, trustAllArg, trustStorePathArg);
    addIfArgsAreConflicting(errors, trustAllArg, trustStorePasswordArg);
    addIfArgsAreConflicting(errors, trustAllArg, trustStorePasswordFileArg);
    addIfArgsAreConflicting(errors, trustStorePasswordArg, trustStorePasswordFileArg);
    final List<LocalizableMessage> errors = new ArrayList<>();
    addErrorMessageIfArgumentsConflict(errors, bindPasswordArg, bindPasswordFileArg);
    addErrorMessageIfArgumentsConflict(errors, trustAllArg, trustStorePathArg);
    addErrorMessageIfArgumentsConflict(errors, trustAllArg, trustStorePasswordArg);
    addErrorMessageIfArgumentsConflict(errors, trustAllArg, trustStorePasswordFileArg);
    addErrorMessageIfArgumentsConflict(errors, trustStorePasswordArg, trustStorePasswordFileArg);
    addErrorMessageIfArgumentsConflict(errors, useStartTLSArg, useSSLArg);
    checkIfPathArgumentIsReadable(errors, trustStorePathArg, ERR_CANNOT_READ_TRUSTSTORE);
    checkIfPathArgumentIsReadable(errors, keyStorePathArg, ERR_CANNOT_READ_KEYSTORE);
    addIfArgsAreConflicting(errors, useStartTLSArg, useSSLArg);
    if (!errors.isEmpty())
    {
      for (LocalizableMessage error : errors)
@@ -330,14 +324,6 @@
    return SUCCESS.get();
  }
  private void addIfArgsAreConflicting(List<LocalizableMessage> errors, Argument arg1, Argument arg2)
  {
    if (arg1.isPresent() && arg2.isPresent())
    {
      errors.add(ERR_TOOL_CONFLICTING_ARGS.get(arg1.getLongIdentifier(), arg2.getLongIdentifier()));
    }
  }
  private void checkIfPathArgumentIsReadable(List<LocalizableMessage> errors, StringArgument pathArg, Arg1<Object> msg)
  {
    if (pathArg.isPresent() && !canRead(pathArg.getValue()))
opendj-server-legacy/src/main/java/org/opends/server/admin/client/cli/SecureConnectionCliParser.java
@@ -211,24 +211,11 @@
   */
  public int validateGlobalOptions(final LocalizableMessageBuilder buf)
  {
    int ret = secureArgsList.validateGlobalOptions(buf) ;
    // Couldn't have at the same time properties file arg and
    // propertiesFileArg
    if (noPropertiesFileArg.isPresent()
        && propertiesFileArg.isPresent())
    final int ret = secureArgsList.validateGlobalOptions(buf) ;
    if (appendErrorMessageIfArgumentsConflict(buf, noPropertiesFileArg, propertiesFileArg))
    {
      LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get(
          noPropertiesFileArg.getLongIdentifier(), propertiesFileArg
              .getLongIdentifier());
      if (buf.length() > 0)
      {
        buf.append(LINE_SEPARATOR);
      }
      buf.append(message);
      return CONFLICTING_ARGS.get();
    }
    return ret;
  }
opendj-server-legacy/src/main/java/org/opends/server/tools/EncodePassword.java
@@ -18,7 +18,6 @@
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.CliMessages.INFO_FILE_PLACEHOLDER;
import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS;
import static com.forgerock.opendj.cli.Utils.*;
import static com.forgerock.opendj.cli.CommonArguments.*;
@@ -264,35 +263,19 @@
    }
    // Check for conflicting arguments.
    if (clearPassword.isPresent() && clearPasswordFile.isPresent())
    try
    {
      printWrappedText(err,
          ERR_TOOL_CONFLICTING_ARGS.get(clearPassword.getLongIdentifier(), clearPasswordFile.getLongIdentifier()));
      throwIfArgumentsConflict(clearPassword, clearPasswordFile);
      throwIfArgumentsConflict(clearPassword, interactivePassword);
      throwIfArgumentsConflict(clearPasswordFile, interactivePassword);
      throwIfArgumentsConflict(encodedPassword, encodedPasswordFile);
    }
    catch (final ArgumentException conflict)
    {
      printWrappedText(err, conflict.getMessageObject());
      return OPERATIONS_ERROR;
    }
    if (clearPassword.isPresent() && interactivePassword.isPresent())
    {
      printWrappedText(err,
          ERR_TOOL_CONFLICTING_ARGS.get(clearPassword.getLongIdentifier(), interactivePassword.getLongIdentifier()));
      return OPERATIONS_ERROR;
    }
    if (clearPasswordFile.isPresent() && interactivePassword.isPresent())
    {
      printWrappedText(err, ERR_TOOL_CONFLICTING_ARGS.get(clearPasswordFile.getLongIdentifier(),
                                                          interactivePassword.getLongIdentifier()));
      return OPERATIONS_ERROR;
    }
    if (encodedPassword.isPresent() && encodedPasswordFile.isPresent())
    {
      printWrappedText(err,
          ERR_TOOL_CONFLICTING_ARGS.get(encodedPassword.getLongIdentifier(), encodedPasswordFile.getLongIdentifier()));
      return OPERATIONS_ERROR;
    }
    // If we are not going to just list the storage schemes, then the clear-text
    // password must have been provided.  If we're going to encode a password,
    // then the scheme must have also been provided.
opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java
@@ -23,7 +23,6 @@
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS;
import java.io.File;
import java.io.OutputStream;
@@ -225,8 +224,7 @@
    {
      if (templateFile.isPresent())
      {
        printWrappedText(err,
            ERR_TOOL_CONFLICTING_ARGS.get(ldifFiles.getLongIdentifier(), templateFile.getLongIdentifier()));
        printWrappedText(err, conflictingArgsErrorMessage(ldifFiles, templateFile));
        return 1;
      }
    }
opendj-server-legacy/src/main/java/org/opends/server/tools/InstallDSArgumentParser.java
@@ -21,8 +21,7 @@
import static com.forgerock.opendj.cli.CliMessages.INFO_NUM_ENTRIES_PLACEHOLDER;
import static com.forgerock.opendj.cli.CliMessages.INFO_PORT_PLACEHOLDER;
import static com.forgerock.opendj.cli.CliMessages.INFO_ROOT_USER_PWD_FILE_PLACEHOLDER;
import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS;
import static com.forgerock.opendj.cli.Utils.addErrorMessageIfArgumentsConflict;
import static org.opends.messages.ToolMessages.*;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
@@ -503,13 +502,7 @@
   */
  private void checkServerPassword(Collection<LocalizableMessage> errorMessages)
  {
    if (directoryManagerPwdStringArg.isPresent() &&
        directoryManagerPwdFileArg.isPresent())
    {
      errorMessages.add(ERR_TOOL_CONFLICTING_ARGS.get(
          directoryManagerPwdStringArg.getLongIdentifier(),
          directoryManagerPwdFileArg.getLongIdentifier()));
    }
    addErrorMessageIfArgumentsConflict(errorMessages, directoryManagerPwdStringArg, directoryManagerPwdFileArg);
    if (noPromptArg.isPresent() && !directoryManagerPwdStringArg.isPresent() &&
        !directoryManagerPwdFileArg.isPresent())
@@ -575,39 +568,13 @@
  private void checkImportDataArguments(Collection<LocalizableMessage> errorMessages)
  {
    //  Make sure that the user didn't provide conflicting arguments.
    if (addBaseEntryArg.isPresent())
    {
      if (importLDIFArg.isPresent())
      {
        errorMessages.add(conflictingArgs(addBaseEntryArg, importLDIFArg));
      }
      else if (sampleDataArg.isPresent())
      {
        errorMessages.add(conflictingArgs(addBaseEntryArg, sampleDataArg));
      }
    }
    else if (importLDIFArg.isPresent() && sampleDataArg.isPresent())
    {
      errorMessages.add(conflictingArgs(importLDIFArg, sampleDataArg));
    }
    if (rejectedImportFileArg.isPresent() && addBaseEntryArg.isPresent())
    {
      errorMessages.add(conflictingArgs(addBaseEntryArg, rejectedImportFileArg));
    }
    else if (rejectedImportFileArg.isPresent() && sampleDataArg.isPresent())
    {
      errorMessages.add(conflictingArgs(rejectedImportFileArg, sampleDataArg));
    }
    if (skippedImportFileArg.isPresent() && addBaseEntryArg.isPresent())
    {
      errorMessages.add(conflictingArgs(addBaseEntryArg, skippedImportFileArg));
    }
    else if (skippedImportFileArg.isPresent() && sampleDataArg.isPresent())
    {
      errorMessages.add(conflictingArgs(skippedImportFileArg, sampleDataArg));
    }
    addErrorMessageIfArgumentsConflict(errorMessages, addBaseEntryArg, importLDIFArg);
    addErrorMessageIfArgumentsConflict(errorMessages, addBaseEntryArg, sampleDataArg);
    addErrorMessageIfArgumentsConflict(errorMessages, importLDIFArg, sampleDataArg);
    addErrorMessageIfArgumentsConflict(errorMessages, addBaseEntryArg, rejectedImportFileArg);
    addErrorMessageIfArgumentsConflict(errorMessages, rejectedImportFileArg, sampleDataArg);
    addErrorMessageIfArgumentsConflict(errorMessages, addBaseEntryArg, skippedImportFileArg);
    addErrorMessageIfArgumentsConflict(errorMessages, skippedImportFileArg, sampleDataArg);
    final boolean noBaseDNProvided = !baseDNArg.isPresent() && baseDNArg.getDefaultValue() == null;
    if (noPromptArg.isPresent() && noBaseDNProvided)
@@ -623,11 +590,6 @@
    }
  }
  private LocalizableMessage conflictingArgs(Argument arg1, Argument arg2)
  {
    return ERR_TOOL_CONFLICTING_ARGS.get(arg1.getLongIdentifier(), arg2.getLongIdentifier());
  }
  /**
   * Checks that there are no conflicts with the security arguments.
   * If we are in no prompt mode, check that all the information required has
@@ -678,14 +640,7 @@
    {
      if (!generateSelfSignedCertificateArg.isPresent())
      {
        // Check that we have only a password.
        if (keyStorePasswordArg.isPresent() &&
            keyStorePasswordFileArg.isPresent())
        {
          errorMessages.add(ERR_TOOL_CONFLICTING_ARGS.get(
              keyStorePasswordArg.getLongIdentifier(),
              keyStorePasswordFileArg.getLongIdentifier()));
        }
        addErrorMessageIfArgumentsConflict(errorMessages, keyStorePasswordArg, keyStorePasswordFileArg);
        // Check that we have one password in no prompt mode.
        if (noPromptArg.isPresent() && !keyStorePasswordArg.isPresent() &&
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPCompare.java
@@ -20,7 +20,6 @@
import static com.forgerock.opendj.cli.CliMessages.INFO_DESCRIPTION_BINDPASSWORDFILE;
import static com.forgerock.opendj.cli.Utils.*;
import static com.forgerock.opendj.cli.CommonArguments.*;
import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.protocols.ldap.LDAPResultCode.*;
@@ -603,10 +602,9 @@
      return SUCCESS;
    }
    if(bindPassword.isPresent() && bindPasswordFile.isPresent())
    if (bindPassword.isPresent() && bindPasswordFile.isPresent())
    {
      printWrappedText(
          err, ERR_TOOL_CONFLICTING_ARGS.get(bindPassword.getLongIdentifier(), bindPasswordFile.getLongIdentifier()));
      printWrappedText(err, conflictingArgsErrorMessage(bindPassword, bindPasswordFile));
      return CLIENT_SIDE_PARAM_ERROR;
    }
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPDelete.java
@@ -18,7 +18,6 @@
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.CliMessages.INFO_DESCRIPTION_BINDPASSWORDFILE;
import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS;
import static com.forgerock.opendj.cli.Utils.*;
import static com.forgerock.opendj.cli.CommonArguments.*;
@@ -512,10 +511,9 @@
      return 0;
    }
    if(bindPassword.isPresent() && bindPasswordFile.isPresent())
    if (bindPassword.isPresent() && bindPasswordFile.isPresent())
    {
      printWrappedText(
          err, ERR_TOOL_CONFLICTING_ARGS.get(bindPassword.getLongIdentifier(), bindPasswordFile.getLongIdentifier()));
      printWrappedText(err, conflictingArgsErrorMessage(bindPassword, bindPasswordFile));
      return CLIENT_SIDE_PARAM_ERROR;
    }
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPModify.java
@@ -21,7 +21,6 @@
import static com.forgerock.opendj.cli.CliMessages.INFO_DESCRIPTION_BINDPASSWORDFILE;
import static com.forgerock.opendj.cli.Utils.*;
import static com.forgerock.opendj.cli.CommonArguments.*;
import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.protocols.ldap.LDAPResultCode.*;
@@ -811,10 +810,9 @@
      return SUCCESS;
    }
    if(bindPassword.isPresent() && bindPasswordFile.isPresent())
    if (bindPassword.isPresent() && bindPasswordFile.isPresent())
    {
      printWrappedText(
          err, ERR_TOOL_CONFLICTING_ARGS.get(bindPassword.getLongIdentifier(), bindPasswordFile.getLongIdentifier()));
      printWrappedText(err, conflictingArgsErrorMessage(bindPassword, bindPasswordFile));
      return CLIENT_SIDE_PARAM_ERROR;
    }
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPPasswordModify.java
@@ -24,7 +24,6 @@
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS;
import static com.forgerock.opendj.cli.CommonArguments.*;
import java.io.OutputStream;
@@ -365,49 +364,21 @@
    // Make sure that the user didn't specify any conflicting arguments.
    if (bindPW.isPresent() && bindPWFile.isPresent())
    try
    {
      printWrappedText(
          err, ERR_TOOL_CONFLICTING_ARGS.get(bindPW.getLongIdentifier(), bindPWFile.getLongIdentifier()));
      throwIfArgumentsConflict(bindPW, bindPWFile);
      throwIfArgumentsConflict(newPW, newPWFile);
      throwIfArgumentsConflict(currentPW, currentPWFile);
      throwIfArgumentsConflict(useSSL, useStartTLS);
      throwIfArgumentsConflict(sslKeyStorePIN, sslKeyStorePINFile);
      throwIfArgumentsConflict(sslTrustStorePIN, sslTrustStorePINFile);
    }
    catch(final ArgumentException conflict)
    {
      printWrappedText(err, conflict.getMessageObject());
      return CLIENT_SIDE_PARAM_ERROR;
    }
    if (newPW.isPresent() && newPWFile.isPresent())
    {
      printWrappedText(
          err, ERR_TOOL_CONFLICTING_ARGS.get(newPW.getLongIdentifier(), newPWFile.getLongIdentifier()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
    if (currentPW.isPresent() && currentPWFile.isPresent())
    {
      printWrappedText(err,
          ERR_TOOL_CONFLICTING_ARGS.get(currentPW.getLongIdentifier(), currentPWFile.getLongIdentifier()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
    if (useSSL.isPresent() && useStartTLS.isPresent())
    {
      printWrappedText(
          err, ERR_TOOL_CONFLICTING_ARGS.get(useSSL.getLongIdentifier(), useStartTLS.getLongIdentifier()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
    if (sslKeyStorePIN.isPresent() && sslKeyStorePINFile.isPresent())
    {
      printWrappedText(err,
          ERR_TOOL_CONFLICTING_ARGS.get(sslKeyStorePIN.getLongIdentifier(), sslKeyStorePINFile.getLongIdentifier()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
    if (sslTrustStorePIN.isPresent() && sslTrustStorePINFile.isPresent())
    {
      printWrappedText(err, ERR_TOOL_CONFLICTING_ARGS.get(sslTrustStorePIN.getLongIdentifier(),
                                                          sslTrustStorePINFile.getLongIdentifier()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
    // If a bind DN was provided, make sure that a password was given.  If a
    // password was given, make sure a bind DN was provided.  If neither were
    // given, then make sure that an authorization ID and the current password
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPSearch.java
@@ -19,7 +19,6 @@
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static com.forgerock.opendj.cli.CommonArguments.*;
import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.protocols.ldap.LDAPConstants.*;
@@ -1015,30 +1014,16 @@
      attributes.addAll(filterAndAttributeStrings);
    }
    if(bindPassword.isPresent() && bindPasswordFile.isPresent())
    try
    {
      printWrappedText(err,
          ERR_TOOL_CONFLICTING_ARGS.get(bindPassword.getLongIdentifier(), bindPasswordFile.getLongIdentifier()));
      return CLIENT_SIDE_PARAM_ERROR;
      throwIfArgumentsConflict(bindPassword, bindPasswordFile);
      throwIfArgumentsConflict(useSSL, startTLS);
      throwIfArgumentsConflict(keyStorePassword, keyStorePasswordFile);
      throwIfArgumentsConflict(trustStorePassword, trustStorePasswordFile);
    }
    if (useSSL.isPresent() && startTLS.isPresent())
    catch (final ArgumentException conflict)
    {
      printWrappedText(err, ERR_TOOL_CONFLICTING_ARGS.get(useSSL.getLongIdentifier(), startTLS.getLongIdentifier()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
    if (keyStorePassword.isPresent() && keyStorePasswordFile.isPresent())
    {
      printWrappedText(err, ERR_TOOL_CONFLICTING_ARGS.get(
          keyStorePassword.getLongIdentifier(), keyStorePasswordFile.getLongIdentifier()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
    if (trustStorePassword.isPresent() && trustStorePasswordFile.isPresent())
    {
      printWrappedText(err, ERR_TOOL_CONFLICTING_ARGS.get(
          trustStorePassword.getLongIdentifier(), trustStorePasswordFile.getLongIdentifier()));
      printWrappedText(err, conflict.getMessageObject());
      return CLIENT_SIDE_PARAM_ERROR;
    }
opendj-server-legacy/src/main/java/org/opends/server/tools/ListBackends.java
@@ -19,7 +19,6 @@
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static com.forgerock.opendj.cli.CommonArguments.*;
import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.messages.ToolMessages.*;
@@ -205,7 +204,7 @@
    // arguments.
    if (backendID.isPresent() && baseDN.isPresent())
    {
      printWrappedText(err, ERR_TOOL_CONFLICTING_ARGS.get(backendID.getLongIdentifier(), baseDN.getLongIdentifier()));
      printWrappedText(err, conflictingArgsErrorMessage(backendID, baseDN));
      return 1;
    }
opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java
@@ -19,7 +19,6 @@
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.CliMessages.INFO_BINDPWD_FILE_PLACEHOLDER;
import static com.forgerock.opendj.cli.CliMessages.INFO_PORT_PLACEHOLDER;
import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS;
import static com.forgerock.opendj.cli.Utils.*;
import static com.forgerock.opendj.cli.CommonArguments.*;
@@ -287,14 +286,9 @@
  {
    int returnValue;
    super.validateGlobalOptions(buf);
    ArrayList<LocalizableMessage> errors = new ArrayList<>();
    if (secureArgsList.getBindPasswordArg().isPresent() &&
        secureArgsList.getBindPasswordFileArg().isPresent()) {
      LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get(
          secureArgsList.getBindPasswordArg().getLongIdentifier(),
          secureArgsList.getBindPasswordFileArg().getLongIdentifier());
      errors.add(message);
    }
    final List<LocalizableMessage> errors = new ArrayList<>();
    addErrorMessageIfArgumentsConflict(
        errors, secureArgsList.getBindPasswordArg(), secureArgsList.getBindPasswordFileArg());
    // Check that we can write on the provided path where we write the
    // equivalent non-interactive commands.
@@ -316,13 +310,7 @@
      }
    }
    if (noPromptArg.isPresent() && advancedArg.isPresent())
    {
      LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get(
          noPromptArg.getLongIdentifier(),
          advancedArg.getLongIdentifier());
      errors.add(message);
    }
    addErrorMessageIfArgumentsConflict(errors, noPromptArg, advancedArg);
    if (!isInteractive())
    {
@@ -1504,28 +1492,13 @@
   */
  private void validateEnableReplicationOptions(LocalizableMessageBuilder buf)
  {
    Argument[][] conflictingPairs =
    {
        { server1.bindPasswordArg, server1.bindPasswordFileArg },
        { server2.bindPasswordArg, server2.bindPasswordFileArg },
        { server1.replicationPortArg, server1.noReplicationServerArg },
        { server1.noReplicationServerArg, server1.onlyReplicationServerArg },
        { server2.replicationPortArg, server2.noReplicationServerArg },
        { server2.noReplicationServerArg, server2.onlyReplicationServerArg },
        {noSchemaReplicationArg, useSecondServerAsSchemaSourceArg}
    };
    for (Argument[] conflictingPair : conflictingPairs)
    {
      Argument arg1 = conflictingPair[0];
      Argument arg2 = conflictingPair[1];
      if (arg1.isPresent() && arg2.isPresent())
      {
        LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get(
            arg1.getLongIdentifier(), arg2.getLongIdentifier());
        addMessage(buf, message);
      }
    }
    appendErrorMessageIfArgumentsConflict(buf, server1.bindPasswordArg, server1.bindPasswordFileArg );
    appendErrorMessageIfArgumentsConflict(buf, server2.bindPasswordArg, server2.bindPasswordFileArg );
    appendErrorMessageIfArgumentsConflict(buf, server1.replicationPortArg, server1.noReplicationServerArg );
    appendErrorMessageIfArgumentsConflict(buf, server1.noReplicationServerArg, server1.onlyReplicationServerArg );
    appendErrorMessageIfArgumentsConflict(buf, server2.replicationPortArg, server2.noReplicationServerArg );
    appendErrorMessageIfArgumentsConflict(buf, server2.noReplicationServerArg, server2.onlyReplicationServerArg );
    appendErrorMessageIfArgumentsConflict(buf,noSchemaReplicationArg, useSecondServerAsSchemaSourceArg);
    if (server1.hostNameArg.getValue().equalsIgnoreCase(server2.hostNameArg.getValue())
        && !isInteractive()
@@ -1549,24 +1522,9 @@
   */
  private void validateDisableReplicationOptions(LocalizableMessageBuilder buf)
  {
    Argument[][] conflictingPairs =
    {
        {getAdminUidArg(), secureArgsList.getBindDnArg() },
        {disableAllArg, disableReplicationServerArg},
        {disableAllArg, baseDNsArg}
    };
    for (Argument[] conflictingPair : conflictingPairs)
    {
      Argument arg1 = conflictingPair[0];
      Argument arg2 = conflictingPair[1];
      if (arg1.isPresent() && arg2.isPresent())
      {
        LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get(
            arg1.getLongIdentifier(), arg2.getLongIdentifier());
        addMessage(buf, message);
      }
    }
    appendErrorMessageIfArgumentsConflict(buf, getAdminUidArg(), secureArgsList.getBindDnArg());
    appendErrorMessageIfArgumentsConflict(buf, disableAllArg, disableReplicationServerArg);
    appendErrorMessageIfArgumentsConflict(buf, disableAllArg, baseDNsArg);
  }
  /**
opendj-server-legacy/src/main/java/org/opends/server/util/cli/LDAPConnectionArgumentParser.java
@@ -19,7 +19,6 @@
import static org.opends.messages.ToolMessages.*;
import static com.forgerock.opendj.cli.Utils.*;
import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS;
import java.io.PrintStream;
import java.util.LinkedList;
@@ -139,11 +138,10 @@
  private LDAPConnection connect(SecureConnectionCliArgs args, PrintStream out, PrintStream err)
      throws LDAPConnectionException, ArgumentException
  {
    // Checks for conflicting arguments
    throwIfArgumentsConflict(err, args.getBindPasswordArg(), args.getBindPasswordArg());
    throwIfArgumentsConflict(err, args.getKeyStorePasswordArg(), args.getKeyStorePasswordFileArg());
    throwIfArgumentsConflict(err, args.getTrustStorePasswordArg(), args.getTrustStorePasswordFileArg());
    throwIfArgumentsConflict(err, args.getUseSSLArg(), args.getUseStartTLSArg());
    throwIfArgumentsConflict(args.getBindPasswordArg(), args.getBindPasswordArg());
    throwIfArgumentsConflict(args.getKeyStorePasswordArg(), args.getKeyStorePasswordFileArg());
    throwIfArgumentsConflict(args.getTrustStorePasswordArg(), args.getTrustStorePasswordFileArg());
    throwIfArgumentsConflict(args.getUseSSLArg(), args.getUseStartTLSArg());
    // Create the LDAP connection options object, which will be used to
    // customize the way that we connect to the server and specify a set of
@@ -463,13 +461,4 @@
      ae.printStackTrace(); // Should never happen
    }
  }
  private void throwIfArgumentsConflict(final PrintStream err, final Argument arg1, final Argument arg2)
      throws ArgumentException
  {
    if (arg1.isPresent() && arg2.isPresent())
    {
      printAndThrowException(err, ERR_TOOL_CONFLICTING_ARGS.get(arg1.getLongIdentifier(), arg2.getLongIdentifier()));
    }
  }
}