opendj3-server-dev/src/server/org/opends/server/core/AddOperation.java
@@ -46,7 +46,7 @@ * * @return The DN of the entry in a raw, unparsed form. */ public abstract ByteString getRawEntryDN(); ByteString getRawEntryDN(); /** * Specifies the raw entry DN for the entry to add. This should only be @@ -57,7 +57,7 @@ * * @param rawEntryDN The raw entry DN for the entry to add. */ public abstract void setRawEntryDN(ByteString rawEntryDN); void setRawEntryDN(ByteString rawEntryDN); /** * Retrieves the DN of the entry to add. This method should not be called @@ -67,7 +67,7 @@ * @return The DN of the entry to add, or <CODE>null</CODE> if it has not yet * been parsed from the raw DN. */ public abstract DN getEntryDN(); DN getEntryDN(); /** * Retrieves the set of attributes in their raw, unparsed form as read from @@ -78,7 +78,7 @@ * @return The set of attributes in their raw, unparsed form as read from the * client request. */ public abstract List<RawAttribute> getRawAttributes(); List<RawAttribute> getRawAttributes(); /** * Adds the provided attribute to the set of raw attributes for this add @@ -87,7 +87,7 @@ * @param rawAttribute The attribute to add to the set of raw attributes for * this add operation. */ public abstract void addRawAttribute(RawAttribute rawAttribute); void addRawAttribute(RawAttribute rawAttribute); /** * Replaces the set of raw attributes for this add operation. This should @@ -95,7 +95,7 @@ * * @param rawAttributes The set of raw attributes for this add operation. */ public abstract void setRawAttributes(List<RawAttribute> rawAttributes); void setRawAttributes(List<RawAttribute> rawAttributes); /** * Retrieves the set of processed user attributes for the entry to add. This @@ -106,7 +106,7 @@ * @return The set of processed user attributes for the entry to add, or * <CODE>null</CODE> if that information is not yet available. */ public abstract Map<AttributeType, List<Attribute>> getUserAttributes(); Map<AttributeType, List<Attribute>> getUserAttributes(); /** * Sets the specified attribute in the entry to add, overwriting any existing @@ -119,8 +119,7 @@ * @param attributeType The attribute type for the attribute. * @param attributeList The attribute list for the provided attribute type. */ public abstract void setAttribute(AttributeType attributeType, List<Attribute> attributeList); void setAttribute(AttributeType attributeType, List<Attribute> attributeList); /** * Removes the specified attribute from the entry to add. This should only be @@ -131,25 +130,7 @@ * * @param attributeType The attribute tyep for the attribute to remove. */ public abstract void removeAttribute(AttributeType attributeType); /** * Retrieves the change number that has been assigned to this operation. * * @return The change number that has been assigned to this operation, or -1 * if none has been assigned yet or if there is no applicable * synchronization mechanism in place that uses change numbers. */ public abstract long getChangeNumber(); /** * Specifies the change number that has been assigned to this operation by the * synchronization mechanism. * * @param changeNumber The change number that has been assigned to this * operation by the synchronization mechanism. */ public abstract void setChangeNumber(long changeNumber); void removeAttribute(AttributeType attributeType); /** * Retrieves the set of processed objectclasses for the entry to add. This @@ -160,7 +141,7 @@ * @return The set of processed objectclasses for the entry to add, or * <CODE>null</CODE> if that information is not yet available. */ public abstract Map<ObjectClass,String> getObjectClasses(); Map<ObjectClass, String> getObjectClasses(); /** * Adds the provided objectclass to the entry to add. This should only be @@ -172,7 +153,7 @@ * @param objectClass The objectclass to add to the entry. * @param name The name to use for the objectclass. */ public abstract void addObjectClass(ObjectClass objectClass, String name); void addObjectClass(ObjectClass objectClass, String name); /** * Removes the provided objectclass from the entry to add. This should only @@ -183,7 +164,7 @@ * * @param objectClass The objectclass to remove from the entry. */ public abstract void removeObjectClass(ObjectClass objectClass); void removeObjectClass(ObjectClass objectClass); /** * Retrieves the set of processed operational attributes for the entry to add. @@ -194,7 +175,7 @@ * @return The set of processed operational attributes for the entry to add, * or <CODE>null</CODE> if that information is not yet available. */ public abstract Map<AttributeType,List<Attribute>> getOperationalAttributes(); Map<AttributeType, List<Attribute>> getOperationalAttributes(); /** * Retrieves the proxied authorization DN for this operation if proxied @@ -204,7 +185,7 @@ * authorization has been requested, or {@code null} if proxied * authorization has not been requested. */ public abstract DN getProxiedAuthorizationDN(); DN getProxiedAuthorizationDN(); /** * Set the proxied authorization DN for this operation if proxied @@ -215,6 +196,6 @@ * authorization has been requested, or {@code null} if proxied * authorization has not been requested. */ public abstract void setProxiedAuthorizationDN(DN proxiedAuthorizationDN); void setProxiedAuthorizationDN(DN proxiedAuthorizationDN); } opendj3-server-dev/src/server/org/opends/server/core/AddOperationBasis.java
@@ -90,9 +90,6 @@ /** The set of objectclasses for the entry to add. */ private Map<ObjectClass,String> objectClasses; /** The change number that has been assigned to this operation. */ private long changeNumber; /** The flag indicates if an LDAP error was reported. */ private boolean ldapError; @@ -128,7 +125,6 @@ operationalAttributes = null; objectClasses = null; proxiedAuthorizationDN = null; changeNumber = -1; } @@ -194,22 +190,16 @@ responseControls = new ArrayList<Control>(); proxiedAuthorizationDN = null; cancelRequest = null; changeNumber = -1; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final ByteString getRawEntryDN() { return rawEntryDN; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final void setRawEntryDN(ByteString rawEntryDN) { @@ -218,10 +208,7 @@ entryDN = null; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final DN getEntryDN() { @@ -244,20 +231,14 @@ return entryDN; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final List<RawAttribute> getRawAttributes() { return rawAttributes; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final void addRawAttribute(RawAttribute rawAttribute) { @@ -268,10 +249,7 @@ operationalAttributes = null; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final void setRawAttributes(List<RawAttribute> rawAttributes) { @@ -282,11 +260,7 @@ operationalAttributes = null; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final Map<ObjectClass,String> getObjectClasses() { @@ -296,33 +270,21 @@ return objectClasses; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final void addObjectClass(ObjectClass objectClass, String name) { objectClasses.put(objectClass, name); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final void removeObjectClass(ObjectClass objectClass) { objectClasses.remove(objectClass); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final Map<AttributeType,List<Attribute>> getUserAttributes() { @@ -332,10 +294,7 @@ return userAttributes; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final Map<AttributeType,List<Attribute>> getOperationalAttributes() { @@ -387,14 +346,11 @@ attr = builder.toAttribute(); } } else else if (attr.hasOption("binary")) { // binary option is not honored for non-BER-encodable attributes. if(attr.hasOption("binary")) { throw new LDAPException(LDAPResultCode.UNDEFINED_ATTRIBUTE_TYPE, ERR_ADD_ATTR_IS_INVALID_OPTION.get(entryDN, attr.getName())); } throw new LDAPException(LDAPResultCode.UNDEFINED_ATTRIBUTE_TYPE, ERR_ADD_ATTR_IS_INVALID_OPTION.get(entryDN, attr.getName())); } if (attrType.isObjectClass()) @@ -475,9 +431,7 @@ } } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final void setAttribute(AttributeType attributeType, List<Attribute> attributeList) @@ -494,18 +448,14 @@ } } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final void removeAttribute(AttributeType attributeType) { getAttributes(attributeType.isOperational()).remove(attributeType); } private Map<AttributeType, List<Attribute>> getAttributes( boolean isOperational) private Map<AttributeType, List<Attribute>> getAttributes(boolean isOperational) { if (isOperational) { @@ -514,29 +464,7 @@ return userAttributes; } /** * {@inheritDoc} */ @Override public final long getChangeNumber() { return changeNumber; } /** * {@inheritDoc} */ @Override public final void setChangeNumber(long changeNumber) { this.changeNumber = changeNumber; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final OperationType getOperationType() { @@ -546,52 +474,35 @@ return OperationType.ADD; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public DN getProxiedAuthorizationDN() { return proxiedAuthorizationDN; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final ArrayList<Control> getResponseControls() { return responseControls; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final void addResponseControl(Control control) { responseControls.add(control); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final void removeResponseControl(Control control) { responseControls.remove(control); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final void toString(StringBuilder buffer) { @@ -604,18 +515,14 @@ buffer.append(")"); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void setProxiedAuthorizationDN(DN proxiedAuthorizationDN) { this.proxiedAuthorizationDN = proxiedAuthorizationDN; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final void run() { opendj3-server-dev/src/server/org/opends/server/core/AddOperationWrapper.java
@@ -32,7 +32,6 @@ import org.opends.server.types.*; import org.forgerock.opendj.ldap.ByteString; /** * This abstract class wraps/decorates a given add operation. * This class will be extended by sub-classes to enhance the @@ -52,108 +51,77 @@ super(add); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void addObjectClass(ObjectClass objectClass, String name) { getOperation().addObjectClass(objectClass, name); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void addRawAttribute(RawAttribute rawAttribute) { getOperation().addRawAttribute(rawAttribute); } /** * {@inheritDoc} */ @Override public long getChangeNumber() { return getOperation().getChangeNumber(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public DN getEntryDN() { return getOperation().getEntryDN(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public Map<ObjectClass, String> getObjectClasses() { return getOperation().getObjectClasses(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public Map<AttributeType, List<Attribute>> getOperationalAttributes() { return getOperation().getOperationalAttributes(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public List<RawAttribute> getRawAttributes() { return getOperation().getRawAttributes(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public ByteString getRawEntryDN() { return getOperation().getRawEntryDN(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public Map<AttributeType, List<Attribute>> getUserAttributes() { return getOperation().getUserAttributes(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void removeAttribute(AttributeType attributeType) { getOperation().removeAttribute(attributeType); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void removeObjectClass(ObjectClass objectClass) { getOperation().removeObjectClass(objectClass); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void setAttribute(AttributeType attributeType, List<Attribute> attributeList) @@ -161,54 +129,35 @@ getOperation().setAttribute(attributeType, attributeList); } /** * {@inheritDoc} */ @Override public void setChangeNumber(long changeNumber) { getOperation().setChangeNumber(changeNumber); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void setRawAttributes(List<RawAttribute> rawAttributes) { getOperation().setRawAttributes(rawAttributes); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void setRawEntryDN(ByteString rawEntryDN) { getOperation().setRawEntryDN(rawEntryDN); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public String toString() { return getOperation().toString(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public DN getProxiedAuthorizationDN() { return getOperation().getProxiedAuthorizationDN(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void setProxiedAuthorizationDN(DN proxiedAuthorizationDN) { opendj3-server-dev/src/server/org/opends/server/core/DeleteOperation.java
@@ -44,7 +44,7 @@ * * @return The raw, unprocessed entry DN as included in the client request. */ public abstract ByteString getRawEntryDN(); ByteString getRawEntryDN(); /** * Specifies the raw, unprocessed entry DN as included in the client request. @@ -54,7 +54,7 @@ * @param rawEntryDN The raw, unprocessed entry DN as included in the client * request. */ public abstract void setRawEntryDN(ByteString rawEntryDN); void setRawEntryDN(ByteString rawEntryDN); /** * Retrieves the DN of the entry to delete. This should not be called by @@ -64,25 +64,7 @@ * @return The DN of the entry to delete, or <CODE>null</CODE> if the raw * entry DN has not yet been processed. */ public abstract DN getEntryDN(); /** * Retrieves the change number that has been assigned to this operation. * * @return The change number that has been assigned to this operation, or -1 * if none has been assigned yet or if there is no applicable * synchronization mechanism in place that uses change numbers. */ public abstract long getChangeNumber(); /** * Specifies the change number that has been assigned to this operation by the * synchronization mechanism. * * @param changeNumber The change number that has been assigned to this * operation by the synchronization mechanism. */ public abstract void setChangeNumber(long changeNumber); DN getEntryDN(); /** * Retrieves the proxied authorization DN for this operation if proxied @@ -92,7 +74,7 @@ * authorization has been requested, or {@code null} if proxied * authorization has not been requested. */ public abstract DN getProxiedAuthorizationDN(); DN getProxiedAuthorizationDN(); /** * Set the proxied authorization DN for this operation if proxied @@ -103,7 +85,7 @@ * authorization has been requested, or {@code null} if proxied * authorization has not been requested. */ public abstract void setProxiedAuthorizationDN(DN proxiedAuthorizationDN); void setProxiedAuthorizationDN(DN proxiedAuthorizationDN); } opendj3-server-dev/src/server/org/opends/server/core/DeleteOperationBasis.java
@@ -40,7 +40,7 @@ import org.forgerock.opendj.ldap.ByteString; import org.opends.server.types.operation.PostResponseDeleteOperation; import org.opends.server.types.operation.PreParseDeleteOperation; import org.opends.server.workflowelement.localbackend.*; import org.opends.server.workflowelement.localbackend.LocalBackendDeleteOperation; /** * This class defines an operation that may be used to remove an entry from the @@ -66,10 +66,6 @@ /** The set of response controls for this delete operation. */ private List<Control> responseControls; /** The change number that has been assigned to this operation. */ private long changeNumber; /** * Creates a new delete operation with the provided information. * @@ -95,7 +91,6 @@ entryDN = null; responseControls = new ArrayList<Control>(); cancelRequest = null; changeNumber = -1; } @@ -124,21 +119,16 @@ rawEntryDN = ByteString.valueOf(entryDN.toString()); responseControls = new ArrayList<Control>(); cancelRequest = null; changeNumber = -1; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final ByteString getRawEntryDN() { return rawEntryDN; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final void setRawEntryDN(ByteString rawEntryDN) { @@ -147,9 +137,7 @@ entryDN = null; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final DN getEntryDN() { @@ -173,27 +161,7 @@ return entryDN; } /** * {@inheritDoc} */ @Override public final long getChangeNumber() { return changeNumber; } /** * {@inheritDoc} */ @Override public final void setChangeNumber(long changeNumber) { this.changeNumber = changeNumber; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override() public final OperationType getOperationType() { @@ -202,45 +170,35 @@ return OperationType.DELETE; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public DN getProxiedAuthorizationDN() { return proxiedAuthorizationDN; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override() public final List<Control> getResponseControls() { return responseControls; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override() public final void addResponseControl(Control control) { responseControls.add(control); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override() public final void removeResponseControl(Control control) { responseControls.remove(control); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override() public final void toString(StringBuilder buffer) { @@ -252,18 +210,15 @@ buffer.append(rawEntryDN); buffer.append(")"); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void setProxiedAuthorizationDN(DN proxiedAuthorizationDN) { this.proxiedAuthorizationDN = proxiedAuthorizationDN; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final void run() { opendj3-server-dev/src/server/org/opends/server/core/DeleteOperationWrapper.java
@@ -26,11 +26,9 @@ */ package org.opends.server.core; import org.forgerock.opendj.ldap.ByteString; import org.opends.server.types.DN; /** * This abstract class wraps/decorates a given delete operation. * This class will be extended by sub-classes to enhance the @@ -50,72 +48,42 @@ super(delete); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public DN getEntryDN() { return getOperation().getEntryDN(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public ByteString getRawEntryDN() { return getOperation().getRawEntryDN(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void setRawEntryDN(ByteString rawEntryDN) { getOperation().setRawEntryDN(rawEntryDN); } /** * {@inheritDoc} */ @Override public final long getChangeNumber() { return getOperation().getChangeNumber(); } /** * {@inheritDoc} */ @Override public final void setChangeNumber(long changeNumber) { getOperation().setChangeNumber(changeNumber); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public String toString() { return getOperation().toString(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public DN getProxiedAuthorizationDN() { return getOperation().getProxiedAuthorizationDN(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void setProxiedAuthorizationDN(DN proxiedAuthorizationDN) { opendj3-server-dev/src/server/org/opends/server/core/ModifyDNOperation.java
@@ -47,7 +47,7 @@ * * @return The raw, unprocessed entry DN as included in the client request. */ public ByteString getRawEntryDN(); ByteString getRawEntryDN(); /** * Specifies the raw, unprocessed entry DN as included in the client request. @@ -56,7 +56,7 @@ * @param rawEntryDN The raw, unprocessed entry DN as included in the client * request. */ public void setRawEntryDN(ByteString rawEntryDN); void setRawEntryDN(ByteString rawEntryDN); /** @@ -67,7 +67,7 @@ * @return The DN of the entry to rename, or <CODE>null</CODE> if the raw * entry DN has not yet been processed. */ public DN getEntryDN(); DN getEntryDN(); /** * Retrieves the raw, unprocessed newRDN as included in the request from the @@ -77,7 +77,7 @@ * @return The raw, unprocessed newRDN as included in the request from the * client. */ public ByteString getRawNewRDN(); ByteString getRawNewRDN(); /** * Specifies the raw, unprocessed newRDN as included in the request from the @@ -87,7 +87,7 @@ * @param rawNewRDN The raw, unprocessed newRDN as included in the request * from the client. */ public void setRawNewRDN(ByteString rawNewRDN); void setRawNewRDN(ByteString rawNewRDN); /** * Retrieves the new RDN to use for the entry. This should not be called by @@ -97,7 +97,7 @@ * @return The new RDN to use for the entry, or <CODE>null</CODE> if the raw * newRDN has not yet been processed. */ public RDN getNewRDN(); RDN getNewRDN(); /** @@ -106,7 +106,7 @@ * @return <CODE>true</CODE> if the current RDN value should be removed from * the entry, or <CODE>false</CODE> if not. */ public boolean deleteOldRDN(); boolean deleteOldRDN(); /** * Specifies whether the current RDN value should be removed from the entry. @@ -114,7 +114,7 @@ * @param deleteOldRDN Specifies whether the current RDN value should be * removed from the entry. */ public void setDeleteOldRDN(boolean deleteOldRDN); void setDeleteOldRDN(boolean deleteOldRDN); /** * Retrieves the raw, unprocessed newSuperior from the client request. This @@ -124,7 +124,7 @@ * @return The raw, unprocessed newSuperior from the client request, or * <CODE>null</CODE> if there is none. */ public ByteString getRawNewSuperior(); ByteString getRawNewSuperior(); /** * Specifies the raw, unprocessed newSuperior for this modify DN operation, as @@ -134,7 +134,7 @@ * @param rawNewSuperior The raw, unprocessed newSuperior as provided in the * request from the client. */ public void setRawNewSuperior(ByteString rawNewSuperior); void setRawNewSuperior(ByteString rawNewSuperior); /** * Retrieves the newSuperior DN for the entry. This should not be called by @@ -146,7 +146,7 @@ * no newSuperior DN for this request or if the raw newSuperior has * not yet been processed. */ public DN getNewSuperior(); DN getNewSuperior(); /** * Retrieves the new DN for the entry. @@ -154,7 +154,7 @@ * @return The new DN for the entry, or <CODE>null</CODE> if there is * neither newRDN, nor entryDN for this request. */ public DN getNewDN(); DN getNewDN(); /** * Retrieves the set of modifications applied to attributes of the target @@ -173,7 +173,7 @@ * of the modify DN processing, or <CODE>null</CODE> if that * information is not yet available (e.g., during pre-parse plugins). */ public List<Modification> getModifications(); List<Modification> getModifications(); /** * Adds the provided modification to the set of modifications to be applied @@ -183,7 +183,7 @@ * @param modification The modification to add to the set of modifications * to apply to the entry. */ public void addModification(Modification modification); void addModification(Modification modification); /** * Retrieves the current entry, before it is renamed. This will not be @@ -193,7 +193,7 @@ * @return The current entry, or <CODE>null</CODE> if it is not yet * available. */ public Entry getOriginalEntry(); Entry getOriginalEntry(); /** @@ -204,27 +204,7 @@ * @return The updated entry, or <CODE>null</CODE> if it is not yet * available. */ public Entry getUpdatedEntry(); /** * Retrieves the change number that has been assigned to this operation. * * @return The change number that has been assigned to this operation, or -1 * if none has been assigned yet or if there is no applicable * synchronization mechanism in place that uses change numbers. */ public long getChangeNumber(); /** * Specifies the change number that has been assigned to this operation by the * synchronization mechanism. * * @param changeNumber The change number that has been assigned to this * operation by the synchronization mechanism. */ public void setChangeNumber(long changeNumber); Entry getUpdatedEntry(); /** * Retrieves the proxied authorization DN for this operation if proxied @@ -234,7 +214,7 @@ * authorization has been requested, or {@code null} if proxied * authorization has not been requested. */ public DN getProxiedAuthorizationDN(); DN getProxiedAuthorizationDN(); /** @@ -245,6 +225,6 @@ * authorization has been requested, or {@code null} if proxied * authorization has not been requested. */ public void setProxiedAuthorizationDN(DN dn); void setProxiedAuthorizationDN(DN dn); } opendj3-server-dev/src/server/org/opends/server/core/ModifyDNOperationBasis.java
@@ -91,14 +91,11 @@ */ private List<Modification> modifications; /** The change number that has been assigned to this operation. */ private long changeNumber; /** The new RDN for the entry. */ private RDN newRDN; /** The new entry DN. */ private DN newDN = null; private DN newDN; /** * Creates a new modify DN operation with the provided information. @@ -138,7 +135,6 @@ responseControls = new ArrayList<Control>(); cancelRequest = null; modifications = null; changeNumber = -1; } @@ -188,25 +184,16 @@ responseControls = new ArrayList<Control>(); cancelRequest = null; modifications = null; changeNumber = -1; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final ByteString getRawEntryDN() { return rawEntryDN; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final void setRawEntryDN(ByteString rawEntryDN) { @@ -215,11 +202,7 @@ entryDN = null; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final DN getEntryDN() { @@ -239,18 +222,14 @@ return entryDN; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final ByteString getRawNewRDN() { return rawNewRDN; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final void setRawNewRDN(ByteString rawNewRDN) { @@ -260,9 +239,7 @@ newDN = null; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final RDN getNewRDN() { @@ -283,37 +260,28 @@ return newRDN; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final boolean deleteOldRDN() { return deleteOldRDN; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final void setDeleteOldRDN(boolean deleteOldRDN) { this.deleteOldRDN = deleteOldRDN; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final ByteString getRawNewSuperior() { return rawNewSuperior; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final void setRawNewSuperior(ByteString rawNewSuperior) { @@ -323,9 +291,7 @@ newDN = null; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final DN getNewSuperior() { @@ -353,20 +319,14 @@ return newSuperior; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final List<Modification> getModifications() { return modifications; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final void addModification(Modification modification) { @@ -380,50 +340,22 @@ } } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final Entry getOriginalEntry() { return null; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final Entry getUpdatedEntry() { return null; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final long getChangeNumber() { return changeNumber; } /** * {@inheritDoc} */ @Override public final void setChangeNumber(long changeNumber) { this.changeNumber = changeNumber; } /** * {@inheritDoc} */ @Override() public final OperationType getOperationType() { // Note that no debugging will be done in this method because it is a likely @@ -432,41 +364,29 @@ return OperationType.MODIFY_DN; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public DN getProxiedAuthorizationDN() { return proxiedAuthorizationDN; } /** * {@inheritDoc} */ @Override() /** {@inheritDoc} */ @Override public final List<Control> getResponseControls() { return responseControls; } /** * {@inheritDoc} */ @Override() /** {@inheritDoc} */ @Override public final void addResponseControl(Control control) { responseControls.add(control); } /** * {@inheritDoc} */ @Override() /** {@inheritDoc} */ @Override public final void removeResponseControl(Control control) { responseControls.remove(control); @@ -639,11 +559,8 @@ appendErrorMessage(ERR_MODDN_NO_BACKEND_FOR_CURRENT_ENTRY.get(entryDN)); } /** * {@inheritDoc} */ @Override() /** {@inheritDoc} */ @Override public final void toString(StringBuilder buffer) { buffer.append("ModifyDNOperation(connID="); @@ -665,20 +582,14 @@ buffer.append(")"); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void setProxiedAuthorizationDN(DN dn) { proxiedAuthorizationDN = dn; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public DN getNewDN() { @@ -698,7 +609,7 @@ parentDN = newSuperior; } if ((parentDN == null) || parentDN.isRootDN()) if (parentDN == null || parentDN.isRootDN()) { setResultCode(ResultCode.UNWILLING_TO_PERFORM); appendErrorMessage(ERR_MODDN_NO_PARENT.get(entryDN)); opendj3-server-dev/src/server/org/opends/server/core/ModifyDNOperationWrapper.java
@@ -50,162 +50,110 @@ super(modifyDN); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void addModification(Modification modification) { getOperation().addModification(modification); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public boolean deleteOldRDN() { return getOperation().deleteOldRDN(); } /** * {@inheritDoc} */ @Override public long getChangeNumber() { return getOperation().getChangeNumber(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public DN getEntryDN() { return getOperation().getEntryDN(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public List<Modification> getModifications() { return getOperation().getModifications(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public RDN getNewRDN() { return getOperation().getNewRDN(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public DN getNewSuperior() { return getOperation().getNewSuperior(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public Entry getOriginalEntry() { return getOperation().getOriginalEntry(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public DN getProxiedAuthorizationDN() { return getOperation().getProxiedAuthorizationDN(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public ByteString getRawEntryDN() { return getOperation().getRawEntryDN(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public ByteString getRawNewRDN() { return getOperation().getRawNewRDN(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public ByteString getRawNewSuperior() { return getOperation().getRawNewSuperior(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public Entry getUpdatedEntry() { return getOperation().getUpdatedEntry(); } /** * {@inheritDoc} */ @Override public void setChangeNumber(long changeNumber) { getOperation().setChangeNumber(changeNumber); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void setDeleteOldRDN(boolean deleteOldRDN) { getOperation().setDeleteOldRDN(deleteOldRDN); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void setRawEntryDN(ByteString rawEntryDN) { getOperation().setRawEntryDN(rawEntryDN); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void setRawNewRDN(ByteString rawNewRDN) { getOperation().setRawNewRDN(rawNewRDN); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void setRawNewSuperior(ByteString rawNewSuperior) { getOperation().setRawNewSuperior(rawNewSuperior); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void setProxiedAuthorizationDN(DN dn) { getOperation().setProxiedAuthorizationDN(dn); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public DN getNewDN() { opendj3-server-dev/src/server/org/opends/server/core/ModifyOperation.java
@@ -44,7 +44,7 @@ * * @return The raw, unprocessed entry DN as included in the client request. */ public abstract ByteString getRawEntryDN(); ByteString getRawEntryDN(); /** * Specifies the raw, unprocessed entry DN as included in the client request. @@ -53,7 +53,7 @@ * @param rawEntryDN The raw, unprocessed entry DN as included in the client * request. */ public abstract void setRawEntryDN(ByteString rawEntryDN); void setRawEntryDN(ByteString rawEntryDN); /** * Retrieves the DN of the entry to modify. This should not be called by @@ -63,7 +63,7 @@ * @return The DN of the entry to modify, or <CODE>null</CODE> if the raw * entry DN has not yet been processed. */ public abstract DN getEntryDN(); DN getEntryDN(); /** * Retrieves the set of raw, unprocessed modifications as included in the @@ -74,7 +74,7 @@ * @return The set of raw, unprocessed modifications as included in the * client request. */ public abstract List<RawModification> getRawModifications(); List<RawModification> getRawModifications(); /** * Adds the provided modification to the set of raw modifications for this @@ -83,15 +83,14 @@ * @param rawModification The modification to add to the set of raw * modifications for this modify operation. */ public abstract void addRawModification(RawModification rawModification); void addRawModification(RawModification rawModification); /** * Specifies the raw modifications for this modify operation. * * @param rawModifications The raw modifications for this modify operation. */ public abstract void setRawModifications( List<RawModification> rawModifications); void setRawModifications(List<RawModification> rawModifications); /** * Retrieves the set of modifications for this modify operation. Its contents @@ -101,7 +100,7 @@ * <CODE>null</CODE> if the modifications have not yet been * processed. */ public abstract List<Modification> getModifications(); List<Modification> getModifications(); /** * Adds the provided modification to the set of modifications to this modify @@ -113,26 +112,7 @@ * @throws DirectoryException If an unexpected problem occurs while applying * the modification to the entry. */ public abstract void addModification(Modification modification) throws DirectoryException; /** * Retrieves the change number that has been assigned to this operation. * * @return The change number that has been assigned to this operation, or -1 * if none has been assigned yet or if there is no applicable * synchronization mechanism in place that uses change numbers. */ public abstract long getChangeNumber(); /** * Specifies the change number that has been assigned to this operation by the * synchronization mechanism. * * @param changeNumber The change number that has been assigned to this * operation by the synchronization mechanism. */ public abstract void setChangeNumber(long changeNumber); void addModification(Modification modification) throws DirectoryException; /** * Retrieves the proxied authorization DN for this operation if proxied @@ -142,7 +122,7 @@ * authorization has been requested, or {@code null} if proxied * authorization has not been requested. */ public abstract DN getProxiedAuthorizationDN(); DN getProxiedAuthorizationDN(); /** * Set the proxied authorization DN for this operation if proxied @@ -153,6 +133,6 @@ * authorization has been requested, or {@code null} if proxied * authorization has not been requested. */ public abstract void setProxiedAuthorizationDN(DN proxiedAuthorizationDN); void setProxiedAuthorizationDN(DN proxiedAuthorizationDN); } opendj3-server-dev/src/server/org/opends/server/core/ModifyOperationBasis.java
@@ -26,8 +26,6 @@ */ package org.opends.server.core; import static org.opends.messages.CoreMessages.*; import static org.opends.server.loggers.AccessLogger.*; import java.util.ArrayList; import java.util.List; @@ -43,7 +41,10 @@ import org.forgerock.opendj.ldap.ByteString; import org.opends.server.types.operation.PostResponseModifyOperation; import org.opends.server.types.operation.PreParseModifyOperation; import org.opends.server.workflowelement.localbackend.*; import org.opends.server.workflowelement.localbackend.LocalBackendModifyOperation; import static org.opends.messages.CoreMessages.*; import static org.opends.server.loggers.AccessLogger.*; /** * This class defines an operation that may be used to modify an entry in the @@ -77,9 +78,6 @@ /** The set of modifications for this modify operation. */ private List<Modification> modifications; /** The change number that has been assigned to this operation. */ private long changeNumber; /** * Creates a new modify operation with the provided information. * @@ -150,18 +148,14 @@ cancelRequest = null; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final ByteString getRawEntryDN() { return rawEntryDN; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final void setRawEntryDN(ByteString rawEntryDN) { @@ -170,9 +164,7 @@ entryDN = null; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final DN getEntryDN() { @@ -190,18 +182,14 @@ return entryDN; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final List<RawModification> getRawModifications() { return rawModifications; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final void addRawModification(RawModification rawModification) { @@ -210,9 +198,7 @@ modifications = null; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final void setRawModifications(List<RawModification> rawModifications) { @@ -221,9 +207,7 @@ modifications = null; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final List<Modification> getModifications() { @@ -248,14 +232,11 @@ mod.setAttribute(attr); } } else else if (attr.hasOption("binary")) { // binary option is not honored for non-BER-encodable attributes. if(attr.hasOption("binary")) { throw new LDAPException(LDAPResultCode.UNDEFINED_ATTRIBUTE_TYPE, ERR_ADD_ATTR_IS_INVALID_OPTION.get(entryDN, attr.getName())); } throw new LDAPException(LDAPResultCode.UNDEFINED_ATTRIBUTE_TYPE, ERR_ADD_ATTR_IS_INVALID_OPTION.get(entryDN, attr.getName())); } modifications.add(mod); @@ -272,9 +253,7 @@ return modifications; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final void addModification(Modification modification) throws DirectoryException @@ -282,9 +261,7 @@ modifications.add(modification); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final OperationType getOperationType() { @@ -294,45 +271,35 @@ return OperationType.MODIFY; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public DN getProxiedAuthorizationDN() { return proxiedAuthorizationDN; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final List<Control> getResponseControls() { return responseControls; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final void addResponseControl(Control control) { responseControls.add(control); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final void removeResponseControl(Control control) { responseControls.remove(control); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final void toString(StringBuilder buffer) { @@ -345,35 +312,14 @@ buffer.append(")"); } /** * {@inheritDoc} */ @Override public final long getChangeNumber(){ return changeNumber; } /** * {@inheritDoc} */ @Override public void setChangeNumber(long changeNumber) { this.changeNumber = changeNumber; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void setProxiedAuthorizationDN(DN proxiedAuthorizationDN) { this.proxiedAuthorizationDN = proxiedAuthorizationDN; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public final void run() { opendj3-server-dev/src/server/org/opends/server/core/ModifyOperationWrapper.java
@@ -26,13 +26,11 @@ */ package org.opends.server.core; import java.util.List; import org.opends.server.types.*; import org.forgerock.opendj.ldap.ByteString; /** * This abstract class wraps/decorates a given modify operation. * This class will be extended by sub-classes to enhance the @@ -52,9 +50,7 @@ super(modify); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void addModification(Modification modification) throws DirectoryException @@ -62,107 +58,70 @@ getOperation().addModification(modification); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void addRawModification(RawModification rawModification) { getOperation().addRawModification(rawModification); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public DN getEntryDN() { return getOperation().getEntryDN(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public List<Modification> getModifications() { return getOperation().getModifications(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public ByteString getRawEntryDN() { return getOperation().getRawEntryDN(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public List<RawModification> getRawModifications() { return getOperation().getRawModifications(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void setRawEntryDN(ByteString rawEntryDN) { getOperation().setRawEntryDN(rawEntryDN); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void setRawModifications(List<RawModification> rawModifications) { getOperation().setRawModifications(rawModifications); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public String toString() { return getOperation().toString(); } /** * {@inheritDoc} */ @Override public final long getChangeNumber(){ return getOperation().getChangeNumber(); } /** * {@inheritDoc} */ @Override public void setChangeNumber(long changeNumber) { getOperation().setChangeNumber(changeNumber); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public DN getProxiedAuthorizationDN() { return getOperation().getProxiedAuthorizationDN(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void setProxiedAuthorizationDN(DN proxiedAuthorizationDN){ getOperation().setProxiedAuthorizationDN(proxiedAuthorizationDN); opendj3-server-dev/src/server/org/opends/server/core/PersistentSearch.java
@@ -26,26 +26,22 @@ */ package org.opends.server.core; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.ldap.ResultCode; import org.opends.server.controls.EntryChangeNotificationControl; import org.opends.server.controls.PersistentSearchChangeType; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.opends.server.types.CancelResult; import org.opends.server.types.Control; import org.opends.server.types.DN; import org.opends.server.types.DirectoryException; import org.opends.server.types.Entry; import org.forgerock.opendj.ldap.ResultCode; import org.opends.server.types.SearchFilter; import org.forgerock.opendj.ldap.SearchScope; import static org.opends.server.controls.PersistentSearchChangeType.*; /** * This class defines a data structure that will be used to hold the @@ -103,7 +99,7 @@ // Cancel a persistent search. /** Cancel a persistent search. */ private static synchronized void cancel(PersistentSearch psearch) { if (!psearch.isCancelled) @@ -132,32 +128,28 @@ } } // The base DN for the search operation. private final DN baseDN; // Cancellation callbacks which should be run when this persistent // search is cancelled. /** * Cancellation callbacks which should be run when this persistent search is * cancelled. */ private final List<CancellationCallback> cancellationCallbacks = new CopyOnWriteArrayList<CancellationCallback>(); // The set of change types we want to see. /** The set of change types to send to the client. */ private final Set<PersistentSearchChangeType> changeTypes; // The filter for the search operation. private final SearchFilter filter; /** * Indicates whether or not this persistent search has already been aborted. */ private boolean isCancelled; // Indicates whether or not this persistent search has already been // aborted. private boolean isCancelled = false; // Indicates whether entries returned should include the entry // change notification control. /** * Indicates whether entries returned should include the entry change * notification control. */ private final boolean returnECs; // The scope for the search operation. private final SearchScope scope; // The reference to the associated search operation. /** The reference to the associated search operation. */ private final SearchOperation searchOperation; @@ -180,10 +172,6 @@ this.searchOperation = searchOperation; this.changeTypes = changeTypes; this.returnECs = returnECs; this.baseDN = searchOperation.getBaseDN(); this.scope = searchOperation.getScope(); this.filter = searchOperation.getFilter(); } @@ -248,209 +236,68 @@ * * @param entry * The entry that was added. * @param changeNumber * The change number associated with the operation that * added the entry, or {@code -1} if there is no change * number. */ public void processAdd(Entry entry, long changeNumber) public void processAdd(Entry entry) { // See if we care about add operations. if (!changeTypes.contains(PersistentSearchChangeType.ADD)) if (changeTypes.contains(ADD) && isInScope(entry.getName()) && matchesFilter(entry)) { return; sendEntry(entry, createControls(ADD, null)); } } // Make sure that the entry is within our target scope. switch (scope.asEnum()) private boolean isInScope(final DN dn) { final DN baseDN = searchOperation.getBaseDN(); switch (searchOperation.getScope().asEnum()) { case BASE_OBJECT: if (!baseDN.equals(entry.getName())) { return; } break; return baseDN.equals(dn); case SINGLE_LEVEL: if (!baseDN.equals(entry.getName().getParentDNInSuffix())) { return; } break; return baseDN.equals(dn.getParentDNInSuffix()); case WHOLE_SUBTREE: if (!baseDN.isAncestorOf(entry.getName())) { return; } break; return baseDN.isAncestorOf(dn); case SUBORDINATES: if (baseDN.equals(entry.getName()) || (!baseDN.isAncestorOf( entry.getName()))) { return; } break; return !baseDN.equals(dn) && baseDN.isAncestorOf(dn); default: return; return false; } } // Make sure that the entry matches the target filter. private boolean matchesFilter(Entry entry) { try { logger.trace(this + " " + entry + " +filter=" + filter.matchesEntry(entry)); if (!filter.matchesEntry(entry)) final boolean filterMatchesEntry = searchOperation.getFilter().matchesEntry(entry); if (logger.isTraceEnabled()) { return; logger.trace(this + " " + entry + " filter=" + filterMatchesEntry); } return filterMatchesEntry; } catch (DirectoryException de) { logger.traceException(de); // FIXME -- Do we need to do anything here? return; } // The entry is one that should be sent to the client. See if we // also need to construct an entry change notification control. ArrayList<Control> entryControls = new ArrayList<Control>(1); if (returnECs) { entryControls.add(new EntryChangeNotificationControl( PersistentSearchChangeType.ADD, changeNumber)); } // Send the entry and see if we should continue processing. If // not, then deregister this persistent search. try { if (!searchOperation.returnEntry(entry, entryControls)) { cancel(); searchOperation.sendSearchResultDone(); } } catch (Exception e) { logger.traceException(e); cancel(); try { searchOperation.sendSearchResultDone(); } catch (Exception e2) { logger.traceException(e2); } return false; } } /** * Notifies the persistent searches that an entry has been deleted. * * @param entry * The entry that was deleted. * @param changeNumber * The change number associated with the operation that * deleted the entry, or {@code -1} if there is no change * number. */ public void processDelete(Entry entry, long changeNumber) public void processDelete(Entry entry) { // See if we care about delete operations. if (!changeTypes.contains(PersistentSearchChangeType.DELETE)) if (changeTypes.contains(DELETE) && isInScope(entry.getName()) && matchesFilter(entry)) { return; } // Make sure that the entry is within our target scope. switch (scope.asEnum()) { case BASE_OBJECT: if (!baseDN.equals(entry.getName())) { return; } break; case SINGLE_LEVEL: if (!baseDN.equals(entry.getName().getParentDNInSuffix())) { return; } break; case WHOLE_SUBTREE: if (!baseDN.isAncestorOf(entry.getName())) { return; } break; case SUBORDINATES: if (baseDN.equals(entry.getName()) || (!baseDN.isAncestorOf( entry.getName()))) { return; } break; default: return; } // Make sure that the entry matches the target filter. try { if (!filter.matchesEntry(entry)) { return; } } catch (DirectoryException de) { logger.traceException(de); // FIXME -- Do we need to do anything here? return; } // The entry is one that should be sent to the client. See if we // also need to construct an entry change notification control. ArrayList<Control> entryControls = new ArrayList<Control>(1); if (returnECs) { entryControls.add(new EntryChangeNotificationControl( PersistentSearchChangeType.DELETE, changeNumber)); } // Send the entry and see if we should continue processing. If // not, then deregister this persistent search. try { if (!searchOperation.returnEntry(entry, entryControls)) { cancel(); searchOperation.sendSearchResultDone(); } } catch (Exception e) { logger.traceException(e); cancel(); try { searchOperation.sendSearchResultDone(); } catch (Exception e2) { logger.traceException(e2); } sendEntry(entry, createControls(DELETE, null)); } } @@ -461,14 +308,10 @@ * * @param entry * The entry after it was modified. * @param changeNumber * The change number associated with the operation that * modified the entry, or {@code -1} if there is no change * number. */ public void processModify(Entry entry, long changeNumber) public void processModify(Entry entry) { processModify(entry, changeNumber, entry); processModify(entry, entry); } @@ -478,210 +321,84 @@ * * @param entry * The entry after it was modified. * @param changeNumber * The change number associated with the operation that * modified the entry, or {@code -1} if there is no change * number. * @param oldEntry * The entry before it was modified. */ public void processModify(Entry entry, long changeNumber, Entry oldEntry) public void processModify(Entry entry, Entry oldEntry) { // See if we care about modify operations. if (!changeTypes.contains(PersistentSearchChangeType.MODIFY)) if (changeTypes.contains(MODIFY) && isInScopeForModify(oldEntry.getName()) && anyMatchesFilter(entry, oldEntry)) { return; } // Make sure that the entry is within our target scope. switch (scope.asEnum()) { case BASE_OBJECT: if (!baseDN.equals(oldEntry.getName())) { return; } break; case SINGLE_LEVEL: if (!baseDN.equals(oldEntry.getName().parent())) { return; } break; case WHOLE_SUBTREE: if (!baseDN.isAncestorOf(oldEntry.getName())) { return; } break; case SUBORDINATES: if (baseDN.equals(oldEntry.getName()) || (!baseDN.isAncestorOf(oldEntry.getName()))) { return; } break; default: return; } // Make sure that the entry matches the target filter. try { if ((!filter.matchesEntry(oldEntry)) && (!filter.matchesEntry(entry))) { return; } } catch (DirectoryException de) { logger.traceException(de); // FIXME -- Do we need to do anything here? return; } // The entry is one that should be sent to the client. See if we // also need to construct an entry change notification control. ArrayList<Control> entryControls = new ArrayList<Control>(1); if (returnECs) { entryControls.add(new EntryChangeNotificationControl( PersistentSearchChangeType.MODIFY, changeNumber)); } // Send the entry and see if we should continue processing. If // not, then deregister this persistent search. try { if (!searchOperation.returnEntry(entry, entryControls)) { cancel(); searchOperation.sendSearchResultDone(); } } catch (Exception e) { logger.traceException(e); cancel(); try { searchOperation.sendSearchResultDone(); } catch (Exception e2) { logger.traceException(e2); } sendEntry(entry, createControls(MODIFY, null)); } } private boolean isInScopeForModify(final DN dn) { final DN baseDN = searchOperation.getBaseDN(); switch (searchOperation.getScope().asEnum()) { case BASE_OBJECT: return baseDN.equals(dn); case SINGLE_LEVEL: return baseDN.equals(dn.parent()); case WHOLE_SUBTREE: return baseDN.isAncestorOf(dn); case SUBORDINATES: return !baseDN.equals(dn) && baseDN.isAncestorOf(dn); default: return false; } } private boolean anyMatchesFilter(Entry entry, Entry oldEntry) { return matchesFilter(oldEntry) || matchesFilter(entry); } /** * Notifies the persistent searches that an entry has been renamed. * * @param entry * The entry after it was modified. * @param changeNumber * The change number associated with the operation that * modified the entry, or {@code -1} if there is no change * number. * @param oldDN * The DN of the entry before it was renamed. */ public void processModifyDN(Entry entry, long changeNumber, DN oldDN) public void processModifyDN(Entry entry, DN oldDN) { // See if we care about modify DN operations. if (!changeTypes.contains(PersistentSearchChangeType.MODIFY_DN)) if (changeTypes.contains(MODIFY_DN) && isAnyInScopeForModify(entry, oldDN) && matchesFilter(entry)) { return; sendEntry(entry, createControls(MODIFY_DN, oldDN)); } } // Make sure that the old or new entry is within our target scope. // In this case, we need to check the DNs of both the old and new // entry so we know which one(s) should be compared against the // filter. boolean oldMatches = false; boolean newMatches = false; private boolean isAnyInScopeForModify(Entry entry, DN oldDN) { return isInScopeForModify(oldDN) || isInScopeForModify(entry.getName()); } switch (scope.asEnum()) { case BASE_OBJECT: oldMatches = baseDN.equals(oldDN); newMatches = baseDN.equals(entry.getName()); if (!(oldMatches || newMatches)) { return; } break; case SINGLE_LEVEL: oldMatches = baseDN.equals(oldDN.parent()); newMatches = baseDN.equals(entry.getName().parent()); if (!(oldMatches || newMatches)) { return; } break; case WHOLE_SUBTREE: oldMatches = baseDN.isAncestorOf(oldDN); newMatches = baseDN.isAncestorOf(entry.getName()); if (!(oldMatches || newMatches)) { return; } break; case SUBORDINATES: oldMatches = ((!baseDN.equals(oldDN)) && baseDN.isAncestorOf(oldDN)); newMatches = ((!baseDN.equals(entry.getName())) && baseDN .isAncestorOf(entry.getName())); if (!(oldMatches || newMatches)) { return; } break; default: return; } // Make sure that the entry matches the target filter. try { if (!oldMatches && !newMatches && !filter.matchesEntry(entry)) { return; } } catch (DirectoryException de) { logger.traceException(de); // FIXME -- Do we need to do anything here? return; } // The entry is one that should be sent to the client. See if we // also need to construct an entry change notification control. ArrayList<Control> entryControls = new ArrayList<Control>(1); /** * The entry is one that should be sent to the client. See if we also need to * construct an entry change notification control. */ private List<Control> createControls(PersistentSearchChangeType changeType, DN previousDN) { if (returnECs) { entryControls.add(new EntryChangeNotificationControl( PersistentSearchChangeType.MODIFY_DN, oldDN, changeNumber)); final Control c = previousDN != null ? new EntryChangeNotificationControl(changeType, previousDN, -1) : new EntryChangeNotificationControl(changeType, -1); return Collections.singletonList(c); } return Collections.emptyList(); } // Send the entry and see if we should continue processing. If // not, then deregister this persistent search. private void sendEntry(Entry entry, List<Control> entryControls) { try { if (!searchOperation.returnEntry(entry, entryControls)) @@ -770,9 +487,9 @@ buffer.append(",baseDN=\""); searchOperation.getBaseDN().toString(buffer); buffer.append("\",scope="); buffer.append(scope.toString()); buffer.append(searchOperation.getScope()); buffer.append(",filter=\""); filter.toString(buffer); searchOperation.getFilter().toString(buffer); buffer.append("\")"); } } opendj3-server-dev/src/server/org/opends/server/replication/server/ECLServerWriter.java
@@ -143,13 +143,17 @@ } if (shutdown) { return; } // Not suspended doIt(); if (shutdown) { return; } suspendWriter(); } @@ -171,12 +175,14 @@ } finally { if (session!=null) if (session != null) { session.close(); } if (replicationServerDomain != null) { replicationServerDomain.stopServer(handler, false); } } } @@ -188,24 +194,10 @@ */ private void doIt() throws IOException, InterruptedException { while (true) while (!shutdown && !suspended) { if (shutdown || suspended) { return; } ECLUpdateMsg update = null; try { update = handler.takeECLUpdate(); } catch(DirectoryException de) { logger.traceException(de); } if (update == null) final ECLUpdateMsg updateMsg = takeECLUpdate(handler); if (updateMsg == null) { if (session != null && handler.isInitPhaseDone()) { @@ -225,14 +217,25 @@ } else { // Publish the update to the remote server using a protocol version it // supports publish(update); update = null; // Publish the update to the remote server using a protocol version it supports publish(updateMsg); } } } private ECLUpdateMsg takeECLUpdate(ECLServerHandler handler) { try { return handler.takeECLUpdate(); } catch(DirectoryException de) { logger.traceException(de); return null; } } /** * Shutdown the writer. */ @@ -248,7 +251,9 @@ private void publish(ECLUpdateMsg msg) throws IOException { if (logger.isTraceEnabled()) { logger.trace(getName() + " publishes msg=[" + msg + "]"); } if (session != null) { @@ -258,8 +263,10 @@ { try { // Using processAdd() because all ECLUpdateMsgs are adds to the external changelog // (even though the underlying changes can be adds, deletes, modifies or modDNs) Entry eclEntry = ECLSearchOperation.createEntryFromMsg(msg); mypsearch.processAdd(eclEntry, -1); mypsearch.processAdd(eclEntry); } catch (Exception e) { opendj3-server-dev/src/server/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java
@@ -26,11 +26,6 @@ */ package org.opends.server.workflowelement.localbackend; import static org.opends.messages.CoreMessages.*; import static org.opends.server.config.ConfigConstants.*; 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.List; @@ -55,6 +50,11 @@ import org.opends.server.types.operation.PreOperationAddOperation; import org.opends.server.util.TimeThread; import static org.opends.messages.CoreMessages.*; import static org.opends.server.config.ConfigConstants.*; import static org.opends.server.util.ServerConstants.*; import static org.opends.server.util.StaticUtils.*; /** * This class defines an operation used to add an entry in a local backend * of the Directory Server. @@ -66,48 +66,30 @@ { private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); /** * The backend in which the entry is to be added. */ private Backend backend; /** The backend in which the entry is to be added. */ private Backend<?> backend; /** * Indicates whether the request includes the LDAP no-op control. */ /** Indicates whether the request includes the LDAP no-op control. */ private boolean noOp; /** * The DN of the entry to be added. */ /** The DN of the entry to be added. */ private DN entryDN; /** * The entry being added to the server. */ /** The entry being added to the server. */ private Entry entry; /** * The post-read request control included in the request, if applicable. */ /** The post-read request control included in the request, if applicable. */ private LDAPPostReadRequestControl postReadRequest; /** * The set of object classes for the entry to add. */ /** The set of object classes for the entry to add. */ private Map<ObjectClass, String> objectClasses; /** * The set of operational attributes for the entry to add. */ /** The set of operational attributes for the entry to add. */ private Map<AttributeType, List<Attribute>> operationalAttributes; /** * The set of user attributes for the entry to add. */ /** The set of user attributes for the entry to add. */ private Map<AttributeType, List<Attribute>> userAttributes; /** * Creates a new operation that may be used to add a new entry in a * local backend of the Directory Server. @@ -204,7 +186,7 @@ // Notify persistent searches. for (PersistentSearch psearch : wfe.getPersistentSearches()) { psearch.processAdd(entry, getChangeNumber()); psearch.processAdd(entry); } // Notify change listeners. @@ -213,8 +195,7 @@ { try { changeListener.handleAddOperation(LocalBackendAddOperation.this, entry); changeListener.handleAddOperation(LocalBackendAddOperation.this, entry); } catch (Exception e) { @@ -302,8 +283,9 @@ userAttributes = getUserAttributes(); operationalAttributes = getOperationalAttributes(); if ((objectClasses == null) || (userAttributes == null) || (operationalAttributes == null)) if (objectClasses == null || userAttributes == null || operationalAttributes == null) { return; } @@ -413,8 +395,7 @@ if (backend == null) { setResultCode(ResultCode.NO_SUCH_OBJECT); appendErrorMessage(LocalizableMessage.raw("No backend for entry " + entryDN.toString())); // TODO: i18n appendErrorMessage(LocalizableMessage.raw("No backend for entry " + entryDN)); // TODO: i18n return; } @@ -580,15 +561,14 @@ { for (AttributeType at : attributes.keySet()) { if (at.isNoUserModification()) if (at.isNoUserModification() && !isInternalOperation() && !isSynchronizationOperation()) { if (!(isInternalOperation() || isSynchronizationOperation())) { setResultCodeAndMessageNoInfoDisclosure(entryDN, ResultCode.CONSTRAINT_VIOLATION, ERR_ADD_ATTR_IS_NO_USER_MOD.get(entryDN, at.getNameOrOID())); return true; } setResultCodeAndMessageNoInfoDisclosure(entryDN, ResultCode.CONSTRAINT_VIOLATION, ERR_ADD_ATTR_IS_NO_USER_MOD.get(entryDN, at.getNameOrOID())); return true; } } return false; @@ -796,7 +776,7 @@ // See if a password was specified. AttributeType passwordAttribute = passwordPolicy.getPasswordAttribute(); List<Attribute> attrList = entry.getAttribute(passwordAttribute); if ((attrList == null) || attrList.isEmpty()) if (attrList == null || attrList.isEmpty()) { // The entry doesn't have a password, so no action is required. return; @@ -824,9 +804,9 @@ return; } if ((!isInternalOperation()) && (!passwordPolicy.isAllowMultiplePasswordValues()) && (passwordAttr.size() > 1)) if (!isInternalOperation() && !passwordPolicy.isAllowMultiplePasswordValues() && passwordAttr.size() > 1) { // FIXME -- What if they're pre-encoded and might all be the // same? @@ -848,44 +828,35 @@ { if (AuthPasswordSyntax.isEncoded(value)) { if (isInternalOperation() || passwordPolicy.isAllowPreEncodedPasswords()) if (isInternalOperation() || passwordPolicy.isAllowPreEncodedPasswords()) { builder.add(value); continue; } else { addPWPolicyControl( PasswordPolicyErrorType.INSUFFICIENT_PASSWORD_QUALITY); addPWPolicyControl(PasswordPolicyErrorType.INSUFFICIENT_PASSWORD_QUALITY); LocalizableMessage message = ERR_PWPOLICY_PREENCODED_NOT_ALLOWED.get( passwordAttribute.getNameOrOID()); throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); ERR_PWPOLICY_PREENCODED_NOT_ALLOWED.get(passwordAttribute.getNameOrOID())); } } } else else if (UserPasswordSyntax.isEncoded(value)) { if (UserPasswordSyntax.isEncoded(value)) if (isInternalOperation() || passwordPolicy.isAllowPreEncodedPasswords()) { if (isInternalOperation() || passwordPolicy.isAllowPreEncodedPasswords()) { builder.add(value); continue; } else { addPWPolicyControl( PasswordPolicyErrorType.INSUFFICIENT_PASSWORD_QUALITY); builder.add(value); continue; } else { addPWPolicyControl(PasswordPolicyErrorType.INSUFFICIENT_PASSWORD_QUALITY); LocalizableMessage message = ERR_PWPOLICY_PREENCODED_NOT_ALLOWED.get( passwordAttribute.getNameOrOID()); throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); } throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, ERR_PWPOLICY_PREENCODED_NOT_ALLOWED.get(passwordAttribute.getNameOrOID())); } } @@ -971,10 +942,9 @@ { for (Control c : getRequestControls()) { if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL)) if (OID_PASSWORD_POLICY_CONTROL.equals(c.getOID())) { addResponseControl(new PasswordPolicyResponseControl(null, 0, errorType)); addResponseControl(new PasswordPolicyResponseControl(null, 0, errorType)); } } } @@ -1091,12 +1061,11 @@ List<Control> requestControls = getRequestControls(); if (requestControls != null && !requestControls.isEmpty()) { for (int i=0; i < requestControls.size(); i++) for (Control c : requestControls) { Control c = requestControls.get(i); String oid = c.getOID(); if (oid.equals(OID_LDAP_ASSERTION)) if (OID_LDAP_ASSERTION.equals(oid)) { // RFC 4528 mandates support for Add operation basically // suggesting an assertion on self. As daft as it may be @@ -1150,16 +1119,16 @@ entryDN, de.getMessageObject())); } } else if (oid.equals(OID_LDAP_NOOP_OPENLDAP_ASSIGNED)) else if (OID_LDAP_NOOP_OPENLDAP_ASSIGNED.equals(oid)) { noOp = true; } else if (oid.equals(OID_LDAP_READENTRY_POSTREAD)) else if (OID_LDAP_READENTRY_POSTREAD.equals(oid)) { postReadRequest = getRequestControl(LDAPPostReadRequestControl.DECODER); } else if (oid.equals(OID_PROXIED_AUTH_V1)) else if (OID_PROXIED_AUTH_V1.equals(oid)) { // Log usage of legacy proxy authz V1 control. addAdditionalLogItem(AdditionalLogItem.keyOnly(getClass(), @@ -1178,16 +1147,9 @@ Entry authorizationEntry = proxyControl.getAuthorizationEntry(); setAuthorizationEntry(authorizationEntry); if (authorizationEntry == null) { setProxiedAuthorizationDN(DN.rootDN()); } else { setProxiedAuthorizationDN(authorizationEntry.getName()); } setProxiedAuthorizationDN(getName(authorizationEntry)); } else if (oid.equals(OID_PROXIED_AUTH_V2)) else if (OID_PROXIED_AUTH_V2.equals(oid)) { // The requester must have the PROXIED_AUTH privilege in order to // be able to use this control. @@ -1203,32 +1165,27 @@ Entry authorizationEntry = proxyControl.getAuthorizationEntry(); setAuthorizationEntry(authorizationEntry); if (authorizationEntry == null) { setProxiedAuthorizationDN(DN.rootDN()); } else { setProxiedAuthorizationDN(authorizationEntry.getName()); } setProxiedAuthorizationDN(getName(authorizationEntry)); } else if (oid.equals(OID_PASSWORD_POLICY_CONTROL)) else if (OID_PASSWORD_POLICY_CONTROL.equals(oid)) { // We don't need to do anything here because it's already handled // in LocalBackendAddOperation.handlePasswordPolicy(). } // NYI -- Add support for additional controls. else if (c.isCritical()) else if (c.isCritical() && (backend == null || !backend.supportsControl(oid))) { if ((backend == null) || (! backend.supportsControl(oid))) { throw newDirectoryException(entryDN, ResultCode.UNAVAILABLE_CRITICAL_EXTENSION, ERR_ADD_UNSUPPORTED_CRITICAL_CONTROL.get(entryDN, oid)); } throw newDirectoryException(entryDN, ResultCode.UNAVAILABLE_CRITICAL_EXTENSION, ERR_ADD_UNSUPPORTED_CRITICAL_CONTROL.get(entryDN, oid)); } } } } private DN getName(Entry e) { return e != null ? e.getName() : DN.rootDN(); } } opendj3-server-dev/src/server/org/opends/server/workflowelement/localbackend/LocalBackendDeleteOperation.java
@@ -26,10 +26,6 @@ */ package org.opends.server.workflowelement.localbackend; import static org.opends.messages.CoreMessages.*; import static org.opends.server.util.ServerConstants.*; import static org.opends.server.util.StaticUtils.*; import java.util.List; import java.util.concurrent.locks.Lock; @@ -52,6 +48,10 @@ import org.opends.server.types.operation.PostSynchronizationDeleteOperation; import org.opends.server.types.operation.PreOperationDeleteOperation; import static org.opends.messages.CoreMessages.*; import static org.opends.server.util.ServerConstants.*; import static org.opends.server.util.StaticUtils.*; /** * This class defines an operation used to delete an entry in a local backend * of the Directory Server. @@ -64,31 +64,19 @@ { private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); /** The backend in which the operation is to be processed. */ private Backend<?> backend; /** * The backend in which the operation is to be processed. */ private Backend backend; /** * Indicates whether the LDAP no-op control has been requested. */ /** Indicates whether the LDAP no-op control has been requested. */ private boolean noOp; /** * The client connection on which this operation was requested. */ /** The client connection on which this operation was requested. */ private ClientConnection clientConnection; /** * The DN of the entry to be deleted. */ /** The DN of the entry to be deleted. */ private DN entryDN; /** * The entry to be deleted. */ /** The entry to be deleted. */ private Entry entry; /** The pre-read request control included in the request, if applicable. */ @@ -189,7 +177,7 @@ // Notify persistent searches. for (PersistentSearch psearch : wfe.getPersistentSearches()) { psearch.processDelete(entry, getChangeNumber()); psearch.processDelete(entry); } // Notify change listeners. @@ -198,8 +186,7 @@ { try { changeListener.handleDeleteOperation( LocalBackendDeleteOperation.this, entry); changeListener.handleDeleteOperation(LocalBackendDeleteOperation.this, entry); } catch (Exception e) { @@ -320,8 +307,7 @@ // handling a subtree delete). But we will need to check if there are // any subordinate backends that should stop us from attempting the // delete. Backend[] subBackends = backend.getSubordinateBackends(); for (Backend b : subBackends) for (Backend<?> b : backend.getSubordinateBackends()) { for (DN dn : b.getBaseDNs()) { @@ -429,7 +415,7 @@ for (Control c : requestControls) { final String oid = c.getOID(); if (oid.equals(OID_LDAP_ASSERTION)) if (OID_LDAP_ASSERTION.equals(oid)) { LDAPAssertionRequestControl assertControl = getRequestControl(LDAPAssertionRequestControl.DECODER); @@ -478,16 +464,16 @@ ERR_DELETE_CANNOT_PROCESS_ASSERTION_FILTER.get(entryDN, de.getMessageObject())); } } else if (oid.equals(OID_LDAP_NOOP_OPENLDAP_ASSIGNED)) else if (OID_LDAP_NOOP_OPENLDAP_ASSIGNED.equals(oid)) { noOp = true; } else if (oid.equals(OID_LDAP_READENTRY_PREREAD)) else if (OID_LDAP_READENTRY_PREREAD.equals(oid)) { preReadRequest = getRequestControl(LDAPPreReadRequestControl.DECODER); } else if (oid.equals(OID_PROXIED_AUTH_V1)) else if (OID_PROXIED_AUTH_V1.equals(oid)) { // Log usage of legacy proxy authz V1 control. addAdditionalLogItem(AdditionalLogItem.keyOnly(getClass(), @@ -506,16 +492,9 @@ Entry authorizationEntry = proxyControl.getAuthorizationEntry(); setAuthorizationEntry(authorizationEntry); if (authorizationEntry == null) { setProxiedAuthorizationDN(DN.rootDN()); } else { setProxiedAuthorizationDN(authorizationEntry.getName()); } setProxiedAuthorizationDN(getName(authorizationEntry)); } else if (oid.equals(OID_PROXIED_AUTH_V2)) else if (OID_PROXIED_AUTH_V2.equals(oid)) { // The requester must have the PROXIED_AUTH privilege in order to // be able to use this control. @@ -530,31 +509,24 @@ Entry authorizationEntry = proxyControl.getAuthorizationEntry(); setAuthorizationEntry(authorizationEntry); if (authorizationEntry == null) { setProxiedAuthorizationDN(DN.rootDN()); } else { setProxiedAuthorizationDN(authorizationEntry.getName()); } setProxiedAuthorizationDN(getName(authorizationEntry)); } // NYI -- Add support for additional controls. else if (c.isCritical()) else if (c.isCritical() && (backend == null || !backend.supportsControl(oid))) { if ((backend == null) || (! backend.supportsControl(oid))) { throw newDirectoryException(entry, ResultCode.UNAVAILABLE_CRITICAL_EXTENSION, ERR_DELETE_UNSUPPORTED_CRITICAL_CONTROL.get(entryDN, oid)); } throw newDirectoryException(entry, ResultCode.UNAVAILABLE_CRITICAL_EXTENSION, ERR_DELETE_UNSUPPORTED_CRITICAL_CONTROL.get(entryDN, oid)); } } } } private DN getName(Entry e) { return e != null ? e.getName() : DN.rootDN(); } /** * Handle conflict resolution. opendj3-server-dev/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java
@@ -28,6 +28,7 @@ import java.util.LinkedList; import java.util.List; import java.util.ListIterator; import java.util.concurrent.locks.Lock; import org.forgerock.i18n.LocalizableMessage; @@ -66,36 +67,22 @@ { private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); /** The backend in which the operation is to be processed. */ private Backend<?> backend; /** * The backend in which the operation is to be processed. */ private Backend backend; /** * Indicates whether the no-op control was included in the request. */ /** Indicates whether the no-op control was included in the request. */ private boolean noOp; /** * The client connection on which this operation was requested. */ /** The client connection on which this operation was requested. */ private ClientConnection clientConnection; /** * The original DN of the entry. */ /** The original DN of the entry. */ private DN entryDN; /** * The current entry, before it is renamed. */ /** The current entry, before it is renamed. */ private Entry currentEntry; /** * The new entry, as it will appear after it has been renamed. */ /** The new entry, as it will appear after it has been renamed. */ private Entry newEntry; /** The LDAP post-read request control, if present in the request. */ @@ -104,9 +91,7 @@ /** The LDAP pre-read request control, if present in the request. */ private LDAPPreReadRequestControl preReadRequest; /** * The new RDN for the entry. */ /** The new RDN for the entry. */ private RDN newRDN; @@ -222,8 +207,7 @@ // Notify persistent searches. for (PersistentSearch psearch : wfe.getPersistentSearches()) { psearch.processModifyDN(newEntry, getChangeNumber(), currentEntry .getName()); psearch.processModifyDN(newEntry, currentEntry.getName()); } // Notify change listeners. @@ -295,7 +279,7 @@ // Get the backend for the current entry, and the backend for the new // entry. If either is null, or if they are different, then fail. Backend currentBackend = backend; Backend<?> currentBackend = backend; if (currentBackend == null) { setResultCode(ResultCode.NO_SUCH_OBJECT); @@ -303,7 +287,7 @@ return; } Backend newBackend = DirectoryServer.getBackend(newDN); Backend<?> newBackend = DirectoryServer.getBackend(newDN); if (newBackend == null) { setResultCode(ResultCode.NO_SUCH_OBJECT); @@ -563,14 +547,14 @@ LocalBackendWorkflowElement.removeAllDisallowedControls(entryDN, this); List<Control> requestControls = getRequestControls(); if ((requestControls != null) && (! requestControls.isEmpty())) if (requestControls != null && !requestControls.isEmpty()) { for (int i=0; i < requestControls.size(); i++) for (ListIterator<Control> iter = requestControls.listIterator(); iter.hasNext();) { Control c = requestControls.get(i); Control c = iter.next(); String oid = c.getOID(); if (oid.equals(OID_LDAP_ASSERTION)) if (OID_LDAP_ASSERTION.equals(oid)) { LDAPAssertionRequestControl assertControl = getRequestControl(LDAPAssertionRequestControl.DECODER); @@ -620,17 +604,16 @@ ERR_MODDN_CANNOT_PROCESS_ASSERTION_FILTER.get(entryDN, de.getMessageObject())); } } else if (oid.equals(OID_LDAP_NOOP_OPENLDAP_ASSIGNED)) else if (OID_LDAP_NOOP_OPENLDAP_ASSIGNED.equals(oid)) { noOp = true; } else if (oid.equals(OID_LDAP_READENTRY_PREREAD)) else if (OID_LDAP_READENTRY_PREREAD.equals(oid)) { preReadRequest = getRequestControl(LDAPPreReadRequestControl.DECODER); requestControls.set(i, preReadRequest); preReadRequest = getRequestControl(LDAPPreReadRequestControl.DECODER); iter.set(preReadRequest); } else if (oid.equals(OID_LDAP_READENTRY_POSTREAD)) else if (OID_LDAP_READENTRY_POSTREAD.equals(oid)) { if (c instanceof LDAPPostReadRequestControl) { @@ -638,12 +621,11 @@ } else { postReadRequest = getRequestControl(LDAPPostReadRequestControl.DECODER); requestControls.set(i, postReadRequest); postReadRequest = getRequestControl(LDAPPostReadRequestControl.DECODER); iter.set(postReadRequest); } } else if (oid.equals(OID_PROXIED_AUTH_V1)) else if (OID_PROXIED_AUTH_V1.equals(oid)) { // Log usage of legacy proxy authz V1 control. addAdditionalLogItem(AdditionalLogItem.keyOnly(getClass(), @@ -662,16 +644,9 @@ Entry authorizationEntry = proxyControl.getAuthorizationEntry(); setAuthorizationEntry(authorizationEntry); if (authorizationEntry == null) { setProxiedAuthorizationDN(DN.rootDN()); } else { setProxiedAuthorizationDN(authorizationEntry.getName()); } setProxiedAuthorizationDN(getName(authorizationEntry)); } else if (oid.equals(OID_PROXIED_AUTH_V2)) else if (OID_PROXIED_AUTH_V2.equals(oid)) { // The requester must have the PROXIED_AUTH privilege in order to // be able to use this control. @@ -686,32 +661,23 @@ Entry authorizationEntry = proxyControl.getAuthorizationEntry(); setAuthorizationEntry(authorizationEntry); if (authorizationEntry == null) { setProxiedAuthorizationDN(DN.rootDN()); } else { setProxiedAuthorizationDN(authorizationEntry.getName()); } setProxiedAuthorizationDN(getName(authorizationEntry)); } // NYI -- Add support for additional controls. else if (c.isCritical()) else if (c.isCritical() && (backend == null || !backend.supportsControl(oid))) { if ((backend == null) || (! backend.supportsControl(oid))) { throw new DirectoryException( ResultCode.UNAVAILABLE_CRITICAL_EXTENSION, ERR_MODDN_UNSUPPORTED_CRITICAL_CONTROL.get(entryDN, oid)); } throw new DirectoryException( ResultCode.UNAVAILABLE_CRITICAL_EXTENSION, ERR_MODDN_UNSUPPORTED_CRITICAL_CONTROL.get(entryDN, oid)); } } } } private DN getName(Entry e) { return e != null ? e.getName() : DN.rootDN(); } /** * Updates the entry so that its attributes are changed to reflect the changes @@ -739,13 +705,12 @@ // If the associated attribute type is marked NO-USER-MODIFICATION, then // refuse the update. if (a.getAttributeType().isNoUserModification()) if (a.getAttributeType().isNoUserModification() && !isInternalOperation() && !isSynchronizationOperation()) { if (! (isInternalOperation() || isSynchronizationOperation())) { throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, ERR_MODDN_OLD_RDN_ATTR_IS_NO_USER_MOD.get(entryDN, a.getName())); } throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, ERR_MODDN_OLD_RDN_ATTR_IS_NO_USER_MOD.get(entryDN, a.getName())); } List<ByteString> missingValues = new LinkedList<ByteString>(); @@ -777,7 +742,7 @@ // refuse the update. if (a.getAttributeType().isNoUserModification()) { if (! (isInternalOperation() || isSynchronizationOperation())) if (!isInternalOperation() && !isSynchronizationOperation()) { throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, ERR_MODDN_NEW_RDN_ATTR_IS_NO_USER_MOD.get(entryDN, a.getName())); @@ -793,7 +758,7 @@ // If the server is configured to check the schema and the operation is not // a synchronization operation, make sure that the resulting entry is valid // as per the server schema. if ((DirectoryServer.checkSchema()) && (! isSynchronizationOperation())) if (DirectoryServer.checkSchema() && !isSynchronizationOperation()) { LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); if (! newEntry.conformsToSchema(null, false, true, true, @@ -959,4 +924,3 @@ } } } opendj3-server-dev/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
@@ -29,6 +29,7 @@ import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.ListIterator; import java.util.concurrent.locks.Lock; import org.forgerock.i18n.LocalizableMessage; @@ -68,10 +69,8 @@ { private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); /** * The backend in which the target entry exists. */ protected Backend backend; /** The backend in which the target entry exists. */ private Backend<?> backend; /** Indicates whether the request included the user's current password. */ private boolean currentPasswordProvided; @@ -80,60 +79,40 @@ * Indicates whether the user's account has been enabled or disabled * by this modify operation. */ protected boolean enabledStateChanged; private boolean enabledStateChanged; /** Indicates whether the user's account is currently enabled. */ private boolean isEnabled; /** * Indicates whether the request included the LDAP no-op control. */ protected boolean noOp; /** Indicates whether the request included the LDAP no-op control. */ private boolean noOp; /** * Indicates whether the request included the Permissive Modify control. */ protected boolean permissiveModify = false; /** Indicates whether the request included the Permissive Modify control. */ private boolean permissiveModify; /** * Indicates whether this modify operation includes a password change. */ protected boolean passwordChanged; /** Indicates whether this modify operation includes a password change. */ private boolean passwordChanged; /** * Indicates whether the request included the password policy request control. */ protected boolean pwPolicyControlRequested; /** Indicates whether the request included the password policy request control. */ private boolean pwPolicyControlRequested; /** * Indicates whether the password change is a self-change. */ protected boolean selfChange; /** Indicates whether the password change is a self-change. */ private boolean selfChange; /** * Indicates whether the user's account was locked before this change. */ protected boolean wasLocked = false; /** Indicates whether the user's account was locked before this change. */ private boolean wasLocked; /** * The client connection associated with this operation. */ protected ClientConnection clientConnection; /** The client connection associated with this operation. */ private ClientConnection clientConnection; /** * The DN of the entry to modify. */ protected DN entryDN; /** The DN of the entry to modify. */ private DN entryDN; /** * The current entry, before any changes are applied. */ protected Entry currentEntry = null; /** The current entry, before any changes are applied. */ private Entry currentEntry; /** * The modified entry that will be stored in the backend. */ protected Entry modifiedEntry = null; /** The modified entry that will be stored in the backend. */ private Entry modifiedEntry; /** The number of passwords contained in the modify operation. */ private int numPasswords; @@ -150,20 +129,14 @@ /** The set of clear-text new passwords (if any were provided).*/ private List<ByteString> newPasswords; /** * The set of modifications contained in this request. */ protected List<Modification> modifications; /** The set of modifications contained in this request. */ private List<Modification> modifications; /** * The password policy error type for this operation. */ protected PasswordPolicyErrorType pwpErrorType; /** The password policy error type for this operation. */ private PasswordPolicyErrorType pwpErrorType; /** * The password policy state for this modify operation. */ protected PasswordPolicyState pwPolicyState; /** The password policy state for this modify operation. */ private PasswordPolicyState pwPolicyState; @@ -348,8 +321,7 @@ // Notify persistent searches. for (PersistentSearch psearch : wfe.getPersistentSearches()) { psearch.processModify(modifiedEntry, getChangeNumber(), currentEntry); psearch.processModify(modifiedEntry, currentEntry); } // Notify change listeners. @@ -442,7 +414,8 @@ // Check that the authorizing account isn't required to change its // password. if ((!isInternalOperation()) && !selfChange if (!isInternalOperation() && !selfChange && getAuthorizationEntry() != null) { AuthenticationPolicy authzPolicy = @@ -514,7 +487,7 @@ handleInitialPasswordPolicyProcessing(); performAdditionalPasswordChangedProcessing(); if ((!passwordChanged) && (!isInternalOperation()) && selfChange if (!passwordChanged && !isInternalOperation() && selfChange && pwPolicyState != null && pwPolicyState.mustChangePassword()) { // The user did not attempt to change their password. @@ -528,11 +501,10 @@ // If the server is configured to check the schema and the // operation is not a synchronization operation, // make sure that the new entry is valid per the server schema. if ((DirectoryServer.checkSchema()) && (!isSynchronizationOperation())) if (DirectoryServer.checkSchema() && !isSynchronizationOperation()) { LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); if (!modifiedEntry.conformsToSchema(null, false, false, false, invalidReason)) if (!modifiedEntry.conformsToSchema(null, false, false, false, invalidReason)) { setResultCode(ResultCode.OBJECTCLASS_VIOLATION); appendErrorMessage(ERR_MODIFY_VIOLATES_SCHEMA.get(entryDN, invalidReason)); @@ -664,16 +636,16 @@ * @throws DirectoryException If a problem is encountered with any of the * controls. */ protected void processRequestControls() throws DirectoryException private void processRequestControls() throws DirectoryException { LocalBackendWorkflowElement.removeAllDisallowedControls(entryDN, this); List<Control> requestControls = getRequestControls(); if ((requestControls != null) && (! requestControls.isEmpty())) if (requestControls != null && !requestControls.isEmpty()) { for (int i=0; i < requestControls.size(); i++) for (ListIterator<Control> iter = requestControls.listIterator(); iter.hasNext();) { Control c = requestControls.get(i); Control c = iter.next(); String oid = c.getOID(); if (oid.equals(OID_LDAP_ASSERTION)) @@ -738,8 +710,7 @@ } else if (oid.equals(OID_LDAP_READENTRY_PREREAD)) { preReadRequest = getRequestControl(LDAPPreReadRequestControl.DECODER); preReadRequest = getRequestControl(LDAPPreReadRequestControl.DECODER); } else if (oid.equals(OID_LDAP_READENTRY_POSTREAD)) { @@ -749,9 +720,8 @@ } else { postReadRequest = getRequestControl(LDAPPostReadRequestControl.DECODER); requestControls.set(i, postReadRequest); postReadRequest = getRequestControl(LDAPPostReadRequestControl.DECODER); iter.set(postReadRequest); } } else if (oid.equals(OID_PROXIED_AUTH_V1)) @@ -773,14 +743,7 @@ Entry authorizationEntry = proxyControl.getAuthorizationEntry(); setAuthorizationEntry(authorizationEntry); if (authorizationEntry == null) { setProxiedAuthorizationDN(DN.rootDN()); } else { setProxiedAuthorizationDN(authorizationEntry.getName()); } setProxiedAuthorizationDN(getName(authorizationEntry)); } else if (oid.equals(OID_PROXIED_AUTH_V2)) { @@ -797,43 +760,37 @@ Entry authorizationEntry = proxyControl.getAuthorizationEntry(); setAuthorizationEntry(authorizationEntry); if (authorizationEntry == null) { setProxiedAuthorizationDN(DN.rootDN()); } else { setProxiedAuthorizationDN(authorizationEntry.getName()); } setProxiedAuthorizationDN(getName(authorizationEntry)); } else if (oid.equals(OID_PASSWORD_POLICY_CONTROL)) { pwPolicyControlRequested = true; } // NYI -- Add support for additional controls. else if (c.isCritical()) else if (c.isCritical() && (backend == null || !backend.supportsControl(oid))) { if ((backend == null) || (! backend.supportsControl(oid))) { throw newDirectoryException(currentEntry, ResultCode.UNAVAILABLE_CRITICAL_EXTENSION, ERR_MODIFY_UNSUPPORTED_CRITICAL_CONTROL.get(entryDN, oid)); } throw newDirectoryException(currentEntry, ResultCode.UNAVAILABLE_CRITICAL_EXTENSION, ERR_MODIFY_UNSUPPORTED_CRITICAL_CONTROL.get(entryDN, oid)); } } } } /** private DN getName(Entry e) { return e != null ? e.getName() : DN.rootDN(); } /** * Handles schema processing for non-password modifications. * * @throws DirectoryException If a problem is encountered that should cause * the modify operation to fail. */ protected void handleSchemaProcessing() throws DirectoryException private void handleSchemaProcessing() throws DirectoryException { for (Modification m : modifications) { Attribute a = m.getAttribute(); @@ -841,35 +798,30 @@ // If the attribute type is marked "NO-USER-MODIFICATION" then fail unless // this is an internal operation or is related to synchronization in some // way. if (t.isNoUserModification()) // this is an internal operation or is related to synchronization in some way. if (t.isNoUserModification() && !isInternalOperation() && !isSynchronizationOperation() && !m.isInternal()) { if (! (isInternalOperation() || isSynchronizationOperation() || m.isInternal())) { throw newDirectoryException(currentEntry, ResultCode.CONSTRAINT_VIOLATION, ERR_MODIFY_ATTR_IS_NO_USER_MOD.get(entryDN, a.getName())); } throw newDirectoryException(currentEntry, ResultCode.CONSTRAINT_VIOLATION, ERR_MODIFY_ATTR_IS_NO_USER_MOD.get(entryDN, a.getName())); } // If the attribute type is marked "OBSOLETE" and the modification is // setting new values, then fail unless this is an internal operation or // is related to synchronization in some way. if (t.isObsolete()) if (t.isObsolete() && !a.isEmpty() && m.getModificationType() != ModificationType.DELETE && !isInternalOperation() && !isSynchronizationOperation() && !m.isInternal()) { if (!a.isEmpty() && (m.getModificationType() != ModificationType.DELETE)) { if (! (isInternalOperation() || isSynchronizationOperation() || m.isInternal())) { throw newDirectoryException(currentEntry, ResultCode.CONSTRAINT_VIOLATION, ERR_MODIFY_ATTR_IS_OBSOLETE.get(entryDN, a.getName())); } } throw newDirectoryException(currentEntry, ResultCode.CONSTRAINT_VIOLATION, ERR_MODIFY_ATTR_IS_OBSOLETE.get(entryDN, a.getName())); } @@ -887,10 +839,9 @@ // If the modification is not updating the password attribute, // then perform any schema processing. boolean isPassword = (pwPolicyState != null) && t.equals(pwPolicyState.getAuthenticationPolicy() .getPasswordAttribute()); if (!isPassword ) boolean isPassword = pwPolicyState != null && t.equals(pwPolicyState.getAuthenticationPolicy().getPasswordAttribute()); if (!isPassword) { switch (m.getModificationType().asEnum()) { @@ -920,8 +871,7 @@ * @throws DirectoryException If a problem is encountered that should cause * the modify operation to fail. */ protected void handleInitialPasswordPolicyProcessing() throws DirectoryException private void handleInitialPasswordPolicyProcessing() throws DirectoryException { // Declare variables used for password policy state processing. currentPasswordProvided = false; @@ -934,8 +884,8 @@ return; } if (currentEntry.hasAttribute( pwPolicyState.getAuthenticationPolicy().getPasswordAttribute())) final PasswordPolicy authPolicy = pwPolicyState.getAuthenticationPolicy(); if (currentEntry.hasAttribute(authPolicy.getPasswordAttribute())) { // It may actually have more than one, but we can't tell the difference if // the values are encoded, and its enough for our purposes just to know @@ -957,22 +907,17 @@ for (Modification m : modifications) { AttributeType t = m.getAttribute().getAttributeType(); boolean isPassword = t.equals(pwPolicyState.getAuthenticationPolicy() .getPasswordAttribute()); boolean isPassword = t.equals(authPolicy.getPasswordAttribute()); if (isPassword) { passwordChanged = true; if (! selfChange) if (!selfChange && !clientConnection.hasPrivilege(Privilege.PASSWORD_RESET, this)) { if (! clientConnection.hasPrivilege(Privilege.PASSWORD_RESET, this)) { pwpErrorType = PasswordPolicyErrorType.PASSWORD_MOD_NOT_ALLOWED; throw new DirectoryException( ResultCode.INSUFFICIENT_ACCESS_RIGHTS, ERR_MODIFY_PWRESET_INSUFFICIENT_PRIVILEGES.get()); } pwpErrorType = PasswordPolicyErrorType.PASSWORD_MOD_NOT_ALLOWED; throw new DirectoryException( ResultCode.INSUFFICIENT_ACCESS_RIGHTS, ERR_MODIFY_PWRESET_INSUFFICIENT_PRIVILEGES.get()); } break; } } @@ -988,8 +933,7 @@ // If the modification is updating the password attribute, then perform // any necessary password policy processing. This processing should be // skipped for synchronization operations. boolean isPassword = t.equals(pwPolicyState.getAuthenticationPolicy() .getPasswordAttribute()); boolean isPassword = t.equals(authPolicy.getPasswordAttribute()); if (isPassword) { if (!isSynchronizationOperation()) @@ -1021,9 +965,7 @@ } // If it's a self change, then see if that's allowed. if (selfChange && (!pwPolicyState.getAuthenticationPolicy() .isAllowUserPasswordChanges())) if (selfChange && !authPolicy.isAllowUserPasswordChanges()) { pwpErrorType = PasswordPolicyErrorType.PASSWORD_MOD_NOT_ALLOWED; throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, @@ -1033,9 +975,8 @@ // If we require secure password changes, then makes sure it's a // secure communication channel. if (pwPolicyState.getAuthenticationPolicy() .isRequireSecurePasswordChanges() && (!clientConnection.isSecure())) if (authPolicy.isRequireSecurePasswordChanges() && !clientConnection.isSecure()) { pwpErrorType = PasswordPolicyErrorType.PASSWORD_MOD_NOT_ALLOWED; throw new DirectoryException(ResultCode.CONFIDENTIALITY_REQUIRED, @@ -1218,7 +1159,7 @@ { if (pwPolicyState.passwordIsPreEncoded(v)) { if ((!isInternalOperation()) && selfChange) if (!isInternalOperation() && selfChange) { pwpErrorType = PasswordPolicyErrorType.INSUFFICIENT_PASSWORD_QUALITY; throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, @@ -1228,9 +1169,8 @@ { // We still need to check if the pre-encoded password matches // an existing value, to decrease the number of passwords. List<Attribute> attrList = currentEntry.getAttribute(pwAttr .getAttributeType()); if ((attrList == null) || (attrList.isEmpty())) List<Attribute> attrList = currentEntry.getAttribute(pwAttr.getAttributeType()); if (attrList == null || attrList.isEmpty()) { throw new DirectoryException(ResultCode.NO_SUCH_ATTRIBUTE, ERR_MODIFY_NO_EXISTING_VALUES.get()); @@ -1255,8 +1195,7 @@ } else { List<Attribute> attrList = currentEntry.getAttribute(pwAttr .getAttributeType()); List<Attribute> attrList = currentEntry.getAttribute(pwAttr.getAttributeType()); if ((attrList == null) || (attrList.isEmpty())) { throw new DirectoryException(ResultCode.NO_SUCH_ATTRIBUTE, @@ -1368,10 +1307,9 @@ // If the server is configured to check schema and the operation // is not a synchronization operation, make sure that all the new // values are valid according to the associated syntax. if ((DirectoryServer.checkSchema()) && (!isSynchronizationOperation())) if (DirectoryServer.checkSchema() && !isSynchronizationOperation()) { AcceptRejectWarn syntaxPolicy = DirectoryServer .getSyntaxEnforcementPolicy(); AcceptRejectWarn syntaxPolicy = DirectoryServer.getSyntaxEnforcementPolicy(); AttributeSyntax<?> syntax = attr.getAttributeType().getSyntax(); if (syntaxPolicy == AcceptRejectWarn.REJECT) @@ -1526,34 +1464,28 @@ AttributeType t = attr.getAttributeType(); RDN rdn = modifiedEntry.getName().rdn(); if ((rdn != null) && rdn.hasAttributeType(t) && (! modifiedEntry.hasValue(t, attr.getOptions(), rdn.getAttributeValue(t)))) if (rdn != null && rdn.hasAttributeType(t) && !modifiedEntry.hasValue(t, attr.getOptions(), rdn.getAttributeValue(t))) { throw newDirectoryException(currentEntry, ResultCode.NOT_ALLOWED_ON_RDN, ERR_MODIFY_DELETE_RDN_ATTR.get(entryDN, attr.getName())); } } else else if (!permissiveModify) { if (! permissiveModify) { String missingValuesStr = Utils.joinAsString(", ", missingValues); String missingValuesStr = Utils.joinAsString(", ", missingValues); throw newDirectoryException(currentEntry, ResultCode.NO_SUCH_ATTRIBUTE, ERR_MODIFY_DELETE_MISSING_VALUES.get(entryDN, attr.getName(), missingValuesStr)); } throw newDirectoryException(currentEntry, ResultCode.NO_SUCH_ATTRIBUTE, ERR_MODIFY_DELETE_MISSING_VALUES.get(entryDN, attr.getName(), missingValuesStr)); } } else else if (!permissiveModify) { if (! permissiveModify) { throw newDirectoryException(currentEntry, ResultCode.NO_SUCH_ATTRIBUTE, ERR_MODIFY_DELETE_NO_SUCH_ATTR.get(entryDN, attr.getName())); } throw newDirectoryException(currentEntry, ResultCode.NO_SUCH_ATTRIBUTE, ERR_MODIFY_DELETE_NO_SUCH_ATTR.get(entryDN, attr.getName())); } } @@ -1575,7 +1507,7 @@ // If the server is configured to check schema and the operation // is not a synchronization operation, make sure that all the // new values are valid according to the associated syntax. if ((DirectoryServer.checkSchema()) && (!isSynchronizationOperation())) if (DirectoryServer.checkSchema() && !isSynchronizationOperation()) { AcceptRejectWarn syntaxPolicy = DirectoryServer .getSyntaxEnforcementPolicy(); @@ -1644,10 +1576,9 @@ // Make sure that the RDN attribute value(s) has not been removed. AttributeType t = attr.getAttributeType(); RDN rdn = modifiedEntry.getName().rdn(); if ((rdn != null) if (rdn != null && rdn.hasAttributeType(t) && (!modifiedEntry.hasValue(t, attr.getOptions(), rdn .getAttributeValue(t)))) && !modifiedEntry.hasValue(t, attr.getOptions(), rdn.getAttributeValue(t))) { throw newDirectoryException(modifiedEntry, ResultCode.NOT_ALLOWED_ON_RDN, ERR_MODIFY_DELETE_RDN_ATTR.get(entryDN, attr.getName())); @@ -1672,14 +1603,13 @@ // The specified attribute type must not be an RDN attribute. AttributeType t = attr.getAttributeType(); RDN rdn = modifiedEntry.getName().rdn(); if ((rdn != null) && rdn.hasAttributeType(t)) if (rdn != null && rdn.hasAttributeType(t)) { throw newDirectoryException(modifiedEntry, ResultCode.NOT_ALLOWED_ON_RDN, ERR_MODIFY_INCREMENT_RDN.get(entryDN, attr.getName())); } // The provided attribute must have a single value, and it must be // an integer. // The provided attribute must have a single value, and it must be an integer if (attr.isEmpty()) { throw newDirectoryException(modifiedEntry, ResultCode.PROTOCOL_ERROR, @@ -1772,10 +1702,10 @@ // If it was a self change, then see if the current password was provided // and handle accordingly. final PasswordPolicy authPolicy = pwPolicyState.getAuthenticationPolicy(); if (selfChange && pwPolicyState.getAuthenticationPolicy() .isPasswordChangeRequiresCurrentPassword() && (!currentPasswordProvided)) && authPolicy.isPasswordChangeRequiresCurrentPassword() && !currentPasswordProvided) { pwpErrorType = PasswordPolicyErrorType.MUST_SUPPLY_OLD_PASSWORD; @@ -1786,9 +1716,7 @@ // If this change would result in multiple password values, then see if // that's OK. if ((numPasswords > 1) && (!pwPolicyState.getAuthenticationPolicy() .isAllowMultiplePasswordValues())) if (numPasswords > 1 && !authPolicy.isAllowMultiplePasswordValues()) { pwpErrorType = PasswordPolicyErrorType.PASSWORD_MOD_NOT_ALLOWED; throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, @@ -1797,9 +1725,7 @@ // If any of the password values should be validated, then do so now. if (selfChange || (!pwPolicyState.getAuthenticationPolicy() .isSkipValidationForAdministrators())) if (selfChange || !authPolicy.isSkipValidationForAdministrators()) { if (newPasswords != null) { @@ -1836,11 +1762,9 @@ if (! pwPolicyState.passwordIsAcceptable(this, modifiedEntry, v, clearPasswords, invalidReason)) { pwpErrorType = PasswordPolicyErrorType.INSUFFICIENT_PASSWORD_QUALITY; pwpErrorType = PasswordPolicyErrorType.INSUFFICIENT_PASSWORD_QUALITY; throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, ERR_MODIFY_PW_VALIDATION_FAILED.get( invalidReason)); ERR_MODIFY_PW_VALIDATION_FAILED.get(invalidReason)); } } } @@ -1854,15 +1778,12 @@ { for (ByteString v : newPasswords) { if (pwPolicyState.isPasswordInHistory(v)) if (pwPolicyState.isPasswordInHistory(v) && (selfChange || !authPolicy.isSkipValidationForAdministrators())) { if (selfChange || (! pwPolicyState.getAuthenticationPolicy(). isSkipValidationForAdministrators())) { pwpErrorType = PasswordPolicyErrorType.PASSWORD_IN_HISTORY; throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, ERR_MODIFY_PW_IN_HISTORY.get()); } pwpErrorType = PasswordPolicyErrorType.PASSWORD_IN_HISTORY; throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, ERR_MODIFY_PW_IN_HISTORY.get()); } } @@ -1883,8 +1804,7 @@ pwPolicyState.clearGraceLoginTimes(); pwPolicyState.clearWarnedTime(); if (pwPolicyState.getAuthenticationPolicy().isForceChangeOnAdd() || pwPolicyState.getAuthenticationPolicy().isForceChangeOnReset()) if (authPolicy.isForceChangeOnAdd() || authPolicy.isForceChangeOnReset()) { if (selfChange) { @@ -1892,18 +1812,16 @@ } else { if ((pwpErrorType == null) && pwPolicyState.getAuthenticationPolicy().isForceChangeOnReset()) if (pwpErrorType == null && authPolicy.isForceChangeOnReset()) { pwpErrorType = PasswordPolicyErrorType.CHANGE_AFTER_RESET; } pwPolicyState.setMustChangePassword( pwPolicyState.getAuthenticationPolicy().isForceChangeOnReset()); pwPolicyState.setMustChangePassword(authPolicy.isForceChangeOnReset()); } } if (pwPolicyState.getAuthenticationPolicy().getRequireChangeByTime() > 0) if (authPolicy.getRequireChangeByTime() > 0) { pwPolicyState.setRequiredChangeTime(); } @@ -1918,7 +1836,7 @@ * Handles any account status notifications that may be needed as a result of * modify processing. */ protected void handleAccountStatusNotifications() private void handleAccountStatusNotifications() { if (pwPolicyState == null) { @@ -2000,7 +1918,7 @@ * @return {@code true} if processing should continue for the operation, or * {@code false} if not. */ protected boolean handleConflictResolution() { private boolean handleConflictResolution() { for (SynchronizationProvider<?> provider : DirectoryServer.getSynchronizationProviders()) { try { @@ -2029,7 +1947,7 @@ * @return {@code true} if processing should continue for the operation, or * {@code false} if not. */ protected boolean processPreOperation() { private boolean processPreOperation() { for (SynchronizationProvider<?> provider : DirectoryServer.getSynchronizationProviders()) { try { @@ -2056,7 +1974,7 @@ /** * Invoke post operation synchronization providers. */ protected void processSynchPostOperationPlugins() { private void processSynchPostOperationPlugins() { for (SynchronizationProvider<?> provider : DirectoryServer.getSynchronizationProviders()) { try { opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/AddOperationTestCase.java
@@ -51,12 +51,14 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import static org.opends.server.protocols.internal.InternalClientConnection.*; import static org.opends.server.protocols.ldap.LDAPConstants.*; import static org.testng.Assert.*; /** * A set of test cases for add operations * A set of test cases for add operations. */ @SuppressWarnings("javadoc") public class AddOperationTestCase extends OperationTestCase { @@ -64,7 +66,7 @@ /** Some of the tests disable the backends, so we reenable them here. */ @AfterMethod(alwaysRun=true) public void reenableBackend() throws DirectoryException { Backend b = DirectoryServer.getBackend(DN.valueOf("o=test")); Backend<?> b = DirectoryServer.getBackend(DN.valueOf("o=test")); b.setWritabilityMode(WritabilityMode.ENABLED); } @@ -79,9 +81,6 @@ public Object[][] getAddOperations() throws Exception { InternalClientConnection conn = InternalClientConnection.getRootConnection(); ArrayList<Control> noControls = new ArrayList<Control>(); ArrayList<RawAttribute> ldapAttrList = new ArrayList<RawAttribute>(); @@ -103,17 +102,17 @@ Operation[] opArray = new Operation[] { new AddOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), new AddOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), null, ByteString.valueOf("ou=People,o=test"), ldapAttrList), new AddOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), new AddOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), noControls, ByteString.valueOf("ou=People,o=test"), ldapAttrList), new AddOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), new AddOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), null, entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()), new AddOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), new AddOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), noControls, entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()), @@ -131,9 +130,7 @@ /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override() protected Operation[] createTestOperations() throws Exception @@ -181,9 +178,6 @@ @Test() public void testGetEntryDNInitiallyNull() { InternalClientConnection conn = InternalClientConnection.getRootConnection(); ArrayList<RawAttribute> ldapAttrList = new ArrayList<RawAttribute>(); ArrayList<ByteString> values = new ArrayList<ByteString>(); @@ -196,7 +190,7 @@ ldapAttrList.add(new LDAPAttribute("ou", values)); AddOperationBasis addOperation = new AddOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), new AddOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), null, ByteString.valueOf("ou=People,o=test"), ldapAttrList); assertNotNull(addOperation.getEntryDN()); @@ -214,9 +208,6 @@ public void testGetEntryDNInitiallyNonNull() throws Exception { InternalClientConnection conn = InternalClientConnection.getRootConnection(); Entry entry = TestCaseUtils.makeEntry( "dn: ou=People,o=test", "objectClass: top", @@ -224,7 +215,7 @@ "ou: People"); AddOperationBasis addOperation = new AddOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), new AddOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), null, entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); @@ -244,9 +235,6 @@ public void testGetEntryDNNonNullChangedToNull() throws Exception { InternalClientConnection conn = InternalClientConnection.getRootConnection(); Entry entry = TestCaseUtils.makeEntry( "dn: ou=People,o=test", "objectClass: top", @@ -254,7 +242,7 @@ "ou: People"); AddOperationBasis addOperation = new AddOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), new AddOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), null, entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); @@ -287,29 +275,24 @@ values.add(ByteString.valueOf("foo")); addOperation.addRawAttribute(new LDAPAttribute("description", values)); boolean found = false; for (RawAttribute a : addOperation.getRawAttributes()) { if (a.getAttributeType().equalsIgnoreCase("description")) { found = true; break; } } assertTrue(found); assertTrue(find(addOperation)); addOperation.setRawAttributes(rawAttrs); found = false; assertFalse(find(addOperation)); } private boolean find(AddOperation addOperation) { boolean found = false; for (RawAttribute a : addOperation.getRawAttributes()) { if (a.getAttributeType().equalsIgnoreCase("description")) if ("description".equalsIgnoreCase(a.getAttributeType())) { found = true; break; return true; } } assertFalse(found); return found; } @@ -331,18 +314,12 @@ "objectClass: organizationalUnit", "ou: People"); InternalClientConnection conn = InternalClientConnection.getRootConnection(); UpdatePreOpPlugin.reset(); ObjectClass oc = DirectoryServer.getObjectClass("extensibleobject", true); UpdatePreOpPlugin.addObjectClassToAdd(oc); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(entry); assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); retrieveCompletedOperationElements(addOperation); @@ -372,18 +349,12 @@ "objectClass: extensibleObject", "ou: People"); InternalClientConnection conn = InternalClientConnection.getRootConnection(); UpdatePreOpPlugin.reset(); ObjectClass oc = DirectoryServer.getObjectClass("extensibleobject", true); UpdatePreOpPlugin.addObjectClassToRemove(oc); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(entry); assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); retrieveCompletedOperationElements(addOperation); @@ -414,18 +385,12 @@ "ou: People", "description: foo"); InternalClientConnection conn = InternalClientConnection.getRootConnection(); UpdatePreOpPlugin.reset(); Attribute a = Attributes.create("description", "bar"); UpdatePreOpPlugin.addAttributeToSet(a); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(entry); assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); retrieveCompletedOperationElements(addOperation); @@ -475,18 +440,12 @@ "objectClass: organizationalUnit", "ou: People"); InternalClientConnection conn = InternalClientConnection.getRootConnection(); UpdatePreOpPlugin.reset(); Attribute a = Attributes.create("description", "foo"); UpdatePreOpPlugin.addAttributeToSet(a); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(entry); assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); retrieveCompletedOperationElements(addOperation); @@ -518,19 +477,13 @@ "ou: People", "description: foo"); InternalClientConnection conn = InternalClientConnection.getRootConnection(); UpdatePreOpPlugin.reset(); AttributeType attrType = DirectoryServer.getAttributeType("description", true); UpdatePreOpPlugin.addAttributeToRemove(attrType); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(entry); assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); retrieveCompletedOperationElements(addOperation); @@ -556,9 +509,6 @@ assertTrue(addOperation.getProcessingStopTime() >= addOperation.getProcessingStartTime()); assertTrue(addOperation.getProcessingTime() >= 0); long changeNumber = addOperation.getChangeNumber(); addOperation.setChangeNumber(changeNumber); } @@ -586,11 +536,8 @@ values.add(ByteString.valueOf("People")); attrs.add(new LDAPAttribute("ou", values)); InternalClientConnection conn = InternalClientConnection.getRootConnection(); AddOperation addOperation = conn.processAdd(ByteString.valueOf("ou=People,o=test"), attrs); getRootConnection().processAdd(ByteString.valueOf("ou=People,o=test"), attrs); assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); retrieveCompletedOperationElements(addOperation); } @@ -615,13 +562,7 @@ "objectClass: organizationalUnit", "ou: People"); InternalClientConnection conn = InternalClientConnection.getRootConnection(); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(entry); assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); retrieveCompletedOperationElements(addOperation); } @@ -651,11 +592,8 @@ values.add(ByteString.valueOf("People")); attrs.add(new LDAPAttribute("ou", values)); InternalClientConnection conn = InternalClientConnection.getRootConnection(); AddOperation addOperation = conn.processAdd(ByteString.valueOf("invalid"), attrs); getRootConnection().processAdd(ByteString.valueOf("invalid"), attrs); assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); } @@ -684,11 +622,8 @@ values.add(ByteString.valueOf("test")); attrs.add(new LDAPAttribute("o", values)); InternalClientConnection conn = InternalClientConnection.getRootConnection(); AddOperation addOperation = conn.processAdd(ByteString.valueOf("o=test"), attrs); getRootConnection().processAdd(ByteString.valueOf("o=test"), attrs); assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); } @@ -717,11 +652,8 @@ values.add(ByteString.valueOf("undefined")); attrs.add(new LDAPAttribute("o", values)); InternalClientConnection conn = InternalClientConnection.getRootConnection(); AddOperation addOperation = conn.processAdd(ByteString.valueOf("o=undefined"), attrs); getRootConnection().processAdd(ByteString.valueOf("o=undefined"), attrs); assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); } @@ -750,8 +682,7 @@ values.add(ByteString.valueOf("People")); attrs.add(new LDAPAttribute("ou", values)); InternalClientConnection conn = InternalClientConnection.getRootConnection(); InternalClientConnection conn = getRootConnection(); AddOperation addOperation = conn.processAdd(ByteString.valueOf("ou=People,o=undefined"), attrs); @@ -783,8 +714,7 @@ values.add(ByteString.valueOf("People")); attrs.add(new LDAPAttribute("ou", values)); InternalClientConnection conn = InternalClientConnection.getRootConnection(); InternalClientConnection conn = getRootConnection(); AddOperation addOperation = conn.processAdd(ByteString.valueOf("ou=People,o=missing,o=test"), @@ -886,8 +816,7 @@ values.add(ByteString.valueOf("People")); attrs.add(new LDAPAttribute("ou", values)); InternalClientConnection conn = InternalClientConnection.getRootConnection(); InternalClientConnection conn = getRootConnection(); AddOperation addOperation = conn.processAdd(ByteString.valueOf("ou=People,o=test"), @@ -923,13 +852,7 @@ "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + "cn=Password Policies,cn=config"); InternalClientConnection conn = InternalClientConnection.getRootConnection(); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(entry); assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); retrieveCompletedOperationElements(addOperation); } @@ -967,8 +890,7 @@ values.add(ByteString.valueOf("bar")); attrs.add(new LDAPAttribute("description", values)); InternalClientConnection conn = InternalClientConnection.getRootConnection(); InternalClientConnection conn = getRootConnection(); AddOperation addOperation = conn.processAdd(ByteString.valueOf("ou=People,o=test"), @@ -1009,8 +931,7 @@ values.add(ByteString.valueOf("foo")); attrs.add(new LDAPAttribute("description;lang-en-us", values)); InternalClientConnection conn = InternalClientConnection.getRootConnection(); InternalClientConnection conn = getRootConnection(); AddOperation addOperation = conn.processAdd(ByteString.valueOf("ou=People,o=test"), @@ -1047,8 +968,7 @@ values.add(ByteString.valueOf("foo")); attrs.add(new LDAPAttribute("description;lang-en-us", values)); InternalClientConnection conn = InternalClientConnection.getRootConnection(); InternalClientConnection conn = getRootConnection(); AddOperation addOperation = conn.processAdd(ByteString.valueOf("ou=People,o=test"), @@ -1086,13 +1006,7 @@ "cn;lang-en-us: Test User", "userPassword: password"); InternalClientConnection conn = InternalClientConnection.getRootConnection(); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(entry); assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); retrieveCompletedOperationElements(addOperation); } @@ -1123,8 +1037,7 @@ values.add(ByteString.valueOf("Root DSE")); attrs.add(new LDAPAttribute("cn", values)); InternalClientConnection conn = InternalClientConnection.getRootConnection(); InternalClientConnection conn = getRootConnection(); AddOperation addOperation = conn.processAdd(ByteString.empty(), attrs); @@ -1149,13 +1062,7 @@ "objectClass: top", "objectClass: organizationalUnit"); InternalClientConnection conn = InternalClientConnection.getRootConnection(); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(entry); assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); retrieveCompletedOperationElements(addOperation); @@ -1184,13 +1091,7 @@ "objectClass: top", "objectClass: organizationalUnit"); InternalClientConnection conn = InternalClientConnection.getRootConnection(); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(entry); assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); DirectoryServer.setAddMissingRDNAttributes(true); @@ -1219,13 +1120,7 @@ "cn: Test User", "userPassword: password"); InternalClientConnection conn = InternalClientConnection.getRootConnection(); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(entry); assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); retrieveCompletedOperationElements(addOperation); @@ -1239,7 +1134,7 @@ { for (ByteString v : a) { if (v.toString().equalsIgnoreCase("top")) if ("top".equalsIgnoreCase(v.toString())) { found = true; break; @@ -1266,13 +1161,7 @@ "dn: ou=People,o=test", "ou: People"); InternalClientConnection conn = InternalClientConnection.getRootConnection(); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(entry); assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); } @@ -1295,13 +1184,7 @@ "objectClass: top", "ou: People"); InternalClientConnection conn = InternalClientConnection.getRootConnection(); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(entry); assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); } @@ -1325,13 +1208,7 @@ "objectClass: extensibleObject", "ou: People"); InternalClientConnection conn = InternalClientConnection.getRootConnection(); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(entry); assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); } @@ -1358,13 +1235,7 @@ "cn: Test User", "sn: User"); InternalClientConnection conn = InternalClientConnection.getRootConnection(); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(entry); assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); } @@ -1392,13 +1263,7 @@ "sn: User", "userPassword: password"); // Missing cn InternalClientConnection conn = InternalClientConnection.getRootConnection(); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(entry); assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); } @@ -1428,13 +1293,7 @@ "sn: User", "userPassword: password"); // Missing cn InternalClientConnection conn = InternalClientConnection.getRootConnection(); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(entry); assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); } @@ -1465,13 +1324,7 @@ "userPassword: password", "dc: Not allowed by inetOrgPerson"); InternalClientConnection conn = InternalClientConnection.getRootConnection(); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(entry); assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); } @@ -1504,13 +1357,7 @@ "userPassword: password", "dc: Not allowed by inetOrgPerson but allowed by extensibleObject"); InternalClientConnection conn = InternalClientConnection.getRootConnection(); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(entry); assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); retrieveCompletedOperationElements(addOperation); } @@ -1543,8 +1390,7 @@ userAttrs.put(attrType, attrList); InternalClientConnection conn = InternalClientConnection.getRootConnection(); InternalClientConnection conn = getRootConnection(); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), userAttrs, @@ -1578,15 +1424,9 @@ "cn: Test User", "userPassword: password"); InternalClientConnection conn = InternalClientConnection.getRootConnection(); DirectoryServer.setWritabilityMode(WritabilityMode.DISABLED); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(entry); assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); DirectoryServer.setWritabilityMode(WritabilityMode.ENABLED); @@ -1618,15 +1458,9 @@ "cn: Test User", "userPassword: password"); InternalClientConnection conn = InternalClientConnection.getRootConnection(); DirectoryServer.setWritabilityMode(WritabilityMode.INTERNAL_ONLY); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(entry); assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); retrieveCompletedOperationElements(addOperation); @@ -1724,16 +1558,10 @@ "cn: Test User", "userPassword: password"); InternalClientConnection conn = InternalClientConnection.getRootConnection(); Backend b = DirectoryServer.getBackend(DN.valueOf("o=test")); Backend<?> b = DirectoryServer.getBackend(DN.valueOf("o=test")); b.setWritabilityMode(WritabilityMode.DISABLED); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(entry); assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); b.setWritabilityMode(WritabilityMode.ENABLED); @@ -1765,16 +1593,10 @@ "cn: Test User", "userPassword: password"); InternalClientConnection conn = InternalClientConnection.getRootConnection(); Backend b = DirectoryServer.getBackend(DN.valueOf("o=test")); Backend<?> b = DirectoryServer.getBackend(DN.valueOf("o=test")); b.setWritabilityMode(WritabilityMode.INTERNAL_ONLY); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(entry); assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); retrieveCompletedOperationElements(addOperation); @@ -1822,7 +1644,7 @@ values.add(ByteString.valueOf("People")); attrs.add(new LDAPAttribute("ou", values)); Backend b = DirectoryServer.getBackend(DN.valueOf("o=test")); Backend<?> b = DirectoryServer.getBackend(DN.valueOf("o=test")); b.setWritabilityMode(WritabilityMode.INTERNAL_ONLY); long addRequests = ldapStatistics.getAddRequests(); @@ -1872,13 +1694,7 @@ "objectClass: organizationalUnit", "ou: People"); InternalClientConnection conn = InternalClientConnection.getRootConnection(); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(entry); assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); retrieveCompletedOperationElements(addOperation); @@ -1911,13 +1727,7 @@ "objectClass: organizationalUnit", "ou: People"); InternalClientConnection conn = InternalClientConnection.getRootConnection(); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(entry); assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); assertEquals(changeListener.getAddCount(), 0); @@ -1943,11 +1753,8 @@ "objectClass: organizationalUnit", "ou: People"); InternalClientConnection conn = InternalClientConnection.getRootConnection(); AddOperationBasis addOperation = new AddOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), new AddOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), null, entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); @@ -1976,11 +1783,8 @@ "objectClass: organizationalUnit", "ou: People"); InternalClientConnection conn = InternalClientConnection.getRootConnection(); AddOperationBasis addOperation = new AddOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), new AddOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), null, entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); @@ -2019,13 +1823,7 @@ "objectClass: organizationalUnit", "ou: People"); InternalClientConnection conn = InternalClientConnection.getRootConnection(); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), entry.getUserAttributes(), entry.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(entry); assertEquals(addOperation.getResultCode(), ResultCode.BUSY); } finally @@ -2483,9 +2281,6 @@ { TestCaseUtils.initializeTestBackend(false); InternalClientConnection conn = InternalClientConnection.getRootConnection(); List<Control> controls = ShortCircuitPlugin.createShortCircuitControlList(0, "PreParse"); @@ -2498,7 +2293,7 @@ rawAttrs.add(RawAttribute.create("o", "test")); AddOperationBasis addOperation = new AddOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), new AddOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), controls, ByteString.valueOf("o=test"), rawAttrs); addOperation.run(); assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/DeleteOperationTestCase.java
@@ -26,9 +26,6 @@ */ package org.opends.server.core; import static org.opends.server.protocols.ldap.LDAPConstants.*; import static org.testng.Assert.*; import java.net.Socket; import java.util.ArrayList; import java.util.List; @@ -54,8 +51,12 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.Test; import static org.opends.server.protocols.internal.InternalClientConnection.*; import static org.opends.server.protocols.ldap.LDAPConstants.*; import static org.testng.Assert.*; /** * A set of test cases for delete operations * A set of test cases for delete operations. */ @SuppressWarnings("javadoc") public class DeleteOperationTestCase extends OperationTestCase @@ -64,13 +65,11 @@ /** Some of the tests disable the backends, so we reenable them here. */ @AfterMethod(alwaysRun=true) public void reenableBackend() throws DirectoryException { Backend b = DirectoryServer.getBackend(DN.valueOf("o=test")); Backend<?> b = DirectoryServer.getBackend(DN.valueOf("o=test")); b.setWritabilityMode(WritabilityMode.ENABLED); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override() protected Operation[] createTestOperations() throws Exception @@ -93,9 +92,7 @@ List<Control> requestControls, ByteString rawEntryDn) { return new DeleteOperationBasis( InternalClientConnection.getRootConnection(), InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), getRootConnection(), nextOperationID(), nextMessageID(), requestControls, rawEntryDn); } @@ -103,9 +100,7 @@ List<Control> requestControls, DN entryDn) { return new DeleteOperationBasis( InternalClientConnection.getRootConnection(), InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), getRootConnection(), nextOperationID(), nextMessageID(), requestControls, entryDn); } @@ -198,10 +193,6 @@ assertTrue(deleteOperation.getProcessingStopTime() >= deleteOperation.getProcessingStartTime()); assertTrue(deleteOperation.getProcessingTime() >= 0); long changeNumber = deleteOperation.getChangeNumber(); deleteOperation.setChangeNumber(changeNumber); } @@ -222,7 +213,7 @@ assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS); retrieveCompletedOperationElements(deleteOperation); List<LocalBackendDeleteOperation> localOps = (List) (deleteOperation.getAttachment(Operation.LOCALBACKENDOPERATIONS)); (List) deleteOperation.getAttachment(Operation.LOCALBACKENDOPERATIONS); assertNotNull(localOps); for (LocalBackendDeleteOperation curOp : localOps) { @@ -232,26 +223,20 @@ private DeleteOperation processDeleteRaw(String entryDN) { InternalClientConnection conn = InternalClientConnection.getRootConnection(); InternalClientConnection conn =getRootConnection(); return conn.processDelete(ByteString.valueOf(entryDN)); } private DeleteOperation processDelete(String entryDN) throws DirectoryException { InternalClientConnection conn = InternalClientConnection.getRootConnection(); InternalClientConnection conn =getRootConnection(); return conn.processDelete(DN.valueOf(entryDN)); } private void processAdd(String... entryLines) throws Exception { Entry e = TestCaseUtils.makeEntry(entryLines); InternalClientConnection conn = InternalClientConnection.getRootConnection(); AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(), e.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(e); assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); } @@ -270,7 +255,7 @@ DeleteOperation deleteOperation = processDeleteRaw("ou=People,o=test"); assertFalse(deleteOperation.getResultCode() == ResultCode.SUCCESS); List<LocalBackendDeleteOperation> localOps = (List) (deleteOperation.getAttachment(Operation.LOCALBACKENDOPERATIONS)); (List) deleteOperation.getAttachment(Operation.LOCALBACKENDOPERATIONS); assertNotNull(localOps); for (LocalBackendDeleteOperation curOp : localOps) { @@ -625,7 +610,7 @@ { TestCaseUtils.initializeTestBackend(true); Backend backend = DirectoryServer.getBackend(DN.valueOf("o=test")); Backend<?> backend = DirectoryServer.getBackend(DN.valueOf("o=test")); backend.setWritabilityMode(WritabilityMode.DISABLED); DeleteOperation deleteOperation = processDeleteRaw("o=test"); @@ -648,7 +633,7 @@ { TestCaseUtils.initializeTestBackend(true); Backend backend = DirectoryServer.getBackend(DN.valueOf("o=test")); Backend<?> backend = DirectoryServer.getBackend(DN.valueOf("o=test")); backend.setWritabilityMode(WritabilityMode.INTERNAL_ONLY); DeleteOperation deleteOperation = processDeleteRaw("o=test"); @@ -671,7 +656,7 @@ { TestCaseUtils.initializeTestBackend(true); Backend backend = DirectoryServer.getBackend(DN.valueOf("o=test")); Backend<?> backend = DirectoryServer.getBackend(DN.valueOf("o=test")); backend.setWritabilityMode(WritabilityMode.INTERNAL_ONLY); String[] args = getArgs("o=test"); opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/ModifyOperationTestCase.java
@@ -56,11 +56,12 @@ import org.testng.annotations.*; import static org.opends.server.TestCaseUtils.*; import static org.opends.server.protocols.internal.InternalClientConnection.*; import static org.opends.server.protocols.ldap.LDAPConstants.*; import static org.testng.Assert.*; /** * A set of test cases for modify operations * A set of test cases for modify operations. */ @SuppressWarnings("javadoc") public class ModifyOperationTestCase @@ -72,14 +73,13 @@ TestCaseUtils.restartServer(); } // Some of the tests disable the backends, so we reenable them here. /** Some of the tests disable the backends, so we reenable them here. */ @AfterMethod(alwaysRun=true) public void reenableBackend() throws DirectoryException { Object[][] backendBaseDNs = getBaseDNs(); for (Object[] backendBaseDN2 : backendBaseDNs) for (Object[] backendBaseDN2 : getBaseDNs()) { String backendBaseDN = backendBaseDN2[0].toString(); Backend b = DirectoryServer.getBackend(DN.valueOf(backendBaseDN)); final DN baseDN = DN.valueOf(backendBaseDN2[0].toString()); Backend<?> b = DirectoryServer.getBackend(baseDN); b.setWritabilityMode(WritabilityMode.ENABLED); } } @@ -213,9 +213,7 @@ DN entryDn, List<Modification> modifications) { return new ModifyOperationBasis( InternalClientConnection.getRootConnection(), InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), getRootConnection(), nextOperationID(), nextMessageID(), requestControls, entryDn, modifications); } @@ -223,9 +221,7 @@ ByteString rawEntryDn, List<RawModification> rawModifications) { return new ModifyOperationBasis( InternalClientConnection.getRootConnection(), InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), getRootConnection(), nextOperationID(), nextMessageID(), requestControls, rawEntryDn, rawModifications); } @@ -244,9 +240,7 @@ } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override() protected Operation[] createTestOperations() throws Exception @@ -378,8 +372,7 @@ modifyOperation.addRawModification(replace(attr)); assertEquals(modifyOperation.getRawModifications().size(), (rawMods.size() + 1)); assertEquals(modifyOperation.getRawModifications().size(), rawMods.size() + 1); modifyOperation.setRawModifications(rawMods); assertEquals(modifyOperation.getRawModifications().size(), rawMods.size()); @@ -403,7 +396,7 @@ assertTrue(modifyOperation.getProcessingTime() >= 0); List<LocalBackendModifyOperation> localOps = (List) (modifyOperation.getAttachment(Operation.LOCALBACKENDOPERATIONS)); (List) modifyOperation.getAttachment(Operation.LOCALBACKENDOPERATIONS); assertNotNull(localOps); for (LocalBackendModifyOperation curOp : localOps) { @@ -412,9 +405,6 @@ assertNotNull(curOp.getCurrentEntry()); assertNotNull(curOp.getModifiedEntry()); } long changeNumber = modifyOperation.getChangeNumber(); modifyOperation.setChangeNumber(changeNumber); } @@ -433,9 +423,6 @@ assertTrue(modifyOperation.getProcessingStopTime() >= modifyOperation.getProcessingStartTime()); assertTrue(modifyOperation.getProcessingTime() >= 0); long changeNumber = modifyOperation.getChangeNumber(); modifyOperation.setChangeNumber(changeNumber); } @@ -459,15 +446,12 @@ Attributes.create("description", "foo"))); InternalClientConnection conn = InternalClientConnection.getRootConnection(); List<Modification> mods = new ArrayList<Modification>(); mods.add(new Modification(ModificationType.REPLACE, Attributes.create("l", "Austin"))); ModifyOperation modifyOperation = conn.processModify(DN.valueOf("o=test"), mods); getRootConnection().processModify(DN.valueOf("o=test"), mods); assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); retrieveSuccessfulOperationElements(modifyOperation); @@ -798,34 +782,27 @@ private ModifyOperation processModify(String entryDN, List<RawModification> mods) { InternalClientConnection conn = InternalClientConnection.getRootConnection(); InternalClientConnection conn = getRootConnection(); return conn.processModify(ByteString.valueOf(entryDN), mods); } private ModifyOperation processModify(String entryDN, RawModification... mods) { InternalClientConnection conn = InternalClientConnection.getRootConnection(); InternalClientConnection conn = getRootConnection(); return conn.processModify(ByteString.valueOf(entryDN), Arrays.asList(mods)); } private ModifyOperation processModify(String entryDN, List<RawModification> mods, List<Control> requestControls) { InternalClientConnection conn = InternalClientConnection.getRootConnection(); InternalClientConnection conn = getRootConnection(); return conn.processModify(ByteString.valueOf(entryDN), mods, requestControls); } private void processAdd(String... entryLines) throws Exception { Entry entry = TestCaseUtils.makeEntry(entryLines); InternalClientConnection conn = InternalClientConnection.getRootConnection(); AddOperation addOperation = conn.processAdd(entry.getName(), entry.getObjectClasses(), entry .getUserAttributes(), entry.getOperationalAttributes()); AddOperation addOperation = getRootConnection().processAdd(entry); assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); } @@ -1430,9 +1407,7 @@ InternalSearchOperation searchOperation = new InternalSearchOperation( InternalClientConnection.getRootConnection(), InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), getRootConnection(), nextOperationID(), nextMessageID(), new ArrayList<Control>(), ByteString.valueOf("uid=test.user," + baseDN), SearchScope.WHOLE_SUBTREE, @@ -1482,9 +1457,7 @@ InternalSearchOperation searchOperation = new InternalSearchOperation( InternalClientConnection.getRootConnection(), InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), getRootConnection(), nextOperationID(), nextMessageID(), new ArrayList<Control>(), ByteString.valueOf(baseDN), SearchScope.WHOLE_SUBTREE, @@ -1537,9 +1510,7 @@ InternalSearchOperation searchOperation = new InternalSearchOperation( InternalClientConnection.getRootConnection(), InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), getRootConnection(), nextOperationID(), nextMessageID(), new ArrayList<Control>(), ByteString.valueOf(baseDN), SearchScope.WHOLE_SUBTREE, @@ -2622,7 +2593,7 @@ "mail: foo", "employeeNumber: 1"); Backend b = DirectoryServer.getBackend(DN.valueOf(baseDN)); Backend<?> b = DirectoryServer.getBackend(DN.valueOf(baseDN)); b.setWritabilityMode(WritabilityMode.DISABLED); LDAPAttribute attr = newLDAPAttribute("objectClass", "extensibleObject"); @@ -2660,7 +2631,7 @@ "mail: foo", "employeeNumber: 1"); Backend b = DirectoryServer.getBackend(DN.valueOf(baseDN)); Backend<?> b = DirectoryServer.getBackend(DN.valueOf(baseDN)); b.setWritabilityMode(WritabilityMode.INTERNAL_ONLY); LDAPAttribute attr = newLDAPAttribute("objectClass", "extensibleObject"); @@ -2698,7 +2669,7 @@ "mail: foo", "employeeNumber: 1"); Backend b = DirectoryServer.getBackend(DN.valueOf(baseDN)); Backend<?> b = DirectoryServer.getBackend(DN.valueOf(baseDN)); b.setWritabilityMode(WritabilityMode.INTERNAL_ONLY); @@ -3564,7 +3535,7 @@ "cn: Test User", "userPassword: password", "userPassword;deleted: oldpassword"); Backend backend = DirectoryServer.getBackend(TEST_BACKEND_ID); Backend<?> backend = DirectoryServer.getBackend(TEST_BACKEND_ID); backend.addEntry(e, null); // Don't use add operation. // Constraint violation. @@ -3606,7 +3577,7 @@ "cn: Test User", "userPassword: password", "userPassword;deleted: oldpassword"); Backend backend = DirectoryServer.getBackend(TEST_BACKEND_ID); Backend<?> backend = DirectoryServer.getBackend(TEST_BACKEND_ID); backend.addEntry(e, null); // Don't use add operation. // Constraint violation.