From fd3f8d8954cd4cc70c7b2670db5ef2d5443519e9 Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Thu, 30 Oct 2014 08:48:52 +0000
Subject: [PATCH] OPENDJ-1591 Modify UniqueMemberEqualityMatchingRuleImpl to normalized DN in the same way than DistinguishedNameEqualityMatchingRuleImpl and add the optional uid if present
---
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/UniqueMemberEqualityMatchingRuleImpl.java | 32 ++++++++++++++++++++++++++++----
1 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/UniqueMemberEqualityMatchingRuleImpl.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/UniqueMemberEqualityMatchingRuleImpl.java
index af37649..0297080 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/UniqueMemberEqualityMatchingRuleImpl.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/UniqueMemberEqualityMatchingRuleImpl.java
@@ -26,17 +26,41 @@
*/
package org.forgerock.opendj.ldap.schema;
+import org.forgerock.i18n.LocalizedIllegalArgumentException;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.ByteStringBuilder;
+import org.forgerock.opendj.ldap.DN;
+import org.forgerock.opendj.ldap.DecodeException;
/**
* This class implements the uniqueMemberMatch matching rule defined in X.520
- * and referenced in RFC 2252. It is based on the name and optional UID syntax,
- * and will compare values with a distinguished name and optional bit string
+ * and referenced in RFC 4517. It is based on the name and optional UID syntax,
+ * and will compare values with a distinguished name and optional bit string (uid)
* suffix.
*/
final class UniqueMemberEqualityMatchingRuleImpl extends AbstractEqualityMatchingRuleImpl {
- public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value) {
- return value.toByteString();
+
+ public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value) throws DecodeException {
+ // Separate value into normalized DN and "optional uid" portion.
+ final String stringValue = value.toString().trim();
+ int dnEndPosition = stringValue.length();
+ String optionalUid = "";
+ int sharpPosition = -1;
+ if (stringValue.endsWith("'B") || stringValue.endsWith("'b")) {
+ sharpPosition = stringValue.lastIndexOf("#'");
+ if (sharpPosition > 0) {
+ dnEndPosition = sharpPosition;
+ optionalUid = stringValue.substring(sharpPosition);
+ }
+ }
+ try {
+ DN dn = DN.valueOf(stringValue.substring(0, dnEndPosition), schema.asNonStrictSchema());
+ return new ByteStringBuilder()
+ .append(dn.toIrreversibleNormalizedByteString())
+ .append(optionalUid).toByteString();
+ } catch (final LocalizedIllegalArgumentException e) {
+ throw DecodeException.error(e.getMessageObject());
+ }
}
}
--
Gitblit v1.10.0