use of software.amazon.awssdk.core.http.ExecutionContext in project aws-sdk-java-v2 by aws.
the class AwsExecutionContextBuilderTest method signing_ifNoOverrides_assignDefaultSigner.
@Test
public void signing_ifNoOverrides_assignDefaultSigner() {
ExecutionContext executionContext = AwsExecutionContextBuilder.invokeInterceptorsAndCreateExecutionContext(clientExecutionParams(), testClientConfiguration().build());
assertThat(executionContext.signer()).isEqualTo(defaultSigner);
}
use of software.amazon.awssdk.core.http.ExecutionContext in project aws-sdk-java-v2 by aws.
the class DefaultS3Presigner method marshalRequestAndUpdateContext.
/**
* Marshal the request and update the execution context with the result.
*/
private <T> void marshalRequestAndUpdateContext(ExecutionContext execCtx, Class<T> requestType, Function<T, SdkHttpFullRequest> requestMarshaller) {
T sdkRequest = Validate.isInstanceOf(requestType, execCtx.interceptorContext().request(), "Interceptor generated unsupported type (%s) when %s was expected.", execCtx.interceptorContext().request().getClass(), requestType);
SdkHttpFullRequest marshalledRequest = requestMarshaller.apply(sdkRequest);
// TODO: The core SDK doesn't put the request body into the interceptor context. That should be fixed.
Optional<RequestBody> requestBody = marshalledRequest.contentStreamProvider().map(ContentStreamProvider::newStream).map(is -> invokeSafely(() -> IoUtils.toByteArray(is))).map(RequestBody::fromBytes);
execCtx.interceptorContext(execCtx.interceptorContext().copy(r -> r.httpRequest(marshalledRequest).requestBody(requestBody.orElse(null))));
}
use of software.amazon.awssdk.core.http.ExecutionContext in project aws-sdk-java-v2 by aws.
the class DefaultS3Presigner method presign.
/**
* Generate a {@link PresignedRequest} from a {@link PresignedRequest} and {@link SdkRequest}.
*/
private <T extends PresignedRequest.Builder, U> T presign(T presignedRequest, PresignRequest presignRequest, SdkRequest requestToPresign, Class<U> requestToPresignType, Function<U, SdkHttpFullRequest> requestMarshaller, String operationName) {
ExecutionContext execCtx = invokeInterceptorsAndCreateExecutionContext(presignRequest, requestToPresign, operationName);
callBeforeMarshallingHooks(execCtx);
marshalRequestAndUpdateContext(execCtx, requestToPresignType, requestMarshaller);
callAfterMarshallingHooks(execCtx);
addRequestLevelHeadersAndQueryParameters(execCtx);
callModifyHttpRequestHooksAndUpdateContext(execCtx);
SdkHttpFullRequest httpRequest = getHttpFullRequest(execCtx);
SdkHttpFullRequest signedHttpRequest = presignRequest(execCtx, httpRequest);
initializePresignedRequest(presignedRequest, execCtx, signedHttpRequest);
return presignedRequest;
}
Aggregations