From a3decf6f3114f51764c1bbe80a892c6e9d1fe2b7 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Fri, 02 Nov 2007 12:05:52 +0000
Subject: [PATCH] The following modifications are aimed to have the same interaction in the status and dsconfig command lines by sharing the same code. The formatting of the table in status command-line has also be modified to be consistent with the one provided by dsconfig.

---
 opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConnectionProtocolPolicy.java |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConnectionProtocolPolicy.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConnectionProtocolPolicy.java
index e020d53..8d2ad19 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConnectionProtocolPolicy.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConnectionProtocolPolicy.java
@@ -49,5 +49,32 @@
   /**
    * Use the less secure available (LDAP, and then LDAPs).
    */
-  USE_LESS_SECURE_AVAILABLE,
+  USE_LESS_SECURE_AVAILABLE;
+
+  /**
+   * Returns the ConnectionPolicy to be used with the parameters provided
+   * by the user.
+   * @param useSSL whether the user asked to use SSL or not.
+   * @param useStartTLS whether the user asked to use Start TLS or not.
+   * @return the ConnectionPolicy to be used with the parameters provided
+   * by the user.
+   */
+  public static ConnectionProtocolPolicy getConnectionPolicy(boolean useSSL,
+      boolean useStartTLS)
+  {
+    ConnectionProtocolPolicy policy;
+    if (useStartTLS)
+    {
+      policy = ConnectionProtocolPolicy.USE_STARTTLS;
+    }
+    else if (useSSL)
+    {
+      policy = ConnectionProtocolPolicy.USE_LDAPS;
+    }
+    else
+    {
+      policy = ConnectionProtocolPolicy.USE_LESS_SECURE_AVAILABLE;
+    }
+    return policy;
+  }
 }

--
Gitblit v1.10.0