Java implementation of Akamai {OPEN} EdgeGrid signing.
This library implements Akamai {OPEN} EdgeGrid Authentication for Java. This particular module is a binding for the Async HTTP Client library.
Include the following Maven dependency in your project POM:
<dependency>
<groupId>com.akamai.edgegrid</groupId>
<artifactId>edgegrid-signer-async-http-client</artifactId>
<version>3.0.1</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();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 the latter case requests must be prepared with the HTTP client.
Note, in both cases the host part of the URI does not matter, because it will be replaced by
the provided AsyncHttpClientEdgeGridSignatureCalculator with the host from the provided client
credential.