From a64eeca99c07bc4bdbb65d4a3643dc77c65f2095 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Thu, 09 Apr 2009 09:18:07 +0000
Subject: [PATCH] Fix for issue 2642 (ldif-diff doesn't detect differences in encoded values)
---
opends/src/server/org/opends/server/tools/LDIFDiff.java | 23 ++++++++++-
opends/resource/bin/ldif-diff | 4 +-
opends/src/messages/messages/tools.properties | 13 +++++-
opends/src/server/org/opends/server/schema/UserPasswordExactEqualityMatchingRule.java | 17 +++++++-
opends/resource/bin/ldif-diff.bat | 4 +-
5 files changed, 50 insertions(+), 11 deletions(-)
diff --git a/opends/resource/bin/ldif-diff b/opends/resource/bin/ldif-diff
index cf961e4..ac5e10f 100755
--- a/opends/resource/bin/ldif-diff
+++ b/opends/resource/bin/ldif-diff
@@ -23,7 +23,7 @@
# CDDL HEADER END
#
#
-# Copyright 2006-2008 Sun Microsystems, Inc.
+# Copyright 2006-2009 Sun Microsystems, Inc.
# This script may be used to compare the contents of two LDIF files.
@@ -34,4 +34,4 @@
export SCRIPT_NAME
SCRIPT_DIR=`dirname "${0}"`
-"${SCRIPT_DIR}/../lib/_client-script.sh" "${@}"
+"${SCRIPT_DIR}/../lib/_server-script.sh" "${@}"
diff --git a/opends/resource/bin/ldif-diff.bat b/opends/resource/bin/ldif-diff.bat
index f8acf04..aabdf6d 100644
--- a/opends/resource/bin/ldif-diff.bat
+++ b/opends/resource/bin/ldif-diff.bat
@@ -23,12 +23,12 @@
rem CDDL HEADER END
rem
rem
-rem Copyright 2006-2008 Sun Microsystems, Inc.
+rem Copyright 2006-2009 Sun Microsystems, Inc.
setlocal
set OPENDS_INVOKE_CLASS="org.opends.server.tools.LDIFDiff"
set SCRIPT_NAME=ldif-diff
-for %%i in (%~sf0) do call "%%~dPsi\..\lib\_client-script.bat" %*
+for %%i in (%~sf0) do call "%%~dPsi\..\lib\_server-script.bat" %*
diff --git a/opends/src/messages/messages/tools.properties b/opends/src/messages/messages/tools.properties
index 660404f..1fe2395 100644
--- a/opends/src/messages/messages/tools.properties
+++ b/opends/src/messages/messages/tools.properties
@@ -2470,10 +2470,10 @@
SEVERE_ERR_STOPDS_DATETIME_ALREADY_PASSED_1669=The specified stop time '%s' \
has already passed
-
+
SEVERE_ERR_LDAPCOMPARE_FILENAME_AND_DNS_1670=Both entry DNs and a file name \
were provided for the compare operation. These arguments are not compatible
-
+
# The following chars correspond to the following properties:
# INFO_TASKINFO_CMD_REFRESH_1415=refresh
# INFO_TASKINFO_CMD_CANCEL_1416=cancel task
@@ -2481,4 +2481,11 @@
INFO_TASKINFO_CMD_REFRESH_CHAR_1671=r
INFO_TASKINFO_CMD_CANCEL_CHAR_1672=c
INFO_TASKINFO_CMD_VIEW_LOGS_CHAR_1673=l
-
\ No newline at end of file
+
+INFO_LDIFDIFF_DESCRIPTION_CHECK_SCHEMA_1674=Takes into account the syntax of \
+ the attributes as defined in the schema to make the value comparison. The \
+ provided LDIF files must be conform to the server schema
+SEVERE_WARN_LDIFDIFF_NO_CONFIG_FILE_1675=WARNING: no configuration file was \
+ provided as argument. No schema check will be performed. If this is being \
+ called throught the '%s' command-line, verify that the script has not been \
+ modified
diff --git a/opends/src/server/org/opends/server/schema/UserPasswordExactEqualityMatchingRule.java b/opends/src/server/org/opends/server/schema/UserPasswordExactEqualityMatchingRule.java
index 11d9a42..36bd930 100644
--- a/opends/src/server/org/opends/server/schema/UserPasswordExactEqualityMatchingRule.java
+++ b/opends/src/server/org/opends/server/schema/UserPasswordExactEqualityMatchingRule.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2006-2008 Sun Microsystems, Inc.
+ * Copyright 2006-2009 Sun Microsystems, Inc.
*/
package org.opends.server.schema;
@@ -148,7 +148,20 @@
if (UserPasswordSyntax.isEncoded(value))
{
StringBuilder builder = new StringBuilder(value.length());
- StaticUtils.toLowerCase(value, builder, false);
+ int closingBracePos = -1;
+ for (int i=1; i < value.length(); i++)
+ {
+ if (value.byteAt(i) == '}')
+ {
+ closingBracePos = i;
+ break;
+ }
+ }
+ ByteSequence seq1 = value.subSequence(0, closingBracePos + 1);
+ ByteSequence seq2 =
+ value.subSequence(closingBracePos + 1, value.length());
+ StaticUtils.toLowerCase(seq1, builder, false);
+ builder.append(seq2);
return ByteString.valueOf(builder.toString());
}
else
diff --git a/opends/src/server/org/opends/server/tools/LDIFDiff.java b/opends/src/server/org/opends/server/tools/LDIFDiff.java
index 0c4764c..5f8e1eb 100644
--- a/opends/src/server/org/opends/server/tools/LDIFDiff.java
+++ b/opends/src/server/org/opends/server/tools/LDIFDiff.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2006-2008 Sun Microsystems, Inc.
+ * Copyright 2006-2009 Sun Microsystems, Inc.
*/
package org.opends.server.tools;
import org.opends.messages.Message;
@@ -54,6 +54,7 @@
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.tools.ToolConstants.*;
+import static org.opends.server.util.ServerConstants.PROPERTY_SCRIPT_NAME;
import static org.opends.server.util.StaticUtils.*;
@@ -153,6 +154,7 @@
BooleanArgument overwriteExisting;
BooleanArgument showUsage;
BooleanArgument singleValueChanges;
+ BooleanArgument doCheckSchema;
StringArgument configClass;
StringArgument configFile;
StringArgument outputLDIF;
@@ -210,6 +212,12 @@
INFO_LDIFDIFF_DESCRIPTION_SINGLE_VALUE_CHANGES.get());
argParser.addArgument(singleValueChanges);
+ doCheckSchema =
+ new BooleanArgument(
+ "checkschema", null, "checkSchema",
+ INFO_LDIFDIFF_DESCRIPTION_CHECK_SCHEMA.get());
+ argParser.addArgument(doCheckSchema);
+
configFile = new StringArgument("configfile", 'c', "configFile", false,
false, true,
INFO_CONFIGFILE_PLACEHOLDER.get(), null,
@@ -264,8 +272,19 @@
return 0;
}
+ if (doCheckSchema.isPresent() && !configFile.isPresent())
+ {
+ String scriptName = System.getProperty(PROPERTY_SCRIPT_NAME);
+ if (scriptName == null)
+ {
+ scriptName = "ldif-diff";
+ }
+ Message message = WARN_LDIFDIFF_NO_CONFIG_FILE.get(scriptName);
+ err.println(message);
+ }
- boolean checkSchema = configFile.isPresent();
+
+ boolean checkSchema = configFile.isPresent() && doCheckSchema.isPresent();
if (! serverInitialized)
{
// Bootstrap the Directory Server configuration for use as a client.
--
Gitblit v1.10.0