This library implements Akamai EdgeGrid Authentication for Java. This particular module is a binding for the Async HTTP Client library. This project contains installation and usage instructions in the README.md.
Include the following Maven dependency in your project POM:
<dependency>
<groupId>com.akamai.edgegrid</groupId>
<artifactId>edgegrid-signer-async-http-client</artifactId>
<version>5.0.0</version>
</dependency>
Create an HTTP request that will be signed with a defined client credential:
Request request = new RequestBuilder("POST")
.setUrl("https://localhost/papi/v0/properties")
.addQueryParam("contractId","ctr_1-3CV382")
.addQueryParam("groupId","grp_18385")
.setBody("{ \"productId\": \"Site_Accel\", \"propertyName\": \"8LuWyUjwea\" }")
.setHeader("Content-Type", "application/json")
.setSignatureCalculator(new AsyncHttpClientEdgeGridSignatureCalculator(clientCredential))
.build();
asyncHttpClient().executeRequest(request).get();
> Note: The `host` part of the URI will be replaced by the provided `AsyncHttpClientEdgeGridSignatureCalculator`
with the host from the client credential in the `.edgerc` file.
Alternatively, create an HTTP client that will sign each HTTP request with a defined client credential:
AsyncHttpClient client = asyncHttpClient()
.setSignatureCalculator(new AsyncHttpClientEdgeGridSignatureCalculator(clientCredential));
client.preparePost("https://localhost/papi/v0/properties")
.addQueryParam("contractId","ctr_1-3CV382")
.addQueryParam("groupId","grp_18385")
.setBody("{ \"productId\": \"Site_Accel\", \"propertyName\": \"8LuWyUjwea\" }")
.setHeader("Content-Type", "application/json")
.execute().get();
Note: In this case you need to prepare requests with the HTTP client.