Class AssemblylineClient
java.lang.Object
ca.gc.cyber.ops.assemblyline.java.client.clients.AssemblylineClient
- All Implemented Interfaces:
IAssemblylineClient
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.springframework.web.reactive.function.client.ExchangeFilterFunctionprotected AssemblylineAuthenticationMethodprotected com.fasterxml.jackson.databind.ObjectMapperprotected Stringprotected org.springframework.web.reactive.function.client.WebClientFields inherited from interface ca.gc.cyber.ops.assemblyline.java.client.clients.IAssemblylineClient
BASE_URL, FILE_DOWNLOAD_URL, FILE_INFO_URL, FILE_RESULT_FOR_SERVICE_URL, FILE_RESULTS_URL, HASH_SEARCH, HASH_SEARCH_LIST_DATA_SOURCES, INGEST_GET_MESSAGE_LIST_URL, INGEST_URL, LOGIN_URL, RESULT_URL, SUBMISSION_COMPLETE_URL, SUBMISSION_FILE_RESULTS_URL, SUBMISSION_FULL_URL, SUBMISSION_TREE_URL, SUBMISSION_URL, SUBMIT_URL -
Constructor Summary
ConstructorsConstructorDescriptionAssemblylineClient(AssemblylineClientProperties assemblylineClientProperties, reactor.netty.http.client.HttpClient httpClient, AssemblylineAuthenticationMethod assemblylineAuthenticationMethod) Constructs a new instance of AssemblylineClient.AssemblylineClient(AssemblylineClientProperties assemblylineClientProperties, reactor.netty.http.client.HttpClient httpClient, com.fasterxml.jackson.databind.ObjectMapper defaultMapper, AssemblylineAuthenticationMethod assemblylineAuthenticationMethod) Deprecated, for removal: This API element is subject to removal in a future version.Allowing external code to supply an ObjectMapper can cause issues if the provided mapper is configured in a way that is not compatible with the JSON produced/consumed by AssemblyLine. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbuildWebClient(AssemblylineClientProperties assemblylineClientProperties, reactor.netty.http.client.HttpClient httpClient) protected <T> reactor.core.publisher.Mono<T>clientResponseToMono(org.springframework.web.reactive.function.client.ClientResponse clientResponse, org.springframework.core.ParameterizedTypeReference<AssemblylineApiResponse<T>> type) Convert ClientResponse to AssemblylineApiResponse content mono.downloadFile(String sha256) downloadFile(String sha256, DownloadFileParams params) protected <T> reactor.core.publisher.Mono<T>get(Function<org.springframework.web.util.UriBuilder, URI> uriBuilder, org.springframework.core.ParameterizedTypeReference<AssemblylineApiResponse<T>> responseType) Helper method to perform a JSON GET request.reactor.core.publisher.Mono<FileInfo>getFileInfo(String sha256) reactor.core.publisher.Mono<FileResultForService>getFileResultForService(String sha256, String serviceName) reactor.core.publisher.Mono<FileResults>getFileResults(String sha256) reactor.core.publisher.Flux<IngestSubmissionResponse>getIngestMessageList(String notification) reactor.core.publisher.Mono<ResultBlock>reactor.core.publisher.Mono<Submission>getSubmission(String sid) reactor.core.publisher.Mono<SubmissionFileResults>getSubmissionFileResults(String sid, String sha256) reactor.core.publisher.Mono<SubmissionFull>getSubmissionFull(String sid) reactor.core.publisher.Mono<SubmissionTree>getSubmissionTree(String sid) reactor.core.publisher.Mono<Map<String,HashSearchResult>> hashSearch(String fileHash) Search for a hash in multiple data sources, using default values for optional parameters.reactor.core.publisher.Mono<Map<String,HashSearchResult>> hashSearch(String fileHash, List<String> dataSources, Integer maxTimeout) Search for a hash in multiple data sources.reactor.core.publisher.Mono<IngestResponse>ingestAsyncBinary(AsyncBinaryFile<IngestBase> asyncBinaryIngest) reactor.core.publisher.Mono<IngestResponse>ingestBinary(BinaryFile<IngestBase> binaryIngest) reactor.core.publisher.Mono<IngestResponse>ingestUrlOrSha256(NonBinaryIngest ingest) reactor.core.publisher.Mono<Boolean>reactor.core.publisher.Mono<LoginResponse>login()protected <T> reactor.core.publisher.Mono<T>post(Function<org.springframework.web.util.UriBuilder, URI> uriBuilder, org.springframework.core.ParameterizedTypeReference<AssemblylineApiResponse<T>> responseType, org.springframework.web.reactive.function.BodyInserter<?, ? super org.springframework.http.client.reactive.ClientHttpRequest> bodyInserter, org.springframework.http.MediaType contentType) Helper method to perform a JSON POST request.protected <T> reactor.core.publisher.Mono<T>retryWrapper(reactor.core.publisher.Mono<T> monoContent) protected voidsetSession(org.springframework.web.reactive.function.client.ClientResponse clientResponse) reactor.core.publisher.Mono<Submission>submitAsyncBinary(AsyncBinaryFile<SubmitMetadata> binaryIngest) reactor.core.publisher.Mono<Submission>submitBinary(BinaryFile<SubmitMetadata> binaryIngest) reactor.core.publisher.Mono<Submission>submitUrlOrSha256(NonBinarySubmit submit) withAuthBearerToken(String authBearerToken) Creates a copy of the current AssemblylineClient that will use the given authentication bearer token.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ca.gc.cyber.ops.assemblyline.java.client.clients.IAssemblylineClient
getSession
-
Field Details
-
session
-
webClient
protected org.springframework.web.reactive.function.client.WebClient webClient -
mapper
protected com.fasterxml.jackson.databind.ObjectMapper mapper -
assemblylineAuthenticationMethod
-
addSession
protected org.springframework.web.reactive.function.client.ExchangeFilterFunction addSession
-
-
Constructor Details
-
AssemblylineClient
@Deprecated(forRemoval=true, since="1.11") public AssemblylineClient(AssemblylineClientProperties assemblylineClientProperties, reactor.netty.http.client.HttpClient httpClient, com.fasterxml.jackson.databind.ObjectMapper defaultMapper, AssemblylineAuthenticationMethod assemblylineAuthenticationMethod) Deprecated, for removal: This API element is subject to removal in a future version.Allowing external code to supply an ObjectMapper can cause issues if the provided mapper is configured in a way that is not compatible with the JSON produced/consumed by AssemblyLine. UseAssemblylineClient(AssemblylineClientProperties, HttpClient, AssemblylineAuthenticationMethod)instead.Constructs a new instance of AssemblylineClient.- Parameters:
assemblylineClientProperties- Properties to use when configuring the AssemblylineClient instance.httpClient- The HTTP client to be used to communicate with AssemblyLine.defaultMapper- A baseObjectMapperthat will be copied and then configured for use with AssemblyLine. This constructor is deprecated because of this parameter; users of this constructor may inadvertently introduce a misconfigured ObjectMapper.assemblylineAuthenticationMethod- The authentication method to use when connecting to AssemblyLine.
-
AssemblylineClient
public AssemblylineClient(AssemblylineClientProperties assemblylineClientProperties, reactor.netty.http.client.HttpClient httpClient, AssemblylineAuthenticationMethod assemblylineAuthenticationMethod) Constructs a new instance of AssemblylineClient.- Parameters:
assemblylineClientProperties- Properties to use when configuring the AssemblylineClient instance.httpClient- The HTTP client to be used to communicate with AssemblyLine.assemblylineAuthenticationMethod- The authentication method to use when connecting to AssemblyLine.
-
-
Method Details
-
withAuthBearerToken
Creates a copy of the current AssemblylineClient that will use the given authentication bearer token.- Specified by:
withAuthBearerTokenin interfaceIAssemblylineClient- Parameters:
authBearerToken- The authentication bearer token for the new client to use.- Returns:
- the new client.
-
buildWebClient
protected void buildWebClient(AssemblylineClientProperties assemblylineClientProperties, reactor.netty.http.client.HttpClient httpClient) -
login
- Specified by:
loginin interfaceIAssemblylineClient
-
isSubmissionComplete
- Specified by:
isSubmissionCompletein interfaceIAssemblylineClient
-
getFileInfo
- Specified by:
getFileInfoin interfaceIAssemblylineClient
-
getFileResults
- Specified by:
getFileResultsin interfaceIAssemblylineClient
-
getFileResultForService
public reactor.core.publisher.Mono<FileResultForService> getFileResultForService(String sha256, String serviceName) - Specified by:
getFileResultForServicein interfaceIAssemblylineClient
-
getResult
- Specified by:
getResultin interfaceIAssemblylineClient
-
getSubmissionFileResults
public reactor.core.publisher.Mono<SubmissionFileResults> getSubmissionFileResults(String sid, String sha256) - Specified by:
getSubmissionFileResultsin interfaceIAssemblylineClient
-
getSubmissionTree
- Specified by:
getSubmissionTreein interfaceIAssemblylineClient
-
getSubmission
- Specified by:
getSubmissionin interfaceIAssemblylineClient
-
getSubmissionFull
- Specified by:
getSubmissionFullin interfaceIAssemblylineClient
-
ingestUrlOrSha256
- Specified by:
ingestUrlOrSha256in interfaceIAssemblylineClient
-
ingestBinary
public reactor.core.publisher.Mono<IngestResponse> ingestBinary(BinaryFile<IngestBase> binaryIngest) - Specified by:
ingestBinaryin interfaceIAssemblylineClient
-
ingestAsyncBinary
public reactor.core.publisher.Mono<IngestResponse> ingestAsyncBinary(AsyncBinaryFile<IngestBase> asyncBinaryIngest) - Specified by:
ingestAsyncBinaryin interfaceIAssemblylineClient
-
getIngestMessageList
public reactor.core.publisher.Flux<IngestSubmissionResponse> getIngestMessageList(String notification) - Specified by:
getIngestMessageListin interfaceIAssemblylineClient
-
submitUrlOrSha256
- Specified by:
submitUrlOrSha256in interfaceIAssemblylineClient
-
submitBinary
public reactor.core.publisher.Mono<Submission> submitBinary(BinaryFile<SubmitMetadata> binaryIngest) - Specified by:
submitBinaryin interfaceIAssemblylineClient
-
submitAsyncBinary
public reactor.core.publisher.Mono<Submission> submitAsyncBinary(AsyncBinaryFile<SubmitMetadata> binaryIngest) - Specified by:
submitAsyncBinaryin interfaceIAssemblylineClient
-
downloadFile
- Specified by:
downloadFilein interfaceIAssemblylineClient
-
downloadFile
- Specified by:
downloadFilein interfaceIAssemblylineClient
-
getHashSearchDataSources
- Specified by:
getHashSearchDataSourcesin interfaceIAssemblylineClient
-
hashSearch
public reactor.core.publisher.Mono<Map<String,HashSearchResult>> hashSearch(String fileHash, List<String> dataSources, Integer maxTimeout) Search for a hash in multiple data sources.- Specified by:
hashSearchin interfaceIAssemblylineClient- Parameters:
fileHash- Hash to search in the multiple data sources (MD5, SHA1 or SHA256)dataSources- list of data sources. Set to null to use server default.maxTimeout- Maximum execution time for the call in seconds. Set to null to use server default.- Returns:
- Search results
- See Also:
-
hashSearch
Search for a hash in multiple data sources, using default values for optional parameters.- Specified by:
hashSearchin interfaceIAssemblylineClient- Parameters:
fileHash- Hash to search in the multiple data sources (MD5, SHA1 or SHA256)- Returns:
- Search results
- See Also:
-
setSession
protected void setSession(org.springframework.web.reactive.function.client.ClientResponse clientResponse) -
retryWrapper
protected <T> reactor.core.publisher.Mono<T> retryWrapper(reactor.core.publisher.Mono<T> monoContent) -
get
protected <T> reactor.core.publisher.Mono<T> get(Function<org.springframework.web.util.UriBuilder, URI> uriBuilder, org.springframework.core.ParameterizedTypeReference<AssemblylineApiResponse<T>> responseType) Helper method to perform a JSON GET request. This helper covers the most common GET requests. For more specialized requests, use webClient directly.- Type Parameters:
T- The type of data that will be in the response.- Parameters:
uriBuilder- UriBuilder that will generate the URI to GET.responseType- A parameterized type reference representing the type of data that will be in the response. The declaration of this object must only include concrete type parameters. For example,new ParameterizedTypeReference<ALApiResponse<Boolean>>is OK, butnew ParameterizedTypeReference<ALApiResponse<T>>(whereTis a type parameter on a method) is not OK.- Returns:
- The content of the "api_response" section of the response.
-
post
protected <T> reactor.core.publisher.Mono<T> post(Function<org.springframework.web.util.UriBuilder, URI> uriBuilder, org.springframework.core.ParameterizedTypeReference<AssemblylineApiResponse<T>> responseType, org.springframework.web.reactive.function.BodyInserter<?, ? super org.springframework.http.client.reactive.ClientHttpRequest> bodyInserter, org.springframework.http.MediaType contentType) Helper method to perform a JSON POST request. This helper covers the most common POST requests. For more specialized requests, use webClient directly.- Type Parameters:
T- The type of data that will be in the response.- Parameters:
uriBuilder- UriBuilder that will generate the URI to POST.responseType- A parameterized type reference representing the type of data that will be in the response. The declaration of this object must only include concrete type parameters. For example,new ParameterizedTypeReference<ALApiResponse<Boolean>>is OK, butnew ParameterizedTypeReference<ALApiResponse<T>>(whereTis a type parameter on a method) is not OK.bodyInserter- BodyInserter to construct the body of the Post RequestcontentType- MediaType of the request body- Returns:
- The content of the "api_response" section of the response.
-
clientResponseToMono
protected <T> reactor.core.publisher.Mono<T> clientResponseToMono(org.springframework.web.reactive.function.client.ClientResponse clientResponse, org.springframework.core.ParameterizedTypeReference<AssemblylineApiResponse<T>> type) Convert ClientResponse to AssemblylineApiResponse content mono.- Type Parameters:
T- The type of data that will be in the response.- Parameters:
clientResponse- ClientResponse returned by calltype- A parameterized type reference representing the type of data that will be in the response. The declaration of this object must only include concrete type parameters. For example,new ParameterizedTypeReference<ALApiResponse<Boolean>>is OK, butnew ParameterizedTypeReference<ALApiResponse<T>>(whereTis a type parameter on a method) is not OK.- Returns:
- Mono of clientResponse body
-