From f73b655466092169abac34833fb628fce1fcdebe Mon Sep 17 00:00:00 2001
From: jcduff <jcduff@localhost>
Date: Thu, 23 Oct 2008 14:04:24 +0000
Subject: [PATCH] The commit will bring the following features :     - An updated version of the underlying database. BDB JE 3.3 is now used.     - Attribute API refactoring providing a better abstraction and offering improved performances.     - A new GUI called the Control-Panel to replace the Status-Panel: the specifications for this       GUI are available on OpenDS Wiki and contains a link to a mockup.        See <https://www.opends.org/wiki/page/ControlPanelUISpecification>.     - Some changes in the replication protocol to implement "Assured Replication Mode". The        specifications are on OpenDS Wiki at <https://www.opends.org/wiki/page/AssuredMode> and section 7       described some of the replication changes required to support this. Assured Replication is not finished,       but the main replication protocol changes to support it are done. As explained by Gilles on an email on       the Dev mailing list (http://markmail.org/message/46rgo3meq3vriy4a), with these changes the newer versions       of OpenDS may not be able to replicate with OpenDS 1.0 instances.     - Support for Service Tags on the platforms where the functionality is available and enabled. Specifications       are published at <https://www.opends.org/wiki/page/OpenDSServiceTagEnabled>. For more information on       Service Tags see <http://wikis.sun.com/display/ServiceTag/Sun+Service+Tag+FAQ>.     - The Admin Connector service. In order to provide agentry of the OpenDS server at any time, a new service       has been added, dedicated to the administration, configuration and monitoring of the server.       An overview of the Admin Connector service and it's use is available on the       OpenDS wiki <https://www.opends.org/wiki/page/ManagingAdministrationTrafficToTheServer>     - Updates to the various command line tools to support the Admin Connector service.     - Some internal re-architecting of the server to put the foundation of future developments such as virtual       directory services. The new NetworkGroups and WorkFlow internal services which have been specified in       <https://www.opends.org/wiki/page/BasicOperationRoutingThroughNetworkGroup> are now implemented.     - Many bug fixes...

---
 opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java |  148 ++++++++++++++++++-------------------------------
 1 files changed, 54 insertions(+), 94 deletions(-)

diff --git a/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java b/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
index 17bb40a..ffba128 100644
--- a/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
+++ b/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
@@ -35,9 +35,8 @@
 import org.opends.admin.ads.TopologyCache;
 import org.opends.admin.ads.TopologyCacheException;
 import org.opends.admin.ads.util.ApplicationTrustManager;
-import org.opends.guitools.statuspanel.ConfigException;
-import org.opends.guitools.statuspanel.ConfigFromFile;
-import org.opends.guitools.statuspanel.ConnectionProtocolPolicy;
+import org.opends.guitools.controlpanel.datamodel.ConnectionProtocolPolicy;
+import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
 import org.opends.messages.Message;
 import org.opends.messages.MessageBuilder;
 
@@ -99,7 +98,12 @@
 
   private LDAPConnectionConsoleInteraction ci = null;
 
-  private ConfigFromFile conf;
+  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;
 
   /**
    * Default constructor.
@@ -242,28 +246,24 @@
       userData.setReplicationServer(
           referencedHostName+":8989");
     }
-    userData.setUseSSL(parser.useSSL());
-    userData.setUseStartTLS(parser.useStartTLS());
-    conf = new ConfigFromFile();
-    conf.readConfiguration();
-    try
-    {
-      String ldapUrl = conf.getURL(
-        ConnectionProtocolPolicy.getConnectionPolicy(parser.useSSL(),
-            parser.useStartTLS()));
-      userData.setLocalServerUrl(ldapUrl);
-    }
-    catch (ConfigException ce)
+    info = ControlPanelInfo.getInstance();
+    info.setTrustManager(userData.getTrustManager());
+    info.regenerateDescriptor();
+    info.setConnectionPolicy(ConnectionProtocolPolicy.USE_ADMIN);
+
+    String adminConnectorUrl = info.getAdminConnectorURL();
+
+    if (adminConnectorUrl == null)
     {
       LOG.log(Level.WARNING,
-          "Error retrieving a valid LDAP URL in conf file: "+ce, ce);
+          "Error retrieving a valid LDAP URL in conf file.");
       if (!parser.isInteractive())
       {
         Message msg = ERR_COULD_NOT_FIND_VALID_LDAPURL.get();
-        throw new ApplicationException(ReturnCode.APPLICATION_ERROR, msg,
-            ce);
+        throw new ApplicationException(ReturnCode.APPLICATION_ERROR, msg, null);
       }
     }
+    userData.setLocalServerUrl(adminConnectorUrl);
     userData.setReferencedHostName(referencedHostName);
 
     /*
@@ -762,14 +762,9 @@
     boolean accepted = true;
     String uid = userData.getAdminUID();
     String pwd = userData.getAdminPwd();
-    boolean useSSL = userData.useSSL();
-    boolean useStartTLS = userData.useStartTLS();
 
     boolean couldConnect = false;
 
-    boolean canUseSSL = conf.getLDAPSURL() != null;
-    boolean canUseStartTLS = conf.getStartTLSURL() != null;
-
     while (!couldConnect && accepted)
     {
 
@@ -808,35 +803,6 @@
         secureArgsList.bindPasswordArg.setPresent(false);
       }
 
-      // We already know if SSL or StartTLS can be used.  If we cannot
-      // use them we will not propose them in the connection parameters
-      // and if none of them can be used we will just not ask for the
-      // protocol to be used.
-      if (!canUseSSL)
-      {
-        if (useSSL)
-        {
-          println();
-          println(ERR_COULD_NOT_FIND_VALID_LDAPURL.get());
-          println();
-          secureArgsList.useSSLArg.setPresent(false);
-        }
-        else
-        {
-          secureArgsList.useSSLArg.setValueSetByProperty(true);
-        }
-      }
-      if (!canUseStartTLS)
-      {
-        if (useStartTLS)
-        {
-          println();
-          println(ERR_COULD_NOT_FIND_VALID_LDAPURL.get());
-          println();
-          secureArgsList.useStartTLSArg.setPresent(false);
-        }
-        secureArgsList.useStartTLSArg.setValueSetByProperty(true);
-      }
       if (ci == null)
       {
         ci =
@@ -847,20 +813,24 @@
       InitialLdapContext ctx = null;
       try
       {
-        ci.run(canUseSSL, canUseStartTLS);
-        useSSL = ci.useSSL();
-        useStartTLS = ci.useStartTLS();
+        ci.run(true, false);
         userData.setAdminUID(ci.getAdministratorUID());
         userData.setAdminPwd(ci.getBindPassword());
-        userData.setUseSSL(useSSL);
-        userData.setUseStartTLS(useStartTLS);
 
-        String ldapUrl = conf.getURL(
-            ConnectionProtocolPolicy.getConnectionPolicy(
-                useSSL, useStartTLS));
+        info.setConnectionPolicy(ConnectionProtocolPolicy.USE_ADMIN);
+
+        String adminConnectorUrl = info.getAdminConnectorURL();
+        if (adminConnectorUrl == null)
+        {
+          LOG.log(Level.WARNING,
+         "Error retrieving a valid Administration Connector URL in conf file.");
+          Message msg = ERR_COULD_NOT_FIND_VALID_LDAPURL.get();
+            throw new ApplicationException(ReturnCode.APPLICATION_ERROR, msg,
+                null);
+        }
         try
         {
-          URI uri = new URI(ldapUrl);
+          URI uri = new URI(adminConnectorUrl);
           int port = uri.getPort();
           secureArgsList.portArg.clearValues();
           secureArgsList.portArg.addValue(String.valueOf(port));
@@ -868,16 +838,27 @@
         }
         catch (Throwable t)
         {
-          LOG.log(Level.SEVERE, "Error parsing url: "+ldapUrl);
+          LOG.log(Level.SEVERE, "Error parsing url: "+adminConnectorUrl);
         }
         LDAPManagementContextFactory factory =
-          new LDAPManagementContextFactory();
+          new LDAPManagementContextFactory(alwaysSSL);
         factory.getManagementContext(this, ci);
         updateTrustManager(userData, ci);
-        ldapUrl = conf.getURL(
-            ConnectionProtocolPolicy.getConnectionPolicy(ci.useSSL(),
-                ci.useStartTLS()));
-        userData.setLocalServerUrl(ldapUrl);
+
+        info.setConnectionPolicy(ConnectionProtocolPolicy.USE_ADMIN);
+
+        adminConnectorUrl = info.getAdminConnectorURL();
+
+        if (adminConnectorUrl == null)
+        {
+          LOG.log(Level.WARNING,
+         "Error retrieving a valid Administration Connector URL in conf file.");
+          Message msg = ERR_COULD_NOT_FIND_VALID_LDAPURL.get();
+          throw new ApplicationException(ReturnCode.APPLICATION_ERROR, msg,
+              null);
+        }
+
+        userData.setLocalServerUrl(adminConnectorUrl);
         couldConnect = true;
       }
       catch (ArgumentException e) {
@@ -888,15 +869,6 @@
         println(e.getMessageObject());
         println();
       }
-      catch (ConfigException ce)
-      {
-        // This is unexpected
-        LOG.log(Level.WARNING,
-            "Error retrieving a valid LDAP URL in conf file: "+ce, ce);
-        Message msg = ERR_COULD_NOT_FIND_VALID_LDAPURL.get();
-        throw new ApplicationException(ReturnCode.APPLICATION_ERROR, msg,
-            ce);
-      }
       finally
       {
         if (ctx != null)
@@ -1141,28 +1113,25 @@
     InitialLdapContext ctx = null;
     try
     {
-      ConfigFromFile conf = new ConfigFromFile();
-      conf.readConfiguration();
+      info.setTrustManager(userData.getTrustManager());
 
       String host = "localhost";
       int port = 389;
-      boolean useSSL = userData.useSSL();
-      boolean useStartTLS = userData.useStartTLS();
       String adminUid = userData.getAdminUID();
       String pwd = userData.getAdminPwd();
       String dn = ADSContext.getAdministratorDN(adminUid);
 
-      String ldapUrl = conf.getURL(
-          ConnectionProtocolPolicy.getConnectionPolicy(useSSL, useStartTLS));
+      info.setConnectionPolicy(ConnectionProtocolPolicy.USE_ADMIN);
+      String adminConnectorUrl = info.getAdminConnectorURL();
       try
       {
-        URI uri = new URI(ldapUrl);
+        URI uri = new URI(adminConnectorUrl);
         host = uri.getHost();
         port = uri.getPort();
       }
       catch (Throwable t)
       {
-        LOG.log(Level.SEVERE, "Error parsing url: "+ldapUrl);
+        LOG.log(Level.SEVERE, "Error parsing url: "+adminConnectorUrl);
       }
       ctx = createAdministrativeContext(host, port, useSSL, useStartTLS, dn,
           pwd, userData.getTrustManager());
@@ -1186,15 +1155,6 @@
 
       exceptionOccurred = false;
     }
-    catch (ConfigException ce)
-    {
-      // This is unexpected, when calling this code this should already been
-      // checked.
-      LOG.log(Level.WARNING,
-          "Error retrieving a valid LDAP URL in conf file: "+ce, ce);
-      Message msg = ERR_COULD_NOT_FIND_VALID_LDAPURL.get();
-      throw new ApplicationException(ReturnCode.APPLICATION_ERROR, msg, ce);
-    }
     catch (NamingException ne)
     {
       LOG.log(Level.WARNING, "Error connecting to server: "+ne, ne);

--
Gitblit v1.10.0