From 486ffa6d0abfa0b91dc7ab22ee71758b5eecfb88 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Wed, 26 Sep 2007 18:57:15 +0000
Subject: [PATCH] Fix for 2306: configure replication encryption on or off in dsreplication and setup-gui

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

diff --git a/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java b/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java
index 35aebfb..361b086 100644
--- a/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java
+++ b/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java
@@ -113,6 +113,10 @@
      */
     IS_REPLICATION_ENABLED,
     /**
+     * The associated value is a Boolean.
+     */
+    IS_REPLICATION_SECURE,
+    /**
      * List of servers specified in the Replication Server configuration.
      * This is a Set of String.
      */
@@ -245,6 +249,27 @@
   }
 
   /**
+   * Returns whether the communication with the replication port on the server
+   * is encrypted or not.
+   * @return <CODE>true</CODE> if the communication with the replication port on
+   * the server is encrypted and <CODE>false</CODE> otherwise.
+   */
+  public boolean isReplicationSecure()
+  {
+    boolean isReplicationSecure;
+    if (isReplicationServer())
+    {
+      isReplicationSecure = Boolean.TRUE.equals(serverProperties.get(
+          ServerProperty.IS_REPLICATION_SECURE));
+    }
+    else
+    {
+      isReplicationSecure = false;
+    }
+    return isReplicationSecure;
+  }
+
+  /**
    * Sets the ADS properties of the server.
    * @param adsProperties a Map containing the ADS properties of the server.
    */
@@ -873,6 +898,30 @@
       {
       }
     }
+
+    boolean replicationSecure = false;
+    if (replicationEnabled)
+    {
+      ctls = new SearchControls();
+      ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
+      ctls.setReturningAttributes(
+      new String[] {"ds-cfg-ssl-encryption"});
+      filter = "(objectclass=ds-cfg-crypto-manager)";
+
+      jndiName = new LdapName("cn=Crypto Manager,cn=config");
+
+      NamingEnumeration entries = ctx.search(jndiName, filter, ctls);
+
+      while(entries.hasMore())
+      {
+        SearchResult sr = (SearchResult)entries.next();
+
+        String v = getFirstValue(sr, "ds-cfg-ssl-encryption");
+        replicationSecure = "true".equalsIgnoreCase(v);
+      }
+    }
+    desc.serverProperties.put(ServerProperty.IS_REPLICATION_SECURE,
+        replicationSecure ? Boolean.TRUE : Boolean.FALSE);
   }
 
   /**

--
Gitblit v1.10.0