use of software.amazon.awssdk.http.SdkHttpFullRequest in project aws-sdk-java-v2 by aws.
the class PresignRequestHandlerTest method testSourceRegionRemovedFromOriginalRequest.
@Test
public void testSourceRegionRemovedFromOriginalRequest() {
CopyDbClusterSnapshotRequest request = makeTestRequest();
SdkHttpFullRequest marshalled = marshallRequest(request);
SdkHttpRequest actual = modifyHttpRequest(presignInterceptor, request, marshalled);
assertFalse(actual.rawQueryParameters().containsKey("SourceRegion"));
}
use of software.amazon.awssdk.http.SdkHttpFullRequest in project aws-sdk-java-v2 by aws.
the class PresignRequestHandlerTest method testParsesDestinationRegionfromRequestEndpoint.
@Test
public void testParsesDestinationRegionfromRequestEndpoint() throws URISyntaxException {
CopyDbClusterSnapshotRequest request = CopyDbClusterSnapshotRequest.builder().sourceRegion("us-east-1").build();
Region destination = Region.of("us-west-2");
SdkHttpFullRequest marshalled = marshallRequest(request);
final SdkHttpRequest presignedRequest = modifyHttpRequest(presignInterceptor, request, marshalled);
final URI presignedUrl = new URI(presignedRequest.rawQueryParameters().get("PreSignedUrl").get(0));
assertTrue(presignedUrl.toString().contains("DestinationRegion=" + destination.id()));
}
use of software.amazon.awssdk.http.SdkHttpFullRequest in project aws-sdk-java-v2 by aws.
the class DefaultPollyPresigner method presign.
/**
* Generate a {@link PresignedRequest} from a {@link PresignedRequest} and {@link PollyRequest}.
*/
private <T extends PresignedRequest.Builder, U extends PollyRequest> T presign(T presignedRequest, PresignRequest presignRequest, U requestToPresign, Function<U, SdkHttpFullRequest.Builder> requestMarshaller) {
ExecutionAttributes execAttrs = createExecutionAttributes(presignRequest, requestToPresign);
SdkHttpFullRequest marshalledRequest = marshallRequest(requestToPresign, requestMarshaller);
SdkHttpFullRequest signedHttpRequest = presignRequest(requestToPresign, marshalledRequest, execAttrs);
initializePresignedRequest(presignedRequest, execAttrs, signedHttpRequest);
return presignedRequest;
}
use of software.amazon.awssdk.http.SdkHttpFullRequest 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.rawQueryParameters().get("X-Amz-SignedHeaders");
Validate.validState(signedHeadersQueryParam != null, "Only SigV4 presigners are supported at this time, but the configured " + "presigner (%s) did not seem to generate a SigV4 signature.", presigner);
return presigned;
}
use of software.amazon.awssdk.http.SdkHttpFullRequest in project aws-sdk-java-v2 by aws.
the class DefaultRdsUtilities method generateAuthenticationToken.
@Override
public String generateAuthenticationToken(GenerateAuthenticationTokenRequest request) {
SdkHttpFullRequest httpRequest = SdkHttpFullRequest.builder().method(SdkHttpMethod.GET).protocol("https").host(request.hostname()).port(request.port()).encodedPath("/").putRawQueryParameter("DBUser", request.username()).putRawQueryParameter("Action", "connect").build();
Instant expirationTime = Instant.now(clock).plus(EXPIRATION_DURATION);
Aws4PresignerParams presignRequest = Aws4PresignerParams.builder().signingClockOverride(clock).expirationTime(expirationTime).awsCredentials(resolveCredentials(request).resolveCredentials()).signingName("rds-db").signingRegion(resolveRegion(request)).build();
SdkHttpFullRequest fullRequest = signer.presign(httpRequest, presignRequest);
String signedUrl = fullRequest.getUri().toString();
// Note: This must be the real RDS hostname, not proxy or tunnels
return StringUtils.replacePrefixIgnoreCase(signedUrl, "https://", "");
}
Aggregations