Search in sources :

Example 1 with AsyncSigner

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;
    });
}
Also used : AsyncSigner(software.amazon.awssdk.core.signer.AsyncSigner) AsyncRequestBodySigner(software.amazon.awssdk.core.signer.AsyncRequestBodySigner) Signer(software.amazon.awssdk.core.signer.Signer) SdkHttpFullRequest(software.amazon.awssdk.http.SdkHttpFullRequest) MetricCollector(software.amazon.awssdk.metrics.MetricCollector) AsyncSigner(software.amazon.awssdk.core.signer.AsyncSigner)

Aggregations

AsyncRequestBodySigner (software.amazon.awssdk.core.signer.AsyncRequestBodySigner)1 AsyncSigner (software.amazon.awssdk.core.signer.AsyncSigner)1 Signer (software.amazon.awssdk.core.signer.Signer)1 SdkHttpFullRequest (software.amazon.awssdk.http.SdkHttpFullRequest)1 MetricCollector (software.amazon.awssdk.metrics.MetricCollector)1