|
5 | 5 |
|
6 | 6 | import org.apache.iceberg.aws.AwsClientProperties; |
7 | 7 | import org.apache.iceberg.aws.s3.S3FileIOProperties; |
8 | | -import org.jetbrains.annotations.NotNull; |
9 | 8 | import software.amazon.awssdk.auth.credentials.AnonymousCredentialsProvider; |
10 | 9 | import software.amazon.awssdk.auth.credentials.AwsCredentials; |
11 | 10 | import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider; |
|
19 | 18 | * fixed. |
20 | 19 | */ |
21 | 20 | // TODO (DH-19448): Remove this class once Iceberg fix for #13131 is released |
22 | | -public class DeephavenS3ClientCredentialsProvider implements AwsCredentialsProvider { |
23 | | - |
24 | | - private final S3FileIOProperties s3FileIOProperties; |
25 | | - private final AwsClientProperties awsClientProperties; |
26 | | - |
27 | | - private AwsCredentials cachedCredentials; |
28 | | - |
29 | | - public static DeephavenS3ClientCredentialsProvider create(Map<String, String> properties) { |
30 | | - return new DeephavenS3ClientCredentialsProvider(properties); |
| 21 | +public final class DeephavenS3ClientCredentialsProvider implements AwsCredentialsProvider { |
| 22 | + |
| 23 | + // See org.apache.iceberg.aws.AwsClientProperties.credentialsProvider |
| 24 | + // It does do a check to make sure the class implements AwsCredentials provider, but that isn't actually necessary |
| 25 | + // since it will just take the return value of this create. |
| 26 | + @SuppressWarnings("unused") |
| 27 | + public static AwsCredentialsProvider create(final Map<String, String> properties) { |
| 28 | + final S3FileIOProperties s3FileIOProperties = new S3FileIOProperties(properties); |
| 29 | + final AwsClientProperties awsClientProperties = new AwsClientProperties(properties); |
| 30 | + return s3FileIOProperties.isRemoteSigningEnabled() |
| 31 | + ? AnonymousCredentialsProvider.create() |
| 32 | + : awsClientProperties.credentialsProvider(s3FileIOProperties.accessKeyId(), |
| 33 | + s3FileIOProperties.secretAccessKey(), s3FileIOProperties.sessionToken()); |
31 | 34 | } |
32 | 35 |
|
33 | | - private DeephavenS3ClientCredentialsProvider(@NotNull final Map<String, String> properties) { |
34 | | - this.s3FileIOProperties = new S3FileIOProperties(properties); |
35 | | - this.awsClientProperties = new AwsClientProperties(properties); |
| 36 | + private DeephavenS3ClientCredentialsProvider() { |
| 37 | + throw new UnsupportedOperationException(); |
36 | 38 | } |
37 | 39 |
|
38 | 40 | @Override |
39 | 41 | public AwsCredentials resolveCredentials() { |
40 | | - if (cachedCredentials == null) { |
41 | | - final AwsCredentialsProvider delegateCredentialsProvider = |
42 | | - s3FileIOProperties.isRemoteSigningEnabled() |
43 | | - ? AnonymousCredentialsProvider.create() |
44 | | - : awsClientProperties.credentialsProvider(s3FileIOProperties.accessKeyId(), |
45 | | - s3FileIOProperties.secretAccessKey(), s3FileIOProperties.sessionToken()); |
46 | | - cachedCredentials = delegateCredentialsProvider.resolveCredentials(); |
47 | | - } |
48 | | - return cachedCredentials; |
| 42 | + throw new UnsupportedOperationException(); |
49 | 43 | } |
50 | 44 | } |
0 commit comments