| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | * |
| | | * @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 |
| | |
| | | * |
| | | * @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 |
| | |
| | | * @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 |
| | |
| | | * @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 |
| | |
| | | * @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 |
| | |
| | | * |
| | | * @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 |
| | |
| | | * @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 |
| | |
| | | * @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 |
| | |
| | | * |
| | | * @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 |
| | |
| | | * @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 |
| | |
| | | * @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 |
| | |
| | | * |
| | | * @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. |
| | |
| | | * @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 |
| | |
| | | * 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 |
| | |
| | | * authorization has been requested, or {@code null} if proxied |
| | | * authorization has not been requested. |
| | | */ |
| | | public abstract void setProxiedAuthorizationDN(DN proxiedAuthorizationDN); |
| | | void setProxiedAuthorizationDN(DN proxiedAuthorizationDN); |
| | | |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2013 ForgeRock AS |
| | | * Portions copyright 2013-2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | /** 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; |
| | | |
| | |
| | | operationalAttributes = null; |
| | | objectClasses = null; |
| | | proxiedAuthorizationDN = null; |
| | | changeNumber = -1; |
| | | } |
| | | |
| | | |
| | |
| | | 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) |
| | | { |
| | |
| | | entryDN = null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final DN getEntryDN() |
| | | { |
| | |
| | | return entryDN; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final List<RawAttribute> getRawAttributes() |
| | | { |
| | | return rawAttributes; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void addRawAttribute(RawAttribute rawAttribute) |
| | | { |
| | |
| | | operationalAttributes = null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void setRawAttributes(List<RawAttribute> rawAttributes) |
| | | { |
| | |
| | | operationalAttributes = null; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final Map<ObjectClass,String> getObjectClasses() |
| | | { |
| | |
| | | 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() |
| | | { |
| | |
| | | return userAttributes; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final Map<AttributeType,List<Attribute>> getOperationalAttributes() |
| | | { |
| | |
| | | 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( |
| | | String.valueOf(entryDN), |
| | | attr.getName())); |
| | | } |
| | | throw new LDAPException(LDAPResultCode.UNDEFINED_ATTRIBUTE_TYPE, |
| | | ERR_ADD_ATTR_IS_INVALID_OPTION.get(String.valueOf(entryDN), attr.getName())); |
| | | } |
| | | |
| | | if (attrType.isObjectClassType()) |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void setAttribute(AttributeType attributeType, |
| | | List<Attribute> attributeList) |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@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) |
| | | { |
| | |
| | | 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() |
| | | { |
| | |
| | | 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) |
| | | { |
| | |
| | | buffer.append(")"); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void setProxiedAuthorizationDN(DN proxiedAuthorizationDN) |
| | | { |
| | | this.proxiedAuthorizationDN = proxiedAuthorizationDN; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void run() |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013 ForgeRock AS |
| | | * Portions Copyright 2013-2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | |
| | | import org.opends.server.types.*; |
| | | |
| | | |
| | | /** |
| | | * This abstract class wraps/decorates a given add operation. |
| | | * This class will be extended by sub-classes to enhance the |
| | |
| | | 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) |
| | |
| | | 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) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | * |
| | | * @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. |
| | |
| | | * @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 |
| | |
| | | * @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 |
| | |
| | | * 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 |
| | |
| | | * authorization has been requested, or {@code null} if proxied |
| | | * authorization has not been requested. |
| | | */ |
| | | public abstract void setProxiedAuthorizationDN(DN proxiedAuthorizationDN); |
| | | void setProxiedAuthorizationDN(DN proxiedAuthorizationDN); |
| | | |
| | | |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2013 ForgeRock AS |
| | | * Portions copyright 2013-2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | import org.opends.server.types.*; |
| | | 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 |
| | |
| | | /** 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. |
| | | * |
| | |
| | | entryDN = null; |
| | | responseControls = new ArrayList<Control>(); |
| | | cancelRequest = null; |
| | | changeNumber = -1; |
| | | } |
| | | |
| | | |
| | |
| | | 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) |
| | | { |
| | |
| | | entryDN = null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final DN getEntryDN() |
| | | { |
| | |
| | | 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() |
| | | { |
| | |
| | | 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) |
| | | { |
| | |
| | | buffer.append(rawEntryDN); |
| | | buffer.append(")"); |
| | | } |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void setProxiedAuthorizationDN(DN proxiedAuthorizationDN) |
| | | { |
| | | this.proxiedAuthorizationDN = proxiedAuthorizationDN; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void run() |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013 ForgeRock AS |
| | | * Portions Copyright 2013-2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | |
| | | import org.opends.server.types.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 |
| | |
| | | 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) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | * |
| | | * @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. |
| | |
| | | * @param rawEntryDN The raw, unprocessed entry DN as included in the client |
| | | * request. |
| | | */ |
| | | public void setRawEntryDN(ByteString rawEntryDN); |
| | | void setRawEntryDN(ByteString rawEntryDN); |
| | | |
| | | |
| | | /** |
| | |
| | | * @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 |
| | |
| | | * @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 |
| | |
| | | * @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 |
| | |
| | | * @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(); |
| | | |
| | | |
| | | /** |
| | |
| | | * @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. |
| | |
| | | * @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 |
| | |
| | | * @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 |
| | |
| | | * @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 |
| | |
| | | * 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. |
| | |
| | | * @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 |
| | |
| | | * 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 |
| | |
| | | * @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 |
| | |
| | | * @return The current entry, or <CODE>null</CODE> if it is not yet |
| | | * available. |
| | | */ |
| | | public Entry getOriginalEntry(); |
| | | Entry getOriginalEntry(); |
| | | |
| | | |
| | | /** |
| | |
| | | * @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 |
| | |
| | | * authorization has been requested, or {@code null} if proxied |
| | | * authorization has not been requested. |
| | | */ |
| | | public DN getProxiedAuthorizationDN(); |
| | | DN getProxiedAuthorizationDN(); |
| | | |
| | | |
| | | /** |
| | |
| | | * authorization has been requested, or {@code null} if proxied |
| | | * authorization has not been requested. |
| | | */ |
| | | public void setProxiedAuthorizationDN(DN dn); |
| | | void setProxiedAuthorizationDN(DN dn); |
| | | |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2013 ForgeRock AS. |
| | | * Portions copyright 2011-2014 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.server.loggers.AccessLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.operation.PostResponseModifyDNOperation; |
| | | import org.opends.server.types.operation.PreParseModifyDNOperation; |
| | | import org.opends.server.workflowelement.localbackend.*; |
| | | import org.opends.server.workflowelement.localbackend.LocalBackendModifyDNOperation; |
| | | |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.server.loggers.AccessLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | |
| | | /** |
| | | * This class defines an operation that may be used to alter the DN of an entry |
| | |
| | | */ |
| | | 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. |
| | |
| | | responseControls = new ArrayList<Control>(); |
| | | cancelRequest = null; |
| | | modifications = null; |
| | | changeNumber = -1; |
| | | } |
| | | |
| | | |
| | |
| | | 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) |
| | | { |
| | |
| | | entryDN = null; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final DN getEntryDN() |
| | | { |
| | |
| | | return entryDN; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final ByteString getRawNewRDN() |
| | | { |
| | | return rawNewRDN; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void setRawNewRDN(ByteString rawNewRDN) |
| | | { |
| | |
| | | newDN = null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final RDN getNewRDN() |
| | | { |
| | |
| | | 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) |
| | | { |
| | |
| | | newDN = null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final DN getNewSuperior() |
| | | { |
| | |
| | | return newSuperior; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final List<Modification> getModifications() |
| | | { |
| | | return modifications; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void addModification(Modification modification) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@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 |
| | |
| | | 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); |
| | |
| | | String.valueOf(entryDN))); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override() |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void toString(StringBuilder buffer) |
| | | { |
| | | buffer.append("ModifyDNOperation(connID="); |
| | |
| | | buffer.append(")"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void setProxiedAuthorizationDN(DN dn) |
| | | { |
| | | proxiedAuthorizationDN = dn; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public DN getNewDN() |
| | | { |
| | |
| | | parentDN = newSuperior; |
| | | } |
| | | |
| | | if ((parentDN == null) || parentDN.isNullDN()) |
| | | if (parentDN == null || parentDN.isNullDN()) |
| | | { |
| | | setResultCode(ResultCode.UNWILLING_TO_PERFORM); |
| | | appendErrorMessage(ERR_MODDN_NO_PARENT.get(String.valueOf(entryDN))); |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013 ForgeRock AS |
| | | * Portions Copyright 2013-2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | 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() |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | * |
| | | * @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. |
| | |
| | | * @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 |
| | |
| | | * @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 |
| | |
| | | * @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 |
| | |
| | | * @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 |
| | |
| | | * <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 |
| | |
| | | * @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 |
| | |
| | | * 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 |
| | |
| | | * authorization has been requested, or {@code null} if proxied |
| | | * authorization has not been requested. |
| | | */ |
| | | public abstract void setProxiedAuthorizationDN(DN proxiedAuthorizationDN); |
| | | void setProxiedAuthorizationDN(DN proxiedAuthorizationDN); |
| | | |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2013 ForgeRock AS. |
| | | * Portions copyright 2012-2014 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.server.loggers.AccessLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | import org.opends.server.types.*; |
| | | 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.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | |
| | | /** |
| | | * This class defines an operation that may be used to modify an entry in the |
| | |
| | | /** 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. |
| | | * |
| | |
| | | cancelRequest = null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final ByteString getRawEntryDN() |
| | | { |
| | | return rawEntryDN; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void setRawEntryDN(ByteString rawEntryDN) |
| | | { |
| | |
| | | entryDN = null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final DN getEntryDN() |
| | | { |
| | |
| | | return entryDN; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final List<RawModification> getRawModifications() |
| | | { |
| | | return rawModifications; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void addRawModification(RawModification rawModification) |
| | | { |
| | |
| | | modifications = null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void setRawModifications(List<RawModification> rawModifications) |
| | | { |
| | |
| | | modifications = null; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final List<Modification> getModifications() |
| | | { |
| | |
| | | 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( |
| | | String.valueOf(entryDN), |
| | | attr.getName())); |
| | | } |
| | | throw new LDAPException(LDAPResultCode.UNDEFINED_ATTRIBUTE_TYPE, |
| | | ERR_ADD_ATTR_IS_INVALID_OPTION.get(String.valueOf(entryDN), attr.getName())); |
| | | } |
| | | |
| | | modifications.add(mod); |
| | |
| | | return modifications; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void addModification(Modification modification) |
| | | throws DirectoryException |
| | |
| | | modifications.add(modification); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final OperationType getOperationType() |
| | | { |
| | |
| | | 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) |
| | | { |
| | |
| | | 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() |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2013 ForgeRock AS |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.opends.server.types.*; |
| | | |
| | | |
| | | /** |
| | | * This abstract class wraps/decorates a given modify operation. |
| | | * This class will be extended by sub-classes to enhance the |
| | |
| | | super(modify); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void addModification(Modification modification) |
| | | throws DirectoryException |
| | |
| | | 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); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | |
| | | |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.concurrent.CopyOnWriteArrayList; |
| | |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.ResultCode; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.types.SearchScope; |
| | | |
| | | |
| | | import static org.opends.server.controls.PersistentSearchChangeType.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | |
| | | /** |
| | | * This class defines a data structure that will be used to hold the |
| | |
| | | |
| | | |
| | | |
| | | // Cancel a persistent search. |
| | | /** Cancel a persistent search. */ |
| | | private static synchronized void cancel(PersistentSearch psearch) |
| | | { |
| | | if (!psearch.isCancelled) |
| | |
| | | } |
| | | } |
| | | |
| | | // 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; |
| | | |
| | | |
| | |
| | | this.searchOperation = searchOperation; |
| | | this.changeTypes = changeTypes; |
| | | this.returnECs = returnECs; |
| | | |
| | | this.baseDN = searchOperation.getBaseDN(); |
| | | this.scope = searchOperation.getScope(); |
| | | this.filter = searchOperation.getFilter(); |
| | | } |
| | | |
| | | |
| | |
| | | * |
| | | * @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.getDN()) |
| | | && matchesFilter(entry)) |
| | | { |
| | | return; |
| | | sendEntry(entry, createControls(ADD, null)); |
| | | } |
| | | } |
| | | |
| | | // Make sure that the entry is within our target scope. |
| | | switch (scope) |
| | | private boolean isInScope(final DN dn) |
| | | { |
| | | final DN baseDN = searchOperation.getBaseDN(); |
| | | switch (searchOperation.getScope()) |
| | | { |
| | | case BASE_OBJECT: |
| | | if (!baseDN.equals(entry.getDN())) |
| | | { |
| | | return; |
| | | } |
| | | break; |
| | | return baseDN.equals(dn); |
| | | case SINGLE_LEVEL: |
| | | if (!baseDN.equals(entry.getDN().getParentDNInSuffix())) |
| | | { |
| | | return; |
| | | } |
| | | break; |
| | | return baseDN.equals(dn.getParentDNInSuffix()); |
| | | case WHOLE_SUBTREE: |
| | | if (!baseDN.isAncestorOf(entry.getDN())) |
| | | { |
| | | return; |
| | | } |
| | | break; |
| | | return baseDN.isAncestorOf(dn); |
| | | case SUBORDINATE_SUBTREE: |
| | | if (baseDN.equals(entry.getDN()) || (!baseDN.isAncestorOf(entry.getDN()))) |
| | | { |
| | | 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 |
| | | { |
| | | TRACER.debugInfo(this + " " + entry + " +filter=" |
| | | + filter.matchesEntry(entry)); |
| | | |
| | | if (!filter.matchesEntry(entry)) |
| | | final boolean filterMatchesEntry = searchOperation.getFilter().matchesEntry(entry); |
| | | if (debugEnabled()) |
| | | { |
| | | return; |
| | | TRACER.debugInfo(this + " " + entry + " filter=" + filterMatchesEntry); |
| | | } |
| | | return filterMatchesEntry; |
| | | } |
| | | catch (DirectoryException 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) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | cancel(); |
| | | |
| | | try |
| | | { |
| | | searchOperation.sendSearchResultDone(); |
| | | } |
| | | catch (Exception e2) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, 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.getDN()) |
| | | && matchesFilter(entry)) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | // Make sure that the entry is within our target scope. |
| | | switch (scope) |
| | | { |
| | | case BASE_OBJECT: |
| | | if (!baseDN.equals(entry.getDN())) |
| | | { |
| | | return; |
| | | } |
| | | break; |
| | | case SINGLE_LEVEL: |
| | | if (!baseDN.equals(entry.getDN().getParentDNInSuffix())) |
| | | { |
| | | return; |
| | | } |
| | | break; |
| | | case WHOLE_SUBTREE: |
| | | if (!baseDN.isAncestorOf(entry.getDN())) |
| | | { |
| | | return; |
| | | } |
| | | break; |
| | | case SUBORDINATE_SUBTREE: |
| | | if (baseDN.equals(entry.getDN()) || (!baseDN.isAncestorOf(entry.getDN()))) |
| | | { |
| | | return; |
| | | } |
| | | break; |
| | | default: |
| | | return; |
| | | } |
| | | |
| | | // Make sure that the entry matches the target filter. |
| | | try |
| | | { |
| | | if (!filter.matchesEntry(entry)) |
| | | { |
| | | return; |
| | | } |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, 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) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | cancel(); |
| | | |
| | | try |
| | | { |
| | | searchOperation.sendSearchResultDone(); |
| | | } |
| | | catch (Exception e2) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e2); |
| | | } |
| | | } |
| | | sendEntry(entry, createControls(DELETE, null)); |
| | | } |
| | | } |
| | | |
| | |
| | | * |
| | | * @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); |
| | | } |
| | | |
| | | |
| | |
| | | * |
| | | * @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.getDN()) |
| | | && anyMatchesFilter(entry, oldEntry)) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | // Make sure that the entry is within our target scope. |
| | | switch (scope) |
| | | { |
| | | case BASE_OBJECT: |
| | | if (!baseDN.equals(oldEntry.getDN())) |
| | | { |
| | | return; |
| | | } |
| | | break; |
| | | case SINGLE_LEVEL: |
| | | if (!baseDN.equals(oldEntry.getDN().getParent())) |
| | | { |
| | | return; |
| | | } |
| | | break; |
| | | case WHOLE_SUBTREE: |
| | | if (!baseDN.isAncestorOf(oldEntry.getDN())) |
| | | { |
| | | return; |
| | | } |
| | | break; |
| | | case SUBORDINATE_SUBTREE: |
| | | if (baseDN.equals(oldEntry.getDN()) |
| | | || (!baseDN.isAncestorOf(oldEntry.getDN()))) |
| | | { |
| | | 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) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, 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) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | cancel(); |
| | | |
| | | try |
| | | { |
| | | searchOperation.sendSearchResultDone(); |
| | | } |
| | | catch (Exception e2) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e2); |
| | | } |
| | | } |
| | | sendEntry(entry, createControls(MODIFY, null)); |
| | | } |
| | | } |
| | | |
| | | private boolean isInScopeForModify(final DN dn) |
| | | { |
| | | final DN baseDN = searchOperation.getBaseDN(); |
| | | switch (searchOperation.getScope()) |
| | | { |
| | | case BASE_OBJECT: |
| | | return baseDN.equals(dn); |
| | | case SINGLE_LEVEL: |
| | | return baseDN.equals(dn.getParent()); |
| | | case WHOLE_SUBTREE: |
| | | return baseDN.isAncestorOf(dn); |
| | | case SUBORDINATE_SUBTREE: |
| | | 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.getDN()); |
| | | } |
| | | |
| | | switch (scope) |
| | | { |
| | | case BASE_OBJECT: |
| | | oldMatches = baseDN.equals(oldDN); |
| | | newMatches = baseDN.equals(entry.getDN()); |
| | | |
| | | if (!(oldMatches || newMatches)) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | break; |
| | | case SINGLE_LEVEL: |
| | | oldMatches = baseDN.equals(oldDN.getParent()); |
| | | newMatches = baseDN.equals(entry.getDN().getParent()); |
| | | |
| | | if (!(oldMatches || newMatches)) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | break; |
| | | case WHOLE_SUBTREE: |
| | | oldMatches = baseDN.isAncestorOf(oldDN); |
| | | newMatches = baseDN.isAncestorOf(entry.getDN()); |
| | | |
| | | if (!(oldMatches || newMatches)) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | break; |
| | | case SUBORDINATE_SUBTREE: |
| | | oldMatches = ((!baseDN.equals(oldDN)) && baseDN.isAncestorOf(oldDN)); |
| | | newMatches = ((!baseDN.equals(entry.getDN())) && baseDN |
| | | .isAncestorOf(entry.getDN())); |
| | | |
| | | 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) |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, 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)) |
| | |
| | | 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("\")"); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | if (shutdown) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | // Not suspended |
| | | doIt(); |
| | | |
| | | if (shutdown) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | suspendWriter(); |
| | | } |
| | |
| | | } |
| | | finally |
| | | { |
| | | if (session!=null) |
| | | if (session != null) |
| | | { |
| | | session.close(); |
| | | } |
| | | if (replicationServerDomain != null) |
| | | { |
| | | replicationServerDomain.stopServer(handler, false); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | 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) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, de); |
| | | } |
| | | |
| | | if (update == null) |
| | | final ECLUpdateMsg updateMsg = takeECLUpdate(handler); |
| | | if (updateMsg == null) |
| | | { |
| | | if (session != null && handler.isInitPhaseDone()) |
| | | { |
| | |
| | | } |
| | | 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) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, de); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Shutdown the writer. |
| | | */ |
| | |
| | | private void publish(ECLUpdateMsg msg) throws IOException |
| | | { |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugInfo(getName() + " publishes msg=[" + msg + "]"); |
| | | } |
| | | |
| | | if (session != null) |
| | | { |
| | |
| | | { |
| | | 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) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2013 ForgeRock AS |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.workflowelement.localbackend; |
| | | |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | |
| | | 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.loggers.ErrorLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | 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. |
| | |
| | | implements PreOperationAddOperation, PostOperationAddOperation, |
| | | PostResponseAddOperation, PostSynchronizationAddOperation |
| | | { |
| | | /** |
| | | * The tracer object for the debug logger. |
| | | */ |
| | | /** The tracer object for the debug logger. */ |
| | | private static final DebugTracer TRACER = getTracer(); |
| | | |
| | | /** |
| | | * 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. |
| | |
| | | // Notify persistent searches. |
| | | for (PersistentSearch psearch : wfe.getPersistentSearches()) |
| | | { |
| | | psearch.processAdd(entry, getChangeNumber()); |
| | | psearch.processAdd(entry); |
| | | } |
| | | |
| | | // Notify change listeners. |
| | |
| | | { |
| | | try |
| | | { |
| | | changeListener.handleAddOperation(LocalBackendAddOperation.this, |
| | | entry); |
| | | changeListener.handleAddOperation(LocalBackendAddOperation.this, entry); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | userAttributes = getUserAttributes(); |
| | | operationalAttributes = getOperationalAttributes(); |
| | | |
| | | if ((objectClasses == null) || (userAttributes == null) |
| | | || (operationalAttributes == null)) |
| | | if (objectClasses == null |
| | | || userAttributes == null |
| | | || operationalAttributes == null) |
| | | { |
| | | return; |
| | | } |
| | |
| | | if (backend == null) |
| | | { |
| | | setResultCode(ResultCode.NO_SUCH_OBJECT); |
| | | appendErrorMessage(Message.raw("No backend for entry " |
| | | + entryDN.toString())); // TODO: i18n |
| | | appendErrorMessage(Message.raw("No backend for entry " + entryDN)); // TODO: i18n |
| | | return; |
| | | } |
| | | |
| | |
| | | { |
| | | 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( |
| | | String.valueOf(entryDN), at.getNameOrOID())); |
| | | return true; |
| | | } |
| | | setResultCodeAndMessageNoInfoDisclosure(entryDN, |
| | | ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_ADD_ATTR_IS_NO_USER_MOD.get( |
| | | String.valueOf(entryDN), at.getNameOrOID())); |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | |
| | | // 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; |
| | |
| | | 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? |
| | |
| | | { |
| | | if (AuthPasswordSyntax.isEncoded(value)) |
| | | { |
| | | if (isInternalOperation() || |
| | | passwordPolicy.isAllowPreEncodedPasswords()) |
| | | if (isInternalOperation() |
| | | || passwordPolicy.isAllowPreEncodedPasswords()) |
| | | { |
| | | builder.add(v); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | addPWPolicyControl( |
| | | PasswordPolicyErrorType.INSUFFICIENT_PASSWORD_QUALITY); |
| | | addPWPolicyControl(PasswordPolicyErrorType.INSUFFICIENT_PASSWORD_QUALITY); |
| | | |
| | | Message 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(v); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | addPWPolicyControl( |
| | | PasswordPolicyErrorType.INSUFFICIENT_PASSWORD_QUALITY); |
| | | builder.add(v); |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | addPWPolicyControl(PasswordPolicyErrorType.INSUFFICIENT_PASSWORD_QUALITY); |
| | | |
| | | Message 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())); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | 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)); |
| | | } |
| | | } |
| | | } |
| | |
| | | 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 |
| | |
| | | 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(), |
| | |
| | | |
| | | Entry authorizationEntry = proxyControl.getAuthorizationEntry(); |
| | | setAuthorizationEntry(authorizationEntry); |
| | | if (authorizationEntry == null) |
| | | { |
| | | setProxiedAuthorizationDN(DN.nullDN()); |
| | | } |
| | | else |
| | | { |
| | | setProxiedAuthorizationDN(authorizationEntry.getDN()); |
| | | } |
| | | setProxiedAuthorizationDN(getDN(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. |
| | |
| | | |
| | | Entry authorizationEntry = proxyControl.getAuthorizationEntry(); |
| | | setAuthorizationEntry(authorizationEntry); |
| | | if (authorizationEntry == null) |
| | | { |
| | | setProxiedAuthorizationDN(DN.nullDN()); |
| | | } |
| | | else |
| | | { |
| | | setProxiedAuthorizationDN(authorizationEntry.getDN()); |
| | | } |
| | | setProxiedAuthorizationDN(getDN(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( |
| | | String.valueOf(entryDN), oid)); |
| | | } |
| | | throw newDirectoryException(entryDN, |
| | | ResultCode.UNAVAILABLE_CRITICAL_EXTENSION, |
| | | ERR_ADD_UNSUPPORTED_CRITICAL_CONTROL.get(String.valueOf(entryDN), oid)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private DN getDN(Entry e) |
| | | { |
| | | return e != null ? e.getDN() : DN.nullDN(); |
| | | } |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2013 ForgeRock AS |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.workflowelement.localbackend; |
| | | |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.concurrent.locks.Lock; |
| | | |
| | |
| | | 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.loggers.ErrorLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | 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. |
| | |
| | | PostResponseDeleteOperation, |
| | | PostSynchronizationDeleteOperation |
| | | { |
| | | /** |
| | | * The tracer object for the debug logger. |
| | | */ |
| | | /** The tracer object for the debug logger. */ |
| | | private static final DebugTracer TRACER = getTracer(); |
| | | |
| | | /** 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. */ |
| | |
| | | // Notify persistent searches. |
| | | for (PersistentSearch psearch : wfe.getPersistentSearches()) |
| | | { |
| | | psearch.processDelete(entry, getChangeNumber()); |
| | | psearch.processDelete(entry); |
| | | } |
| | | |
| | | // Notify change listeners. |
| | |
| | | { |
| | | try |
| | | { |
| | | changeListener.handleDeleteOperation( |
| | | LocalBackendDeleteOperation.this, entry); |
| | | changeListener.handleDeleteOperation(LocalBackendDeleteOperation.this, entry); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | Message message = |
| | | ERR_DELETE_ERROR_NOTIFYING_CHANGE_LISTENER |
| | | .get(getExceptionMessage(e)); |
| | | logError(message); |
| | | logError(ERR_DELETE_ERROR_NOTIFYING_CHANGE_LISTENER |
| | | .get(getExceptionMessage(e))); |
| | | } |
| | | } |
| | | } |
| | |
| | | // 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()) |
| | | { |
| | |
| | | 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); |
| | |
| | | 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(), |
| | |
| | | |
| | | Entry authorizationEntry = proxyControl.getAuthorizationEntry(); |
| | | setAuthorizationEntry(authorizationEntry); |
| | | if (authorizationEntry == null) |
| | | { |
| | | setProxiedAuthorizationDN(DN.nullDN()); |
| | | } |
| | | else |
| | | { |
| | | setProxiedAuthorizationDN(authorizationEntry.getDN()); |
| | | } |
| | | setProxiedAuthorizationDN(getDN(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. |
| | |
| | | |
| | | Entry authorizationEntry = proxyControl.getAuthorizationEntry(); |
| | | setAuthorizationEntry(authorizationEntry); |
| | | if (authorizationEntry == null) |
| | | { |
| | | setProxiedAuthorizationDN(DN.nullDN()); |
| | | } |
| | | else |
| | | { |
| | | setProxiedAuthorizationDN(authorizationEntry.getDN()); |
| | | } |
| | | setProxiedAuthorizationDN(getDN(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( |
| | | String.valueOf(entryDN), oid)); |
| | | } |
| | | throw newDirectoryException(entry, |
| | | ResultCode.UNAVAILABLE_CRITICAL_EXTENSION, |
| | | ERR_DELETE_UNSUPPORTED_CRITICAL_CONTROL.get(String.valueOf(entryDN), oid)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private DN getDN(Entry e) |
| | | { |
| | | return e != null ? e.getDN() : DN.nullDN(); |
| | | } |
| | | |
| | | /** |
| | | * Handle conflict resolution. |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2013 ForgeRock AS |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.workflowelement.localbackend; |
| | | |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.ListIterator; |
| | | import java.util.concurrent.locks.Lock; |
| | | |
| | | import org.opends.messages.Message; |
| | |
| | | PostResponseModifyDNOperation, |
| | | PostSynchronizationModifyDNOperation |
| | | { |
| | | /** |
| | | * The tracer object for the debug logger. |
| | | */ |
| | | /** The tracer object for the debug logger. */ |
| | | private static final DebugTracer TRACER = getTracer(); |
| | | |
| | | /** 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. */ |
| | |
| | | /** 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; |
| | | |
| | | |
| | |
| | | // Notify persistent searches. |
| | | for (PersistentSearch psearch : wfe.getPersistentSearches()) |
| | | { |
| | | psearch.processModifyDN(newEntry, getChangeNumber(), currentEntry |
| | | .getDN()); |
| | | psearch.processModifyDN(newEntry, currentEntry.getDN()); |
| | | } |
| | | |
| | | // Notify change listeners. |
| | |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | Message message = |
| | | ERR_MODDN_ERROR_NOTIFYING_CHANGE_LISTENER |
| | | .get(getExceptionMessage(e)); |
| | | logError(message); |
| | | logError(ERR_MODDN_ERROR_NOTIFYING_CHANGE_LISTENER |
| | | .get(getExceptionMessage(e))); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | // 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); |
| | |
| | | return; |
| | | } |
| | | |
| | | Backend newBackend = DirectoryServer.getBackend(newDN); |
| | | Backend<?> newBackend = DirectoryServer.getBackend(newDN); |
| | | if (newBackend == null) |
| | | { |
| | | setResultCode(ResultCode.NO_SUCH_OBJECT); |
| | |
| | | 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); |
| | |
| | | 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) |
| | | { |
| | |
| | | } |
| | | 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(), |
| | |
| | | |
| | | Entry authorizationEntry = proxyControl.getAuthorizationEntry(); |
| | | setAuthorizationEntry(authorizationEntry); |
| | | if (authorizationEntry == null) |
| | | { |
| | | setProxiedAuthorizationDN(DN.nullDN()); |
| | | } |
| | | else |
| | | { |
| | | setProxiedAuthorizationDN(authorizationEntry.getDN()); |
| | | } |
| | | setProxiedAuthorizationDN(getDN(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. |
| | |
| | | |
| | | Entry authorizationEntry = proxyControl.getAuthorizationEntry(); |
| | | setAuthorizationEntry(authorizationEntry); |
| | | if (authorizationEntry == null) |
| | | { |
| | | setProxiedAuthorizationDN(DN.nullDN()); |
| | | } |
| | | else |
| | | { |
| | | setProxiedAuthorizationDN(authorizationEntry.getDN()); |
| | | } |
| | | setProxiedAuthorizationDN(getDN(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( |
| | | String.valueOf(entryDN), oid)); |
| | | } |
| | | throw new DirectoryException( |
| | | ResultCode.UNAVAILABLE_CRITICAL_EXTENSION, |
| | | ERR_MODDN_UNSUPPORTED_CRITICAL_CONTROL.get(String.valueOf(entryDN), oid)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | private DN getDN(Entry e) |
| | | { |
| | | return e != null ? e.getDN() : DN.nullDN(); |
| | | } |
| | | |
| | | /** |
| | | * Updates the entry so that its attributes are changed to reflect the changes |
| | |
| | | |
| | | // 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( |
| | | String.valueOf(entryDN), a.getName())); |
| | | } |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_MODDN_OLD_RDN_ATTR_IS_NO_USER_MOD.get(String.valueOf(entryDN), a.getName())); |
| | | } |
| | | |
| | | List<AttributeValue> missingValues = new LinkedList<AttributeValue>(); |
| | |
| | | // 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( |
| | |
| | | // 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()) |
| | | { |
| | | MessageBuilder invalidReason = new MessageBuilder(); |
| | | if (! newEntry.conformsToSchema(null, false, true, true, |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2011 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2013 ForgeRock AS |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.workflowelement.localbackend; |
| | | |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.HashSet; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.ListIterator; |
| | | import java.util.concurrent.locks.Lock; |
| | | |
| | | import org.opends.messages.Message; |
| | |
| | | import org.opends.server.types.operation.PreOperationModifyOperation; |
| | | import org.opends.server.util.Validator; |
| | | |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | /** |
| | | * This class defines an operation used to modify an entry in a local backend |
| | | * of the Directory Server. |
| | |
| | | PostResponseModifyOperation, |
| | | PostSynchronizationModifyOperation |
| | | { |
| | | /** |
| | | * The tracer object for the debug logger. |
| | | */ |
| | | /** The tracer object for the debug logger. */ |
| | | private static final DebugTracer TRACER = getTracer(); |
| | | |
| | | /** |
| | | * 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; |
| | |
| | | * 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; |
| | |
| | | private LDAPPreReadRequestControl preReadRequest; |
| | | |
| | | /** The set of clear-text current passwords (if any were provided).*/ |
| | | private List<AttributeValue> currentPasswords = null; |
| | | private List<AttributeValue> currentPasswords; |
| | | |
| | | /** The set of clear-text new passwords (if any were provided).*/ |
| | | private List<AttributeValue> newPasswords = null; |
| | | private List<AttributeValue> 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; |
| | | |
| | | |
| | | |
| | |
| | | // Notify persistent searches. |
| | | for (PersistentSearch psearch : wfe.getPersistentSearches()) |
| | | { |
| | | psearch.processModify(modifiedEntry, getChangeNumber(), |
| | | currentEntry); |
| | | psearch.processModify(modifiedEntry, currentEntry); |
| | | } |
| | | |
| | | // Notify change listeners. |
| | |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | Message message = ERR_MODIFY_ERROR_NOTIFYING_CHANGE_LISTENER |
| | | .get(getExceptionMessage(e)); |
| | | logError(message); |
| | | logError(ERR_MODIFY_ERROR_NOTIFYING_CHANGE_LISTENER |
| | | .get(getExceptionMessage(e))); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (modifications.isEmpty()) |
| | | { |
| | | setResultCode(ResultCode.CONSTRAINT_VIOLATION); |
| | | appendErrorMessage(ERR_MODIFY_NO_MODIFICATIONS.get(String |
| | | .valueOf(entryDN))); |
| | | appendErrorMessage(ERR_MODIFY_NO_MODIFICATIONS.get(String.valueOf(entryDN))); |
| | | return; |
| | | } |
| | | |
| | |
| | | if (entryLock == null) |
| | | { |
| | | setResultCode(ResultCode.BUSY); |
| | | appendErrorMessage(ERR_MODIFY_CANNOT_LOCK_ENTRY.get( |
| | | String.valueOf(entryDN))); |
| | | appendErrorMessage(ERR_MODIFY_CANNOT_LOCK_ENTRY.get(String.valueOf(entryDN))); |
| | | return; |
| | | } |
| | | |
| | |
| | | if (currentEntry == null) |
| | | { |
| | | setResultCode(ResultCode.NO_SUCH_OBJECT); |
| | | appendErrorMessage(ERR_MODIFY_NO_SUCH_ENTRY |
| | | .get(String.valueOf(entryDN))); |
| | | appendErrorMessage(ERR_MODIFY_NO_SUCH_ENTRY.get(String.valueOf(entryDN))); |
| | | |
| | | // See if one of the entry's ancestors exists. |
| | | setMatchedDN(findMatchedDN(entryDN)); |
| | |
| | | |
| | | // Check that the authorizing account isn't required to change its |
| | | // password. |
| | | if ((!isInternalOperation()) && !selfChange |
| | | if (!isInternalOperation() |
| | | && !selfChange |
| | | && getAuthorizationEntry() != null) |
| | | { |
| | | AuthenticationPolicy authzPolicy = |
| | |
| | | handleInitialPasswordPolicyProcessing(); |
| | | performAdditionalPasswordChangedProcessing(); |
| | | |
| | | if ((!passwordChanged) && (!isInternalOperation()) && selfChange |
| | | if (!passwordChanged && !isInternalOperation() && selfChange |
| | | && pwPolicyState != null && pwPolicyState.mustChangePassword()) |
| | | { |
| | | // The user did not attempt to change their password. |
| | |
| | | // 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()) |
| | | { |
| | | MessageBuilder invalidReason = new MessageBuilder(); |
| | | 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(String |
| | |
| | | * @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)) |
| | |
| | | } |
| | | else if (oid.equals(OID_LDAP_READENTRY_PREREAD)) |
| | | { |
| | | preReadRequest = |
| | | getRequestControl(LDAPPreReadRequestControl.DECODER); |
| | | preReadRequest = getRequestControl(LDAPPreReadRequestControl.DECODER); |
| | | } |
| | | else if (oid.equals(OID_LDAP_READENTRY_POSTREAD)) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | postReadRequest = |
| | | getRequestControl(LDAPPostReadRequestControl.DECODER); |
| | | requestControls.set(i, postReadRequest); |
| | | postReadRequest = getRequestControl(LDAPPostReadRequestControl.DECODER); |
| | | iter.set(postReadRequest); |
| | | } |
| | | } |
| | | else if (oid.equals(OID_PROXIED_AUTH_V1)) |
| | |
| | | |
| | | Entry authorizationEntry = proxyControl.getAuthorizationEntry(); |
| | | setAuthorizationEntry(authorizationEntry); |
| | | if (authorizationEntry == null) |
| | | { |
| | | setProxiedAuthorizationDN(DN.nullDN()); |
| | | } |
| | | else |
| | | { |
| | | setProxiedAuthorizationDN(authorizationEntry.getDN()); |
| | | } |
| | | setProxiedAuthorizationDN(getDN(authorizationEntry)); |
| | | } |
| | | else if (oid.equals(OID_PROXIED_AUTH_V2)) |
| | | { |
| | |
| | | |
| | | Entry authorizationEntry = proxyControl.getAuthorizationEntry(); |
| | | setAuthorizationEntry(authorizationEntry); |
| | | if (authorizationEntry == null) |
| | | { |
| | | setProxiedAuthorizationDN(DN.nullDN()); |
| | | } |
| | | else |
| | | { |
| | | setProxiedAuthorizationDN(authorizationEntry.getDN()); |
| | | } |
| | | setProxiedAuthorizationDN(getDN(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( |
| | | String.valueOf(entryDN), oid)); |
| | | } |
| | | throw newDirectoryException(currentEntry, |
| | | ResultCode.UNAVAILABLE_CRITICAL_EXTENSION, |
| | | ERR_MODIFY_UNSUPPORTED_CRITICAL_CONTROL.get(String.valueOf(entryDN), oid)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | private DN getDN(Entry e) |
| | | { |
| | | return e != null ? e.getDN() : DN.nullDN(); |
| | | } |
| | | |
| | | /** |
| | | * 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(); |
| | |
| | | |
| | | |
| | | // 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( |
| | | String.valueOf(entryDN), a.getName())); |
| | | } |
| | | throw newDirectoryException(currentEntry, |
| | | ResultCode.CONSTRAINT_VIOLATION, ERR_MODIFY_ATTR_IS_NO_USER_MOD |
| | | .get(String.valueOf(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( |
| | | String.valueOf(entryDN), a.getName())); |
| | | } |
| | | } |
| | | throw newDirectoryException(currentEntry, |
| | | ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_MODIFY_ATTR_IS_OBSOLETE.get(String.valueOf(entryDN), a.getName())); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | // 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()) |
| | | { |
| | |
| | | * @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; |
| | |
| | | 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 |
| | |
| | | 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; |
| | | } |
| | | } |
| | |
| | | // 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()) |
| | |
| | | } |
| | | |
| | | // 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, |
| | |
| | | |
| | | // 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, |
| | |
| | | |
| | | for (ByteString s : pwPolicyState.encodePassword(v.getValue())) |
| | | { |
| | | builder.add(AttributeValues.create( |
| | | pwAttr.getAttributeType(), s)); |
| | | builder.add(AttributeValues.create(pwAttr.getAttributeType(), s)); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | if (pwPolicyState.passwordIsPreEncoded(v.getValue())) |
| | | { |
| | | if ((!isInternalOperation()) && selfChange) |
| | | if (!isInternalOperation() && selfChange) |
| | | { |
| | | pwpErrorType = PasswordPolicyErrorType.INSUFFICIENT_PASSWORD_QUALITY; |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | |
| | | { |
| | | // 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()); |
| | |
| | | } |
| | | 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, |
| | |
| | | // 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) |
| | |
| | | AttributeType t = attr.getAttributeType(); |
| | | |
| | | RDN rdn = modifiedEntry.getDN().getRDN(); |
| | | 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, |
| | |
| | | String.valueOf(entryDN), attr.getName())); |
| | | } |
| | | } |
| | | else |
| | | else if (!permissiveModify) |
| | | { |
| | | if (! permissiveModify) |
| | | { |
| | | String missingValuesStr = collectionToString(missingValues, ", "); |
| | | String missingValuesStr = collectionToString(missingValues, ", "); |
| | | |
| | | throw newDirectoryException(currentEntry, |
| | | ResultCode.NO_SUCH_ATTRIBUTE, |
| | | ERR_MODIFY_DELETE_MISSING_VALUES.get( |
| | | String.valueOf(entryDN), attr.getName(), missingValuesStr)); |
| | | } |
| | | throw newDirectoryException(currentEntry, |
| | | ResultCode.NO_SUCH_ATTRIBUTE, |
| | | ERR_MODIFY_DELETE_MISSING_VALUES.get( |
| | | String.valueOf(entryDN), attr.getName(), missingValuesStr)); |
| | | } |
| | | } |
| | | else |
| | | else if (!permissiveModify) |
| | | { |
| | | if (! permissiveModify) |
| | | { |
| | | throw newDirectoryException(currentEntry, ResultCode.NO_SUCH_ATTRIBUTE, |
| | | ERR_MODIFY_DELETE_NO_SUCH_ATTR.get( |
| | | String.valueOf(entryDN), attr.getName())); |
| | | } |
| | | throw newDirectoryException(currentEntry, ResultCode.NO_SUCH_ATTRIBUTE, |
| | | ERR_MODIFY_DELETE_NO_SUCH_ATTR.get(String.valueOf(entryDN), attr.getName())); |
| | | } |
| | | } |
| | | |
| | |
| | | // 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(); |
| | |
| | | // Make sure that the RDN attribute value(s) has not been removed. |
| | | AttributeType t = attr.getAttributeType(); |
| | | RDN rdn = modifiedEntry.getDN().getRDN(); |
| | | 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(String.valueOf(entryDN), attr |
| | | .getName())); |
| | | ERR_MODIFY_DELETE_RDN_ATTR.get(String.valueOf(entryDN), attr.getName())); |
| | | } |
| | | } |
| | | |
| | |
| | | // The specified attribute type must not be an RDN attribute. |
| | | AttributeType t = attr.getAttributeType(); |
| | | RDN rdn = modifiedEntry.getDN().getRDN(); |
| | | 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(String.valueOf(entryDN), |
| | | attr.getName())); |
| | | ERR_MODIFY_INCREMENT_RDN.get(String.valueOf(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, |
| | | ERR_MODIFY_INCREMENT_REQUIRES_VALUE.get(String.valueOf(entryDN), attr |
| | | .getName())); |
| | | ERR_MODIFY_INCREMENT_REQUIRES_VALUE.get(String.valueOf(entryDN), attr.getName())); |
| | | } |
| | | |
| | | if (attr.size() > 1) |
| | |
| | | |
| | | // 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; |
| | | |
| | |
| | | |
| | | // 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, |
| | |
| | | |
| | | |
| | | // 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) |
| | | { |
| | |
| | | if (! pwPolicyState.passwordIsAcceptable(this, modifiedEntry, |
| | | v.getValue(), 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)); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | for (AttributeValue v : newPasswords) |
| | | { |
| | | if (pwPolicyState.isPasswordInHistory(v.getValue())) |
| | | if (pwPolicyState.isPasswordInHistory(v.getValue()) |
| | | && (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()); |
| | | } |
| | | } |
| | | |
| | |
| | | pwPolicyState.clearGraceLoginTimes(); |
| | | pwPolicyState.clearWarnedTime(); |
| | | |
| | | if (pwPolicyState.getAuthenticationPolicy().isForceChangeOnAdd() || |
| | | pwPolicyState.getAuthenticationPolicy().isForceChangeOnReset()) |
| | | if (authPolicy.isForceChangeOnAdd() || authPolicy.isForceChangeOnReset()) |
| | | { |
| | | if (selfChange) |
| | | { |
| | |
| | | } |
| | | 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(); |
| | | } |
| | |
| | | * Handles any account status notifications that may be needed as a result of |
| | | * modify processing. |
| | | */ |
| | | protected void handleAccountStatusNotifications() |
| | | private void handleAccountStatusNotifications() |
| | | { |
| | | if (pwPolicyState == null) |
| | | { |
| | |
| | | * @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 { |
| | |
| | | * @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 { |
| | |
| | | /** |
| | | * Invoke post operation synchronization providers. |
| | | */ |
| | | protected void processSynchPostOperationPlugins() { |
| | | private void processSynchPostOperationPlugins() { |
| | | for (SynchronizationProvider<?> provider : |
| | | DirectoryServer.getSynchronizationProviders()) { |
| | | try { |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2013 ForgeRock AS. |
| | | * Portions copyright 2011-2014 ForgeRock AS. |
| | | */ |
| | | 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; |
| | |
| | | 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 |
| | | { |
| | |
| | | /** 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.decode("o=test")); |
| | | Backend<?> b = DirectoryServer.getBackend(DN.decode("o=test")); |
| | | b.setWritabilityMode(WritabilityMode.ENABLED); |
| | | } |
| | | |
| | |
| | | public Object[][] getAddOperations() |
| | | throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | ArrayList<Control> noControls = new ArrayList<Control>(); |
| | | |
| | | ArrayList<RawAttribute> ldapAttrList = new ArrayList<RawAttribute>(); |
| | |
| | | |
| | | 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.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()), |
| | | new AddOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | new AddOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), |
| | | noControls, entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()), |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | protected Operation[] createTestOperations() |
| | | throws Exception |
| | |
| | | @Test() |
| | | public void testGetEntryDNInitiallyNull() |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | ArrayList<RawAttribute> ldapAttrList = new ArrayList<RawAttribute>(); |
| | | |
| | | ArrayList<ByteString> values = new ArrayList<ByteString>(); |
| | |
| | | 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()); |
| | |
| | | public void testGetEntryDNInitiallyNonNull() |
| | | throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: ou=People,o=test", |
| | | "objectClass: top", |
| | |
| | | "ou: People"); |
| | | |
| | | AddOperationBasis addOperation = |
| | | new AddOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | new AddOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), |
| | | null, entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | |
| | | public void testGetEntryDNNonNullChangedToNull() |
| | | throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: ou=People,o=test", |
| | | "objectClass: top", |
| | |
| | | "ou: People"); |
| | | |
| | | AddOperationBasis addOperation = |
| | | new AddOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | new AddOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), |
| | | null, entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | |
| | | 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; |
| | | } |
| | | |
| | | |
| | |
| | | "objectClass: organizationalUnit", |
| | | "ou: People"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | UpdatePreOpPlugin.reset(); |
| | | |
| | | ObjectClass oc = DirectoryServer.getObjectClass("extensibleobject", true); |
| | | UpdatePreOpPlugin.addObjectClassToAdd(oc); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | retrieveCompletedOperationElements(addOperation); |
| | | |
| | |
| | | "objectClass: extensibleObject", |
| | | "ou: People"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | UpdatePreOpPlugin.reset(); |
| | | |
| | | ObjectClass oc = DirectoryServer.getObjectClass("extensibleobject", true); |
| | | UpdatePreOpPlugin.addObjectClassToRemove(oc); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | retrieveCompletedOperationElements(addOperation); |
| | | |
| | |
| | | "ou: People", |
| | | "description: foo"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | UpdatePreOpPlugin.reset(); |
| | | |
| | | Attribute a = Attributes.create("description", "bar"); |
| | | UpdatePreOpPlugin.addAttributeToSet(a); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | retrieveCompletedOperationElements(addOperation); |
| | | |
| | |
| | | "objectClass: organizationalUnit", |
| | | "ou: People"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | UpdatePreOpPlugin.reset(); |
| | | |
| | | Attribute a = Attributes.create("description", "foo"); |
| | | UpdatePreOpPlugin.addAttributeToSet(a); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | retrieveCompletedOperationElements(addOperation); |
| | | |
| | |
| | | "ou: People", |
| | | "description: foo"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | UpdatePreOpPlugin.reset(); |
| | | |
| | | AttributeType attrType = DirectoryServer.getAttributeType("description", |
| | | true); |
| | | UpdatePreOpPlugin.addAttributeToRemove(attrType); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | retrieveCompletedOperationElements(addOperation); |
| | | |
| | |
| | | assertTrue(addOperation.getProcessingStopTime() >= |
| | | addOperation.getProcessingStartTime()); |
| | | assertTrue(addOperation.getProcessingTime() >= 0); |
| | | |
| | | long changeNumber = addOperation.getChangeNumber(); |
| | | addOperation.setChangeNumber(changeNumber); |
| | | } |
| | | |
| | | |
| | |
| | | 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); |
| | | } |
| | |
| | | "objectClass: organizationalUnit", |
| | | "ou: People"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | retrieveCompletedOperationElements(addOperation); |
| | | } |
| | |
| | | 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); |
| | | } |
| | | |
| | |
| | | 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); |
| | | } |
| | | |
| | |
| | | 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); |
| | | } |
| | | |
| | |
| | | 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); |
| | |
| | | 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"), |
| | |
| | | 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"), |
| | |
| | | "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," + |
| | | "cn=Password Policies,cn=config"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | retrieveCompletedOperationElements(addOperation); |
| | | } |
| | |
| | | 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"), |
| | |
| | | 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"), |
| | |
| | | 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"), |
| | |
| | | "cn;lang-en-us: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | retrieveCompletedOperationElements(addOperation); |
| | | } |
| | |
| | | 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); |
| | |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | retrieveCompletedOperationElements(addOperation); |
| | | |
| | |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); |
| | | |
| | | DirectoryServer.setAddMissingRDNAttributes(true); |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | retrieveCompletedOperationElements(addOperation); |
| | | |
| | |
| | | { |
| | | for (AttributeValue v : a) |
| | | { |
| | | if (v.getValue().toString().equalsIgnoreCase("top")) |
| | | if ("top".equalsIgnoreCase(v.getValue().toString())) |
| | | { |
| | | found = true; |
| | | break; |
| | |
| | | "dn: ou=People,o=test", |
| | | "ou: People"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | "objectClass: top", |
| | | "ou: People"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | "objectClass: extensibleObject", |
| | | "ou: People"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | "cn: Test User", |
| | | "sn: User"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | "sn: User", |
| | | "userPassword: password"); // Missing cn |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | "sn: User", |
| | | "userPassword: password"); // Missing cn |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | "userPassword: password", |
| | | "dc: Not allowed by inetOrgPerson"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | "userPassword: password", |
| | | "dc: Not allowed by inetOrgPerson but allowed by extensibleObject"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | retrieveCompletedOperationElements(addOperation); |
| | | } |
| | |
| | | userAttrs.put(attrType, attrList); |
| | | |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getDN(), entry.getObjectClasses(), userAttrs, |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | DirectoryServer.setWritabilityMode(WritabilityMode.DISABLED); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); |
| | | |
| | | DirectoryServer.setWritabilityMode(WritabilityMode.ENABLED); |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | DirectoryServer.setWritabilityMode(WritabilityMode.INTERNAL_ONLY); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | retrieveCompletedOperationElements(addOperation); |
| | | |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | Backend b = DirectoryServer.getBackend(DN.decode("o=test")); |
| | | Backend<?> b = DirectoryServer.getBackend(DN.decode("o=test")); |
| | | b.setWritabilityMode(WritabilityMode.DISABLED); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); |
| | | |
| | | b.setWritabilityMode(WritabilityMode.ENABLED); |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | Backend b = DirectoryServer.getBackend(DN.decode("o=test")); |
| | | Backend<?> b = DirectoryServer.getBackend(DN.decode("o=test")); |
| | | b.setWritabilityMode(WritabilityMode.INTERNAL_ONLY); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | retrieveCompletedOperationElements(addOperation); |
| | | |
| | |
| | | values.add(ByteString.valueOf("People")); |
| | | attrs.add(new LDAPAttribute("ou", values)); |
| | | |
| | | Backend b = DirectoryServer.getBackend(DN.decode("o=test")); |
| | | Backend<?> b = DirectoryServer.getBackend(DN.decode("o=test")); |
| | | b.setWritabilityMode(WritabilityMode.INTERNAL_ONLY); |
| | | |
| | | long addRequests = ldapStatistics.getAddRequests(); |
| | |
| | | "objectClass: organizationalUnit", |
| | | "ou: People"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | retrieveCompletedOperationElements(addOperation); |
| | | |
| | |
| | | "objectClass: organizationalUnit", |
| | | "ou: People"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS); |
| | | |
| | | assertEquals(changeListener.getAddCount(), 0); |
| | |
| | | "objectClass: organizationalUnit", |
| | | "ou: People"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | AddOperationBasis addOperation = |
| | | new AddOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | new AddOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), |
| | | null, entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | |
| | | "objectClass: organizationalUnit", |
| | | "ou: People"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | AddOperationBasis addOperation = |
| | | new AddOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | new AddOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), |
| | | null, entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | |
| | | "objectClass: organizationalUnit", |
| | | "ou: People"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | AddOperation addOperation = |
| | | conn.processAdd(entry.getDN(), entry.getObjectClasses(), |
| | | entry.getUserAttributes(), |
| | | entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.BUSY); |
| | | } |
| | | finally |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(false); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | List<Control> controls = |
| | | ShortCircuitPlugin.createShortCircuitControlList(0, "PreParse"); |
| | | |
| | |
| | | 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); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2013 ForgeRock AS. |
| | | * Portions copyright 2011-2014 ForgeRock AS. |
| | | */ |
| | | 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; |
| | |
| | | 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 |
| | |
| | | /** 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.decode("o=test")); |
| | | Backend<?> b = DirectoryServer.getBackend(DN.decode("o=test")); |
| | | b.setWritabilityMode(WritabilityMode.ENABLED); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | protected Operation[] createTestOperations() |
| | | throws Exception |
| | |
| | | List<Control> requestControls, ByteString rawEntryDn) |
| | | { |
| | | return new DeleteOperationBasis( |
| | | InternalClientConnection.getRootConnection(), |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | requestControls, rawEntryDn); |
| | | } |
| | | |
| | |
| | | List<Control> requestControls, DN entryDn) |
| | | { |
| | | return new DeleteOperationBasis( |
| | | InternalClientConnection.getRootConnection(), |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | requestControls, entryDn); |
| | | } |
| | | |
| | |
| | | assertTrue(deleteOperation.getProcessingStopTime() >= |
| | | deleteOperation.getProcessingStartTime()); |
| | | assertTrue(deleteOperation.getProcessingTime() >= 0); |
| | | |
| | | |
| | | long changeNumber = deleteOperation.getChangeNumber(); |
| | | deleteOperation.setChangeNumber(changeNumber); |
| | | } |
| | | |
| | | |
| | |
| | | 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) |
| | | { |
| | |
| | | |
| | | 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.decode(entryDN)); |
| | | } |
| | | |
| | | private void processAdd(String... entryLines) throws Exception |
| | | { |
| | | Entry e = TestCaseUtils.makeEntry(entryLines); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | AddOperation addOperation = |
| | | conn.processAdd(e.getDN(), e.getObjectClasses(), e.getUserAttributes(), |
| | | e.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(e); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | 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) |
| | | { |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | Backend backend = DirectoryServer.getBackend(DN.decode("o=test")); |
| | | Backend<?> backend = DirectoryServer.getBackend(DN.decode("o=test")); |
| | | backend.setWritabilityMode(WritabilityMode.DISABLED); |
| | | |
| | | DeleteOperation deleteOperation = processDeleteRaw("o=test"); |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | Backend backend = DirectoryServer.getBackend(DN.decode("o=test")); |
| | | Backend<?> backend = DirectoryServer.getBackend(DN.decode("o=test")); |
| | | backend.setWritabilityMode(WritabilityMode.INTERNAL_ONLY); |
| | | |
| | | DeleteOperation deleteOperation = processDeleteRaw("o=test"); |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | Backend backend = DirectoryServer.getBackend(DN.decode("o=test")); |
| | | Backend<?> backend = DirectoryServer.getBackend(DN.decode("o=test")); |
| | | backend.setWritabilityMode(WritabilityMode.INTERNAL_ONLY); |
| | | |
| | | String[] args = getArgs("o=test"); |
| | |
| | | break responseLoop; |
| | | default: |
| | | // This is a problem. It's an unexpected response. |
| | | try |
| | | { |
| | | s.close(); |
| | | } catch (Exception e) {} |
| | | StaticUtils.close(s); |
| | | |
| | | throw new Exception("Unexpected response message " + message + |
| | | " encountered in " + |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2011 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2013 ForgeRock AS |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.net.Socket; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | |
| | | import org.opends.server.workflowelement.localbackend.LocalBackendModifyOperation; |
| | | 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 |
| | |
| | | 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.decode(backendBaseDN)); |
| | | final DN baseDN = DN.decode(backendBaseDN2[0].toString()); |
| | | Backend<?> b = DirectoryServer.getBackend(baseDN); |
| | | b.setWritabilityMode(WritabilityMode.ENABLED); |
| | | } |
| | | } |
| | |
| | | DN entryDn, List<Modification> modifications) |
| | | { |
| | | return new ModifyOperationBasis( |
| | | InternalClientConnection.getRootConnection(), |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | requestControls, entryDn, modifications); |
| | | } |
| | | |
| | |
| | | ByteString rawEntryDn, List<RawModification> rawModifications) |
| | | { |
| | | return new ModifyOperationBasis( |
| | | InternalClientConnection.getRootConnection(), |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | requestControls, rawEntryDn, rawModifications); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | protected Operation[] createTestOperations() |
| | | throws Exception |
| | |
| | | |
| | | 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()); |
| | |
| | | assertTrue(modifyOperation.getProcessingTime() >= 0); |
| | | |
| | | List<LocalBackendModifyOperation> localOps = |
| | | (List) (modifyOperation.getAttachment(Operation.LOCALBACKENDOPERATIONS)); |
| | | (List) modifyOperation.getAttachment(Operation.LOCALBACKENDOPERATIONS); |
| | | assertNotNull(localOps); |
| | | for (LocalBackendModifyOperation curOp : localOps) |
| | | { |
| | |
| | | assertNotNull(curOp.getCurrentEntry()); |
| | | assertNotNull(curOp.getModifiedEntry()); |
| | | } |
| | | |
| | | long changeNumber = modifyOperation.getChangeNumber(); |
| | | modifyOperation.setChangeNumber(changeNumber); |
| | | } |
| | | |
| | | |
| | |
| | | assertTrue(modifyOperation.getProcessingStopTime() >= |
| | | modifyOperation.getProcessingStartTime()); |
| | | assertTrue(modifyOperation.getProcessingTime() >= 0); |
| | | |
| | | long changeNumber = modifyOperation.getChangeNumber(); |
| | | modifyOperation.setChangeNumber(changeNumber); |
| | | } |
| | | |
| | | |
| | |
| | | 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.decode("o=test"), mods); |
| | | getRootConnection().processModify(DN.decode("o=test"), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | retrieveSuccessfulOperationElements(modifyOperation); |
| | | |
| | |
| | | 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.getDN(), entry.getObjectClasses(), entry |
| | | .getUserAttributes(), entry.getOperationalAttributes()); |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | |
| | | 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, |
| | |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | InternalClientConnection.getRootConnection(), |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(baseDN), |
| | | SearchScope.WHOLE_SUBTREE, |
| | |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | InternalClientConnection.getRootConnection(), |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(baseDN), |
| | | SearchScope.WHOLE_SUBTREE, |
| | |
| | | "mail: foo", |
| | | "employeeNumber: 1"); |
| | | |
| | | Backend b = DirectoryServer.getBackend(DN.decode(baseDN)); |
| | | Backend<?> b = DirectoryServer.getBackend(DN.decode(baseDN)); |
| | | b.setWritabilityMode(WritabilityMode.DISABLED); |
| | | |
| | | LDAPAttribute attr = newLDAPAttribute("objectClass", "extensibleObject"); |
| | |
| | | "mail: foo", |
| | | "employeeNumber: 1"); |
| | | |
| | | Backend b = DirectoryServer.getBackend(DN.decode(baseDN)); |
| | | Backend<?> b = DirectoryServer.getBackend(DN.decode(baseDN)); |
| | | b.setWritabilityMode(WritabilityMode.INTERNAL_ONLY); |
| | | |
| | | LDAPAttribute attr = newLDAPAttribute("objectClass", "extensibleObject"); |
| | |
| | | "mail: foo", |
| | | "employeeNumber: 1"); |
| | | |
| | | Backend b = DirectoryServer.getBackend(DN.decode(baseDN)); |
| | | Backend<?> b = DirectoryServer.getBackend(DN.decode(baseDN)); |
| | | b.setWritabilityMode(WritabilityMode.INTERNAL_ONLY); |
| | | |
| | | |
| | |
| | | "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. |
| | |
| | | "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. |