From 272e306217cfa3e394574d9a1a4e69ff9e3a9600 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Wed, 11 Apr 2007 21:07:24 +0000
Subject: [PATCH] Add a new password validator that can be used to require that passwords have a specified number of characters from various user-defined character sets. It is also possible to control whether passwords will be allowed to contain characters outside of any defined character set.
---
opends/src/server/org/opends/server/util/LDIFReader.java | 60 ++++++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 42 insertions(+), 18 deletions(-)
diff --git a/opends/src/server/org/opends/server/util/LDIFReader.java b/opends/src/server/org/opends/server/util/LDIFReader.java
index b8eecbc..ea638f3 100644
--- a/opends/src/server/org/opends/server/util/LDIFReader.java
+++ b/opends/src/server/org/opends/server/util/LDIFReader.java
@@ -79,9 +79,6 @@
*/
public final class LDIFReader
{
-
-
-
// The reader that will be used to read the data.
private BufferedReader reader;
@@ -243,7 +240,7 @@
for (StringBuilder line : lines)
{
readAttribute(lines, line, entryDN, objectClasses, userAttributes,
- operationalAttributes);
+ operationalAttributes, checkSchema);
}
}
catch (LDIFException e)
@@ -814,6 +811,8 @@
* for the current entry.
* @param operationalAttributes The set of operational attributes decoded so
* far for the current entry.
+ * @param checkSchema Indicates whether to perform schema
+ * validation for the attribute.
*
* @throws LDIFException If a problem occurs while trying to decode the
* attribute contained in the provided entry.
@@ -822,7 +821,8 @@
StringBuilder line, DN entryDN,
HashMap<ObjectClass,String> objectClasses,
HashMap<AttributeType,List<Attribute>> userAttributes,
- HashMap<AttributeType,List<Attribute>> operationalAttributes)
+ HashMap<AttributeType,List<Attribute>> operationalAttributes,
+ boolean checkSchema)
throws LDIFException
{
// Parse the attribute type description.
@@ -934,14 +934,40 @@
LinkedHashSet<AttributeValue> valueSet = a.getValues();
if (valueSet.contains(attributeValue))
{
- int msgID = MSGID_LDIF_DUPLICATE_ATTR;
- String message = getMessage(msgID, String.valueOf(entryDN),
- lastEntryLineNumber, attrName,
- value.stringValue());
- logToRejectWriter(lines, message);
- throw new LDIFException(msgID, message, lastEntryLineNumber, true);
+ if (! checkSchema)
+ {
+ // If we're not doing schema checking, then it is possible that
+ // the attribute type should use case-sensitive matching and the
+ // values differ in capitalization. Only reject the proposed
+ // value if we find another value that is exactly the same as the
+ // one that was provided.
+ for (AttributeValue v : valueSet)
+ {
+ if (v.getValue().equals(attributeValue.getValue()))
+ {
+ int msgID = MSGID_LDIF_DUPLICATE_ATTR;
+ String message = getMessage(msgID, String.valueOf(entryDN),
+ lastEntryLineNumber, attrName,
+ value.stringValue());
+ logToRejectWriter(lines, message);
+ throw new LDIFException(msgID, message, lastEntryLineNumber,
+ true);
+ }
+ }
+ }
+ else
+ {
+ int msgID = MSGID_LDIF_DUPLICATE_ATTR;
+ String message = getMessage(msgID, String.valueOf(entryDN),
+ lastEntryLineNumber, attrName,
+ value.stringValue());
+ logToRejectWriter(lines, message);
+ throw new LDIFException(msgID, message, lastEntryLineNumber,
+ true);
+ }
}
- else if (attrType.isSingleValue() && (! valueSet.isEmpty()))
+
+ if (attrType.isSingleValue() && (! valueSet.isEmpty()) && checkSchema)
{
int msgID = MSGID_LDIF_MULTIPLE_VALUES_FOR_SINGLE_VALUED_ATTR;
String message = getMessage(msgID, String.valueOf(entryDN),
@@ -949,11 +975,9 @@
logToRejectWriter(lines, message);
throw new LDIFException(msgID, message, lastEntryLineNumber, true);
}
- else
- {
- valueSet.add(attributeValue);
- return;
- }
+
+ valueSet.add(attributeValue);
+ return;
}
}
@@ -1469,7 +1493,7 @@
for(StringBuilder line : lines)
{
readAttribute(lines, line, entryDN, objectClasses,
- attributes, attributes);
+ attributes, attributes, importConfig.validateSchema());
}
// Reconstruct the object class attribute.
--
Gitblit v1.10.0