From 67ca26f9c9f0b26bfbed8b4e22618afc6d1d0196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Sugawara=20=28=E2=88=A9=EF=BD=80-=C2=B4=29?= =?UTF-8?q?=E2=8A=83=E2=94=81=E7=82=8E=E7=82=8E=E7=82=8E=E7=82=8E=E7=82=8E?= Date: Wed, 11 Oct 2023 14:42:26 -0700 Subject: [PATCH] Move the auth schemes into sdk --- .../AwsServiceClientConfiguration.java | 32 ++++--------------- .../core/RequestOverrideConfiguration.java | 1 + .../core/SdkServiceClientConfiguration.java | 29 +++++++++++++++-- 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/core/aws-core/src/main/java/software/amazon/awssdk/awscore/AwsServiceClientConfiguration.java b/core/aws-core/src/main/java/software/amazon/awssdk/awscore/AwsServiceClientConfiguration.java index 883405d8e3aa..cc9dc2c10c5f 100644 --- a/core/aws-core/src/main/java/software/amazon/awssdk/awscore/AwsServiceClientConfiguration.java +++ b/core/aws-core/src/main/java/software/amazon/awssdk/awscore/AwsServiceClientConfiguration.java @@ -37,13 +37,11 @@ public abstract class AwsServiceClientConfiguration extends SdkServiceClientConf private final Region region; private final IdentityProvider credentialsProvider; - private final Map> authSchemes; protected AwsServiceClientConfiguration(Builder builder) { super(builder); this.region = builder.region(); this.credentialsProvider = builder.credentialsProvider(); - this.authSchemes = builder.authSchemes(); } /** @@ -61,20 +59,12 @@ public IdentityProvider credentialsProvider() return credentialsProvider; } - /** - * @return The configured map of auth schemes. - */ - public Map> authSchemes() { - return authSchemes; - } - @Override public int hashCode() { int result = 1; result = 31 * result + super.hashCode(); result = 31 * result + (region != null ? region.hashCode() : 0); result = 31 * result + (credentialsProvider != null ? credentialsProvider.hashCode() : 0); - result = 31 * result + (authSchemes != null ? authSchemes.hashCode() : 0); return result; } @@ -86,8 +76,7 @@ public boolean equals(Object o) { AwsServiceClientConfiguration that = (AwsServiceClientConfiguration) o; return Objects.equals(region, that.region) - && Objects.equals(credentialsProvider, that.credentialsProvider) - && Objects.equals(authSchemes, that.authSchemes); + && Objects.equals(credentialsProvider, that.credentialsProvider); } /** @@ -123,28 +112,19 @@ default Builder endpointProvider(EndpointProvider endpointProvider) { throw new UnsupportedOperationException(); } - /** - * Configure the credentials provider - */ - default Builder credentialsProvider(IdentityProvider credentialsProvider) { - throw new UnsupportedOperationException(); - } - - default IdentityProvider credentialsProvider() { + @Override + default Builder putAuthScheme(AuthScheme authScheme) { throw new UnsupportedOperationException(); } /** - * Adds the given auth scheme. Replaces the an existing auth scheme with the same id. + * Configure the credentials provider */ - default Builder putAuthScheme(AuthScheme authScheme) { + default Builder credentialsProvider(IdentityProvider credentialsProvider) { throw new UnsupportedOperationException(); } - /** - * Returns the configured map of auth schemes. - */ - default Map> authSchemes() { + default IdentityProvider credentialsProvider() { throw new UnsupportedOperationException(); } diff --git a/core/sdk-core/src/main/java/software/amazon/awssdk/core/RequestOverrideConfiguration.java b/core/sdk-core/src/main/java/software/amazon/awssdk/core/RequestOverrideConfiguration.java index 7a6581ae380b..ae6bd6fd85a5 100644 --- a/core/sdk-core/src/main/java/software/amazon/awssdk/core/RequestOverrideConfiguration.java +++ b/core/sdk-core/src/main/java/software/amazon/awssdk/core/RequestOverrideConfiguration.java @@ -489,6 +489,7 @@ default B putRawQueryParameter(String name, String value) { * @param plugins The list of plugins for this request. * @return This object for method chaining. */ + @SdkPreviewApi B plugins(List plugins); /** diff --git a/core/sdk-core/src/main/java/software/amazon/awssdk/core/SdkServiceClientConfiguration.java b/core/sdk-core/src/main/java/software/amazon/awssdk/core/SdkServiceClientConfiguration.java index 7ae46d9944c6..ff88e44e3728 100644 --- a/core/sdk-core/src/main/java/software/amazon/awssdk/core/SdkServiceClientConfiguration.java +++ b/core/sdk-core/src/main/java/software/amazon/awssdk/core/SdkServiceClientConfiguration.java @@ -16,12 +16,14 @@ package software.amazon.awssdk.core; import java.net.URI; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.Consumer; import software.amazon.awssdk.annotations.SdkPublicApi; import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration; import software.amazon.awssdk.endpoints.EndpointProvider; +import software.amazon.awssdk.http.auth.spi.scheme.AuthScheme; /** * Class to expose SDK service client settings to the user, e.g., ClientOverrideConfiguration @@ -31,13 +33,14 @@ public abstract class SdkServiceClientConfiguration { private final ClientOverrideConfiguration overrideConfiguration; private final URI endpointOverride; - private final EndpointProvider endpointProvider; + private final Map> authSchemes; protected SdkServiceClientConfiguration(Builder builder) { this.overrideConfiguration = builder.overrideConfiguration(); this.endpointOverride = builder.endpointOverride(); this.endpointProvider = builder.endpointProvider(); + this.authSchemes = builder.authSchemes(); } /** @@ -67,6 +70,12 @@ public Optional endpointProvider() { return Optional.ofNullable(this.endpointProvider); } + /** + * @return The configured map of auth schemes. + */ + public Map> authSchemes() { + return authSchemes; + } @Override public boolean equals(Object o) { @@ -80,7 +89,8 @@ public boolean equals(Object o) { SdkServiceClientConfiguration serviceClientConfiguration = (SdkServiceClientConfiguration) o; return Objects.equals(overrideConfiguration, serviceClientConfiguration.overrideConfiguration()) && Objects.equals(endpointOverride, serviceClientConfiguration.endpointOverride().orElse(null)) - && Objects.equals(endpointProvider, serviceClientConfiguration.endpointProvider().orElse(null)); + && Objects.equals(endpointProvider, serviceClientConfiguration.endpointProvider().orElse(null)) + && Objects.equals(authSchemes, serviceClientConfiguration.authSchemes); } @Override @@ -88,6 +98,7 @@ public int hashCode() { int result = overrideConfiguration != null ? overrideConfiguration.hashCode() : 0; result = 31 * result + (endpointOverride != null ? endpointOverride.hashCode() : 0); result = 31 * result + (endpointProvider != null ? endpointProvider.hashCode() : 0); + result = 31 * result + (authSchemes != null ? authSchemes.hashCode() : 0); return result; } @@ -144,6 +155,20 @@ default Builder endpointProvider(EndpointProvider endpointProvider) { throw new UnsupportedOperationException(); } + /** + * Adds the given auth scheme. Replaces an existing auth scheme with the same id. + */ + default Builder putAuthScheme(AuthScheme authScheme) { + throw new UnsupportedOperationException(); + } + + /** + * Returns the configured map of auth schemes. + */ + default Map> authSchemes() { + throw new UnsupportedOperationException(); + } + /** * Build the service client configuration using the configuration on this builder */