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

Jean-Noël Rouvignac
18.06.2016 d6b4863175cbac9c771441d8d50b75774044c07d
opendj-server-legacy/src/main/java/org/opends/guitools/uninstaller/UninstallCliHelper.java
@@ -17,7 +17,6 @@
package org.opends.guitools.uninstaller;
import static org.forgerock.util.Utils.*;
import static org.opends.admin.ads.util.ConnectionUtils.*;
import static org.opends.admin.ads.util.PreferredConnection.Type.*;
import static org.opends.messages.AdminToolMessages.*;
import static org.opends.messages.QuickSetupMessages.*;
@@ -36,8 +35,6 @@
import java.util.Set;
import javax.naming.NamingException;
import javax.naming.NoPermissionException;
import javax.naming.ldap.InitialLdapContext;
import javax.net.ssl.TrustManager;
import org.forgerock.i18n.LocalizableMessage;
@@ -48,7 +45,6 @@
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.admin.ads.util.ConnectionWrapper;
import org.opends.admin.ads.util.PreferredConnection.Type;
import org.opends.guitools.controlpanel.datamodel.ConnectionProtocolPolicy;
@@ -113,8 +109,6 @@
   * @param args
   *          the ArgumentParser with the allowed arguments of the command line.
   *          The code assumes that the arguments have already been parsed.
   * @param rawArguments
   *          the arguments provided in the command line.
   * @return the UserData object with what the user wants to uninstall and null
   *         if the user cancels the uninstallation.
   * @throws UserDataException
@@ -123,7 +117,7 @@
   *           If there is an error processing data in non-interactive mode and
   *           an error must be thrown (not in force on error mode).
   */
  public UninstallUserData createUserData(UninstallerArgumentParser args, String[] rawArguments)
  public UninstallUserData createUserData(UninstallerArgumentParser args)
      throws UserDataException, ClientException
  {
    parser = args;
@@ -999,10 +993,12 @@
      @Override
      public void cancel()
      {
        // no-op
      }
      @Override
      public void run()
      {
        // no-op
      }
    };
    application.setProgressMessageFormatter(
@@ -1053,59 +1049,6 @@
  }
  /**
   * 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, null);
    }
    else if (useStartTLS)
    {
      ctx =
          Utils.createStartTLSContext(ldapUrl, bindDn, pwd, connectTimeout,
              null, trustManager, null);
    }
    else
    {
      ctx = 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