mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Matthew Swift
03.39.2011 2cf4acc0a786cfd040ec45e2b77db115a3672f66
Fix OPENDJ-304: The result code 53 (unwillingToPerform) should only be used for service errors

8 files modified
95 ■■■■ changed files
opends/src/server/org/opends/server/core/ExtendedOperationBasis.java 3 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/ModifyDNOperationBasis.java 11 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/extensions/PasswordModifyExtendedOperation.java 6 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/types/Entry.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java 30 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java 6 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java 34 ●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/controls/PasswordPolicyControlTestCase.java 3 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/ExtendedOperationBasis.java
@@ -23,6 +23,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions copyright 2011 ForgeRock AS.
 */
package org.opends.server.core;
import org.opends.messages.MessageBuilder;
@@ -397,7 +398,7 @@
      // Get the extended operation handler for the request OID.  If there is
      // none, then fail.
      ExtendedOperationHandler handler =
      ExtendedOperationHandler<?> handler =
           DirectoryServer.getExtendedOperationHandler(requestOID);
      if (handler == null)
      {
opends/src/server/org/opends/server/core/ModifyDNOperationBasis.java
@@ -23,6 +23,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions copyright 2011 ForgeRock AS.
 */
package org.opends.server.core;
import org.opends.messages.MessageBuilder;
@@ -699,15 +700,15 @@
    {
      // Invoke the post response plugins that have been registered by
      // the workflow elements
      List localOperations =
        (List)getAttachment(Operation.LOCALBACKENDOPERATIONS);
      @SuppressWarnings("unchecked")
      List<LocalBackendModifyDNOperation> localOperations =
        (List<LocalBackendModifyDNOperation>)
          getAttachment(Operation.LOCALBACKENDOPERATIONS);
      if (localOperations != null)
      {
        for (Object localOp : localOperations)
        for (LocalBackendModifyDNOperation localOperation : localOperations)
        {
          LocalBackendModifyDNOperation localOperation =
            (LocalBackendModifyDNOperation)localOp;
          pluginConfigManager.invokePostResponseModifyDNPlugins(localOperation);
        }
      }
opends/src/server/org/opends/server/extensions/PasswordModifyExtendedOperation.java
@@ -813,7 +813,7 @@
          if (!pwPolicyState.getAuthenticationPolicy()
              .isAllowPreEncodedPasswords())
          {
            operation.setResultCode(ResultCode.UNWILLING_TO_PERFORM);
            operation.setResultCode(ResultCode.CONSTRAINT_VIOLATION);
            operation.appendErrorMessage(
                    ERR_EXTOP_PASSMOD_PRE_ENCODED_NOT_ALLOWED.get());
@@ -862,7 +862,7 @@
                                                       pwPolicyErrorType));
              }
              operation.setResultCode(ResultCode.UNWILLING_TO_PERFORM);
              operation.setResultCode(ResultCode.CONSTRAINT_VIOLATION);
              operation.appendErrorMessage(
                      ERR_EXTOP_PASSMOD_UNACCEPTABLE_PW.get(
@@ -880,7 +880,7 @@
              if (selfChange || (! pwPolicyState.getAuthenticationPolicy().
                                      isSkipValidationForAdministrators()))
              {
                operation.setResultCode(ResultCode.UNWILLING_TO_PERFORM);
                operation.setResultCode(ResultCode.CONSTRAINT_VIOLATION);
                operation.appendErrorMessage(
                        ERR_EXTOP_PASSMOD_PW_IN_HISTORY.get());
opends/src/server/org/opends/server/types/Entry.java
@@ -1867,7 +1867,7 @@
          Message message =
              ERR_ENTRY_OC_INCREMENT_NOT_SUPPORTED.get();
          throw new DirectoryException(
                         ResultCode.UNWILLING_TO_PERFORM, message);
                         ResultCode.CONSTRAINT_VIOLATION, message);
        default:
          message = ERR_ENTRY_UNKNOWN_MODIFICATION_TYPE.get(
opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java
@@ -313,7 +313,7 @@
          {
            if (! (isInternalOperation() || isSynchronizationOperation()))
            {
              setResultCode(ResultCode.UNWILLING_TO_PERFORM);
              setResultCode(ResultCode.CONSTRAINT_VIOLATION);
              appendErrorMessage(ERR_ADD_ATTR_IS_NO_USER_MOD.get(
                                      String.valueOf(entryDN),
                                      at.getNameOrOID()));
@@ -329,7 +329,7 @@
          {
            if (! (isInternalOperation() || isSynchronizationOperation()))
            {
              setResultCode(ResultCode.UNWILLING_TO_PERFORM);
              setResultCode(ResultCode.CONSTRAINT_VIOLATION);
              appendErrorMessage(ERR_ADD_ATTR_IS_NO_USER_MOD.get(
                                      String.valueOf(entryDN),
                                      at.getNameOrOID()));
@@ -877,7 +877,7 @@
          }
          else
          {
            throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
            throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                                         ERR_ADD_MISSING_RDN_ATTRIBUTE.get(
                                              String.valueOf(entryDN), n));
          }
@@ -913,7 +913,7 @@
            }
            else
            {
              throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
              throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                                           ERR_ADD_MISSING_RDN_ATTRIBUTE.get(
                                                String.valueOf(entryDN), n));
            }
@@ -934,7 +934,7 @@
          }
          else
          {
            throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
            throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                                         ERR_ADD_MISSING_RDN_ATTRIBUTE.get(
                                              String.valueOf(entryDN),n));
          }
@@ -970,7 +970,7 @@
            }
            else
            {
              throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
              throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                                           ERR_ADD_MISSING_RDN_ATTRIBUTE.get(
                                                String.valueOf(entryDN),n));
            }
@@ -1045,7 +1045,7 @@
      // passwords.
      Message message = ERR_PWPOLICY_ATTRIBUTE_OPTIONS_NOT_ALLOWED.get(
          passwordAttribute.getNameOrOID());
      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
    }
    Attribute passwordAttr = attrList.get(0);
@@ -1053,7 +1053,7 @@
    {
      Message message = ERR_PWPOLICY_ATTRIBUTE_OPTIONS_NOT_ALLOWED.get(
          passwordAttribute.getNameOrOID());
      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
    }
    if (passwordAttr.isEmpty())
@@ -1072,7 +1072,7 @@
      Message message = ERR_PWPOLICY_MULTIPLE_PW_VALUES_NOT_ALLOWED
          .get(passwordAttribute.getNameOrOID());
      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
    }
    List<PasswordStorageScheme<?>> defaultStorageSchemes =
@@ -1101,7 +1101,7 @@
            Message message = ERR_PWPOLICY_PREENCODED_NOT_ALLOWED.get(
                passwordAttribute.getNameOrOID());
            throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
            throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                                         message);
          }
        }
@@ -1123,7 +1123,7 @@
            Message message = ERR_PWPOLICY_PREENCODED_NOT_ALLOWED.get(
                passwordAttribute.getNameOrOID());
            throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
            throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                                         message);
          }
        }
@@ -1149,7 +1149,7 @@
            Message message = ERR_PWPOLICY_VALIDATION_FAILED.
                get(passwordAttribute.getNameOrOID(),
                    String.valueOf(invalidReason));
            throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
            throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                                         message);
          }
        }
@@ -1364,7 +1364,7 @@
    {
      if (at.isObsolete())
      {
        throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                                     WARN_ADD_ATTR_IS_OBSOLETE.get(
                                          String.valueOf(entryDN),
                                          at.getNameOrOID()));
@@ -1375,7 +1375,7 @@
    {
      if (at.isObsolete())
      {
        throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                                     WARN_ADD_ATTR_IS_OBSOLETE.get(
                                          String.valueOf(entryDN),
                                          at.getNameOrOID()));
@@ -1386,7 +1386,7 @@
    {
      if (oc.isObsolete())
      {
        throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                                     WARN_ADD_OC_IS_OBSOLETE.get(
                                          String.valueOf(entryDN),
                                          oc.getNameOrOID()));
opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java
@@ -915,7 +915,7 @@
        {
          if (! (isInternalOperation() || isSynchronizationOperation()))
          {
            throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
            throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                           ERR_MODDN_OLD_RDN_ATTR_IS_NO_USER_MOD.get(
                                String.valueOf(entryDN), a.getName()));
          }
@@ -954,7 +954,7 @@
        {
          if (! (isInternalOperation() || isSynchronizationOperation()))
          {
            throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
            throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                           ERR_MODDN_NEW_RDN_ATTR_IS_NO_USER_MOD.get(
                                String.valueOf(entryDN), a.getName()));
          }
@@ -986,7 +986,7 @@
        AttributeType at = newRDN.getAttributeType(i);
        if (at.isObsolete())
        {
          throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
          throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                                       ERR_MODDN_NEWRDN_ATTR_IS_OBSOLETE.get(
                                            String.valueOf(entryDN),
                                            at.getNameOrOID()));
opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
@@ -361,7 +361,7 @@
            }
          }
          setResultCode(ResultCode.UNWILLING_TO_PERFORM);
          setResultCode(ResultCode.CONSTRAINT_VIOLATION);
          appendErrorMessage(ERR_MODIFY_MUST_CHANGE_PASSWORD.get());
          break modifyProcessing;
        }
@@ -545,7 +545,7 @@
          {
            // The user did not attempt to change their password.
            pwpErrorType = PasswordPolicyErrorType.CHANGE_AFTER_RESET;
            setResultCode(ResultCode.UNWILLING_TO_PERFORM);
            setResultCode(ResultCode.CONSTRAINT_VIOLATION);
            appendErrorMessage(ERR_MODIFY_MUST_CHANGE_PASSWORD.get());
            break modifyProcessing;
          }
@@ -952,7 +952,7 @@
        if (! (isInternalOperation() || isSynchronizationOperation() ||
                m.isInternal()))
        {
          throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
          throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                  ERR_MODIFY_ATTR_IS_NO_USER_MOD.get(
                          String.valueOf(entryDN), a.getName()));
        }
@@ -969,7 +969,7 @@
          if (! (isInternalOperation() || isSynchronizationOperation() ||
                  m.isInternal()))
          {
            throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
            throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                    ERR_MODIFY_ATTR_IS_OBSOLETE.get(
                            String.valueOf(entryDN), a.getName()));
          }
@@ -1105,7 +1105,7 @@
          {
            if (a.hasOptions())
            {
              throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
              throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                  ERR_MODIFY_PASSWORDS_CANNOT_HAVE_OPTIONS.get());
            }
@@ -1128,7 +1128,7 @@
                && (!clientConnection.isSecure()))
            {
              pwpErrorType = PasswordPolicyErrorType.PASSWORD_MOD_NOT_ALLOWED;
              throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
              throw new DirectoryException(ResultCode.CONFIDENTIALITY_REQUIRED,
                  ERR_MODIFY_REQUIRE_SECURE_CHANGES.get());
            }
@@ -1159,7 +1159,7 @@
            break;
          default:
            throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
            throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                ERR_MODIFY_INVALID_MOD_TYPE_FOR_PASSWORD.get(String.valueOf(m
                    .getModificationType()), a.getName()));
          }
@@ -1224,7 +1224,7 @@
            .isAllowMultiplePasswordValues()) && (passwordsToAdd > 1))
    {
      pwpErrorType = PasswordPolicyErrorType.PASSWORD_MOD_NOT_ALLOWED;
      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
          ERR_MODIFY_MULTIPLE_VALUES_NOT_ALLOWED.get());
    }
@@ -1242,7 +1242,7 @@
                .isAllowPreEncodedPasswords())
        {
          pwpErrorType = PasswordPolicyErrorType.INSUFFICIENT_PASSWORD_QUALITY;
          throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
          throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
              ERR_MODIFY_NO_PREENCODED_PASSWORDS.get());
        }
        else
@@ -1315,7 +1315,7 @@
        if ((!isInternalOperation()) && selfChange)
        {
          pwpErrorType = PasswordPolicyErrorType.INSUFFICIENT_PASSWORD_QUALITY;
          throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
          throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
              ERR_MODIFY_NO_PREENCODED_PASSWORDS.get());
        }
        else
@@ -1326,7 +1326,7 @@
              .getAttributeType());
          if ((attrList == null) || (attrList.isEmpty()))
          {
            throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
            throw new DirectoryException(ResultCode.NO_SUCH_ATTRIBUTE,
                ERR_MODIFY_NO_EXISTING_VALUES.get());
          }
          boolean found = false;
@@ -1353,7 +1353,7 @@
            .getAttributeType());
        if ((attrList == null) || (attrList.isEmpty()))
        {
          throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
          throw new DirectoryException(ResultCode.NO_SUCH_ATTRIBUTE,
              ERR_MODIFY_NO_EXISTING_VALUES.get());
        }
        boolean found = false;
@@ -1429,7 +1429,7 @@
        }
        else
        {
          throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
          throw new DirectoryException(ResultCode.NO_SUCH_ATTRIBUTE,
              ERR_MODIFY_INVALID_PASSWORD.get());
        }
@@ -1579,7 +1579,7 @@
      {
        Message message = ERR_ENTRY_ADD_OBSOLETE_OC.get(name, String
            .valueOf(entryDN));
        throw new DirectoryException(ResultCode.OBJECTCLASS_VIOLATION, message);
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
      }
    }
  }
@@ -1879,7 +1879,7 @@
            .isAllowMultiplePasswordValues()))
    {
      pwpErrorType = PasswordPolicyErrorType.PASSWORD_MOD_NOT_ALLOWED;
      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
          ERR_MODIFY_MULTIPLE_PASSWORDS_NOT_ALLOWED.get());
    }
@@ -1941,7 +1941,7 @@
          {
            pwpErrorType =
                 PasswordPolicyErrorType.INSUFFICIENT_PASSWORD_QUALITY;
            throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
            throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                                         ERR_MODIFY_PW_VALIDATION_FAILED.get(
                                              invalidReason));
          }
@@ -1963,7 +1963,7 @@
                                      isSkipValidationForAdministrators()))
            {
              pwpErrorType = PasswordPolicyErrorType.PASSWORD_IN_HISTORY;
              throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
              throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                                           ERR_MODIFY_PW_IN_HISTORY.get());
            }
          }
opends/tests/unit-tests-testng/src/server/org/opends/server/controls/PasswordPolicyControlTestCase.java
@@ -23,6 +23,7 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions copyright 2011 ForgeRock AS.
 */
package org.opends.server.controls;
@@ -824,7 +825,7 @@
      if (changeAfterReset)
      {
        assertEquals(modifyResponse.getResultCode(),
            LDAPResultCode.UNWILLING_TO_PERFORM);
            LDAPResultCode.CONSTRAINT_VIOLATION);
      }
      else
      {