From d65316c746990cbe4c2b433b007afe00e9492c36 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.

---
 opends/src/ads/org/opends/admin/ads/util/ConnectionUtils.java |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/opends/src/ads/org/opends/admin/ads/util/ConnectionUtils.java b/opends/src/ads/org/opends/admin/ads/util/ConnectionUtils.java
index 8fcc2b7..c0c1aab 100644
--- a/opends/src/ads/org/opends/admin/ads/util/ConnectionUtils.java
+++ b/opends/src/ads/org/opends/admin/ads/util/ConnectionUtils.java
@@ -29,6 +29,7 @@
 
 import java.io.IOException;
 import java.net.ConnectException;
+import java.security.GeneralSecurityException;
 import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Set;
@@ -45,6 +46,7 @@
 import javax.naming.ldap.StartTlsResponse;
 import javax.net.ssl.HostnameVerifier;
 import javax.net.ssl.KeyManager;
+import javax.net.ssl.SSLHandshakeException;
 import javax.net.ssl.TrustManager;
 
 /**
@@ -495,6 +497,28 @@
   }
 
   /**
+   * Tells whether the provided Throwable was caused because of a problem with
+   * a certificate while trying to establish a connection.
+   * @param t the Throwable to analyze.
+   * @return <CODE>true</CODE> if the provided Throwable was caused because of a
+   * problem with a certificate while trying to establish a connection and
+   * <CODE>false</CODE> otherwise.
+   */
+  public static boolean isCertificateException(Throwable t)
+  {
+    boolean returnValue = false;
+
+    while (!returnValue && (t != null))
+    {
+      returnValue = (t instanceof SSLHandshakeException) ||
+      (t instanceof GeneralSecurityException);
+      t = t.getCause();
+    }
+
+    return returnValue;
+  }
+
+  /**
    * Returns the String representation of the first value of an attribute in a
    * LDAP entry.
    * @param entry the entry.

--
Gitblit v1.10.0