use of software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration in project aws-sdk-java-v2 by aws.
the class DefaultQueryWaiter method applyWaitersUserAgent.
private <T extends QueryRequest> T applyWaitersUserAgent(T request) {
Consumer<AwsRequestOverrideConfiguration.Builder> userAgentApplier = b -> b.addApiName(ApiName.builder().version("waiter").name("hll").build());
AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration().map(c -> c.toBuilder().applyMutation(userAgentApplier).build()).orElse((AwsRequestOverrideConfiguration.builder().applyMutation(userAgentApplier).build()));
return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build();
}
use of software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration in project aws-sdk-java-v2 by aws.
the class S3PresignerTest method putObject_CredentialsCanBeOverriddenAtTheRequestLevel.
@Test
public void putObject_CredentialsCanBeOverriddenAtTheRequestLevel() {
AwsCredentials clientCredentials = AwsBasicCredentials.create("a", "a");
AwsCredentials requestCredentials = AwsBasicCredentials.create("b", "b");
S3Presigner presigner = presignerBuilder().credentialsProvider(() -> clientCredentials).build();
AwsRequestOverrideConfiguration overrideConfiguration = AwsRequestOverrideConfiguration.builder().credentialsProvider(() -> requestCredentials).build();
PresignedPutObjectRequest presignedWithClientCredentials = presigner.presignPutObject(r -> r.signatureDuration(Duration.ofMinutes(5)).putObjectRequest(go -> go.bucket("foo34343434").key("bar")));
PresignedPutObjectRequest presignedWithRequestCredentials = presigner.presignPutObject(r -> r.signatureDuration(Duration.ofMinutes(5)).putObjectRequest(go -> go.bucket("foo34343434").key("bar").overrideConfiguration(overrideConfiguration)));
assertThat(presignedWithClientCredentials.httpRequest().rawQueryParameters().get("X-Amz-Credential").get(0)).startsWith("a");
assertThat(presignedWithRequestCredentials.httpRequest().rawQueryParameters().get("X-Amz-Credential").get(0)).startsWith("b");
}
use of software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration in project aws-sdk-java-v2 by aws.
the class S3PresignerTest method putObject_Sigv4PresignerHonorsSignatureDuration.
@Test
public void putObject_Sigv4PresignerHonorsSignatureDuration() {
AwsRequestOverrideConfiguration override = AwsRequestOverrideConfiguration.builder().signer(AwsS3V4Signer.create()).build();
PresignedPutObjectRequest presigned = presigner.presignPutObject(r -> r.signatureDuration(Duration.ofSeconds(1234)).putObjectRequest(gor -> gor.bucket("a").key("b").overrideConfiguration(override)));
assertThat(presigned.httpRequest().rawQueryParameters().get("X-Amz-Expires").get(0)).satisfies(expires -> {
assertThat(expires).containsOnlyDigits();
assertThat(Integer.parseInt(expires)).isCloseTo(1234, Offset.offset(2));
});
}
use of software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration in project aws-sdk-java-v2 by aws.
the class DefaultJsonClient method applySignerOverride.
private <T extends JsonRequest> T applySignerOverride(T request, Signer signer) {
if (request.overrideConfiguration().flatMap(c -> c.signer()).isPresent()) {
return request;
}
Consumer<AwsRequestOverrideConfiguration.Builder> signerOverride = b -> b.signer(signer).build();
AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration().map(c -> c.toBuilder().applyMutation(signerOverride).build()).orElse((AwsRequestOverrideConfiguration.builder().applyMutation(signerOverride).build()));
return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build();
}
use of software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration in project aws-sdk-java-v2 by aws.
the class DefaultXmlAsyncClient method applySignerOverride.
private <T extends XmlRequest> T applySignerOverride(T request, Signer signer) {
if (request.overrideConfiguration().flatMap(c -> c.signer()).isPresent()) {
return request;
}
Consumer<AwsRequestOverrideConfiguration.Builder> signerOverride = b -> b.signer(signer).build();
AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration().map(c -> c.toBuilder().applyMutation(signerOverride).build()).orElse((AwsRequestOverrideConfiguration.builder().applyMutation(signerOverride).build()));
return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build();
}
Aggregations