You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2023/03/16 13:04:29 UTC
[camel] 02/04: CAMEL-19159 - Camel-AWS: Support Profile Credential provider as configuration - AWS S3
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 5c8c367a0281fa5a09c6530b64801c7d4ac4f1cf
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Mar 16 13:21:19 2023 +0100
CAMEL-19159 - Camel-AWS: Support Profile Credential provider as configuration - AWS S3
Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
.../java/org/apache/camel/component/aws2/s3/AWS2S3Component.java | 4 +++-
.../aws2/s3/client/impl/AWS2S3ClientIAMProfileOptimizedImpl.java | 9 ++++-----
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Component.java b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Component.java
index 3650ecfe3cf..8f4a4d3fd64 100644
--- a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Component.java
+++ b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Component.java
@@ -51,7 +51,9 @@ public class AWS2S3Component extends DefaultComponent {
configuration.setBucketName(remaining);
AWS2S3Endpoint endpoint = new AWS2S3Endpoint(uri, this, configuration);
setProperties(endpoint, parameters);
- if (Boolean.FALSE.equals(configuration.isUseDefaultCredentialsProvider()) && Boolean.FALSE.equals(configuration.isUseProfileCredentialsProvider()) && configuration.getAmazonS3Client() == null
+ if (Boolean.FALSE.equals(configuration.isUseDefaultCredentialsProvider())
+ && Boolean.FALSE.equals(configuration.isUseProfileCredentialsProvider())
+ && configuration.getAmazonS3Client() == null
&& (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
throw new IllegalArgumentException(
"useDefaultCredentialsProvider is set to false, useProfileCredentialsProvider is set to false, AmazonS3Client or accessKey and secretKey must be specified");
diff --git a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/client/impl/AWS2S3ClientIAMProfileOptimizedImpl.java b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/client/impl/AWS2S3ClientIAMProfileOptimizedImpl.java
index 3576a9252f0..e2f74370518 100644
--- a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/client/impl/AWS2S3ClientIAMProfileOptimizedImpl.java
+++ b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/client/impl/AWS2S3ClientIAMProfileOptimizedImpl.java
@@ -16,14 +16,14 @@
*/
package org.apache.camel.component.aws2.s3.client.impl;
+import java.net.URI;
+
import org.apache.camel.component.aws2.s3.AWS2S3Configuration;
import org.apache.camel.component.aws2.s3.client.AWS2CamelS3InternalClient;
import org.apache.camel.util.ObjectHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
-import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.http.SdkHttpClient;
import software.amazon.awssdk.http.SdkHttpConfigurationOption;
import software.amazon.awssdk.http.apache.ApacheHttpClient;
@@ -33,8 +33,6 @@ import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.S3ClientBuilder;
import software.amazon.awssdk.utils.AttributeMap;
-import java.net.URI;
-
/**
* Manage an AWS s3 client for all users to use. This implementation is for local instances to use a static and solid
* credential set.
@@ -76,7 +74,8 @@ public class AWS2S3ClientIAMProfileOptimizedImpl implements AWS2CamelS3InternalC
clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder)
.credentialsProvider(ProfileCredentialsProvider.create(configuration.getProfileCredentialsName()));
} else {
- clientBuilder = clientBuilder.credentialsProvider(ProfileCredentialsProvider.create(configuration.getProfileCredentialsName()));
+ clientBuilder = clientBuilder
+ .credentialsProvider(ProfileCredentialsProvider.create(configuration.getProfileCredentialsName()));
}
} else {
if (!isClientConfigFound) {