From 7e6a2d6cd3a9b95acb001a3f37437893067bca27 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Mon, 30 Jul 2007 15:53:44 +0000
Subject: [PATCH] The following modifications are done in order to be able to handle properly secure connections in both the status command-line and the status panel.  Some options to specify a keystore, a trustore, etc. have been added to the status command-line so that is consistent with the other command-lines that use LDAP.  As for these command-lines if the user does not specify to use Start TLS or LDAPS, the command-line will try to use LDAP to connect. But if there is no LDAP port enabled, the command-line will try to connect to the LDAPS port.

---
 opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusPanelController.java |   38 ++++++++++++++++++++++++++++----------
 1 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusPanelController.java b/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusPanelController.java
index f725f28..358690c 100644
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusPanelController.java
+++ b/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusPanelController.java
@@ -39,7 +39,9 @@
 
 import org.opends.server.core.DirectoryServer;
 
+import org.opends.admin.ads.util.ApplicationTrustManager;
 import org.opends.quicksetup.Installation;
+import org.opends.quicksetup.ui.ProgressDialog;
 import org.opends.quicksetup.ui.UIFactory;
 import org.opends.quicksetup.ui.Utilities;
 import org.opends.quicksetup.util.BackgroundTask;
@@ -51,7 +53,6 @@
 import org.opends.statuspanel.event.StatusPanelButtonListener;
 import org.opends.statuspanel.i18n.ResourceProvider;
 import org.opends.statuspanel.ui.LoginDialog;
-import org.opends.statuspanel.ui.ProgressDialog;
 import org.opends.statuspanel.ui.StatusPanelDialog;
 
 /**
@@ -86,9 +87,14 @@
 
   private Thread progressUpdater;
 
+  private ApplicationTrustManager trustManager;
+
 //Update period of the progress dialog.
   private static final int UPDATE_PERIOD = 500;
 
+  private static final ConnectionProtocolPolicy CONNECTION_POLICY =
+    ConnectionProtocolPolicy.USE_MOST_SECURE_AVAILABLE;
+
   /**
    * This method creates the control panel dialogs and to check the current
    * install status. This method must be called outside the event thread because
@@ -108,11 +114,12 @@
   {
     DirectoryServer.bootstrapClient();
     initLookAndFeel();
+    trustManager = new ApplicationTrustManager(null);
     /* Call this methods to create the dialogs (the control panel dialog
      * is generated when we call getLoginDialog()). */
     getLoginDialog();
     getProgressDialog();
-    serverStatusPooler = new ServerStatusPooler();
+    serverStatusPooler = new ServerStatusPooler(CONNECTION_POLICY);
     serverStatusPooler.addServerStatusChangeListener(this);
     serverStatusPooler.startPooling();
     desc = serverStatusPooler.getLastDescriptor();
@@ -445,9 +452,19 @@
     getLoginDialog().setVisible(true);
     if (!getLoginDialog().isCancelled())
     {
-      serverStatusPooler.setAuthentication(
-          getLoginDialog().getDirectoryManagerDn(),
-          getLoginDialog().getDirectoryManagerPwd());
+      try
+      {
+        serverStatusPooler.setAuthentication(
+            getLoginDialog().getDirectoryManagerDn(),
+            getLoginDialog().getDirectoryManagerPwd(),
+            trustManager);
+      }
+      catch (ConfigException ce)
+      {
+        Utilities.displayError(getLoginDialog(), ce.getMessage(),
+            getMsg("error-title"));
+        getLoginDialog().toFront();
+      }
     }
   }
 
@@ -468,7 +485,8 @@
   {
     if (loginDialog == null)
     {
-      loginDialog = new LoginDialog(getStatusPanelDialog());
+      loginDialog = new LoginDialog(getStatusPanelDialog(), trustManager,
+          CONNECTION_POLICY);
       loginDialog.setModal(true);
     }
     return loginDialog;
@@ -819,10 +837,10 @@
    * This method is used to update the progress dialog.
    *
    * We are receiving notifications from the installer and uninstaller (this
-   * class is a ProgressListener). However if we lots of notifications updating
-   * the progress panel every time we get a progress update can result of a lot
-   * of flickering. So the idea here is to have a minimal time between 2 updates
-   * of the progress dialog (specified by UPDATE_PERIOD).
+   * class is a ProgressListener). However if we send lots of notifications
+   * updating the progress panel every time we get a progress update can result
+   * of a lot of flickering. So the idea here is to have a minimal time between
+   * 2 updates of the progress dialog (specified by UPDATE_PERIOD).
    */
   private void runProgressUpdater()
   {

--
Gitblit v1.10.0