Class Operation
- All Implemented Interfaces:
PluginOperation,PostCommitOperation,PostResponseOperation,PreParseOperation
- Direct Known Subclasses:
AbandonOperation,AddOperation,BindOperation,CompareOperation,DeleteOperation,ExtendedOperation,ModifyDnOperation,ModifyOperation,SearchOperation,UnbindOperation
Note that this class is not intended to be subclassed by any third-party code outside of the OpenDJ project. It should only be extended by the operation types included in the
org.opends.server.core package.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final LocalBackend<?>The local backend associated with this operation.protected final RequestContextThe request context associated with this operation.protected final Consumer<ResponseStream>A consumer responsible for sending responses to the client.protected final PluginConfigManagerThe plugin manager associated with this operation.protected final RequestThe request.protected final ServerContextThe server context associated with this operation. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedOperation(RequestContext context, LocalBackend<?> backend, Request request, Consumer<ResponseStream> out) Creates a new local operation that will be applied to the specified local backend. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidAdds an additional log item to this operation, which should be written to the log but not included in the response to the client.final voidAdds a password policy warning message in the Log additional items.protected voidaddPostReadResponse(PostReadRequestControl postReadRequest, Entry entry) Adds the post-read response control to the response if requested.protected voidaddPreReadResponse(PreReadRequestControl preReadRequest, Entry entry) Adds the pre-read response control to the response if requested.final voidaddRequestControl(Control control) Adds the provided control to the set of request controls for this operation.abstract voidaddResponseControl(Control control) Adds the provided control to the set of controls to include in the response to the client.final voidappendErrorMessage(LocalizableMessage message) Appends the provided message to the error message buffer.final voidappendMaskedErrorMessage(LocalizableMessage maskedMessage) Appends the provided message to the real, masked error message buffer.protected voidcheckAttributeConformsToSyntax(Entry entry, Attribute attribute, LocalizableMessageDescriptor.Arg4<Object, Object, Object, Object> invalidSyntaxErrorMsg, LocalizableMessageDescriptor.Arg3<Object, Object, Object> invalidSyntaxNoValueErrorMsg, LocalizableMessageDescriptor.Arg1<Object> rejectErrorMsg) Checks whether an attribute's values conform to its syntax.protected voidcheckIfBackendIsWritable(Dn entryDN, LocalizableMessageDescriptor.Arg1<Object> serverMsg, LocalizableMessageDescriptor.Arg1<Object> backendMsg) Checks if an update operation can be performed against a backend.final voidcheckIfCanceled(boolean signalTooLate) Checks to see if this operation requested to cancel in which caseCancelledResultExceptionwill be thrown.protected static LdapExceptionReturns a newLdapExceptionbuilt from the provided resultCodes and messages.final booleanfinal voidEvaluate all aci and privilege checks for any proxy auth controls.final List<AdditionalLogItem>Returns an unmodifiable list containing the additional log items for this operation, which should be written to the log but not included in the response to the client.final <T> TgetAttachment(String name) Retrieves the attachment with the specified name.Retrieves the set of attachments defined for this operation, as a mapping between the attachment name and the associated object.final DnRetrieves the authorization DN for this operation.final EntryRetrieves the entry for the user that should be considered the authorization identity for this operation.final ClientConnectionRetrieves the client connection with which this operation is associated.final longRetrieves the unique identifier that is assigned to the client connection that submitted this operation.Retrieves the error message for this operation.final longReturns the operation largest entry size, or zero if no size is available.final DnRetrieves the matched DN for this operation.final intRetrieves the message ID assigned to this operation.final longRetrieves the operation ID for this operation.final DnRetrieves the proxied authorization DN for this operation if proxied authorization has been requested.Retrieves the set of referral URLs for this operation.Returns the request associated to this operation.final RequestContextReturns the request context associated with this operation.final <T extends Control>
TgetRequestControl(ControlDecoder<T> d, DecodeOptions options) Retrieves a control included in the request from the client.Retrieves the set of controls included in the request from the client.final ResultCodeRetrieves the result code for this operation.final inthashCode()final booleanhasPrivilege(Privilege privilege) Returnstrueif this operation has the provided privilege.final booleanhasRequestControl(String oid) Returnstrueif this operation contains the specified request control.protected abstract voidInvokes any applicable post-response plugins.protected abstract @com.forgerock.opendj.util.LoomTODO({"Pre-parse plugins should be invoked in the router for all requests"}) booleanInvokes any applicable pre-parse plugins.final booleanIndicates whether this is an internal operation rather than one that was requested by an external client.protected static booleanCheck if an OID is for a proxy authorization control.final booleanIndicates whether this is a synchronization operation rather than one that was requested by an external client.protected booleanReturnstrueif a request must be validated according to the server's schema.protected ResultGenerates a result for this operation.booleanprocessOperationResult(PluginResult.OperationResult operationResult) Processes the provided operation result for the current operation.protected final voidremoveAllDisallowedControls(Dn targetDN) Removes all the disallowed request controls from this operation.abstract voidremoveResponseControl(Control control) Removes the provided control from the set of controls to include in the response to the client.final voidrun()Processes this operation in the local backend.protected abstract booleanrunImpl()Performs the work of actually processing this operation.final voidsendResponses(ResponseStream responses) Sends the provided intermediate response messages to the client.protected final ResultSends the result for this operation.final voidsetAttachment(String name, Object value) Sets the value of the specified attachment.final voidsetErrorMessage(LocalizableMessageBuilder errorMessage) Specifies the error message for this operation.final voidsetMatchedDN(Dn matchedDN) Specifies the matched DN for this operation.final voidsetReferralURLs(List<String> referralURLs) Specifies the set of referral URLs for this operation.final voidSets the response elements for this operation based on the information contained in the providedexceptionobject.final voidSpecifies the result for this operation.final voidsetResultCode(ResultCode resultCode) Specifies the result code for this operation.protected static voidsetResultCodeAndMessageNoInfoDisclosure(Operation operation, Entry entry, Dn entryDN, Result realResult, Result altResult) Sets the provided resultCodes and messages on the provided operation.final StringtoString()Retrieves a string representation of this operation.abstract voidtoString(StringBuilder buffer) Appends a string representation of this operation to the provided buffer.final voidtrySetLargestEntrySize(long size) Try to update the size of the largest entry that has been accessed by the request.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.opends.server.types.operation.PluginOperation
getRequestControl, getResponseControls
-
Field Details
-
serverContext
The server context associated with this operation. -
pluginConfigManager
The plugin manager associated with this operation. -
context
The request context associated with this operation. -
backend
The local backend associated with this operation. -
request
The request. -
out
A consumer responsible for sending responses to the client.
-
-
Constructor Details
-
Operation
protected Operation(RequestContext context, LocalBackend<?> backend, Request request, Consumer<ResponseStream> out) Creates a new local operation that will be applied to the specified local backend.- Parameters:
context- The request context.backend- The local backend.request- The request.out- A consumer responsible for sending responses to the client.
-
-
Method Details
-
getRequestContext
Returns the request context associated with this operation.- Returns:
- The request context associated with this operation.
-
getClientConnection
Description copied from interface:PluginOperationRetrieves the client connection with which this operation is associated.- Specified by:
getClientConnectionin interfacePluginOperation- Returns:
- The client connection with which this operation is associated.
-
hasPrivilege
Description copied from interface:PluginOperationReturnstrueif this operation has the provided privilege.- Specified by:
hasPrivilegein interfacePluginOperation- Parameters:
privilege- the privilege to test- Returns:
- true if this operation has the provided privilege.
-
getConnectionID
public final long getConnectionID()Description copied from interface:PluginOperationRetrieves the unique identifier that is assigned to the client connection that submitted this operation.- Specified by:
getConnectionIDin interfacePluginOperation- Returns:
- The unique identifier that is assigned to the client connection that submitted this operation.
-
getOperationID
public final long getOperationID()Description copied from interface:PluginOperationRetrieves the operation ID for this operation.- Specified by:
getOperationIDin interfacePluginOperation- Returns:
- The operation ID for this operation.
-
getMessageID
public final int getMessageID()Description copied from interface:PluginOperationRetrieves the message ID assigned to this operation.- Specified by:
getMessageIDin interfacePluginOperation- Returns:
- The message ID assigned to this operation.
-
getRequest
Returns the request associated to this operation.- Specified by:
getRequestin interfacePluginOperation- Returns:
- The request associated to this operation.
-
getRequestControls
Description copied from interface:PluginOperationRetrieves the set of controls included in the request from the client. The returned this list must not be altered.- Specified by:
getRequestControlsin interfacePluginOperation- Returns:
- The set of controls included in the request from the client.
Note: the list of request controls can be modified by the server. Therefore
PluginOperation.getRequestControls()may return a list different from the list returned byPluginOperation.getRequest().getControls().
-
getRequestControl
public final <T extends Control> T getRequestControl(ControlDecoder<T> d, DecodeOptions options) throws LdapException Description copied from interface:PluginOperationRetrieves a control included in the request from the client.- Specified by:
getRequestControlin interfacePluginOperation- Type Parameters:
T- The type of control requested.- Parameters:
d- The requested control's decoder.options- The decode options.- Returns:
- The decoded form of the requested control included in the request from the client or
nullif the control was not found. - Throws:
LdapException- if an error occurs while decoding the control.Note: the list of request controls can be modified by the server. Therefore
PluginOperation.getRequestControls(ControlDecoder<T> d, DecodeOptions options)may return a list different from the list returned byPluginOperation.getRequest().getControls().
-
hasRequestControl
Returnstrueif this operation contains the specified request control.- Parameters:
oid- The OID of the request control.- Returns:
trueif this operation contains the specified request control.
-
addRequestControl
Adds the provided control to the set of request controls for this operation.This method may only be called by pre-parse plugins.
- Specified by:
addRequestControlin interfacePreParseOperation- Parameters:
control- The control to add to the set of request controls for this operation.
-
addResponseControl
Adds the provided control to the set of controls to include in the response to the client.This method may not be called by post-response plugins.
- Specified by:
addResponseControlin interfacePreParseOperation- Parameters:
control- The control to add to the set of controls to include in the response to the client.
-
removeResponseControl
Removes the provided control from the set of controls to include in the response to the client.This method may not be called by post-response plugins.
- Specified by:
removeResponseControlin interfacePreParseOperation- Parameters:
control- The control to remove from the set of controls to include in the response to the client.
-
getResultCode
Description copied from interface:PostCommitOperationRetrieves the result code for this operation.- Specified by:
getResultCodein interfacePostCommitOperation- Specified by:
getResultCodein interfacePostResponseOperation- Returns:
- The result code associated for this operation, or
UNDEFINEDif the operation has not yet completed.
-
setResult
Specifies the result for this operation. This method may not be called by post-response plugins.- Parameters:
result- The result for this operation.
-
setResultCode
Specifies the result code for this operation. This method may not be called by post-response plugins.- Parameters:
resultCode- The result code for this operation.
-
getErrorMessage
Retrieves the error message for this operation. Its contents may be altered by pre-parse, pre-operation, and post-operation plugins, but not by post-response plugins.- Specified by:
getErrorMessagein interfacePostCommitOperation- Specified by:
getErrorMessagein interfacePostResponseOperation- Specified by:
getErrorMessagein interfacePreParseOperation- Returns:
- The error message for this operation.
-
setErrorMessage
Specifies the error message for this operation.This method may not be called by post-response plugins.
- Specified by:
setErrorMessagein interfacePreParseOperation- Parameters:
errorMessage- The error message for this operation.
-
appendErrorMessage
Appends the provided message to the error message buffer. If the buffer has not yet been created, then this will create it first and then add the provided message.This method may not be called by post-response plugins.
- Specified by:
appendErrorMessagein interfacePreParseOperation- Parameters:
message- The message to append to the error message buffer.
-
appendMaskedErrorMessage
Appends the provided message to the real, masked error message buffer. If the buffer has not yet been created, then this will create it first and then add the provided message. This method may not be called by post-response plugins.- Parameters:
maskedMessage- The message to append to the real, masked error message
-
getAdditionalLogItems
Description copied from interface:PreParseOperationReturns an unmodifiable list containing the additional log items for this operation, which should be written to the log but not included in the response to the client.- Specified by:
getAdditionalLogItemsin interfacePostCommitOperation- Specified by:
getAdditionalLogItemsin interfacePostResponseOperation- Specified by:
getAdditionalLogItemsin interfacePreParseOperation- Returns:
- An unmodifiable list containing the additional log items for this operation.
-
addAdditionalLogItem
Description copied from interface:PreParseOperationAdds an additional log item to this operation, which should be written to the log but not included in the response to the client. This method may not be called by post-response plugins.- Specified by:
addAdditionalLogItemin interfacePreParseOperation- Parameters:
item- The additional log item for this operation.
-
addPasswordPolicyWarningToLog
Adds a password policy warning message in the Log additional items.- Parameters:
msg- the message to log.
-
getMatchedDN
Description copied from interface:PostCommitOperationRetrieves the matched DN for this operation.- Specified by:
getMatchedDNin interfacePostCommitOperation- Specified by:
getMatchedDNin interfacePostResponseOperation- Returns:
- The matched DN for this operation, or
nullif the operation has not yet completed or does not have a matched DN.
-
setMatchedDN
Specifies the matched DN for this operation. This may not be called by post-response plugins.- Parameters:
matchedDN- The matched DN for this operation.
-
getReferralURLs
Description copied from interface:PostCommitOperationRetrieves the set of referral URLs for this operation. Its contents must not be altered by the caller.- Specified by:
getReferralURLsin interfacePostCommitOperation- Specified by:
getReferralURLsin interfacePostResponseOperation- Returns:
- The set of referral URLs for this operation, or
nullif the operation is not yet complete or does not have a set of referral URLs.
-
setReferralURLs
Specifies the set of referral URLs for this operation. This may not be called by post-response plugins.- Parameters:
referralURLs- The set of referral URLs for this operation.
-
setResult
Sets the response elements for this operation based on the information contained in the providedexceptionobject. This method may not be called by post-response plugins.- Parameters:
e- The exception containing the information to use for the response elements.
-
isInternalOperation
public final boolean isInternalOperation()Description copied from interface:PluginOperationIndicates whether this is an internal operation rather than one that was requested by an external client.- Specified by:
isInternalOperationin interfacePluginOperation- Returns:
trueif this is an internal operation, orfalseif it is not.
-
isSynchronizationOperation
public final boolean isSynchronizationOperation()Description copied from interface:PluginOperationIndicates whether this is a synchronization operation rather than one that was requested by an external client.- Specified by:
isSynchronizationOperationin interfacePluginOperation- Returns:
trueif this is a data synchronization operation, orfalseif it is not.
-
getAuthorizationEntry
Retrieves the entry for the user that should be considered the authorization identity for this operation. In many cases, it will be the same as the authorization entry for the underlying client connection, ornullif no authentication has been performed on that connection. However, it may be some other value if special processing has been requested (e.g., the operation included a proxied authorization control). This method should not be called by pre-parse plugins because the correct value may not yet have been determined.- Returns:
- The entry for the user that should be considered the authorization identity for this operation, or
nullif the authorization identity should be the unauthenticated user.
-
getAuthorizationDN
Retrieves the authorization DN for this operation. In many cases, it will be the same as the DN of the authenticated user for the underlying connection, or the null DN if no authentication has been performed on that connection. However, it may be some other value if special processing has been requested (e.g., the operation included a proxied authorization control).This method should not be called by pre-parse plugins because the correct value may not have yet been determined.
- Specified by:
getAuthorizationDNin interfacePostCommitOperation- Specified by:
getAuthorizationDNin interfacePostResponseOperation- Returns:
- The authorization DN for this operation.
-
getAttachments
Description copied from interface:PluginOperationRetrieves the set of attachments defined for this operation, as a mapping between the attachment name and the associated object.- Specified by:
getAttachmentsin interfacePluginOperation- Returns:
- The set of attachments defined for this operation.
-
getAttachment
Description copied from interface:PluginOperationRetrieves the attachment with the specified name.- Specified by:
getAttachmentin interfacePluginOperation- Type Parameters:
T- the type of the attached object- Parameters:
name- The name for the attachment to retrieve. It will be treated in a case-sensitive manner.- Returns:
- The requested attachment object, or
nullif it does not exist.
-
setAttachment
Description copied from interface:PluginOperationSets the value of the specified attachment. If an attachment already exists with the same name, it will be replaced. Otherwise, a new attachment will be added.- Specified by:
setAttachmentin interfacePluginOperation- Parameters:
name- The name to use for the attachment.value- The value to use for the attachment.
-
checkIfCanceled
Checks to see if this operation requested to cancel in which caseCancelledResultExceptionwill be thrown.Kept to maintain compatibility with the
PluginOperationinterface.- Specified by:
checkIfCanceledin interfacePluginOperation- Parameters:
signalTooLate-trueto signal that any further cancel requests will be too late after return from this call orfalseotherwise.- Throws:
CancelledResultException- if this operation should be cancelled.
-
toString
Description copied from interface:PluginOperationRetrieves a string representation of this operation.- Specified by:
toStringin interfacePluginOperation- Overrides:
toStringin classObject- Returns:
- A string representation of this operation.
-
toString
Description copied from interface:PluginOperationAppends a string representation of this operation to the provided buffer.- Specified by:
toStringin interfacePluginOperation- Parameters:
buffer- The buffer into which a string representation of this operation should be appended.
-
getProxiedAuthorizationDN
Retrieves the proxied authorization DN for this operation if proxied authorization has been requested.- Returns:
- The proxied authorization DN for this operation if proxied authorization has been requested, or
nullif proxied authorization has not been requested.
-
hashCode
public final int hashCode() -
equals
-
processOperationResult
Processes the provided operation result for the current operation.- Parameters:
operationResult- the operation result- Returns:
trueif processing can continue,falseotherwise
-
isProxyAuthzControl
Check if an OID is for a proxy authorization control.- Parameters:
oid- The OID to check- Returns:
trueif the OID is for a proxy auth v1 or v2 control,falseotherwise.
-
removeAllDisallowedControls
Removes all the disallowed request controls from this operation.As per RFC 4511 4.1.11, if a disallowed request control is critical, then a LdapException is thrown with unavailableCriticalExtension. Otherwise, if the disallowed request control is non critical, it is removed because we do not want the backend to process it.
- Parameters:
targetDN- the target DN of the operation- Throws:
LdapException- If a disallowed request control is critical, thrown with unavailableCriticalExtension. If an error occurred while performing the access control check. For example, if an attribute could not be decoded. Care must be taken not to expose any potentially sensitive information in the exception.
-
evaluateProxyAuthControls
Evaluate all aci and privilege checks for any proxy auth controls. This must be done before evaluating all other controls so that their aci can then be checked correctly.- Throws:
LdapException- if a proxy auth control is found but cannot be used.
-
createLdapException
protected static LdapException createLdapException(Operation operation, Entry entry, Dn entryDN, Result result, Result altResult) throws LdapException Returns a newLdapExceptionbuilt from the provided resultCodes and messages. Depending on whether ACIs prevent information disclosure, the provided resultCode and message will be masked and altResultCode and altMessage will be used instead.- Parameters:
operation- the operation for which to check if ACIs prevent information disclosureentry- the entry for which to check if ACIs prevent information disclosure, if null, then a fake entry will be created from the entryDN parameterentryDN- the entry dn for which to check if ACIs prevent information disclosure. Only used if entry is null.result- the result containing the result code and message to put on the LdapException if ACIs allow disclosure. Otherwise it will be put on the LdapException as a masked result code.altResult- the result contains the result code and message to put on the LdapException if ACIs do not allow disclosing the resultCode.- Returns:
- a newLdapException containing the provided resultCodes and messages depending on ACI allowing disclosure or not
- Throws:
LdapException- If an error occurred while performing the access control check.
-
setResultCodeAndMessageNoInfoDisclosure
protected static void setResultCodeAndMessageNoInfoDisclosure(Operation operation, Entry entry, Dn entryDN, Result realResult, Result altResult) throws LdapException Sets the provided resultCodes and messages on the provided operation. Depending on whether ACIs prevent information disclosure, the provided resultCode and message will be masked and altResultCode and altMessage will be used instead.- Parameters:
operation- the operation for which to check if ACIs prevent information disclosureentry- the entry for which to check if ACIs prevent information disclosure, if null, then a fake entry will be created from the entryDN parameterentryDN- the entry dn for which to check if ACIs prevent information disclosure. Only used if entry is null.realResult- the result containing the result code and the message to put on the LdapException if ACIs allow disclosure. Otherwise it will be put on the LdapException as a masked result code.altResult- the result containing the result code and the message to put on the LdapException if ACIs do not allow disclosing the resultCode.- Throws:
LdapException- If an error occurred while performing the access control check.
-
addPostReadResponse
Adds the post-read response control to the response if requested.- Parameters:
postReadRequest- The request control, if present.entry- The post-update entry.
-
addPreReadResponse
Adds the pre-read response control to the response if requested.- Parameters:
preReadRequest- The request control, if present.entry- The pre-update entry.
-
checkIfBackendIsWritable
protected void checkIfBackendIsWritable(Dn entryDN, LocalizableMessageDescriptor.Arg1<Object> serverMsg, LocalizableMessageDescriptor.Arg1<Object> backendMsg) throws LdapException Checks if an update operation can be performed against a backend. The operation will be rejected based on the server and backend writability modes.- Parameters:
entryDN- The name of the entry being updated.serverMsg- The message to log if the update was rejected because the server is read-only.backendMsg- The message to log if the update was rejected because the backend is read-only.- Throws:
LdapException- If the update operation has been rejected.
-
getLargestEntrySize
public final long getLargestEntrySize()Returns the operation largest entry size, or zero if no size is available.- Returns:
- the operation largest entry size, or zero if no size is available.
-
trySetLargestEntrySize
public final void trySetLargestEntrySize(long size) Try to update the size of the largest entry that has been accessed by the request.- Parameters:
size- The size of the latest entry that has been accessed by the request.
-
checkAttributeConformsToSyntax
protected void checkAttributeConformsToSyntax(Entry entry, Attribute attribute, LocalizableMessageDescriptor.Arg4<Object, Object, throws LdapExceptionObject, Object> invalidSyntaxErrorMsg, LocalizableMessageDescriptor.Arg3<Object, Object, Object> invalidSyntaxNoValueErrorMsg, LocalizableMessageDescriptor.Arg1<Object> rejectErrorMsg) Checks whether an attribute's values conform to its syntax. The server's syntax enforcement policy is applied if an invalid value is encountered.- Parameters:
entry- The entry being modified or renamed.attribute- The attribute whose values are to be checked.invalidSyntaxErrorMsg- The error message which should be used for human readable syntaxes.invalidSyntaxNoValueErrorMsg- The error message which should be used for binary syntaxes.rejectErrorMsg- The error message which should be used when the request is to be rejected.- Throws:
LdapException- If an invalid value is encountered and strict enforcement is enabled.
-
mustCheckSchema
protected boolean mustCheckSchema()Returnstrueif a request must be validated according to the server's schema.- Returns:
trueif a request must be validated according to the server's schema.
-
run
Processes this operation in the local backend.- Throws:
LdapException- If the request failed.
-
sendResponses
Description copied from interface:PreParseOperationSends the provided intermediate response messages to the client.- Specified by:
sendResponsesin interfacePreParseOperation- Parameters:
responses- The intermediate response messages to be sent.
-
sendResult
Sends the result for this operation.- Returns:
- The result.
-
runImpl
Performs the work of actually processing this operation.- Returns:
trueif the result should be sent immediately, orfalseif it will be sent later, e.g. as part of a persistent search.- Throws:
LdapException- If an error occurred when processing the operation.
-
invokePreParsePlugins
protected abstract @com.forgerock.opendj.util.LoomTODO({"Pre-parse plugins should be invoked in the router for all requests"}) boolean invokePreParsePlugins() throws LdapExceptionInvokes any applicable pre-parse plugins.- Returns:
trueif processing should continue.- Throws:
LdapException- If an error occurred when invoking the pre-parse plugins.
-
invokePostResponsePlugins
protected abstract void invokePostResponsePlugins()Invokes any applicable post-response plugins. -
operationToResult
Generates a result for this operation.- Returns:
- The result.
-