ExtendedOperationBasis.java revision ea1068c292e9b341af6d6b563cd8988a96be20a9
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2006-2010 Sun Microsystems, Inc.
* Portions Copyright 2011-2015 ForgeRock AS.
*/
/**
* This class defines an extended operation, which can perform virtually any
* kind of task.
*/
public class ExtendedOperationBasis
extends AbstractOperation
implements ExtendedOperation,
{
/** The value for the request associated with this extended operation. */
private ByteString requestValue;
/** The value for the response associated with this extended operation. */
private ByteString responseValue;
/** The set of response controls for this extended operation. */
/** The OID for the request associated with this extended operation. */
private String requestOID;
/** The OID for the response associated with this extended operation. */
private String responseOID;
/**
* Creates a new extended operation with the provided information.
*
* @param clientConnection The client connection with which this operation
* is associated.
* @param operationID The operation ID for this operation.
* @param messageID The message ID of the request with which this
* operation is associated.
* @param requestControls The set of controls included in the request.
* @param requestOID The OID for the request associated with this
* extended operation.
* @param requestValue The value for the request associated with this
* extended operation.
*/
long operationID,
{
this.requestOID = requestOID;
this.requestValue = requestValue;
responseOID = null;
{
}
{
}
}
/**
* {@inheritDoc}
*/
public final String getRequestOID()
{
return requestOID;
}
/**
* Specifies the OID for the request associated with this extended operation.
* This should only be called by pre-parse plugins.
*
* @param requestOID The OID for the request associated with this extended
* operation.
*/
{
this.requestOID = requestOID;
}
/**
* {@inheritDoc}
*/
public final ByteString getRequestValue()
{
return requestValue;
}
/**
* Specifies the value for the request associated with this extended
* operation. This should only be called by pre-parse plugins.
*
* @param requestValue The value for the request associated with this
* extended operation.
*/
{
this.requestValue = requestValue;
}
/**
* {@inheritDoc}
*/
public final String getResponseOID()
{
return responseOID;
}
/**
* {@inheritDoc}
*/
{
this.responseOID = responseOID;
}
/**
* {@inheritDoc}
*/
public final ByteString getResponseValue()
{
return responseValue;
}
/**
* {@inheritDoc}
*/
{
this.responseValue = responseValue;
}
/**
* {@inheritDoc}
*/
public final OperationType getOperationType()
{
// Note that no debugging will be done in this method because it is a likely
// candidate for being called by the logging subsystem.
return OperationType.EXTENDED;
}
/**
* {@inheritDoc}
*/
{
return responseControls;
}
/**
* {@inheritDoc}
*/
{
}
/**
* {@inheritDoc}
*/
{
}
/**
* Performs the work of actually processing this operation. This
* should include all processing for the operation, including
* invoking plugins, logging messages, performing access control,
* managing synchronization, and any other work that might need to
* be done in the course of processing.
*/
public final void run()
{
// Start the processing timer.
// Log the extended request message.
logExtendedRequest(this);
// Get the plugin config manager that will be used for invoking plugins.
try
{
// Check for and handle a request to cancel this operation.
checkIfCanceled(false);
// Invoke the pre-parse extended plugins.
if(!preParseResult.continueProcessing())
{
return;
}
checkIfCanceled(false);
// Get the extended operation handler for the request OID. If there is
// none, then fail.
{
return;
}
// Look at the controls included in the request and ensure that all
// critical controls are supported by the handler.
{
.hasNext();)
{
try
{
.isAllowed(getAuthorizationDN(), this, c))
{
// As per RFC 4511 4.1.11.
if (c.isCritical())
{
}
else
{
// We don't want to process this non-critical control, so
// remove it.
continue;
}
}
}
catch (DirectoryException e)
{
setResultCode(e.getResultCode());
return;
}
if (! c.isCritical())
{
// The control isn't critical, so we don't care if it's supported
// or not.
}
{
return;
}
}
}
// Check to see if the client has permission to perform the
// extended operation.
// FIXME: for now assume that this will check all permission
// pertinent to the operation. This includes proxy authorization
// and any other controls specified.
try
{
.getAccessControlHandler().isAllowed(this) == false)
{
return;
}
}
catch (DirectoryException e)
{
setResultCode(e.getResultCode());
return;
}
try
{
// Invoke the pre-operation extended plugins.
if(!preOpResult.continueProcessing())
{
return;
}
checkIfCanceled(false);
// Actually perform the processing for this operation.
handler.processExtendedOperation(this);
}
finally
{
}
}
catch(CanceledOperationException coe)
{
}
finally
{
// Stop the processing timer.
// Log the extended response.
logExtendedResponse(this);
// Send the response to the client.
{
clientConnection.sendResponse(this);
}
{
}
// Invoke the post-response extended plugins.
// If no cancel result, set it
if(cancelResult == null)
{
}
}
}
/**
* {@inheritDoc}
*/
{
}
}