use of software.amazon.awssdk.core.signer.AsyncRequestBodySigner in project aws-sdk-java-v2 by aws.
the class SigningStage method signRequest.
/**
* Sign the request if the signer if provided and credentials are present.
*/
private SdkHttpFullRequest signRequest(SdkHttpFullRequest request, RequestExecutionContext context) throws Exception {
updateInterceptorContext(request, context.executionContext());
Signer signer = context.signer();
MetricCollector metricCollector = context.attemptMetricCollector();
if (shouldSign(signer)) {
adjustForClockSkew(context.executionAttributes());
Pair<SdkHttpFullRequest, Duration> measuredSign = MetricUtils.measureDuration(() -> signer.sign(request, context.executionAttributes()));
metricCollector.reportMetric(CoreMetric.SIGNING_DURATION, measuredSign.right());
SdkHttpFullRequest signedRequest = measuredSign.left();
if (signer instanceof AsyncRequestBodySigner) {
// Transform request body provider with signing operator
AsyncRequestBody transformedRequestProvider = ((AsyncRequestBodySigner) signer).signAsyncRequestBody(signedRequest, context.requestProvider(), context.executionAttributes());
context.requestProvider(transformedRequestProvider);
}
updateInterceptorContext(signedRequest, context.executionContext());
return signedRequest;
}
return request;
}
Aggregations