From 09960e519cb96cf4bae82879e4dac1baced76336 Mon Sep 17 00:00:00 2001
From: Chris Ridd <chris.ridd@forgerock.com>
Date: Tue, 03 Jun 2014 10:57:51 +0000
Subject: [PATCH] Fix OPENDJ-1427: Control-panel reports duplicate ds-sync-hist values for pwdHistory

---
 opends/src/messages/messages/admin_tool_fr.properties                                 |    3 
 opends/src/messages/messages/admin_tool_es.properties                                 |    3 
 opends/src/guitools/org/opends/guitools/controlpanel/ui/TableViewEntryPanel.java      |    5 -
 opends/src/ads/org/opends/admin/ads/util/ConnectionUtils.java                         |    9 ++
 opends/src/messages/messages/admin_tool.properties                                    |    3 
 opends/src/messages/messages/admin_tool_ja.properties                                 |    3 
 opends/src/guitools/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java |    6 -
 opends/src/messages/messages/admin_tool_zh_CN.properties                              |    3 
 opends/src/guitools/org/opends/guitools/controlpanel/ui/LDIFViewEntryPanel.java       |    6 -
 opends/src/guitools/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java           |   84 ---------------------------
 opends/src/messages/messages/admin_tool_de.properties                                 |    3 
 11 files changed, 18 insertions(+), 110 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 262a684..0621531 100644
--- a/opends/src/ads/org/opends/admin/ads/util/ConnectionUtils.java
+++ b/opends/src/ads/org/opends/admin/ads/util/ConnectionUtils.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2008-2010 Sun Microsystems, Inc.
- *      Portions Copyright 2012-2013 ForgeRock AS
+ *      Portions Copyright 2012-2014 ForgeRock AS
  */
 
 package org.opends.admin.ads.util;
@@ -54,6 +54,7 @@
 import javax.net.ssl.SSLHandshakeException;
 import javax.net.ssl.TrustManager;
 
+import org.opends.server.replication.plugin.EntryHistorical;
 import org.opends.server.schema.SchemaConstants;
 
 /**
@@ -114,6 +115,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)
     {
@@ -192,6 +195,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());
@@ -346,6 +351,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/opends/src/guitools/org/opends/guitools/controlpanel/ui/LDIFViewEntryPanel.java b/opends/src/guitools/org/opends/guitools/controlpanel/ui/LDIFViewEntryPanel.java
index 65e74e1..b7c19f9 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/ui/LDIFViewEntryPanel.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/ui/LDIFViewEntryPanel.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2008-2010 Sun Microsystems, Inc.
- *      Portions Copyright 2012 ForgeRock AS
+ *      Portions Copyright 2012-2014 ForgeRock AS
  */
 
 package org.opends.guitools.controlpanel.ui;
@@ -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/opends/src/guitools/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java b/opends/src/guitools/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
index d874034..c1711b5 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2008-2010 Sun Microsystems, Inc.
- *      Portions Copyright 2013 ForgeRock AS.
+ *      Portions Copyright 2013-2014 ForgeRock AS.
  */
 
 package org.opends.guitools.controlpanel.ui;
@@ -435,10 +435,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/opends/src/guitools/org/opends/guitools/controlpanel/ui/TableViewEntryPanel.java b/opends/src/guitools/org/opends/guitools/controlpanel/ui/TableViewEntryPanel.java
index a78bbcb..b611b72 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/ui/TableViewEntryPanel.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/ui/TableViewEntryPanel.java
@@ -22,6 +22,7 @@
  *
  *
  *      Copyright 2008-2010 Sun Microsystems, Inc.
+ *      Portions Copyright 2014 ForgeRock AS.
  */
 
 package org.opends.guitools.controlpanel.ui;
@@ -173,10 +174,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/opends/src/guitools/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java b/opends/src/guitools/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java
index 228a903..57de8ae 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2008-2010 Sun Microsystems, Inc.
- *      Portions Copyright 2011-2012 ForgeRock AS
+ *      Portions Copyright 2011-2014 ForgeRock AS
  */
 
 package org.opends.guitools.controlpanel.ui;
@@ -53,7 +53,6 @@
 import org.opends.guitools.controlpanel.util.Utilities;
 import org.opends.messages.Message;
 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.opends.server.types.AttributeValue;
@@ -634,87 +633,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/opends/src/messages/messages/admin_tool.properties b/opends/src/messages/messages/admin_tool.properties
index 2945d4d..73be39d 100644
--- a/opends/src/messages/messages/admin_tool.properties
+++ b/opends/src/messages/messages/admin_tool.properties
@@ -20,7 +20,7 @@
 # CDDL HEADER END
 #
 #      Copyright 2006-2010 Sun Microsystems, Inc.
-#      Portions copyright 2011-2013 ForgeRock AS.
+#      Portions copyright 2011-2014 ForgeRock AS.
 #      Portions copyright 2012 profiq s.r.o.
 
 
@@ -2917,7 +2917,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/opends/src/messages/messages/admin_tool_de.properties b/opends/src/messages/messages/admin_tool_de.properties
index c32c7cc..a80810b 100644
--- a/opends/src/messages/messages/admin_tool_de.properties
+++ b/opends/src/messages/messages/admin_tool_de.properties
@@ -20,7 +20,7 @@
 # CDDL HEADER END
 #
 #      Copyright 2006-2010 Sun Microsystems, Inc.
-#      Portions Copyright 2011-2013 ForgeRock AS
+#      Portions Copyright 2011-2014 ForgeRock AS
 
 
 
@@ -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/opends/src/messages/messages/admin_tool_es.properties b/opends/src/messages/messages/admin_tool_es.properties
index 9700182..d03dba7 100644
--- a/opends/src/messages/messages/admin_tool_es.properties
+++ b/opends/src/messages/messages/admin_tool_es.properties
@@ -20,7 +20,7 @@
 # CDDL HEADER END
 #
 #      Copyright 2006-2010 Sun Microsystems, Inc.
-#      Portions Copyright 2011-2013 ForgeRock AS
+#      Portions Copyright 2011-2014 ForgeRock AS
 
 
 
@@ -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/opends/src/messages/messages/admin_tool_fr.properties b/opends/src/messages/messages/admin_tool_fr.properties
index b1f9923..c0bd39d 100644
--- a/opends/src/messages/messages/admin_tool_fr.properties
+++ b/opends/src/messages/messages/admin_tool_fr.properties
@@ -20,7 +20,7 @@
 # CDDL HEADER END
 #
 #      Copyright 2006-2010 Sun Microsystems, Inc.
-#      Portions Copyright 2011-2013 ForgeRock AS
+#      Portions Copyright 2011-2014 ForgeRock AS
 
 
 
@@ -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/opends/src/messages/messages/admin_tool_ja.properties b/opends/src/messages/messages/admin_tool_ja.properties
index 694a389..64d96da 100644
--- a/opends/src/messages/messages/admin_tool_ja.properties
+++ b/opends/src/messages/messages/admin_tool_ja.properties
@@ -20,7 +20,7 @@
 # CDDL HEADER END
 #
 #      Copyright 2006-2010 Sun Microsystems, Inc.
-#      Portions Copyright 2011-2013 ForgeRock AS
+#      Portions Copyright 2011-2014 ForgeRock AS
 
 
 
@@ -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/opends/src/messages/messages/admin_tool_zh_CN.properties b/opends/src/messages/messages/admin_tool_zh_CN.properties
index c774c8b..f3d8b34 100644
--- a/opends/src/messages/messages/admin_tool_zh_CN.properties
+++ b/opends/src/messages/messages/admin_tool_zh_CN.properties
@@ -20,7 +20,7 @@
 # CDDL HEADER END
 #
 #      Copyright 2006-2010 Sun Microsystems, Inc.
-#      Portions Copyright 2011-2013 ForgeRock AS
+#      Portions Copyright 2011-2014 ForgeRock AS
 
 
 
@@ -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