From f73b655466092169abac34833fb628fce1fcdebe Mon Sep 17 00:00:00 2001
From: jcduff <jcduff@localhost>
Date: Thu, 23 Oct 2008 14:04:24 +0000
Subject: [PATCH] The commit will bring the following features : - An updated version of the underlying database. BDB JE 3.3 is now used. - Attribute API refactoring providing a better abstraction and offering improved performances. - A new GUI called the Control-Panel to replace the Status-Panel: the specifications for this GUI are available on OpenDS Wiki and contains a link to a mockup. See <https://www.opends.org/wiki/page/ControlPanelUISpecification>. - Some changes in the replication protocol to implement "Assured Replication Mode". The specifications are on OpenDS Wiki at <https://www.opends.org/wiki/page/AssuredMode> and section 7 described some of the replication changes required to support this. Assured Replication is not finished, but the main replication protocol changes to support it are done. As explained by Gilles on an email on the Dev mailing list (http://markmail.org/message/46rgo3meq3vriy4a), with these changes the newer versions of OpenDS may not be able to replicate with OpenDS 1.0 instances. - Support for Service Tags on the platforms where the functionality is available and enabled. Specifications are published at <https://www.opends.org/wiki/page/OpenDSServiceTagEnabled>. For more information on Service Tags see <http://wikis.sun.com/display/ServiceTag/Sun+Service+Tag+FAQ>. - The Admin Connector service. In order to provide agentry of the OpenDS server at any time, a new service has been added, dedicated to the administration, configuration and monitoring of the server. An overview of the Admin Connector service and it's use is available on the OpenDS wiki <https://www.opends.org/wiki/page/ManagingAdministrationTrafficToTheServer> - Updates to the various command line tools to support the Admin Connector service. - Some internal re-architecting of the server to put the foundation of future developments such as virtual directory services. The new NetworkGroups and WorkFlow internal services which have been specified in <https://www.opends.org/wiki/page/BasicOperationRoutingThroughNetworkGroup> are now implemented. - Many bug fixes...
---
opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java | 185 ++++++++++++++++++----------------------------
1 files changed, 72 insertions(+), 113 deletions(-)
diff --git a/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java b/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java
index f4b3069..985e55c 100644
--- a/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java
+++ b/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java
@@ -28,10 +28,16 @@
+import static org.opends.messages.CoreMessages.*;
+import static org.opends.server.config.ConfigConstants.*;
+import static org.opends.server.loggers.ErrorLogger.*;
+import static org.opends.server.loggers.debug.DebugLogger.*;
+import static org.opends.server.util.ServerConstants.*;
+import static org.opends.server.util.StaticUtils.*;
+
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -61,19 +67,19 @@
import org.opends.server.core.PasswordPolicy;
import org.opends.server.core.PluginConfigManager;
import org.opends.server.loggers.debug.DebugTracer;
-import org.opends.server.protocols.asn1.ASN1OctetString;
import org.opends.server.schema.AuthPasswordSyntax;
-import org.opends.server.schema.BooleanSyntax;
import org.opends.server.schema.UserPasswordSyntax;
import org.opends.server.types.Attribute;
+import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
+import org.opends.server.types.Attributes;
import org.opends.server.types.ByteString;
import org.opends.server.types.CanceledOperationException;
import org.opends.server.types.Control;
+import org.opends.server.types.DN;
import org.opends.server.types.DebugLogLevel;
import org.opends.server.types.DirectoryException;
-import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.LDAPException;
import org.opends.server.types.LockManager;
@@ -86,17 +92,10 @@
import org.opends.server.types.SynchronizationProviderResult;
import org.opends.server.types.operation.PostOperationAddOperation;
import org.opends.server.types.operation.PostResponseAddOperation;
-import org.opends.server.types.operation.PreOperationAddOperation;
import org.opends.server.types.operation.PostSynchronizationAddOperation;
+import org.opends.server.types.operation.PreOperationAddOperation;
import org.opends.server.util.TimeThread;
-import static org.opends.messages.CoreMessages.*;
-import static org.opends.server.loggers.ErrorLogger.*;
-import static org.opends.server.loggers.debug.DebugLogger.*;
-import static org.opends.server.config.ConfigConstants.*;
-import static org.opends.server.util.ServerConstants.*;
-import static org.opends.server.util.StaticUtils.*;
-
/**
@@ -887,13 +886,8 @@
if (isSynchronizationOperation() ||
DirectoryServer.addMissingRDNAttributes())
{
- LinkedHashSet<AttributeValue> valueList =
- new LinkedHashSet<AttributeValue>(1);
- valueList.add(v);
-
attrList = new ArrayList<Attribute>();
- attrList.add(new Attribute(t, n, valueList));
-
+ attrList.add(Attributes.create(t, n, v));
operationalAttributes.put(t, attrList);
}
else
@@ -906,33 +900,31 @@
else
{
boolean found = false;
- for (Attribute a : attrList)
- {
+ for (int j = 0; j < attrList.size(); j++) {
+ Attribute a = attrList.get(j);
+
if (a.hasOptions())
{
continue;
}
- else
- {
- if (! a.hasValue(v))
- {
- a.getValues().add(v);
- }
- found = true;
- break;
+ if (!a.contains(v))
+ {
+ AttributeBuilder builder = new AttributeBuilder(a);
+ builder.add(v);
+ attrList.set(j, builder.toAttribute());
}
+
+ found = true;
+ break;
}
- if (! found)
+ if (!found)
{
if (isSynchronizationOperation() ||
DirectoryServer.addMissingRDNAttributes())
{
- LinkedHashSet<AttributeValue> valueList =
- new LinkedHashSet<AttributeValue>(1);
- valueList.add(v);
- attrList.add(new Attribute(t, n, valueList));
+ attrList.add(Attributes.create(t, n, v));
}
else
{
@@ -951,13 +943,8 @@
if (isSynchronizationOperation() ||
DirectoryServer.addMissingRDNAttributes())
{
- LinkedHashSet<AttributeValue> valueList =
- new LinkedHashSet<AttributeValue>(1);
- valueList.add(v);
-
attrList = new ArrayList<Attribute>();
- attrList.add(new Attribute(t, n, valueList));
-
+ attrList.add(Attributes.create(t, n, v));
userAttributes.put(t, attrList);
}
else
@@ -970,33 +957,31 @@
else
{
boolean found = false;
- for (Attribute a : attrList)
- {
+ for (int j = 0; j < attrList.size(); j++) {
+ Attribute a = attrList.get(j);
+
if (a.hasOptions())
{
continue;
}
- else
- {
- if (! a.hasValue(v))
- {
- a.getValues().add(v);
- }
- found = true;
- break;
+ if (!a.contains(v))
+ {
+ AttributeBuilder builder = new AttributeBuilder(a);
+ builder.add(v);
+ attrList.set(j, builder.toAttribute());
}
+
+ found = true;
+ break;
}
- if (! found)
+ if (!found)
{
if (isSynchronizationOperation() ||
DirectoryServer.addMissingRDNAttributes())
{
- LinkedHashSet<AttributeValue> valueList =
- new LinkedHashSet<AttributeValue>(1);
- valueList.add(v);
- attrList.add(new Attribute(t, n, valueList));
+ attrList.add(Attributes.create(t, n, v));
}
else
{
@@ -1057,8 +1042,7 @@
if ((pwAttrList != null) && (! pwAttrList.isEmpty()))
{
Attribute a = pwAttrList.get(0);
- LinkedHashSet<AttributeValue> valueSet = a.getValues();
- Iterator<AttributeValue> iterator = valueSet.iterator();
+ Iterator<AttributeValue> iterator = a.iterator();
if (iterator.hasNext())
{
DN policyDN;
@@ -1120,28 +1104,29 @@
throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
}
- LinkedHashSet<AttributeValue> values = passwordAttr.getValues();
- if (values.isEmpty())
+ if (passwordAttr.isEmpty())
{
// This will be treated the same as not having a password.
return;
}
- if ((! passwordPolicy.allowMultiplePasswordValues()) && (values.size() > 1))
+ if ((!passwordPolicy.allowMultiplePasswordValues())
+ && (passwordAttr.size() > 1))
{
- // FIXME -- What if they're pre-encoded and might all be the same?
+ // FIXME -- What if they're pre-encoded and might all be the
+ // same?
addPWPolicyControl(PasswordPolicyErrorType.PASSWORD_MOD_NOT_ALLOWED);
- Message message = ERR_PWPOLICY_MULTIPLE_PW_VALUES_NOT_ALLOWED.get(
- passwordAttribute.getNameOrOID());
+ Message message = ERR_PWPOLICY_MULTIPLE_PW_VALUES_NOT_ALLOWED
+ .get(passwordAttribute.getNameOrOID());
throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
}
- CopyOnWriteArrayList<PasswordStorageScheme> defaultStorageSchemes =
+ CopyOnWriteArrayList<PasswordStorageScheme<?>> defaultStorageSchemes =
passwordPolicy.getDefaultStorageSchemes();
- LinkedHashSet<AttributeValue> newValues =
- new LinkedHashSet<AttributeValue>(defaultStorageSchemes.size());
- for (AttributeValue v : values)
+ AttributeBuilder builder = new AttributeBuilder(passwordAttr, true);
+ builder.setInitialCapacity(defaultStorageSchemes.size());
+ for (AttributeValue v : passwordAttr)
{
ByteString value = v.getValue();
@@ -1152,7 +1137,7 @@
{
if (passwordPolicy.allowPreEncodedPasswords())
{
- newValues.add(v);
+ builder.add(v);
continue;
}
else
@@ -1173,7 +1158,7 @@
{
if (passwordPolicy.allowPreEncodedPasswords())
{
- newValues.add(v);
+ builder.add(v);
continue;
}
else
@@ -1222,7 +1207,7 @@
for (PasswordStorageScheme s : defaultStorageSchemes)
{
ByteString encodedValue = s.encodeAuthPassword(value);
- newValues.add(new AttributeValue(passwordAttribute, encodedValue));
+ builder.add(new AttributeValue(passwordAttribute, encodedValue));
}
}
else
@@ -1230,37 +1215,22 @@
for (PasswordStorageScheme s : defaultStorageSchemes)
{
ByteString encodedValue = s.encodePasswordWithScheme(value);
- newValues.add(new AttributeValue(passwordAttribute, encodedValue));
+ builder.add(new AttributeValue(passwordAttribute, encodedValue));
}
}
}
// Put the new encoded values in the entry.
- passwordAttr.setValues(newValues);
+ entry.replaceAttribute(builder.toAttribute());
// Set the password changed time attribute.
- ByteString timeString =
- new ASN1OctetString(TimeThread.getGeneralizedTime());
- AttributeType changedTimeType =
- DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_CHANGED_TIME_LC);
- if (changedTimeType == null)
- {
- changedTimeType = DirectoryServer.getDefaultAttributeType(
- OP_ATTR_PWPOLICY_CHANGED_TIME);
- }
-
- LinkedHashSet<AttributeValue> changedTimeValues =
- new LinkedHashSet<AttributeValue>(1);
- changedTimeValues.add(new AttributeValue(changedTimeType, timeString));
-
ArrayList<Attribute> changedTimeList = new ArrayList<Attribute>(1);
- changedTimeList.add(new Attribute(changedTimeType,
- OP_ATTR_PWPOLICY_CHANGED_TIME,
- changedTimeValues));
-
- entry.putAttribute(changedTimeType, changedTimeList);
+ Attribute changedTime = Attributes.create(
+ OP_ATTR_PWPOLICY_CHANGED_TIME, TimeThread.getGeneralizedTime());
+ changedTimeList.add(changedTime);
+ entry.putAttribute(changedTime.getAttributeType(), changedTimeList);
// If we should force change on add, then set the appropriate flag.
@@ -1268,22 +1238,11 @@
{
addPWPolicyControl(PasswordPolicyErrorType.CHANGE_AFTER_RESET);
- AttributeType resetType =
- DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_RESET_REQUIRED_LC);
- if (resetType == null)
- {
- resetType = DirectoryServer.getDefaultAttributeType(
- OP_ATTR_PWPOLICY_RESET_REQUIRED);
- }
-
- LinkedHashSet<AttributeValue> resetValues = new
- LinkedHashSet<AttributeValue>(1);
- resetValues.add(BooleanSyntax.createBooleanValue(true));
-
ArrayList<Attribute> resetList = new ArrayList<Attribute>(1);
- resetList.add(new Attribute(resetType, OP_ATTR_PWPOLICY_RESET_REQUIRED,
- resetValues));
- entry.putAttribute(resetType, resetList);
+ Attribute reset = Attributes.create(
+ OP_ATTR_PWPOLICY_RESET_REQUIRED, "TRUE");
+ resetList.add(reset);
+ entry.putAttribute(reset.getAttributeType(), resetList);
}
}
@@ -1336,10 +1295,10 @@
{
for (Attribute a : attrList)
{
- AttributeSyntax syntax = a.getAttributeType().getSyntax();
+ AttributeSyntax<?> syntax = a.getAttributeType().getSyntax();
if (syntax != null)
{
- for (AttributeValue v : a.getValues())
+ for (AttributeValue v : a)
{
if (! syntax.valueIsAcceptable(v.getValue(), invalidReason))
{
@@ -1363,10 +1322,10 @@
{
for (Attribute a : attrList)
{
- AttributeSyntax syntax = a.getAttributeType().getSyntax();
+ AttributeSyntax<?> syntax = a.getAttributeType().getSyntax();
if (syntax != null)
{
- for (AttributeValue v : a.getValues())
+ for (AttributeValue v : a)
{
if (! syntax.valueIsAcceptable(v.getValue(),
invalidReason))
@@ -1395,10 +1354,10 @@
{
for (Attribute a : attrList)
{
- AttributeSyntax syntax = a.getAttributeType().getSyntax();
+ AttributeSyntax<?> syntax = a.getAttributeType().getSyntax();
if (syntax != null)
{
- for (AttributeValue v : a.getValues())
+ for (AttributeValue v : a)
{
if (! syntax.valueIsAcceptable(v.getValue(),
invalidReason))
@@ -1418,10 +1377,10 @@
{
for (Attribute a : attrList)
{
- AttributeSyntax syntax = a.getAttributeType().getSyntax();
+ AttributeSyntax<?> syntax = a.getAttributeType().getSyntax();
if (syntax != null)
{
- for (AttributeValue v : a.getValues())
+ for (AttributeValue v : a)
{
if (! syntax.valueIsAcceptable(v.getValue(),
invalidReason))
--
Gitblit v1.10.0