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

jvergara
05.02.2007 6c2e04c90410734dc61a340c1a73bc7c7864fe13
Fixed some issues with the connection handling in the ReplicationCliMain, and improvded the messages when we prompt for the type of connection that the user wants to use to update configuration.

Fixed a localization bug in SubCommandArgumentParser.
3 files modified
151 ■■■■ changed files
opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliMain.java 120 ●●●●● patch | view | raw | blame | history
opends/src/messages/messages/admin_tool.properties 23 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/util/args/SubCommandArgumentParser.java 8 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliMain.java
@@ -460,12 +460,12 @@
    boolean useStartTLS1 = argParser.useStartTLS1();
    if (!useSSL1 && !useStartTLS1)
    {
      useSSL1 = confirm(INFO_CLI_USESSL_PROMPT.get(), false);
      useSSL1 = confirm(INFO_REPLICATION_ENABLE_USESSL1_PROMPT.get(), false);
      prompted = true;
      if (!useSSL1)
      {
        useStartTLS1 =
          confirm(INFO_CLI_USESTARTTLS_PROMPT.get(), false);
          confirm(INFO_REPLICATION_ENABLE_USESTARTTLS1_PROMPT.get(), false);
        prompted = true;
      }
    }
@@ -544,10 +544,12 @@
          pwd1 = promptForPassword(
              INFO_REPLICATION_ENABLE_PASSWORD1_PROMPT.get(bindDn1));
          useSSL1 = confirm(INFO_CLI_USESSL_PROMPT.get(), useSSL1);
          useSSL1 = confirm(INFO_REPLICATION_ENABLE_USESSL1_PROMPT.get(),
              useSSL1);
          if (!useSSL1)
          {
            useStartTLS1 = confirm(INFO_CLI_USESTARTTLS_PROMPT.get(),
            useStartTLS1 = confirm(
                INFO_REPLICATION_ENABLE_USESTARTTLS1_PROMPT.get(),
                useStartTLS1);
          }
        }
@@ -612,7 +614,9 @@
      // enableReplication(EnableReplicationUserData) method.  Here we have
      // to load the ADS to ask the user to accept the certificates and
      // eventually admin authentication data.
      cancelled = !loadADSAndAcceptCertificates(ctx1, uData, true);
      InitialLdapContext[] aux = new InitialLdapContext[] {ctx1};
      cancelled = !loadADSAndAcceptCertificates(aux, uData, true);
      ctx1 = aux[0];
      if (!cancelled)
      {
        administratorDefined |= hasAdministrator(ctx1);
@@ -665,11 +669,11 @@
      useStartTLS2 = argParser.useStartTLS2();
      if (!useSSL2 && !useStartTLS2)
      {
        useSSL2 = confirm(INFO_CLI_USESSL_PROMPT.get(), false);
        useSSL2 = confirm(INFO_REPLICATION_ENABLE_USESSL2_PROMPT.get(), false);
        if (!useSSL2)
        {
          useStartTLS2 =
            confirm(INFO_CLI_USESTARTTLS_PROMPT.get(), false);
            confirm(INFO_REPLICATION_ENABLE_USESTARTTLS2_PROMPT.get(), false);
        }
      }
@@ -743,11 +747,12 @@
              getValue(bindDn2, argParser.getDefaultBindDn2()), false);
          pwd2 = promptForPassword(
              INFO_REPLICATION_ENABLE_PASSWORD2_PROMPT.get(bindDn2));
          useSSL2 = confirm(INFO_CLI_USESSL_PROMPT.get(),
          useSSL2 = confirm(INFO_REPLICATION_ENABLE_USESSL2_PROMPT.get(),
              useSSL2);
          if (!useSSL2)
          {
            useStartTLS2 = confirm(INFO_CLI_USESTARTTLS_PROMPT.get(),
            useStartTLS2 = confirm(
                INFO_REPLICATION_ENABLE_USESTARTTLS2_PROMPT.get(),
                useStartTLS2);
          }
        }
@@ -821,7 +826,9 @@
      // there are issues with the ADS they will be encountered in the
      // enableReplication(EnableReplicationUserData) method.  Here we have
      // to load the ADS to ask the user to accept the certificates.
      cancelled = !loadADSAndAcceptCertificates(ctx2, uData, false);
      InitialLdapContext[] aux = new InitialLdapContext[] {ctx2};
      cancelled = !loadADSAndAcceptCertificates(aux, uData, false);
      ctx2 = aux[0];
      if (!cancelled)
      {
        administratorDefined |= hasAdministrator(ctx2);
@@ -1052,7 +1059,9 @@
      // disableReplication(DisableReplicationUserData) method.  Here we have
      // to load the ADS to ask the user to accept the certificates and
      // eventually admin authentication data.
      cancelled = !loadADSAndAcceptCertificates(ctx, uData, false);
      InitialLdapContext[] aux = new InitialLdapContext[] {ctx};
      cancelled = !loadADSAndAcceptCertificates(aux, uData, false);
      ctx = aux[0];
    }
    if (!cancelled)
@@ -1147,11 +1156,13 @@
    boolean useStartTLSSource = argParser.useStartTLSSource();
    if (!useSSLSource && !useStartTLSSource)
    {
      useSSLSource = confirm(INFO_CLI_USESSL_PROMPT.get(), false);
      useSSLSource = confirm(
          INFO_REPLICATION_INITIALIZE_USESSLSOURCE_PROMPT.get(), false);
      if (!useSSLSource)
      {
        useStartTLSSource =
          confirm(INFO_CLI_USESTARTTLS_PROMPT.get(), false);
          confirm(INFO_REPLICATION_INITIALIZE_USESTARTTLSSOURCE_PROMPT.get(),
              false);
      }
    }
    /*
@@ -1195,11 +1206,14 @@
              getValue(portSource, argParser.getDefaultPortSource()), false);
          adminUid = askForAdministratorUID(adminUid);
          adminPwd = askForAdministratorPwd();
          useSSLSource = confirm(INFO_CLI_USESSL_PROMPT.get(), useSSLSource);
          useSSLSource = confirm(
              INFO_REPLICATION_INITIALIZE_USESSLSOURCE_PROMPT.get(),
              useSSLSource);
          if (!useSSLSource)
          {
            useStartTLSSource =
              confirm(INFO_CLI_USESTARTTLS_PROMPT.get(), useStartTLSSource);
            useStartTLSSource = confirm(
                INFO_REPLICATION_INITIALIZE_USESTARTTLSSOURCE_PROMPT.get(),
                useStartTLSSource);
          }
        }
      }
@@ -1246,11 +1260,13 @@
    boolean useStartTLSDestination = argParser.useStartTLSDestination();
    if (!useSSLDestination && !useStartTLSDestination)
    {
      useSSLDestination = confirm(INFO_CLI_USESSL_PROMPT.get(), false);
      useSSLDestination = confirm(
          INFO_REPLICATION_INITIALIZE_USESSLDESTINATION_PROMPT.get(), false);
      if (!useSSLDestination)
      {
        useStartTLSDestination =
          confirm(INFO_CLI_USESTARTTLS_PROMPT.get(), false);
        useStartTLSDestination = confirm(
            INFO_REPLICATION_INITIALIZE_USESTARTTLSDESTINATION_PROMPT.get(),
            false);
      }
    }
    /*
@@ -1295,13 +1311,14 @@
              INFO_REPLICATION_INITIALIZE_PORTDESTINATION_PROMPT.get(),
              getValue(portDestination,
                  argParser.getDefaultPortDestination()), false);
          useSSLDestination = confirm(INFO_CLI_USESSL_PROMPT.get(),
          useSSLDestination = confirm(
              INFO_REPLICATION_INITIALIZE_USESSLDESTINATION_PROMPT.get(),
              useSSLDestination);
          if (!useSSLDestination)
          {
            useStartTLSDestination =
              confirm(INFO_CLI_USESTARTTLS_PROMPT.get(),
                  useStartTLSDestination);
            useStartTLSDestination = confirm(
                INFO_REPLICATION_INITIALIZE_USESTARTTLSDESTINATION_PROMPT.get(),
                useStartTLSDestination);
          }
        }
      }
@@ -1613,7 +1630,8 @@
   * provided ctx is not using Global Administrator credentials, we prompt the
   * user to provide them and update the provide ReplicationUserData
   * accordingly.
   * @param ctx the Ldap context to be used.
   * @param ctx the Ldap context to be used in an array: note the context
   * may be modified with the new credentials provided by the user.
   * @param uData the ReplicationUserData to be udpated.
   * @param isFirstOrSourceServer whether this is the first server in the
   * enable replication subcommand or the source server in the initialize server
@@ -1623,18 +1641,18 @@
   * if a critical error occurred or the user did not accept a certificate or
   * any of the confirmation messages.
   */
  private boolean loadADSAndAcceptCertificates(InitialLdapContext ctx,
  private boolean loadADSAndAcceptCertificates(InitialLdapContext[] ctx,
      ReplicationUserData uData, boolean isFirstOrSourceServer)
  {
    boolean cancelled = false;
    boolean triedWithUserProvidedAdmin = false;
    String host = ConnectionUtils.getHostName(ctx);
    int port = ConnectionUtils.getPort(ctx);
    boolean isSSL = ConnectionUtils.isSSL(ctx);
    boolean isStartTLS = ConnectionUtils.isStartTLS(ctx);
    String host = ConnectionUtils.getHostName(ctx[0]);
    int port = ConnectionUtils.getPort(ctx[0]);
    boolean isSSL = ConnectionUtils.isSSL(ctx[0]);
    boolean isStartTLS = ConnectionUtils.isStartTLS(ctx[0]);
    try
    {
      ADSContext adsContext = new ADSContext(ctx);
      ADSContext adsContext = new ADSContext(ctx[0]);
      if (adsContext.hasAdminData())
      {
        TopologyCache cache = new TopologyCache(adsContext, getTrustManager());
@@ -1692,18 +1710,19 @@
                  }
                  try
                  {
                    ctx.close();
                    ctx[0].close();
                  }
                  catch (Throwable t)
                  {
                  }
                  try
                  {
                    ctx = createContext(host, port, isSSL, isStartTLS,
                    ctx[0] = createContext(host, port, isSSL, isStartTLS,
                        ADSContext.getAdministratorDN(adminUid), adminPwd,
                        getTrustManager());
                    adsContext = new ADSContext(ctx);
                    adsContext = new ADSContext(ctx[0]);
                    cache = new TopologyCache(adsContext, getTrustManager());
                    connected = true;
                  }
                  catch (Throwable t)
                  {
@@ -1742,7 +1761,7 @@
              {
                reloadTopology = true;
                cancelled = !promptForCertificateConfirmation(e.getCause(),
                    e.getTrustManager(), e.getLdapUrl(), e.getTrustManager());
                    e.getTrustManager(), e.getLdapUrl(), getTrustManager());
              }
              else
              {
@@ -1842,6 +1861,7 @@
      {
        for (ReplicaDescriptor rep2 : replicas2)
        {
          switch (type)
          {
          case NOT_REPLICATED:
@@ -3482,10 +3502,32 @@
      LinkedHashSet<String> replicationServers,
      Set<Integer> usedReplicationDomainIds) throws OpenDsException
  {
    printProgressMessage(formatter.getFormattedWithPoints(
        INFO_REPLICATION_ENABLE_CONFIGURING_BASEDN.get(baseDN,
            ConnectionUtils.getHostPort(ctx))));
    boolean userSpecifiedAdminBaseDN = false;
    LinkedList<String> l = argParser.getBaseDNs();
    if (l != null)
    {
      for (String dn : l)
      {
        if (Utils.areDnsEqual(dn, ADSContext.getAdministrationSuffixDN()))
        {
          userSpecifiedAdminBaseDN = true;
          break;
        }
      }
    }
    if (!userSpecifiedAdminBaseDN && Utils.areDnsEqual(baseDN,
        ADSContext.getAdministrationSuffixDN()))
    {
      printProgressMessage(formatter.getFormattedWithPoints(
          INFO_REPLICATION_ENABLE_CONFIGURING_ADS.get(
              ConnectionUtils.getHostPort(ctx))));
    }
    else
    {
      printProgressMessage(formatter.getFormattedWithPoints(
          INFO_REPLICATION_ENABLE_CONFIGURING_BASEDN.get(baseDN,
              ConnectionUtils.getHostPort(ctx))));
    }
    ManagementContext mCtx = LDAPManagementContext.createFromContext(
        JNDIDirContextAdaptor.adapt(ctx));
    RootCfgClient root = mCtx.getRootConfiguration();
@@ -3589,7 +3631,7 @@
          String pwd = ConnectionUtils.getBindPassword(
              cache.getAdsContext().getDirContext());
          ServerLoader loader = new ServerLoader(server.getAdsProperties(),
          ServerLoader loader = new ServerLoader(s.getAdsProperties(),
              dn, pwd, getTrustManager());
          InitialLdapContext ctx = null;
          try
opends/src/messages/messages/admin_tool.properties
@@ -534,25 +534,38 @@
 server (the port must be free)
INFO_REPLICATION_ENABLE_BINDDN1_PROMPT=Bind DN for the first server
INFO_REPLICATION_ENABLE_PASSWORD1_PROMPT=Password for %s on the first server:
INFO_REPLICATION_ENABLE_USESSL1_PROMPT=Use SSL to connect to the first server?
INFO_REPLICATION_ENABLE_USESTARTTLS1_PROMPT=Use StartTLS to connect to the \
 first server?
INFO_REPLICATION_ENABLE_HOSTNAME2_PROMPT=Host name of the second server
INFO_REPLICATION_ENABLE_PORT2_PROMPT=LDAP port of the second server
INFO_REPLICATION_ENABLE_REPLICATIONPORT2_PROMPT=Replication port for the \
second server (the port must be free)
 second server (the port must be free)
INFO_REPLICATION_ENABLE_BINDDN2_PROMPT=Bind DN for the second server
INFO_REPLICATION_ENABLE_PASSWORD2_PROMPT=Password for %s on the second server:
INFO_REPLICATION_ENABLE_USESSL2_PROMPT=Use SSL to connect to the second server?
INFO_REPLICATION_ENABLE_USESTARTTLS2_PROMPT=Use StartTLS to connect to the \
 second server?
INFO_REPLICATION_INITIALIZE_HOSTNAMESOURCE_PROMPT=Host name of the source \
 server
INFO_REPLICATION_INITIALIZE_PORTSOURCE_PROMPT=LDAP port of the source server
INFO_REPLICATION_INITIALIZE_USESSLSOURCE_PROMPT=Use SSL to connect to the \
 source server?
INFO_REPLICATION_INITIALIZE_USESTARTTLSSOURCE_PROMPT=Use StartTLS to connect \
 to the source server?
INFO_REPLICATION_DISABLE_HOSTNAME_PROMPT=Host name of the server
INFO_REPLICATION_DISABLE_PORT_PROMPT=LDAP port of the server
INFO_REPLICATION_DISABLE_BINDDN_PROMPT=Global Administrator User ID (or bind \
DN if no Global Administrator is defined)
 DN if no Global Administrator is defined)
INFO_REPLICATION_DISABLE_PASSWORD_PROMPT=Password for %s:
INFO_REPLICATION_INITIALIZE_HOSTNAMEDESTINATION_PROMPT=Host name of the \
 destination server
INFO_REPLICATION_INITIALIZE_PORTDESTINATION_PROMPT=LDAP port of the \
 destination server
INFO_REPLICATION_INITIALIZE_USESSLDESTINATION_PROMPT=Use SSL to connect to \
 the destination server?
INFO_REPLICATION_INITIALIZE_USESTARTTLSDESTINATION_PROMPT=Use StartTLS to \
 connect to the destination server?
INFO_CLI_BINDDN_PROMPT=Bind DN
INFO_CLI_USESSL_PROMPT=Use SSL to connect?
INFO_CLI_INVALID_PORT=The provided value is not a valid port
@@ -616,7 +629,9 @@
INFO_REPLICATION_ENABLE_UPDATING_ADS_CONTENTS=Checking Registration information
INFO_REPLICATION_ENABLE_CONFIGURING_REPLICATION_SERVER=Configuring Replication \
 port on server %s
INFO_REPLICATION_ENABLE_CONFIGURING_BASEDN=Enabling Replication for baseDN %s \
INFO_REPLICATION_ENABLE_CONFIGURING_BASEDN=Updating replication configuration \
 for baseDN %s on server %s
 INFO_REPLICATION_ENABLE_CONFIGURING_ADS=Updating Registration configuration \
 on server %s
INFO_ENABLE_REPLICATION_INITIALIZING_ADS=Initializing Registration information \
 on server %s with the contents of server %s
opends/src/server/org/opends/server/util/args/SubCommandArgumentParser.java
@@ -1327,7 +1327,7 @@
    buffer.append(" ");
    buffer.append(subCommand.getName());
    buffer.append(" {options}");
    buffer.append(" ").append(INFO_SUBCMDPARSER_OPTIONS.get());
    if (subCommand.allowsTrailingArguments()) {
      buffer.append(' ');
      buffer.append(subCommand.getTrailingArgumentsDisplayName());
@@ -1686,6 +1686,7 @@
        }
      }
      indentNb++;
      boolean isFirst = true;
      for (SubCommand sc : c) {
        if (sc.isHidden()) {
          continue;
@@ -1694,8 +1695,13 @@
        for (int i = 0; i < indentNb - sc.getName().length(); i++) {
          buffer.append(" ");
        }
        if (!isFirst)
        {
          buffer.append(EOL);
        }
        buffer.append(sc.getDescription());
        buffer.append(EOL);
        isFirst = false;
      }
    }