| | |
| | | |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.ClientConnection; |
| | | 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.LDAPAssertionRequestControl; |
| | | import org.opends.server.controls.ProxiedAuthV1Control; |
| | | import org.opends.server.controls.ProxiedAuthV2Control; |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.PluginConfigManager; |
| | | import org.opends.server.loggers.debug.DebugTracer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.LockManager; |
| | | import org.opends.server.types.Privilege; |
| | | import org.opends.server.types.ResultCode; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.operation.PostOperationCompareOperation; |
| | | import org.opends.server.types.operation.PostResponseCompareOperation; |
| | | import org.opends.server.types.operation.PreOperationCompareOperation; |
| | |
| | | // The backend in which the comparison is to be performed. |
| | | private Backend backend; |
| | | |
| | | // Indicates whether to skip post-operation processing. |
| | | private boolean skipPostOperation; |
| | | |
| | | // The client connection for this operation. |
| | | private ClientConnection clientConnection; |
| | | |
| | |
| | | * |
| | | * @param backend The backend in which the compare operation should be |
| | | * processed. |
| | | * |
| | | * @throws CanceledOperationException if this operation should be |
| | | * cancelled |
| | | */ |
| | | void processLocalCompare(Backend backend) |
| | | { |
| | | void processLocalCompare(Backend backend) throws CanceledOperationException { |
| | | boolean executePostOpPlugins = false; |
| | | |
| | | this.backend = backend; |
| | | |
| | | clientConnection = getClientConnection(); |
| | | skipPostOperation = false; |
| | | |
| | | // Get the plugin config manager that will be used for invoking plugins. |
| | | PluginConfigManager pluginConfigManager = |
| | |
| | | |
| | | |
| | | // Check for a request to cancel this operation. |
| | | if (cancelIfRequested()) |
| | | { |
| | | return; |
| | | } |
| | | checkIfCanceled(false); |
| | | |
| | | |
| | | // Create a labeled block of code that we can break out of if a problem is |
| | |
| | | entryDN = getEntryDN(); |
| | | if (entryDN == null) |
| | | { |
| | | skipPostOperation = true; |
| | | break compareProcessing; |
| | | } |
| | | |
| | |
| | | { |
| | | appendErrorMessage(ERR_COMPARE_CONFIG_INSUFFICIENT_PRIVILEGES.get()); |
| | | setResultCode(ResultCode.INSUFFICIENT_ACCESS_RIGHTS); |
| | | skipPostOperation = true; |
| | | break compareProcessing; |
| | | } |
| | | |
| | | |
| | | // Check for a request to cancel this operation. |
| | | if (cancelIfRequested()) |
| | | { |
| | | return; |
| | | } |
| | | checkIfCanceled(false); |
| | | |
| | | |
| | | // Grab a read lock on the entry. |
| | |
| | | appendErrorMessage(ERR_COMPARE_CANNOT_LOCK_ENTRY.get( |
| | | String.valueOf(entryDN))); |
| | | |
| | | skipPostOperation = true; |
| | | break compareProcessing; |
| | | } |
| | | |
| | |
| | | setResultCode(ResultCode.INSUFFICIENT_ACCESS_RIGHTS); |
| | | appendErrorMessage(ERR_COMPARE_AUTHZ_INSUFFICIENT_ACCESS_RIGHTS.get( |
| | | String.valueOf(entryDN))); |
| | | skipPostOperation = true; |
| | | break compareProcessing; |
| | | } |
| | | |
| | | // Check for a request to cancel this operation. |
| | | if (cancelIfRequested()) |
| | | { |
| | | return; |
| | | } |
| | | checkIfCanceled(false); |
| | | |
| | | |
| | | // Invoke the pre-operation compare plugins. |
| | | PreOperationPluginResult preOpResult = |
| | | executePostOpPlugins = true; |
| | | PluginResult.PreOperation preOpResult = |
| | | pluginConfigManager.invokePreOperationComparePlugins(this); |
| | | if (preOpResult.connectionTerminated()) |
| | | { |
| | | // There's no point in continuing with anything. Log the request and |
| | | // result and return. |
| | | setResultCode(ResultCode.CANCELED); |
| | | appendErrorMessage(ERR_CANCELED_BY_PREOP_DISCONNECT.get()); |
| | | setProcessingStopTime(); |
| | | return; |
| | | } |
| | | else if (preOpResult.sendResponseImmediately()) |
| | | { |
| | | skipPostOperation = true; |
| | | break compareProcessing; |
| | | } |
| | | else if (preOpResult.skipCoreProcessing()) |
| | | { |
| | | skipPostOperation = false; |
| | | break compareProcessing; |
| | | } |
| | | if (!preOpResult.continueProcessing()) |
| | | { |
| | | setResultCode(preOpResult.getResultCode()); |
| | | appendErrorMessage(preOpResult.getErrorMessage()); |
| | | setMatchedDN(preOpResult.getMatchedDN()); |
| | | setReferralURLs(preOpResult.getReferralURLs()); |
| | | break compareProcessing; |
| | | } |
| | | |
| | | |
| | | // Get the base attribute type and set of options. |
| | |
| | | |
| | | |
| | | // Check for a request to cancel this operation. |
| | | if (cancelIfRequested()) |
| | | { |
| | | return; |
| | | } |
| | | checkIfCanceled(false); |
| | | |
| | | |
| | | // Invoke the post-operation compare plugins. |
| | | if (! skipPostOperation) |
| | | if (executePostOpPlugins) |
| | | { |
| | | PostOperationPluginResult postOperationResult = |
| | | PluginResult.PostOperation postOpResult = |
| | | pluginConfigManager.invokePostOperationComparePlugins(this); |
| | | if (postOperationResult.connectionTerminated()) |
| | | if (!postOpResult.continueProcessing()) |
| | | { |
| | | setResultCode(ResultCode.CANCELED); |
| | | appendErrorMessage(ERR_CANCELED_BY_POSTOP_DISCONNECT.get()); |
| | | return; |
| | | setResultCode(postOpResult.getResultCode()); |
| | | appendErrorMessage(postOpResult.getErrorMessage()); |
| | | setMatchedDN(postOpResult.getMatchedDN()); |
| | | setReferralURLs(postOpResult.getReferralURLs()); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * Checks to determine whether there has been a request to cancel this |
| | | * operation. If so, then set the cancel result and processing stop time. |
| | | * |
| | | * @return {@code true} if there was a cancel request, or {@code false} if |
| | | * not. |
| | | */ |
| | | private boolean cancelIfRequested() |
| | | { |
| | | if (getCancelRequest() == null) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | indicateCancelled(getCancelRequest()); |
| | | setProcessingStopTime(); |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Performs any processing required for the controls included in the request. |
| | | * |
| | | * @throws DirectoryException If a problem occurs that should prevent the |
| | |
| | | if (! AccessControlConfigManager.getInstance(). |
| | | getAccessControlHandler().isAllowed(entryDN, this, c)) |
| | | { |
| | | skipPostOperation = true; |
| | | throw new DirectoryException(ResultCode.INSUFFICIENT_ACCESS_RIGHTS, |
| | | ERR_CONTROL_INSUFFICIENT_ACCESS_RIGHTS.get(oid)); |
| | | } |