use of software.amazon.awssdk.core.signer.AsyncSigner in project aws-sdk-java-v2 by aws.
the class AsyncSigningStage method signRequest.
/**
* Sign the request if the signer is provided and credentials are present.
*/
private CompletableFuture<SdkHttpFullRequest> signRequest(SdkHttpFullRequest request, RequestExecutionContext context) {
updateInterceptorContext(request, context.executionContext());
Signer signer = context.signer();
MetricCollector metricCollector = context.attemptMetricCollector();
if (!shouldSign(signer)) {
return CompletableFuture.completedFuture(request);
}
adjustForClockSkew(context.executionAttributes());
AsyncSigner asyncSigner = asAsyncSigner(signer, context);
long signingStart = System.nanoTime();
CompletableFuture<SdkHttpFullRequest> signedRequestFuture = asyncSigner.sign(request, context.requestProvider(), context.executionAttributes());
signedRequestFuture.whenComplete((r, t) -> metricCollector.reportMetric(CoreMetric.SIGNING_DURATION, Duration.ofNanos(System.nanoTime() - signingStart)));
return signedRequestFuture.thenApply(r -> {
updateInterceptorContext(r, context.executionContext());
return r;
});
}
Aggregations