public class RequestContext extends AbstractContext
Modifier and Type | Class and Description |
---|---|
static class |
RequestContext.RequestFlag
Distinguishes operations from server components, not directly from LDAP clients.
|
Modifier and Type | Field and Description |
---|---|
static TimeService |
NANO_TIME
A time service with nanosecond precision.
|
Constructor and Description |
---|
RequestContext(int messageId,
long operationId,
org.forgerock.services.context.Context parent)
Creates a new request context.
|
RequestContext(int messageId,
long operationId,
org.forgerock.services.context.Context parent,
Set<RequestContext.RequestFlag> requestFlags)
Creates a new request context, by also specifying additional request settings.
|
Modifier and Type | Method and Description |
---|---|
void |
addAdditionalItem(AdditionalLogItem item)
Adds a
AdditionalLogItem to the list for logging. |
void |
addCancelRequestListener(CancelRequestListener listener)
Registers the provided cancellation listener with this request context so that it can be notified if a
cancellation request is received and processing of the request should be aborted if possible.
|
void |
appendMaskedErrorMessage(LocalizableMessage maskedMessage)
Appends the provided message to the real, masked error message buffer.
|
void |
cannotCancel(LocalizableMessage cannotCancelReason)
Marks the request associated to this request context as not cancellable.
|
void |
checkIfCancelled(boolean signalTooLate)
Throws
CancelledResultException if a cancellation request has been received and processing of the request
should be aborted if possible. |
RequestContext |
etimeStarted(TimeService timeService)
Sets the time at which processing started for this request.
|
RequestContext |
etimeStopped()
Sets the time at which the processing stopped for this request.
|
List<AdditionalLogItem> |
getAdditionalLogItems()
Returns additional information to be logged, as a potentially empty
List of AdditionalLogItem . |
LocalizableMessage |
getAuthFailureReason()
Returns a human-readable message providing the reason why the authentication failed, if available.
|
FlowableOperator<Response,Response> |
getCancellationOperator()
Returns a probe monitoring the response sent to the client in order to maintain the cancellation state.
|
ConnectionContext |
getConnectionContext()
Returns the connection context associated to this context.
|
Entry |
getEntryAsAddedByServer()
Returns the entry as added by the server, with all additional operational attributes.
|
LocalizableMessageBuilder |
getMaskedErrorMessage()
Retrieves the real, masked error message for this operation.
|
ResultCode |
getMaskedResultCode()
Retrieves the real, masked result code for this operation.
|
int |
getMessageId()
Returns the message id associated to the request.
|
List<Modification> |
getModificationsAsAppliedByServer()
Returns the list of modifications applied by the server.
|
long |
getOperationId()
Returns the operation id associated to the request.
|
long |
getProcessingTime()
Returns the processing time for the request.
|
TimeUnit |
getProcessingTimeUnit()
Returns the processing time unit for the request.
|
Dn |
getProxiedAuthorizationDn()
Returns the proxied authorization DN if proxy authorization has been requested.
|
int |
getSearchNumberOfEntriesReturned()
Returns the number of entries sent by the search request associated to this context.
|
boolean |
hasFlag(RequestContext.RequestFlag requestFlag)
Returns whether this request has the provided flag.
|
boolean |
hasPrivilege(Privilege privilege)
Returns
true if the authorized user has the specified privilege. |
void |
setAdditionalItems(List<AdditionalLogItem> items)
Sets the
AdditionalLogItem s. |
void |
setAuthFailureReason(LocalizableMessage reason)
Specifies the reason why authentication failed.
|
void |
setEntryAsAddedByServer(Entry entryAsAddedByServer)
Sets the entry added as added by the server in the DIT.
|
RequestContext |
setMaskedResultCode(ResultCode maskedResultCode)
Specifies the real, masked result code for this operation.
|
void |
setModificationsAsAppliedByServer(List<Modification> modificationsAsAppliedByServer)
Sets the list of modifications applied to an entry by the server while processing a Modify request.
|
RequestContext |
setProxiedAuthorizationDn(Dn proxiedAuthorizationDn)
Set the proxied authorization DN for this operation if any.
|
void |
setSearchNumberOfEntriesReturned(int searchNumberOfEntriesReturned)
Sets the number of entries returned by the search request associated to this context.
|
asContext, containsContext, containsContext, getContext, getContextName, getId, getParent, isRootContext, toJsonValue, toString
public static final TimeService NANO_TIME
public RequestContext(int messageId, long operationId, org.forgerock.services.context.Context parent)
messageId
- The message id associated to this request.operationId
- The operation id associated to this request.parent
- The parent context.public RequestContext(int messageId, long operationId, org.forgerock.services.context.Context parent, Set<RequestContext.RequestFlag> requestFlags)
messageId
- The message id associated to this request.operationId
- The operation id associated to this request.parent
- The parent context.requestFlags
- The set of additional flags for this requestpublic Entry getEntryAsAddedByServer()
May differ from the entry specified in the Add request as attributes may be encoded, audit log will preferentially use the server entry.
public void setEntryAsAddedByServer(Entry entryAsAddedByServer)
entryAsAddedByServer
- the entry added by the serverpublic List<Modification> getModificationsAsAppliedByServer()
May differ from client specified modifications as some attributes may be encoded, audit log will preferentially use the returned list.
public void setModificationsAsAppliedByServer(List<Modification> modificationsAsAppliedByServer)
modificationsAsAppliedByServer
- the list of modifications generated by the serverpublic FlowableOperator<Response,Response> getCancellationOperator()
public void addCancelRequestListener(CancelRequestListener listener)
listener
- The listener which should be notified if processing of the request should be aborted if possible.NullPointerException
- If the listener
was null
.checkIfCancelled(boolean)
public void checkIfCancelled(boolean signalTooLate) throws CancelledResultException
CancelledResultException
if a cancellation request has been received and processing of the request
should be aborted if possible. Requests may be cancelled as a result of an abandon request or a cancel
extended request sent from the client, or by the server itself (e.g. during server shutdown). This method
provides a polling mechanism which can be used by synchronous request handler implementations to detect
cancellation of requests.signalTooLate
- true
to signal that, after this method returns, processing of the request will have proceeded too
far for it to be aborted by subsequent cancellation requests.CancelledResultException
- If processing of the request should be aborted if possible.addCancelRequestListener(org.forgerock.opendj.server.core.CancelRequestListener)
public void cannotCancel(LocalizableMessage cannotCancelReason)
ResultCode.CANNOT_CANCEL
and the provided reason.cannotCancelReason
- The reason which will be provided in the cancel responses.public boolean hasFlag(RequestContext.RequestFlag requestFlag)
requestFlag
- the request flag to test fortrue
if this request has the provided flagpublic int getMessageId()
public long getOperationId()
public boolean hasPrivilege(Privilege privilege)
true
if the authorized user has the specified privilege.privilege
- The required privilege.true
if the authorized user has the specified privilege.public ConnectionContext getConnectionContext()
public RequestContext etimeStarted(TimeService timeService)
timeService
- the TimeService
for computing processing time for the requestpublic RequestContext etimeStopped()
public long getProcessingTime()
public TimeUnit getProcessingTimeUnit()
public ResultCode getMaskedResultCode()
null
if there is no need for onepublic RequestContext setMaskedResultCode(ResultCode maskedResultCode)
null
value will reset to not having a masked error code to log.maskedResultCode
- The real, masked result code for this operation If null
, the masked error message will be
removed.public LocalizableMessageBuilder getMaskedErrorMessage()
null
if none has been setpublic final void appendMaskedErrorMessage(LocalizableMessage maskedMessage)
maskedMessage
- The message to append to the real, masked error messagepublic LocalizableMessage getAuthFailureReason()
null
if none is
available.public void setAuthFailureReason(LocalizableMessage reason)
reason
- the message describing why authentication failedpublic Dn getProxiedAuthorizationDn()
null
is proxy authorization has not been requestedpublic RequestContext setProxiedAuthorizationDn(Dn proxiedAuthorizationDn)
proxiedAuthorizationDn
- The proxied authorization DN. if null
this operation will have no proxy authorization.public int getSearchNumberOfEntriesReturned()
public void setSearchNumberOfEntriesReturned(int searchNumberOfEntriesReturned)
searchNumberOfEntriesReturned
- the number of entries sentpublic List<AdditionalLogItem> getAdditionalLogItems()
List
of AdditionalLogItem
.List
of AdditionalLogItem
public void addAdditionalItem(AdditionalLogItem item)
AdditionalLogItem
to the list for logging. null
items will be ignored.item
- the additional log item to addpublic void setAdditionalItems(List<AdditionalLogItem> items)
AdditionalLogItem
s. All existing elements will be deleted.items
- the new log itemsCopyright 2010-2018 ForgeRock AS.