Package datadog.appsec.api.blocking
Class Blocking
java.lang.Object
datadog.appsec.api.blocking.Blocking
Functionality related to blocking requests. This functionality is available if and only if the
AppSec subsystem is enabled.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic Blocking.UserBlockingSpecStarts a user-blocking action.static voidsetBlockingService(BlockingService service) Controls the implementation for blocking.static booleantryCommitBlockingResponse(int statusCode, BlockingContentType contentType) Equivalent to callingtryCommitBlockingResponse(int, BlockingContentType, Map<String, String>)with the last parameter being an empty map.static booleantryCommitBlockingResponse(int statusCode, BlockingContentType contentType, Map<String, String> extraHeaders) Tries to commit an HTTP response with the specified status code and content type.
-
Method Details
-
forUser
Starts a user-blocking action.- Parameters:
userId- a non-null unique identifier for the currently identified user- Returns:
- an object through which the action in case of a match can be controlled
-
tryCommitBlockingResponse
public static boolean tryCommitBlockingResponse(int statusCode, BlockingContentType contentType, Map<String, String> extraHeaders) Tries to commit an HTTP response with the specified status code and content type. No exception should escape if this fails.This method returns
falseif blocking cannot be attempted because of the following conditions:- there is no span available,
- blocking is not supported for the server being used, or
- the blocking service is otherwise incapable, in principle, of blocking (e.g. it's a no-op implementation).
This method does not return false if a blocking response has already been committed, or if there is an error when trying to write the response. This is because the writing may happen asynchronously, after the caller has returned.
- Parameters:
statusCode- the status code of the responsecontentType- the content-type of the response.extraHeaders- map of headers to set in the response- Returns:
- whether blocking was/will be attempted
-
tryCommitBlockingResponse
Equivalent to callingtryCommitBlockingResponse(int, BlockingContentType, Map<String, String>)with the last parameter being an empty map.- Parameters:
statusCode- the status code of the responsecontentType- the content-type of the response.- Returns:
- whether blocking was/will be attempted
-
setBlockingService
Controls the implementation for blocking. The AppSec subsystem calls this method on startup. This can be called explicitly for e.g. testing purposes.- Parameters:
service- the implementation for blocking.
-