From fd16c5b5a765bc36ff9281ed22bc90a93fad2995 Mon Sep 17 00:00:00 2001
From: Chris Ridd <chris.ridd@forgerock.com>
Date: Mon, 16 Jun 2014 10:53:59 +0000
Subject: [PATCH] Forward port fix OPENDJ-1427: Control-panel reports duplicate ds-sync-hist values for pwdHistory

---
 opendj3-server-dev/src/messages/messages/admin_tool_zh_CN.properties                              |    1 
 opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java |    4 --
 opendj3-server-dev/src/messages/messages/admin_tool.properties                                    |    1 
 opendj3-server-dev/src/messages/messages/admin_tool_ja.properties                                 |    1 
 opendj3-server-dev/src/ads/org/opends/admin/ads/util/ConnectionUtils.java                         |    7 +++
 opendj3-server-dev/src/messages/messages/admin_tool_es.properties                                 |    1 
 opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/LDIFViewEntryPanel.java       |    4 --
 opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/TableViewEntryPanel.java      |    4 --
 opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java           |   82 -----------------------------------------
 opendj3-server-dev/src/messages/messages/admin_tool_de.properties                                 |    1 
 opendj3-server-dev/src/messages/messages/admin_tool_fr.properties                                 |    1 
 11 files changed, 7 insertions(+), 100 deletions(-)

diff --git a/opendj3-server-dev/src/ads/org/opends/admin/ads/util/ConnectionUtils.java b/opendj3-server-dev/src/ads/org/opends/admin/ads/util/ConnectionUtils.java
index 15cdb39..072d4eb 100644
--- a/opendj3-server-dev/src/ads/org/opends/admin/ads/util/ConnectionUtils.java
+++ b/opendj3-server-dev/src/ads/org/opends/admin/ads/util/ConnectionUtils.java
@@ -55,6 +55,7 @@
 import javax.net.ssl.SSLHandshakeException;
 import javax.net.ssl.TrustManager;
 
+import org.opends.server.replication.plugin.EntryHistorical;
 import org.opends.server.schema.SchemaConstants;
 
 /**
@@ -112,6 +113,8 @@
     }
     env.put(Context.INITIAL_CONTEXT_FACTORY,
         "com.sun.jndi.ldap.LdapCtxFactory");
+    env.put("java.naming.ldap.attributes.binary",
+        EntryHistorical.HISTORICAL_ATTRIBUTE_NAME);
     env.put(Context.PROVIDER_URL, ldapURL);
     if (timeout >= 1)
     {
@@ -190,6 +193,8 @@
     }
     env.put(Context.INITIAL_CONTEXT_FACTORY,
         "com.sun.jndi.ldap.LdapCtxFactory");
+    env.put("java.naming.ldap.attributes.binary",
+        EntryHistorical.HISTORICAL_ATTRIBUTE_NAME);
     env.put(Context.PROVIDER_URL, ldapsURL);
     env.put("java.naming.ldap.factory.socket",
         org.opends.admin.ads.util.TrustedSocketFactory.class.getName());
@@ -344,6 +349,8 @@
     }
     env.put(Context.INITIAL_CONTEXT_FACTORY,
         "com.sun.jndi.ldap.LdapCtxFactory");
+    env.put("java.naming.ldap.attributes.binary",
+        EntryHistorical.HISTORICAL_ATTRIBUTE_NAME);
     env.put(Context.PROVIDER_URL, ldapURL);
     env.put(Context.SECURITY_AUTHENTICATION , "none");
 
diff --git a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/LDIFViewEntryPanel.java b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/LDIFViewEntryPanel.java
index 5cc1703..cfc6a8c 100644
--- a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/LDIFViewEntryPanel.java
+++ b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/LDIFViewEntryPanel.java
@@ -158,10 +158,6 @@
   public void update(CustomSearchResult sr, boolean isReadOnly, TreePath path)
   {
     boolean sameEntry = false;
-    if (sr != null)
-    {
-      sr = filterSearchResult(sr);
-    }
     if ((searchResult != null) && (sr != null))
     {
       sameEntry = searchResult.getDN().equals(sr.getDN());
diff --git a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
index cfb001a..9be1c94 100644
--- a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
+++ b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
@@ -436,10 +436,6 @@
   public void update(CustomSearchResult sr, boolean isReadOnly, TreePath path)
   {
     boolean sameEntry = false;
-    if (sr != null)
-    {
-      sr = filterSearchResult(sr);
-    }
     if ((searchResult != null) && (sr != null))
     {
       sameEntry = searchResult.getDN().equals(sr.getDN());
diff --git a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/TableViewEntryPanel.java b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/TableViewEntryPanel.java
index 0ba99cd..95ad731 100644
--- a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/TableViewEntryPanel.java
+++ b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/TableViewEntryPanel.java
@@ -172,10 +172,6 @@
   public void update(CustomSearchResult sr, boolean isReadOnly, TreePath path)
   {
     boolean sameEntry = false;
-    if (sr != null)
-    {
-      sr = filterSearchResult(sr);
-    }
     if ((searchResult != null) && (sr != null))
     {
       sameEntry = searchResult.getDN().equals(sr.getDN());
diff --git a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java
index 4970c1d..e7e67b0 100644
--- a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java
+++ b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java
@@ -53,7 +53,6 @@
 import org.opends.guitools.controlpanel.util.Utilities;
 import org.forgerock.i18n.LocalizableMessage;
 import org.opends.server.api.AttributeSyntax;
-import org.opends.server.replication.plugin.EntryHistorical;
 import org.opends.server.schema.SchemaConstants;
 import org.opends.server.types.AttributeType;
 import org.forgerock.opendj.ldap.ByteString;
@@ -632,87 +631,6 @@
   }
 
   /**
-   * This method is called because the ds-sync-hist attribute has a
-   * DirectoryString syntax, but it contains byte[] on it (if there has been
-   * a modification in a binary value).
-   * @param sr the search result to use.
-   * @return the filtered search result to be used to be displayed.
-   */
-  protected CustomSearchResult filterSearchResult(CustomSearchResult sr)
-  {
-    CustomSearchResult filteredSr;
-    List<Object> values =
-      sr.getAttributeValues(EntryHistorical.HISTORICAL_ATTRIBUTE_NAME);
-    if (values != null)
-    {
-      List<Object> newValues = new ArrayList<Object>();
-      for (Object v : values)
-      {
-        newValues.add(filterStringValue(String.valueOf(v)));
-      }
-      if (newValues.equals(values))
-      {
-        filteredSr = sr;
-      }
-      else
-      {
-        filteredSr = sr.duplicate();
-        filteredSr.set(EntryHistorical.HISTORICAL_ATTRIBUTE_NAME, newValues);
-      }
-    }
-    else
-    {
-      filteredSr = sr;
-    }
-    return filteredSr;
-  }
-
-  /**
-   * This method is called because the ds-sync-hist attribute has a
-   * DirectoryString syntax, but it contains byte[] on it (if there has been
-   * a modification in a binary value).
-   * @param value the value to be filtered.
-   * @return the value that will actually be displayed.
-   */
-  private String filterStringValue(String value)
-  {
-    String filteredValue;
-    // Parse the value to find out if this corresponds to a change in a
-    // binary attribute.
-    int index = value.indexOf(":");
-    if (index != -1)
-    {
-      String modifiedAttr = value.substring(0, index).trim();
-      modifiedAttr = Utilities.getAttributeNameWithoutOptions(modifiedAttr);
-      if (isBinary(modifiedAttr))
-      {
-        String replTag = "repl:";
-        int index2 = value.indexOf(replTag, index);
-        if (index2 != -1)
-        {
-          filteredValue = value.substring(0, index2+replTag.length()) +
-          INFO_CTRL_PANEL_DS_SYNC_HIST_BINARY_VALUE.get();
-        }
-        else
-        {
-          filteredValue = value.substring(0, index+1) +
-          INFO_CTRL_PANEL_DS_SYNC_HIST_BINARY_VALUE.get();
-        }
-      }
-      else
-      {
-        filteredValue = value;
-      }
-    }
-    else
-    {
-      filteredValue = value;
-    }
-    return filteredValue;
-  }
-
-
-  /**
    * Returns the list of superior object classes (to top) for a given object
    * class.
    * @param oc the object class.
diff --git a/opendj3-server-dev/src/messages/messages/admin_tool.properties b/opendj3-server-dev/src/messages/messages/admin_tool.properties
index 6d69d62..040999f 100644
--- a/opendj3-server-dev/src/messages/messages/admin_tool.properties
+++ b/opendj3-server-dev/src/messages/messages/admin_tool.properties
@@ -2913,7 +2913,6 @@
 INFO_CTRL_PANEL_DUPLICATE_ENTRY_NEWPASSWORD_LABEL=New Password:
 INFO_CTRL_PANEL_DUPLICATE_ENTRY_CONFIRMNEWPASSWORD_LABEL=Password (confirm):
 INFO_CTRL_PANEL_DUPLICATE_ENTRY_PASSWORD_INFO=Leave empty for no password.
-INFO_CTRL_PANEL_DS_SYNC_HIST_BINARY_VALUE=<Binary Value>
 INFO_REQUIRED_ICON_ACCESSIBLE_DESCRIPTION=Required Icon.
 INFO_WARNING_ICON_ACCESSIBLE_DESCRIPTION=Warning Icon.
 INFO_ERROR_DURING_PURGE_HISTORICAL_NO_LOG=Unexpected error during \
diff --git a/opendj3-server-dev/src/messages/messages/admin_tool_de.properties b/opendj3-server-dev/src/messages/messages/admin_tool_de.properties
index e92f139..72d4bbb 100644
--- a/opendj3-server-dev/src/messages/messages/admin_tool_de.properties
+++ b/opendj3-server-dev/src/messages/messages/admin_tool_de.properties
@@ -1926,6 +1926,5 @@
 INFO_CTRL_PANEL_DUPLICATE_ENTRY_NEWPASSWORD_LABEL=Neues Benutzer-Passwort:
 INFO_CTRL_PANEL_DUPLICATE_ENTRY_CONFIRMNEWPASSWORD_LABEL=Passwortbest\u00e4tigung:
 INFO_CTRL_PANEL_DUPLICATE_ENTRY_PASSWORD_INFO=Leer lassen f\u00fcr kein Passwort.
-INFO_CTRL_PANEL_DS_SYNC_HIST_BINARY_VALUE=<Bin\u00e4rwert>
 INFO_REQUIRED_ICON_ACCESSIBLE_DESCRIPTION=Erforderliches Symbol.
 INFO_WARNING_ICON_ACCESSIBLE_DESCRIPTION=Warnsymbol.
diff --git a/opendj3-server-dev/src/messages/messages/admin_tool_es.properties b/opendj3-server-dev/src/messages/messages/admin_tool_es.properties
index bbf5775..5fe7374 100644
--- a/opendj3-server-dev/src/messages/messages/admin_tool_es.properties
+++ b/opendj3-server-dev/src/messages/messages/admin_tool_es.properties
@@ -1926,6 +1926,5 @@
 INFO_CTRL_PANEL_DUPLICATE_ENTRY_NEWPASSWORD_LABEL=Contrase\u00f1a:
 INFO_CTRL_PANEL_DUPLICATE_ENTRY_CONFIRMNEWPASSWORD_LABEL=Contrase\u00f1a (confirmar):
 INFO_CTRL_PANEL_DUPLICATE_ENTRY_PASSWORD_INFO=Dejar en blanco para ninguna contrase\u00f1a.
-INFO_CTRL_PANEL_DS_SYNC_HIST_BINARY_VALUE=<valor binario>
 INFO_REQUIRED_ICON_ACCESSIBLE_DESCRIPTION=Icono requerido.
 INFO_WARNING_ICON_ACCESSIBLE_DESCRIPTION=Icono de advertencia.
diff --git a/opendj3-server-dev/src/messages/messages/admin_tool_fr.properties b/opendj3-server-dev/src/messages/messages/admin_tool_fr.properties
index 4b7eede..adf8f66 100644
--- a/opendj3-server-dev/src/messages/messages/admin_tool_fr.properties
+++ b/opendj3-server-dev/src/messages/messages/admin_tool_fr.properties
@@ -1926,6 +1926,5 @@
 INFO_CTRL_PANEL_DUPLICATE_ENTRY_NEWPASSWORD_LABEL=Nouveau mot de passe\u00a0:
 INFO_CTRL_PANEL_DUPLICATE_ENTRY_CONFIRMNEWPASSWORD_LABEL=Mot de passe (confirmation)\u00a0:
 INFO_CTRL_PANEL_DUPLICATE_ENTRY_PASSWORD_INFO=Laissez vide pour aucun mot de passe.
-INFO_CTRL_PANEL_DS_SYNC_HIST_BINARY_VALUE=<valeur binaire>
 INFO_REQUIRED_ICON_ACCESSIBLE_DESCRIPTION=Ic\u00f4ne requise.
 INFO_WARNING_ICON_ACCESSIBLE_DESCRIPTION=Ic\u00f4ne d'avertissement.
diff --git a/opendj3-server-dev/src/messages/messages/admin_tool_ja.properties b/opendj3-server-dev/src/messages/messages/admin_tool_ja.properties
index 12608e4..0cfd4bb 100644
--- a/opendj3-server-dev/src/messages/messages/admin_tool_ja.properties
+++ b/opendj3-server-dev/src/messages/messages/admin_tool_ja.properties
@@ -1923,6 +1923,5 @@
 INFO_CTRL_PANEL_DUPLICATE_ENTRY_NEWPASSWORD_LABEL=\u65b0\u898f\u30e6\u30fc\u30b6\u30fc\u30d1\u30b9\u30ef\u30fc\u30c9:
 INFO_CTRL_PANEL_DUPLICATE_ENTRY_CONFIRMNEWPASSWORD_LABEL=\u30d1\u30b9\u30ef\u30fc\u30c9 (\u78ba\u8a8d):
 # INFO_CTRL_PANEL_DUPLICATE_ENTRY_PASSWORD_INFO=Leave empty for no password.
-INFO_CTRL_PANEL_DS_SYNC_HIST_BINARY_VALUE=<\u30d0\u30a4\u30ca\u30ea\u5024>
 INFO_REQUIRED_ICON_ACCESSIBLE_DESCRIPTION=\u5fc5\u9808\u30a2\u30a4\u30b3\u30f3\u3002
 INFO_WARNING_ICON_ACCESSIBLE_DESCRIPTION=\u8b66\u544a\u30a2\u30a4\u30b3\u30f3\u3002
diff --git a/opendj3-server-dev/src/messages/messages/admin_tool_zh_CN.properties b/opendj3-server-dev/src/messages/messages/admin_tool_zh_CN.properties
index feb5792..1e4ad29 100644
--- a/opendj3-server-dev/src/messages/messages/admin_tool_zh_CN.properties
+++ b/opendj3-server-dev/src/messages/messages/admin_tool_zh_CN.properties
@@ -1926,6 +1926,5 @@
 INFO_CTRL_PANEL_DUPLICATE_ENTRY_NEWPASSWORD_LABEL=\u65b0\u5efa\u7528\u6237\u5bc6\u7801:
 INFO_CTRL_PANEL_DUPLICATE_ENTRY_CONFIRMNEWPASSWORD_LABEL=\u5bc6\u7801\uff08\u786e\u8ba4\uff09:
 # INFO_CTRL_PANEL_DUPLICATE_ENTRY_PASSWORD_INFO=Leave empty for no password.
-INFO_CTRL_PANEL_DS_SYNC_HIST_BINARY_VALUE=<\u4e8c\u8fdb\u5236\u503c>
 INFO_REQUIRED_ICON_ACCESSIBLE_DESCRIPTION=\u9700\u8981\u7684\u56fe\u6807\u3002
 INFO_WARNING_ICON_ACCESSIBLE_DESCRIPTION=\u8b66\u544a\u56fe\u6807\u3002

--
Gitblit v1.10.0