From a35f8a47cca3dbdb584cad85c5aa61f27e0bf42a Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Sat, 07 Oct 2006 02:48:40 +0000
Subject: [PATCH] Fix a bug that allows the server to overlook the fact that there are duplicate values in an LDAP attribute when converting to a core Attribute (it would silently discard the duplicate rather than rejecting it).
---
opends/src/server/org/opends/server/messages/ProtocolMessages.java | 13 +++++++++++++
opends/src/server/org/opends/server/protocols/ldap/LDAPAttribute.java | 8 +++++++-
opends/src/server/org/opends/server/messages/CoreMessages.java | 3 ++-
3 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/opends/src/server/org/opends/server/messages/CoreMessages.java b/opends/src/server/org/opends/server/messages/CoreMessages.java
index b6ad186..57acb02 100644
--- a/opends/src/server/org/opends/server/messages/CoreMessages.java
+++ b/opends/src/server/org/opends/server/messages/CoreMessages.java
@@ -5928,7 +5928,8 @@
/**
* The message ID for the message that will be used if a modify operation does
- * not contain any modifications. This does not take any arguments.
+ * not contain any modifications. This takes a single argument, which is the
+ * DN of the entry to modify.
*/
public static final int MSGID_MODIFY_NO_MODIFICATIONS =
CATEGORY_MASK_CORE | SEVERITY_MASK_SEVERE_ERROR | 566;
diff --git a/opends/src/server/org/opends/server/messages/ProtocolMessages.java b/opends/src/server/org/opends/server/messages/ProtocolMessages.java
index 448c770..98d4f8c 100644
--- a/opends/src/server/org/opends/server/messages/ProtocolMessages.java
+++ b/opends/src/server/org/opends/server/messages/ProtocolMessages.java
@@ -4169,6 +4169,16 @@
/**
+ * The message ID for the message that will be used if an LDAP attribute
+ * contains duplicate values. This takes a single argument, which is the name
+ * of the attribute.
+ */
+ public static final int MSGID_LDAP_ATTRIBUTE_DUPLICATE_VALUES =
+ CATEGORY_MASK_PROTOCOL | SEVERITY_MASK_MILD_ERROR | 384;
+
+
+
+ /**
* Associates a set of generic messages with the message IDs defined in this
* class.
*/
@@ -4661,6 +4671,9 @@
"Cannot decode the provided ASN.1 element as an LDAP " +
"attribute because the set of values could not be " +
"decoded: %s.");
+ registerMessage(MSGID_LDAP_ATTRIBUTE_DUPLICATE_VALUES,
+ "The provided LDAP attribute %s contains duplicate " +
+ "values.");
registerMessage(MSGID_LDAP_ADD_REQUEST_DECODE_SEQUENCE,
diff --git a/opends/src/server/org/opends/server/protocols/ldap/LDAPAttribute.java b/opends/src/server/org/opends/server/protocols/ldap/LDAPAttribute.java
index 280e72d..2ea3357 100644
--- a/opends/src/server/org/opends/server/protocols/ldap/LDAPAttribute.java
+++ b/opends/src/server/org/opends/server/protocols/ldap/LDAPAttribute.java
@@ -365,7 +365,13 @@
new LinkedHashSet<AttributeValue>(values.size());
for (ASN1OctetString value : values)
{
- attributeValues.add(new AttributeValue(attrType, value));
+ if (! attributeValues.add(new AttributeValue(attrType, value)))
+ {
+ int msgID = MSGID_LDAP_ATTRIBUTE_DUPLICATE_VALUES;
+ String message = getMessage(msgID, attributeType);
+ throw new LDAPException(LDAPResultCode.ATTRIBUTE_OR_VALUE_EXISTS, msgID,
+ message);
+ }
}
--
Gitblit v1.10.0