From 35a408038c1de64a6f13f0e7b246a645e9945e3c Mon Sep 17 00:00:00 2001
From: boli <boli@localhost>
Date: Tue, 18 Mar 2008 22:44:58 +0000
Subject: [PATCH] With this refactoring:
---
opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendBindOperation.java | 106 +++++++++++++++++++---------------------------------
1 files changed, 39 insertions(+), 67 deletions(-)
diff --git a/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendBindOperation.java b/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendBindOperation.java
index a130f82..0e15a35 100644
--- a/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendBindOperation.java
+++ b/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendBindOperation.java
@@ -38,8 +38,7 @@
import org.opends.server.api.Backend;
import org.opends.server.api.ClientConnection;
import org.opends.server.api.SASLMechanismHandler;
-import org.opends.server.api.plugin.PostOperationPluginResult;
-import org.opends.server.api.plugin.PreOperationPluginResult;
+import org.opends.server.api.plugin.PluginResult;
import org.opends.server.controls.AuthorizationIdentityResponseControl;
import org.opends.server.controls.PasswordExpiredControl;
import org.opends.server.controls.PasswordExpiringControl;
@@ -119,8 +118,8 @@
// control in the bind response.
private boolean returnAuthzID;
- // Indicates whether to skip post-operation plugin processing.
- private boolean skipPostOperation;
+ // Indicates whether to execute post-operation plugins.
+ private boolean executePostOpPlugins;
// The client connection associated with this bind operation.
private ClientConnection clientConnection;
@@ -194,7 +193,7 @@
// Initialize a number of variables for use during the bind processing.
clientConnection = getClientConnection();
returnAuthzID = false;
- skipPostOperation = false;
+ executePostOpPlugins = false;
sizeLimit = DirectoryServer.getSizeLimit();
timeLimit = DirectoryServer.getTimeLimit();
lookthroughLimit = DirectoryServer.getLookthroughLimit();
@@ -229,7 +228,6 @@
setResultCode(ResultCode.INVALID_CREDENTIALS);
setAuthFailureReason(ERR_BIND_AUTHZ_INSUFFICIENT_ACCESS_RIGHTS.get(
String.valueOf(bindDN)));
- skipPostOperation = true;
break bindProcessing;
}
@@ -260,7 +258,7 @@
{
if (! processSimpleBind())
{
- return;
+ break bindProcessing;
}
}
catch (DirectoryException de)
@@ -289,7 +287,7 @@
{
if (! processSASLBind())
{
- return;
+ break bindProcessing;
}
}
catch (DirectoryException de)
@@ -316,7 +314,7 @@
default:
// Send a protocol error response to the client and disconnect.
// NYI
- return;
+ setResultCode(ResultCode.PROTOCOL_ERROR);
}
}
@@ -342,18 +340,16 @@
// Invoke the post-operation bind plugins.
- if (! skipPostOperation)
+ if (executePostOpPlugins)
{
- PostOperationPluginResult postOpResult =
+ PluginResult.PostOperation postOpResult =
pluginConfigManager.invokePostOperationBindPlugins(this);
- if (postOpResult.connectionTerminated())
+ if (!postOpResult.continueProcessing())
{
- // There's no point in continuing with anything. Log the result
- // and return.
- setResultCode(ResultCode.CANCELED);
- appendErrorMessage(ERR_CANCELED_BY_PREOP_DISCONNECT.get());
- setProcessingStopTime();
- return;
+ setResultCode(postOpResult.getResultCode());
+ appendErrorMessage(postOpResult.getErrorMessage());
+ setMatchedDN(postOpResult.getMatchedDN());
+ setReferralURLs(postOpResult.getReferralURLs());
}
}
@@ -421,9 +417,6 @@
}
}
}
-
- // Stop the processing timer.
- setProcessingStopTime();
}
@@ -448,7 +441,6 @@
if (! AccessControlConfigManager.getInstance().
getAccessControlHandler(). isAllowed(bindDN, this, c))
{
- skipPostOperation = true;
throw new DirectoryException(ResultCode.INSUFFICIENT_ACCESS_RIGHTS,
ERR_CONTROL_INSUFFICIENT_ACCESS_RIGHTS.get(oid));
}
@@ -557,7 +549,7 @@
// Check to see if the user has a password. If not, then fail.
// FIXME -- We need to have a way to enable/disable debugging.
- pwPolicyState = new PasswordPolicyState(userEntry, false, false);
+ pwPolicyState = new PasswordPolicyState(userEntry, false);
policy = pwPolicyState.getPolicy();
AttributeType pwType = policy.getPasswordAttribute();
@@ -575,23 +567,17 @@
// Invoke the pre-operation bind plugins.
- PreOperationPluginResult preOpResult =
- pluginConfigManager.invokePreOperationBindPlugins(this);
- if (preOpResult.connectionTerminated())
+ executePostOpPlugins = true;
+ PluginResult.PreOperation preOpResult =
+ pluginConfigManager.invokePreOperationBindPlugins(this);
+ if (!preOpResult.continueProcessing())
{
- // There's no point in continuing with anything. Log the result
- // and return.
- setResultCode(ResultCode.CANCELED);
- appendErrorMessage(ERR_CANCELED_BY_PREOP_DISCONNECT.get());
- setProcessingStopTime();
+ setResultCode(preOpResult.getResultCode());
+ appendErrorMessage(preOpResult.getErrorMessage());
+ setMatchedDN(preOpResult.getMatchedDN());
+ setReferralURLs(preOpResult.getReferralURLs());
return false;
}
- else if (preOpResult.sendResponseImmediately() ||
- preOpResult.skipCoreProcessing())
- {
- skipPostOperation = false;
- return true;
- }
// Determine whether the provided password matches any of the stored
@@ -719,23 +705,17 @@
// Invoke the pre-operation bind plugins.
- PreOperationPluginResult preOpResult =
- pluginConfigManager.invokePreOperationBindPlugins(this);
- if (preOpResult.connectionTerminated())
+ executePostOpPlugins = true;
+ PluginResult.PreOperation preOpResult =
+ pluginConfigManager.invokePreOperationBindPlugins(this);
+ if (!preOpResult.continueProcessing())
{
- // There's no point in continuing with anything. Log the result
- // and return.
- setResultCode(ResultCode.CANCELED);
- appendErrorMessage(ERR_CANCELED_BY_PREOP_DISCONNECT.get());
- setProcessingStopTime();
+ setResultCode(preOpResult.getResultCode());
+ appendErrorMessage(preOpResult.getErrorMessage());
+ setMatchedDN(preOpResult.getMatchedDN());
+ setReferralURLs(preOpResult.getReferralURLs());
return false;
}
- else if (preOpResult.sendResponseImmediately() ||
- preOpResult.skipCoreProcessing())
- {
- skipPostOperation = true;
- return true;
- }
setResultCode(ResultCode.SUCCESS);
setAuthenticationInfo(new AuthenticationInfo());
@@ -773,23 +753,16 @@
// Invoke the pre-operation bind plugins.
- PreOperationPluginResult preOpResult =
- pluginConfigManager.invokePreOperationBindPlugins(this);
- if (preOpResult.connectionTerminated())
+ PluginResult.PreOperation preOpResult =
+ pluginConfigManager.invokePreOperationBindPlugins(this);
+ if (!preOpResult.continueProcessing())
{
- // There's no point in continuing with anything. Log the result
- // and return.
- setResultCode(ResultCode.CANCELED);
- appendErrorMessage(ERR_CANCELED_BY_PREOP_DISCONNECT.get());
- setProcessingStopTime();
+ setResultCode(preOpResult.getResultCode());
+ appendErrorMessage(preOpResult.getErrorMessage());
+ setMatchedDN(preOpResult.getMatchedDN());
+ setReferralURLs(preOpResult.getReferralURLs());
return false;
}
- else if (preOpResult.sendResponseImmediately() ||
- preOpResult.skipCoreProcessing())
- {
- skipPostOperation = false;
- return true;
- }
// Actually process the SASL bind.
saslHandler.processSASLBind(this);
@@ -822,8 +795,7 @@
else
{
// FIXME -- Need to have a way to enable debugging.
- pwPolicyState = new PasswordPolicyState(saslAuthUserEntry, false,
- false);
+ pwPolicyState = new PasswordPolicyState(saslAuthUserEntry, false);
policy = pwPolicyState.getPolicy();
setUserEntryDN(saslAuthUserEntry.getDN());
--
Gitblit v1.10.0