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

Violette Roche-Montane
07.09.2014 55ba6cdba97f085598334c296a54bf1c2392d971
opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java
@@ -563,7 +563,7 @@
     * @return The DN of the administrator for the given UID.
     */
    public static String getAdministratorDN(String uid) {
        return "cn=" + RDN.valueOf(uid) + ",cn=Administrators, cn=admin data";
        return RDN.valueOf("cn=" + uid) + ",cn=Administrators, cn=admin data";
    }
    /**
opendj-sdk/opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
@@ -106,8 +106,6 @@
  private ControlPanelInfo info;
  /** This CLI is always using the administration connector with SSL. */
  private final boolean alwaysSSL = true;
  private boolean useSSL = true;
  private boolean useStartTLS = false;
@@ -859,7 +857,7 @@
      try
      {
        ci.run(alwaysSSL, false);
        ci.run(false);
        userData.setAdminUID(ci.getAdministratorUID());
        userData.setAdminPwd(ci.getBindPassword());
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DSConfig.java
@@ -292,9 +292,6 @@
   */
  public static final String GENERIC_TYPE = "generic";
  /** This CLI is always using the administration connector with SSL. */
  private static final boolean alwaysSSL = true;
  private long sessionStartTime;
  private boolean sessionStartTimePrinted = false;
  private int sessionEquivalentOperationNumber = 0;
@@ -336,7 +333,7 @@
    JDKLogging.disableLogging();
    DSConfig app =
        new DSConfig(System.in, outStream, errStream,
            new LDAPManagementContextFactory(alwaysSSL));
            new LDAPManagementContextFactory());
    app.sessionStartTime = System.currentTimeMillis();
    /*
     * FIXME: obtain path info from system properties.
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java
@@ -83,20 +83,14 @@
  /** The connection parameters command builder. */
  private CommandBuilder contextCommandBuilder;
  /** This CLI is always using the administration connector with SSL. */
  private boolean alwaysSSL = false;
  /** Raw arguments. */
  private String[] rawArgs;
  /**
   * Creates a new LDAP management context factory.
   *
   * @param alwaysSSL If true, always use the SSL connection type. In this case,
   * the arguments useSSL and startTLS are not present.
   */
  public LDAPManagementContextFactory(boolean alwaysSSL) {
    this.alwaysSSL = alwaysSSL;
  public LDAPManagementContextFactory() {
    // Nothing to do.
  }
  /** {@inheritDoc} */
@@ -258,7 +252,7 @@
  public void registerGlobalArguments(SubCommandArgumentParser parser)
      throws ArgumentException {
    // Create the global arguments.
    secureArgsList = new SecureConnectionCliArgs(alwaysSSL);
    secureArgsList = new SecureConnectionCliArgs(true);
    LinkedHashSet<Argument> args = secureArgsList.createGlobalArguments();
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCli.java
@@ -319,7 +319,7 @@
              new LDAPConnectionConsoleInteraction(this, argParser
                  .getSecureArgsList());
          ci.run(true, false);
          ci.run(false);
          if (argParser.isInteractive())
          {
            bindDn = ci.getBindDN();
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java
@@ -68,6 +68,9 @@
/**
 * Supports interacting with a user through the command line to prompt for
 * information necessary to create an LDAP connection.
 *
 * Actually the LDAPConnectionConsoleInteraction is used by UninstallCliHelper, StatusCli,
 * LDAPManagementContextFactory and ReplicationCliMain.
 */
public class LDAPConnectionConsoleInteraction
{
@@ -324,37 +327,27 @@
   */
  public void run() throws ArgumentException
  {
    run(true, true);
    run(true);
  }
  /**
   * Interact with the user though the console to get information necessary to
   * establish an LDAP connection.
   *
   * @param canUseSSL
   *          whether we can propose to connect using SSL or not.
   * @param canUseStartTLS
   *          whether we can propose to connect using Start TLS or not.
   * @throws ArgumentException
   *           if there is a problem with the arguments
   */
  public void run(boolean canUseSSL, boolean canUseStartTLS)
  public void run(boolean canUseStartTLS)
      throws ArgumentException
  {
    // Reset everything
    commandBuilder.clearArguments();
    copySecureArgsList.createGlobalArguments();
    boolean secureConnection =
        (canUseSSL || canUseStartTLS)
            && (secureArgsList.useSSLArg.isPresent()
                || secureArgsList.useStartTLSArg.isPresent()
                || secureArgsList.trustAllArg.isPresent()
                || secureArgsList.trustStorePathArg.isPresent()
                || secureArgsList.trustStorePasswordArg.isPresent()
                || secureArgsList.trustStorePasswordFileArg.isPresent()
                || secureArgsList.keyStorePathArg.isPresent()
                || secureArgsList.keyStorePasswordArg.isPresent() || secureArgsList.keyStorePasswordFileArg
                  .isPresent());
    boolean secureConnection = true;
    // Get the LDAP host.
    hostName = secureArgsList.hostNameArg.getValue();
    final String tmpHostName = hostName;
@@ -403,7 +396,7 @@
      }
      catch (ClientException e)
      {
        cannotReadConnectionParameters(e);
        throw cannotReadConnectionParameters(e);
      }
    }
@@ -443,10 +436,6 @@
        {
          continue;
        }
        if (!canUseSSL && p.equals(Protocols.SSL))
        {
          continue;
        }
        if (!canUseStartTLS && p.equals(Protocols.START_TLS))
        {
          continue;
@@ -514,6 +503,7 @@
        portNumber = secureArgsList.getPortFromConfig();
      }
    }
    final int tmpPortNumber = portNumber;
    if (app.isInteractive() && !secureArgsList.portArg.isPresent())
    {
@@ -571,7 +561,7 @@
      }
      catch (ClientException e)
      {
        cannotReadConnectionParameters(e);
        throw cannotReadConnectionParameters(e);
      }
    }
@@ -683,7 +673,7 @@
        }
        catch (ClientException e)
        {
          cannotReadConnectionParameters(e);
          throw cannotReadConnectionParameters(e);
        }
      }
      if (useAdminOrBindDn)
@@ -805,10 +795,9 @@
    connectTimeout = secureArgsList.connectTimeoutArg.getIntValue();
  }
  private void cannotReadConnectionParameters(ClientException e)
      throws ArgumentException
  private ArgumentException cannotReadConnectionParameters(ClientException e)
  {
    throw new ArgumentException(ERR_ERROR_CANNOT_READ_CONNECTION_PARAMETERS
    return new ArgumentException(ERR_ERROR_CANNOT_READ_CONNECTION_PARAMETERS
        .get(e.getMessage()), e.getCause());
  }
@@ -982,7 +971,7 @@
      }
      catch (ClientException e)
      {
        cannotReadConnectionParameters(e);
        throw cannotReadConnectionParameters(e);
      }
    }
@@ -1159,7 +1148,7 @@
      }
      catch (ClientException e)
      {
        cannotReadConnectionParameters(e);
        throw cannotReadConnectionParameters(e);
      }
    }
@@ -1287,7 +1276,7 @@
      }
      catch (ClientException e)
      {
        cannotReadConnectionParameters(e);
        throw cannotReadConnectionParameters(e);
      }
    }