If the application running the SDK requires a custom HTTP Client, to enable features such as configuring SSL or adding default headers to requests, then the TargetClient
will need to be configured using ClientConfig.builder().httpClient()
:
The SDK currently supports HTTP Clients that implement the org.apache.http.client.HttpClient
interface.
CloseableHttpClient httpClient = HttpClients.custom().build();
ClientConfig clientConfig = ClientConfig.builder()
.client("acmeclient")
.organizationId("1234567890@AdobeOrg")
.httpClient(httpClient)
.build();
TargetClient targetClient = TargetClient.create(clientConfig);
Here is an example of how to configure SSL in the TargetClient
by customizing the HttpClient
passed into the ClientConfig
. The following code snippet uses classes from the org.apache.http.conn.ssl
package for SSL configuration.
SSLContext context = SSLContextBuilder.create().build();
SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(context);
CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(sslSocketFactory).build();
ClientConfig clientConfig = ClientConfig.builder()
.client("acmeclient")
.organizationId("1234567890@AdobeOrg")
.httpClient(httpClient)
.build();
TargetClient targetClient = TargetClient.create(clientConfig);