use of software.amazon.awssdk.core.signer.Presigner in project aws-sdk-java-v2 by aws.
the class DefaultS3Presigner method initializePresignedRequest.
/**
* Initialize the provided presigned request.
*/
private void initializePresignedRequest(PresignedRequest.Builder presignedRequest, ExecutionContext execCtx, SdkHttpFullRequest signedHttpRequest) {
SdkBytes signedPayload = signedHttpRequest.contentStreamProvider().map(p -> SdkBytes.fromInputStream(p.newStream())).orElse(null);
List<String> signedHeadersQueryParam = signedHttpRequest.firstMatchingRawQueryParameters("X-Amz-SignedHeaders");
Validate.validState(!signedHeadersQueryParam.isEmpty(), "Only SigV4 presigners are supported at this time, but the configured " + "presigner (%s) did not seem to generate a SigV4 signature.", execCtx.signer());
Map<String, List<String>> signedHeaders = signedHeadersQueryParam.stream().flatMap(h -> Stream.of(h.split(";"))).collect(toMap(h -> h, h -> signedHttpRequest.firstMatchingHeader(h).map(Collections::singletonList).orElseGet(ArrayList::new)));
boolean isBrowserExecutable = signedHttpRequest.method() == SdkHttpMethod.GET && signedPayload == null && (signedHeaders.isEmpty() || (signedHeaders.size() == 1 && signedHeaders.containsKey("host")));
presignedRequest.expiration(execCtx.executionAttributes().getAttribute(PRESIGNER_EXPIRATION)).isBrowserExecutable(isBrowserExecutable).httpRequest(signedHttpRequest).signedHeaders(signedHeaders).signedPayload(signedPayload);
}
use of software.amazon.awssdk.core.signer.Presigner in project aws-sdk-java-v2 by aws.
the class DefaultPollyPresigner method presignRequest.
private SdkHttpFullRequest presignRequest(PollyRequest requestToPresign, SdkHttpFullRequest marshalledRequest, ExecutionAttributes executionAttributes) {
Presigner presigner = resolvePresigner(requestToPresign);
SdkHttpFullRequest presigned = presigner.presign(marshalledRequest, executionAttributes);
List<String> signedHeadersQueryParam = presigned.firstMatchingRawQueryParameters("X-Amz-SignedHeaders");
Validate.validState(!signedHeadersQueryParam.isEmpty(), "Only SigV4 presigners are supported at this time, but the configured " + "presigner (%s) did not seem to generate a SigV4 signature.", presigner);
return presigned;
}
Aggregations