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

Jean-Noël Rouvignac
12.37.2016 e259bafdefd1db0bbfa0cedc96cb587e722c0a92
use DN is dsreplication

LDAPConnectionConsoleInteraction now uses DN
4 files modified
58 ■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliMain.java 8 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/status/StatusCli.java 10 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/util/cli/LDAPConnectionArgumentParser.java 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java 38 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliMain.java
@@ -1201,7 +1201,7 @@
  private ConnectionWrapper newConnectionWrapper(
      LDAPConnectionConsoleInteraction ci, Type connType, int connectTimeout) throws NamingException
  {
    return new ConnectionWrapper(getHostPort(ci), connType, DN.valueOf(ci.getBindDN()), ci.getBindPassword(),
    return new ConnectionWrapper(getHostPort(ci), connType, ci.getBindDN(), ci.getBindPassword(),
        connectTimeout, ci.getTrustManager(), ci.getKeyManager());
  }
@@ -2373,14 +2373,14 @@
      pwdFile = getPwdFile();
    }
    serverCI.initializeGlobalArguments(host, port, adminUid, bindDn, pwd, pwdFile);
    serverCI.initializeGlobalArguments(host, port, adminUid, DN.valueOf(bindDn), pwd, pwdFile);
    return doNotDisplayFirstError;
  }
  private void setConnectionDetails(EnableReplicationServerData serverData, LDAPConnectionConsoleInteraction serverCI)
  {
    serverData.setHostPort(getHostPort2(serverCI));
    serverData.setBindDn(DN.valueOf(serverCI.getBindDN()));
    serverData.setBindDn(serverCI.getBindDN());
    serverData.setPwd(serverCI.getBindPassword());
  }
@@ -2489,7 +2489,7 @@
      final String adminUid = sourceServerCI.getProvidedAdminUID();
      uData.setHostPort(getHostPort2(sourceServerCI));
      uData.setAdminUid(adminUid);
      uData.setBindDn(DN.valueOf(sourceServerCI.getProvidedBindDN()));
      uData.setBindDn(sourceServerCI.getProvidedBindDN());
      uData.setAdminPwd(sourceServerCI.getBindPassword());
      if (adminUid != null)
opendj-server-legacy/src/main/java/org/opends/server/tools/status/StatusCli.java
@@ -240,7 +240,7 @@
    if (controlInfo.getServerDescriptor().getStatus() == ServerDescriptor.ServerStatus.STARTED)
    {
      String bindDn = null;
      DN bindDn = null;
      String bindPwd = null;
      // This is done because we do not need to ask the user about these
@@ -292,7 +292,7 @@
        }
        else
        {
          bindDn = argParser.getBindDN();
          bindDn = DN.valueOf(argParser.getBindDN());
          bindPwd = argParser.getBindPassword();
        }
        if (bindPwd != null && !bindPwd.isEmpty())
@@ -316,7 +316,7 @@
      if (managementContextOpened)
      {
        try (ConnectionWrapper conn = Utilities.getAdminDirContext(controlInfo, DN.valueOf(bindDn), bindPwd))
        try (ConnectionWrapper conn = Utilities.getAdminDirContext(controlInfo, bindDn, bindPwd))
        {
          controlInfo.setConnection(conn);
          controlInfo.regenerateDescriptor();
@@ -1131,7 +1131,7 @@
    // LDAP connection information
    final String hostName = getHostNameForLdapUrl(ci.getHostName());
    final Integer portNumber = ci.getPortNumber();
    final String bindDN = ci.getBindDN();
    final DN bindDN = ci.getBindDN();
    final String bindPassword = ci.getBindPassword();
    TrustManager trustManager = ci.getTrustManager();
    final KeyManager keyManager = ci.getKeyManager();
@@ -1153,7 +1153,7 @@
        factory = new LDAPConnectionFactory(hostName, portNumber, options);
        connection = factory.getConnection();
        connection.bind(bindDN, bindPassword.toCharArray());
        connection.bind(bindDN.toString(), bindPassword.toCharArray());
        break;
      }
      catch (LdapException e)
opendj-server-legacy/src/main/java/org/opends/server/util/cli/LDAPConnectionArgumentParser.java
@@ -273,7 +273,7 @@
      ui.run();
      LDAPConnectionOptions options = new LDAPConnectionOptions();
      options.setVersionNumber(3);
      return connect(ui.getHostName(), ui.getPortNumber(), ui.getBindDN(),
      return connect(ui.getHostName(), ui.getPortNumber(), ui.getBindDN().toString(),
          ui.getBindPassword(), ui.populateLDAPOptions(options), ui.getConnectTimeout(), out, err);
    }
    catch (OpenDsException e)
opendj-server-legacy/src/main/java/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java
@@ -41,6 +41,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.DN;
import org.opends.admin.ads.util.ApplicationKeyManager;
import org.opends.admin.ads.util.ApplicationTrustManager;
import org.opends.server.admin.client.cli.SecureConnectionCliArgs;
@@ -88,8 +89,8 @@
    private boolean useSSL;
    private boolean useStartTLS;
    private String hostName;
    private String bindDN;
    private String providedBindDN;
    private DN bindDN;
    private DN providedBindDN;
    private String adminUID;
    private String providedAdminUID;
    private String bindPassword;
@@ -139,7 +140,7 @@
      return INFO_LDAPAUTH_PASSWORD_PROMPT.get(adminUID);
    }
    protected String getAdminOrBindDN()
    protected DN getAdminOrBindDN()
    {
      if (providedBindDN != null)
      {
@@ -147,7 +148,7 @@
      }
      else if (providedAdminUID != null)
      {
        return getAdministratorDN(providedAdminUID).toString();
        return getAdministratorDN(providedAdminUID);
      }
      else if (bindDN != null)
      {
@@ -155,7 +156,7 @@
      }
      else if (adminUID != null)
      {
        return getAdministratorDN(adminUID).toString();
        return getAdministratorDN(adminUID);
      }
      return null;
@@ -415,7 +416,7 @@
    }
    else
    {
      addArgToCommandBuilder(copySecureArgsList.getBindDnArg(), getBindDN());
      addArgToCommandBuilder(copySecureArgsList.getBindDnArg(), getBindDN().toString());
    }
  }
@@ -425,10 +426,10 @@
    final Argument bindDn = secureArgsList.getBindDnArg();
    state.providedAdminUID = (isAdminUidArgVisible() && adminUid.isPresent()) ? adminUid.getValue() : null;
    state.providedBindDN = ((useAdminOrBindDn || !isAdminUidArgVisible()) && bindDn.isPresent()) ? bindDn.getValue()
                                                                                                 : null;
    boolean useBindDnArg = (useAdminOrBindDn || !isAdminUidArgVisible()) && bindDn.isPresent();
    state.providedBindDN = useBindDnArg ? DN.valueOf(bindDn.getValue()) : null;
    state.adminUID = !useKeyManager() ? adminUid.getValue() : null;
    state.bindDN = !useKeyManager() ? bindDn.getValue() : null;
    state.bindDN = !useKeyManager() ? DN.valueOf(bindDn.getValue()) : null;
  }
  private void resolveCredentialPassword() throws ArgumentException
@@ -623,12 +624,13 @@
      app.println();
      if (useAdminOrBindDn)
      {
        String def = state.adminUID != null ? state.adminUID : state.bindDN;
        String def = state.adminUID != null ? state.adminUID : state.bindDN.toString();
        String v = app.readValidatedInput(INFO_LDAP_CONN_GLOBAL_ADMINISTRATOR_OR_BINDDN_PROMPT.get(def), callback);
        if (isDN(v))
        {
          state.bindDN = v;
          state.providedBindDN = v;
          DN dn = DN.valueOf(v);
          state.bindDN = dn;
          state.providedBindDN = dn;
          state.adminUID = null;
          state.providedAdminUID = null;
        }
@@ -647,7 +649,7 @@
      }
      else
      {
        state.bindDN = app.readValidatedInput(INFO_LDAP_CONN_PROMPT_BIND_DN.get(state.bindDN), callback);
        state.bindDN = DN.valueOf(app.readValidatedInput(INFO_LDAP_CONN_PROMPT_BIND_DN.get(state.bindDN), callback));
        state.providedBindDN = state.bindDN;
      }
    }
@@ -1236,7 +1238,7 @@
   *
   * @return bind DN for connections
   */
  public String getBindDN()
  public DN getBindDN()
  {
    if (useAdminOrBindDn)
    {
@@ -1244,7 +1246,7 @@
    }
    else if (isAdminUidArgVisible())
    {
      return getAdministratorDN(state.adminUID).toString();
      return getAdministratorDN(state.adminUID);
    }
    else
    {
@@ -1747,7 +1749,7 @@
   *          the Map containing the file and the password to bind.
   */
  public void initializeGlobalArguments(String hostName, int port,
      String adminUid, String bindDn, String bindPwd,
      String adminUid, DN bindDn, String bindPwd,
      LinkedHashMap<String, String> pwdFile)
  {
    resetConnectionArguments();
@@ -1777,7 +1779,7 @@
    }
    if (bindDn != null)
    {
      secureArgsList.getBindDnArg().addValue(bindDn);
      secureArgsList.getBindDnArg().addValue(bindDn.toString());
      secureArgsList.getBindDnArg().setPresent(true);
    }
    if (pwdFile != null)
@@ -1851,7 +1853,7 @@
   * @return the explicitly provided bind DN from the user (interactively or
   *         through the argument).
   */
  public String getProvidedBindDN()
  public DN getProvidedBindDN()
  {
    return state.providedBindDN;
  }