From d144020178e1c97c57a85fe9b0be47020cb63bb9 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Mon, 03 Oct 2011 16:39:16 +0000
Subject: [PATCH] Fix OPENDJ-304: The result code 53 (unwillingToPerform) should only be used for service errors
---
opendj-sdk/opends/src/server/org/opends/server/core/ModifyDNOperationBasis.java | 11 +++--
opendj-sdk/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java | 30 +++++++-------
opendj-sdk/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java | 34 ++++++++--------
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/controls/PasswordPolicyControlTestCase.java | 3 +
opendj-sdk/opends/src/server/org/opends/server/extensions/PasswordModifyExtendedOperation.java | 6 +-
opendj-sdk/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java | 6 +-
opendj-sdk/opends/src/server/org/opends/server/types/Entry.java | 2
opendj-sdk/opends/src/server/org/opends/server/core/ExtendedOperationBasis.java | 3 +
8 files changed, 49 insertions(+), 46 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/core/ExtendedOperationBasis.java b/opendj-sdk/opends/src/server/org/opends/server/core/ExtendedOperationBasis.java
index be376fb..0aeb4ae 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/core/ExtendedOperationBasis.java
+++ b/opendj-sdk/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)
{
diff --git a/opendj-sdk/opends/src/server/org/opends/server/core/ModifyDNOperationBasis.java b/opendj-sdk/opends/src/server/org/opends/server/core/ModifyDNOperationBasis.java
index cf19f56..6ad2c43 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/core/ModifyDNOperationBasis.java
+++ b/opendj-sdk/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);
}
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/extensions/PasswordModifyExtendedOperation.java b/opendj-sdk/opends/src/server/org/opends/server/extensions/PasswordModifyExtendedOperation.java
index 3502229..4eb565a 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/extensions/PasswordModifyExtendedOperation.java
+++ b/opendj-sdk/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());
diff --git a/opendj-sdk/opends/src/server/org/opends/server/types/Entry.java b/opendj-sdk/opends/src/server/org/opends/server/types/Entry.java
index 0782a5f..5b3717b 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/types/Entry.java
+++ b/opendj-sdk/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(
diff --git a/opendj-sdk/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java b/opendj-sdk/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java
index 54196ae..e1c6457 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java
+++ b/opendj-sdk/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()));
diff --git a/opendj-sdk/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java b/opendj-sdk/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java
index 80ac7b9..0b13532 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java
+++ b/opendj-sdk/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()));
diff --git a/opendj-sdk/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java b/opendj-sdk/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
index 15d9ca0..98ee77f 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
+++ b/opendj-sdk/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());
}
}
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/controls/PasswordPolicyControlTestCase.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/controls/PasswordPolicyControlTestCase.java
index a05b24b..38d3e24 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/controls/PasswordPolicyControlTestCase.java
+++ b/opendj-sdk/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
{
--
Gitblit v1.10.0