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/21 10:18:56 UTC

[camel] branch main updated (0898a2cf308 -> 49c30daee0c)

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


    from 0898a2cf308 CAMEL-19132: Replace vm with seda endpoint (#9587)
     new 0eb391575ce CAMEL-19159 - Camel-AWS: Support Profile Credential provider as configuration - AWS SQS
     new abe96e0e82e CAMEL-19159 - Camel-AWS: Support Profile Credential provider as configuration - AWS SQS
     new 90107da2fc3 CAMEL-19159 - Camel-AWS: Support Profile Credential provider as configuration - AWS SQS
     new 8cc1c3f580b CAMEL-19159 - Camel-AWS: Support Profile Credential provider as configuration - AWS SQS
     new 74614d5ba75 CAMEL-19159 - Camel-AWS: Support Profile Credential provider as configuration - AWS SQS
     new 3fb1add9c34 CAMEL-19159 - Camel-AWS: Support Profile Credential provider as configuration - AWS SQS
     new 49225ccaa1e CAMEL-19159 - Camel-AWS: Support Profile Credential provider as configuration - AWS SQS
     new 49c30daee0c CAMEL-19159 - Camel-AWS: Support Profile Credential provider as configuration - AWS SQS

The 8 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../aws2/sqs/Sqs2ComponentConfigurer.java          | 12 +++++
 .../component/aws2/sqs/Sqs2EndpointConfigurer.java | 12 +++++
 .../component/aws2/sqs/Sqs2EndpointUriFactory.java |  4 +-
 .../apache/camel/component/aws2/sqs/aws2-sqs.json  |  4 ++
 .../src/main/docs/aws2-sqs-component.adoc          |  8 ++-
 .../camel/component/aws2/sqs/Sqs2Component.java    |  6 ++-
 .../component/aws2/sqs/Sqs2Configuration.java      | 27 ++++++++++
 .../aws2/sqs/client/Sqs2ClientFactory.java         | 10 +++-
 ...java => Sqs2ClientIAMProfileOptimizedImpl.java} | 15 +++---
 ...qs2ConsumerHealthCheckIAMProfileCredsTest.java} |  4 +-
 .../component/aws2/sqs/SqsClientFactoryTest.java   | 60 ++++++++++++++++++++++
 11 files changed, 146 insertions(+), 16 deletions(-)
 copy components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/impl/{Sqs2ClientStandardImpl.java => Sqs2ClientIAMProfileOptimizedImpl.java} (88%)
 copy components/camel-aws/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/{Sqs2ConsumerHealthCheckProfileCredsTest.java => Sqs2ConsumerHealthCheckIAMProfileCredsTest.java} (96%)
 create mode 100644 components/camel-aws/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/SqsClientFactoryTest.java


[camel] 03/08: CAMEL-19159 - Camel-AWS: Support Profile Credential provider as configuration - AWS SQS

Posted by ac...@apache.org.
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 90107da2fc3010c3070f8803465778336201bc2d
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Mar 21 10:30:42 2023 +0100

    CAMEL-19159 - Camel-AWS: Support Profile Credential provider as configuration - AWS SQS
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../component/aws2/sqs/SqsClientFactoryTest.java   | 61 ++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/components/camel-aws/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/SqsClientFactoryTest.java b/components/camel-aws/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/SqsClientFactoryTest.java
new file mode 100644
index 00000000000..e9db9f6b3ea
--- /dev/null
+++ b/components/camel-aws/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/SqsClientFactoryTest.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws2.sqs;
+
+
+import org.apache.camel.component.aws2.sqs.client.Sqs2ClientFactory;
+import org.apache.camel.component.aws2.sqs.client.Sqs2InternalClient;
+import org.apache.camel.component.aws2.sqs.client.impl.Sqs2ClientIAMOptimized;
+import org.apache.camel.component.aws2.sqs.client.impl.Sqs2ClientIAMProfileOptimizedImpl;
+import org.apache.camel.component.aws2.sqs.client.impl.Sqs2ClientStandardImpl;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class SqsClientFactoryTest {
+
+    @Test
+    public void getStandardSqsClientDefault() {
+        Sqs2Configuration sqsConfiguration = new Sqs2Configuration();
+        Sqs2InternalClient awsssqsClient = Sqs2ClientFactory.getSqsClient(sqsConfiguration);
+        assertTrue(awsssqsClient instanceof Sqs2ClientStandardImpl);
+    }
+
+    @Test
+    public void getStandardSqsClient() {
+        Sqs2Configuration sqsConfiguration = new Sqs2Configuration();
+        sqsConfiguration.setUseDefaultCredentialsProvider(false);
+        Sqs2InternalClient awsssqsClient = Sqs2ClientFactory.getSqsClient(sqsConfiguration);
+        assertTrue(awsssqsClient instanceof Sqs2ClientStandardImpl);
+    }
+
+    @Test
+    public void getIAMOptimizedSqsClient() {
+        Sqs2Configuration sqsConfiguration = new Sqs2Configuration();
+        sqsConfiguration.setUseDefaultCredentialsProvider(true);
+        Sqs2InternalClient awsssqsClient = Sqs2ClientFactory.getSqsClient(sqsConfiguration);
+        assertTrue(awsssqsClient instanceof Sqs2ClientIAMOptimized);
+    }
+
+    @Test
+    public void getIAMProfileOptimizedSqsClient() {
+        Sqs2Configuration sqsConfiguration = new Sqs2Configuration();
+        sqsConfiguration.setUseProfileCredentialsProvider(true);
+        Sqs2InternalClient awsssqsClient = Sqs2ClientFactory.getSqsClient(sqsConfiguration);
+        assertTrue(awsssqsClient instanceof Sqs2ClientIAMProfileOptimizedImpl);
+    }
+}


[camel] 02/08: CAMEL-19159 - Camel-AWS: Support Profile Credential provider as configuration - AWS SQS

Posted by ac...@apache.org.
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 abe96e0e82e9042523a10c065c23329fee5b661a
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Mar 21 10:26:50 2023 +0100

    CAMEL-19159 - Camel-AWS: Support Profile Credential provider as configuration - AWS SQS
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../camel/component/aws2/sqs/Sqs2ComponentConfigurer.java    | 12 ++++++++++++
 .../camel/component/aws2/sqs/Sqs2EndpointConfigurer.java     | 12 ++++++++++++
 .../camel/component/aws2/sqs/Sqs2EndpointUriFactory.java     |  4 +++-
 .../org/apache/camel/component/aws2/sqs/aws2-sqs.json        |  4 ++++
 4 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/components/camel-aws/camel-aws2-sqs/src/generated/java/org/apache/camel/component/aws2/sqs/Sqs2ComponentConfigurer.java b/components/camel-aws/camel-aws2-sqs/src/generated/java/org/apache/camel/component/aws2/sqs/Sqs2ComponentConfigurer.java
index c58d85502a9..80ae4eabd24 100644
--- a/components/camel-aws/camel-aws2-sqs/src/generated/java/org/apache/camel/component/aws2/sqs/Sqs2ComponentConfigurer.java
+++ b/components/camel-aws/camel-aws2-sqs/src/generated/java/org/apache/camel/component/aws2/sqs/Sqs2ComponentConfigurer.java
@@ -81,6 +81,8 @@ public class Sqs2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "overrideendpoint":
         case "overrideEndpoint": getOrCreateConfiguration(target).setOverrideEndpoint(property(camelContext, boolean.class, value)); return true;
         case "policy": getOrCreateConfiguration(target).setPolicy(property(camelContext, java.lang.String.class, value)); return true;
+        case "profilecredentialsname":
+        case "profileCredentialsName": getOrCreateConfiguration(target).setProfileCredentialsName(property(camelContext, java.lang.String.class, value)); return true;
         case "protocol": getOrCreateConfiguration(target).setProtocol(property(camelContext, java.lang.String.class, value)); return true;
         case "proxyhost":
         case "proxyHost": getOrCreateConfiguration(target).setProxyHost(property(camelContext, java.lang.String.class, value)); return true;
@@ -107,6 +109,8 @@ public class Sqs2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "uriEndpointOverride": getOrCreateConfiguration(target).setUriEndpointOverride(property(camelContext, java.lang.String.class, value)); return true;
         case "usedefaultcredentialsprovider":
         case "useDefaultCredentialsProvider": getOrCreateConfiguration(target).setUseDefaultCredentialsProvider(property(camelContext, boolean.class, value)); return true;
+        case "useprofilecredentialsprovider":
+        case "useProfileCredentialsProvider": getOrCreateConfiguration(target).setUseProfileCredentialsProvider(property(camelContext, boolean.class, value)); return true;
         case "visibilitytimeout":
         case "visibilityTimeout": getOrCreateConfiguration(target).setVisibilityTimeout(property(camelContext, java.lang.Integer.class, value)); return true;
         case "waittimeseconds":
@@ -176,6 +180,8 @@ public class Sqs2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "overrideendpoint":
         case "overrideEndpoint": return boolean.class;
         case "policy": return java.lang.String.class;
+        case "profilecredentialsname":
+        case "profileCredentialsName": return java.lang.String.class;
         case "protocol": return java.lang.String.class;
         case "proxyhost":
         case "proxyHost": return java.lang.String.class;
@@ -202,6 +208,8 @@ public class Sqs2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "uriEndpointOverride": return java.lang.String.class;
         case "usedefaultcredentialsprovider":
         case "useDefaultCredentialsProvider": return boolean.class;
+        case "useprofilecredentialsprovider":
+        case "useProfileCredentialsProvider": return boolean.class;
         case "visibilitytimeout":
         case "visibilityTimeout": return java.lang.Integer.class;
         case "waittimeseconds":
@@ -267,6 +275,8 @@ public class Sqs2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "overrideendpoint":
         case "overrideEndpoint": return getOrCreateConfiguration(target).isOverrideEndpoint();
         case "policy": return getOrCreateConfiguration(target).getPolicy();
+        case "profilecredentialsname":
+        case "profileCredentialsName": return getOrCreateConfiguration(target).getProfileCredentialsName();
         case "protocol": return getOrCreateConfiguration(target).getProtocol();
         case "proxyhost":
         case "proxyHost": return getOrCreateConfiguration(target).getProxyHost();
@@ -293,6 +303,8 @@ public class Sqs2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "uriEndpointOverride": return getOrCreateConfiguration(target).getUriEndpointOverride();
         case "usedefaultcredentialsprovider":
         case "useDefaultCredentialsProvider": return getOrCreateConfiguration(target).isUseDefaultCredentialsProvider();
+        case "useprofilecredentialsprovider":
+        case "useProfileCredentialsProvider": return getOrCreateConfiguration(target).isUseProfileCredentialsProvider();
         case "visibilitytimeout":
         case "visibilityTimeout": return getOrCreateConfiguration(target).getVisibilityTimeout();
         case "waittimeseconds":
diff --git a/components/camel-aws/camel-aws2-sqs/src/generated/java/org/apache/camel/component/aws2/sqs/Sqs2EndpointConfigurer.java b/components/camel-aws/camel-aws2-sqs/src/generated/java/org/apache/camel/component/aws2/sqs/Sqs2EndpointConfigurer.java
index 8f4b390363e..7390a236471 100644
--- a/components/camel-aws/camel-aws2-sqs/src/generated/java/org/apache/camel/component/aws2/sqs/Sqs2EndpointConfigurer.java
+++ b/components/camel-aws/camel-aws2-sqs/src/generated/java/org/apache/camel/component/aws2/sqs/Sqs2EndpointConfigurer.java
@@ -91,6 +91,8 @@ public class Sqs2EndpointConfigurer extends PropertyConfigurerSupport implements
         case "policy": target.getConfiguration().setPolicy(property(camelContext, java.lang.String.class, value)); return true;
         case "pollstrategy":
         case "pollStrategy": target.setPollStrategy(property(camelContext, org.apache.camel.spi.PollingConsumerPollStrategy.class, value)); return true;
+        case "profilecredentialsname":
+        case "profileCredentialsName": target.getConfiguration().setProfileCredentialsName(property(camelContext, java.lang.String.class, value)); return true;
         case "protocol": target.getConfiguration().setProtocol(property(camelContext, java.lang.String.class, value)); return true;
         case "proxyhost":
         case "proxyHost": target.getConfiguration().setProxyHost(property(camelContext, java.lang.String.class, value)); return true;
@@ -134,6 +136,8 @@ public class Sqs2EndpointConfigurer extends PropertyConfigurerSupport implements
         case "useDefaultCredentialsProvider": target.getConfiguration().setUseDefaultCredentialsProvider(property(camelContext, boolean.class, value)); return true;
         case "usefixeddelay":
         case "useFixedDelay": target.setUseFixedDelay(property(camelContext, boolean.class, value)); return true;
+        case "useprofilecredentialsprovider":
+        case "useProfileCredentialsProvider": target.getConfiguration().setUseProfileCredentialsProvider(property(camelContext, boolean.class, value)); return true;
         case "visibilitytimeout":
         case "visibilityTimeout": target.getConfiguration().setVisibilityTimeout(property(camelContext, java.lang.Integer.class, value)); return true;
         case "waittimeseconds":
@@ -220,6 +224,8 @@ public class Sqs2EndpointConfigurer extends PropertyConfigurerSupport implements
         case "policy": return java.lang.String.class;
         case "pollstrategy":
         case "pollStrategy": return org.apache.camel.spi.PollingConsumerPollStrategy.class;
+        case "profilecredentialsname":
+        case "profileCredentialsName": return java.lang.String.class;
         case "protocol": return java.lang.String.class;
         case "proxyhost":
         case "proxyHost": return java.lang.String.class;
@@ -263,6 +269,8 @@ public class Sqs2EndpointConfigurer extends PropertyConfigurerSupport implements
         case "useDefaultCredentialsProvider": return boolean.class;
         case "usefixeddelay":
         case "useFixedDelay": return boolean.class;
+        case "useprofilecredentialsprovider":
+        case "useProfileCredentialsProvider": return boolean.class;
         case "visibilitytimeout":
         case "visibilityTimeout": return java.lang.Integer.class;
         case "waittimeseconds":
@@ -345,6 +353,8 @@ public class Sqs2EndpointConfigurer extends PropertyConfigurerSupport implements
         case "policy": return target.getConfiguration().getPolicy();
         case "pollstrategy":
         case "pollStrategy": return target.getPollStrategy();
+        case "profilecredentialsname":
+        case "profileCredentialsName": return target.getConfiguration().getProfileCredentialsName();
         case "protocol": return target.getConfiguration().getProtocol();
         case "proxyhost":
         case "proxyHost": return target.getConfiguration().getProxyHost();
@@ -388,6 +398,8 @@ public class Sqs2EndpointConfigurer extends PropertyConfigurerSupport implements
         case "useDefaultCredentialsProvider": return target.getConfiguration().isUseDefaultCredentialsProvider();
         case "usefixeddelay":
         case "useFixedDelay": return target.isUseFixedDelay();
+        case "useprofilecredentialsprovider":
+        case "useProfileCredentialsProvider": return target.getConfiguration().isUseProfileCredentialsProvider();
         case "visibilitytimeout":
         case "visibilityTimeout": return target.getConfiguration().getVisibilityTimeout();
         case "waittimeseconds":
diff --git a/components/camel-aws/camel-aws2-sqs/src/generated/java/org/apache/camel/component/aws2/sqs/Sqs2EndpointUriFactory.java b/components/camel-aws/camel-aws2-sqs/src/generated/java/org/apache/camel/component/aws2/sqs/Sqs2EndpointUriFactory.java
index 19693a8ee25..14c504e9e30 100644
--- a/components/camel-aws/camel-aws2-sqs/src/generated/java/org/apache/camel/component/aws2/sqs/Sqs2EndpointUriFactory.java
+++ b/components/camel-aws/camel-aws2-sqs/src/generated/java/org/apache/camel/component/aws2/sqs/Sqs2EndpointUriFactory.java
@@ -21,7 +21,7 @@ public class Sqs2EndpointUriFactory extends org.apache.camel.support.component.E
     private static final Set<String> SECRET_PROPERTY_NAMES;
     private static final Set<String> MULTI_VALUE_PREFIXES;
     static {
-        Set<String> props = new HashSet<>(63);
+        Set<String> props = new HashSet<>(65);
         props.add("accessKey");
         props.add("amazonAWSHost");
         props.add("amazonSQSClient");
@@ -59,6 +59,7 @@ public class Sqs2EndpointUriFactory extends org.apache.camel.support.component.E
         props.add("overrideEndpoint");
         props.add("policy");
         props.add("pollStrategy");
+        props.add("profileCredentialsName");
         props.add("protocol");
         props.add("proxyHost");
         props.add("proxyPort");
@@ -83,6 +84,7 @@ public class Sqs2EndpointUriFactory extends org.apache.camel.support.component.E
         props.add("uriEndpointOverride");
         props.add("useDefaultCredentialsProvider");
         props.add("useFixedDelay");
+        props.add("useProfileCredentialsProvider");
         props.add("visibilityTimeout");
         props.add("waitTimeSeconds");
         PROPERTY_NAMES = Collections.unmodifiableSet(props);
diff --git a/components/camel-aws/camel-aws2-sqs/src/generated/resources/org/apache/camel/component/aws2/sqs/aws2-sqs.json b/components/camel-aws/camel-aws2-sqs/src/generated/resources/org/apache/camel/component/aws2/sqs/aws2-sqs.json
index d0961f010d4..52464066dca 100644
--- a/components/camel-aws/camel-aws2-sqs/src/generated/resources/org/apache/camel/component/aws2/sqs/aws2-sqs.json
+++ b/components/camel-aws/camel-aws2-sqs/src/generated/resources/org/apache/camel/component/aws2/sqs/aws2-sqs.json
@@ -27,6 +27,7 @@
     "autoCreateQueue": { "kind": "property", "displayName": "Auto Create Queue", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "Setting the autocreation of the queue" },
     "configuration": { "kind": "property", "displayName": "Configuration", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "deprecated": false, "autowired": false, "secret": false, "description": "The AWS SQS default configuration" },
     "overrideEndpoint": { "kind": "property", "displayName": "Override Endpoint", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "Set the need for overriding the endpoint. This option needs to be used in combination with uriEndpoint [...]
+    "profileCredentialsName": { "kind": "property", "displayName": "Profile Credentials Name", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "If using a profile credentials provider this parameter will set the profile name" },
     "protocol": { "kind": "property", "displayName": "Protocol", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "https", "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "The underlying protocol used to communicate with SQS" },
     "proxyProtocol": { "kind": "property", "displayName": "Proxy Protocol", "group": "common", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the [...]
     "queueOwnerAWSAccountId": { "kind": "property", "displayName": "Queue Owner AWSAccount Id", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "Specify the queue owner aws account id when you need to connect the queue with different account owner." },
@@ -34,6 +35,7 @@
     "trustAllCertificates": { "kind": "property", "displayName": "Trust All Certificates", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overriding the endpoint" },
     "uriEndpointOverride": { "kind": "property", "displayName": "Uri Endpoint Override", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "Set the overriding uri endpoint. This option needs to be used in combination with overrideEndpoint option" },
     "useDefaultCredentialsProvider": { "kind": "property", "displayName": "Use Default Credentials Provider", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "Set whether the SQS client should expect to load credentials on an AWS inf [...]
+    "useProfileCredentialsProvider": { "kind": "property", "displayName": "Use Profile Credentials Provider", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "Set whether the SQS client should expect to load credentials through a pro [...]
     "attributeNames": { "kind": "property", "displayName": "Attribute Names", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "A list of attribute names to receive when consuming. Multiple names can be separated by comma." },
     "bridgeErrorHandler": { "kind": "property", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a me [...]
     "concurrentConsumers": { "kind": "property", "displayName": "Concurrent Consumers", "group": "consumer", "label": "consumer", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 1, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "Allows you to use multiple threads to poll the sqs queue to increase throughput" },
@@ -84,6 +86,7 @@
     "autoCreateQueue": { "kind": "parameter", "displayName": "Auto Create Queue", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "Setting the autocreation of the queue" },
     "headerFilterStrategy": { "kind": "parameter", "displayName": "Header Filter Strategy", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.spi.HeaderFilterStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom HeaderFilterStrategy to map headers to\/from Camel." },
     "overrideEndpoint": { "kind": "parameter", "displayName": "Override Endpoint", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "Set the need for overriding the endpoint. This option needs to be used in combination with uriEndpoin [...]
+    "profileCredentialsName": { "kind": "parameter", "displayName": "Profile Credentials Name", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "If using a profile credentials provider this parameter will set the profile name" },
     "protocol": { "kind": "parameter", "displayName": "Protocol", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "https", "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "The underlying protocol used to communicate with SQS" },
     "proxyProtocol": { "kind": "parameter", "displayName": "Proxy Protocol", "group": "common", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating th [...]
     "queueOwnerAWSAccountId": { "kind": "parameter", "displayName": "Queue Owner AWSAccount Id", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "Specify the queue owner aws account id when you need to connect the queue with different account owner." },
@@ -91,6 +94,7 @@
     "trustAllCertificates": { "kind": "parameter", "displayName": "Trust All Certificates", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overriding the endpoint" },
     "uriEndpointOverride": { "kind": "parameter", "displayName": "Uri Endpoint Override", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "Set the overriding uri endpoint. This option needs to be used in combination with overrideEndpoint option" },
     "useDefaultCredentialsProvider": { "kind": "parameter", "displayName": "Use Default Credentials Provider", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "Set whether the SQS client should expect to load credentials on an AWS in [...]
+    "useProfileCredentialsProvider": { "kind": "parameter", "displayName": "Use Profile Credentials Provider", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "Set whether the SQS client should expect to load credentials through a pr [...]
     "attributeNames": { "kind": "parameter", "displayName": "Attribute Names", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "A list of attribute names to receive when consuming. Multiple names can be separated by comma." },
     "concurrentConsumers": { "kind": "parameter", "displayName": "Concurrent Consumers", "group": "consumer", "label": "consumer", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 1, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "Allows you to use multiple threads to poll the sqs queue to increase throughput" },
     "defaultVisibilityTimeout": { "kind": "parameter", "displayName": "Default Visibility Timeout", "group": "consumer", "label": "consumer", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "The default visibility timeout (in seconds)" },


[camel] 08/08: CAMEL-19159 - Camel-AWS: Support Profile Credential provider as configuration - AWS SQS

Posted by ac...@apache.org.
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 49c30daee0cee5f3d24987b269e57957380299ef
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Mar 21 11:13:49 2023 +0100

    CAMEL-19159 - Camel-AWS: Support Profile Credential provider as configuration - AWS SQS
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../java/org/apache/camel/component/aws2/sqs/Sqs2Component.java     | 6 ++++--
 .../aws2/sqs/client/impl/Sqs2ClientIAMProfileOptimizedImpl.java     | 6 ++----
 .../aws2/sqs/Sqs2ConsumerHealthCheckIAMProfileCredsTest.java        | 6 +++---
 .../org/apache/camel/component/aws2/sqs/SqsClientFactoryTest.java   | 1 -
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Component.java b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Component.java
index 224e327e74b..2e0336f9e73 100644
--- a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Component.java
+++ b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Component.java
@@ -64,9 +64,11 @@ public class Sqs2Component extends DefaultComponent {
 
         //validation of client has to be done after endpoint initialization (in case that sqs client is autowired)
         // - covered by SqsDeadletterWithClientRegistryLocalstackIT
-        if (!configuration.isUseDefaultCredentialsProvider()  && !configuration.isUseProfileCredentialsProvider() && configuration.getAmazonSQSClient() == null
+        if (!configuration.isUseDefaultCredentialsProvider() && !configuration.isUseProfileCredentialsProvider()
+                && configuration.getAmazonSQSClient() == null
                 && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
-            throw new IllegalArgumentException("useDefaultCredentialsProvider is set to false, useProfileCredentialsProvider is set to false, AmazonSQSClient or accessKey and secretKey must be specified");
+            throw new IllegalArgumentException(
+                    "useDefaultCredentialsProvider is set to false, useProfileCredentialsProvider is set to false, AmazonSQSClient or accessKey and secretKey must be specified");
         }
         // Verify that visibilityTimeout is set if extendMessageVisibility is
         // set to true.
diff --git a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/impl/Sqs2ClientIAMProfileOptimizedImpl.java b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/impl/Sqs2ClientIAMProfileOptimizedImpl.java
index 1ccbc587487..4556e77a791 100644
--- a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/impl/Sqs2ClientIAMProfileOptimizedImpl.java
+++ b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/impl/Sqs2ClientIAMProfileOptimizedImpl.java
@@ -16,15 +16,15 @@
  */
 package org.apache.camel.component.aws2.sqs.client.impl;
 
+import java.net.URI;
+
 import org.apache.camel.component.aws2.sqs.Sqs2Configuration;
 import org.apache.camel.component.aws2.sqs.client.Sqs2InternalClient;
 import org.apache.camel.util.FileUtil;
 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;
@@ -34,8 +34,6 @@ import software.amazon.awssdk.services.sqs.SqsClient;
 import software.amazon.awssdk.services.sqs.SqsClientBuilder;
 import software.amazon.awssdk.utils.AttributeMap;
 
-import java.net.URI;
-
 /**
  * Manage an AWS SQS client for all users to use. This implementation is for local instances to use a static and solid
  * credential set.
diff --git a/components/camel-aws/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/Sqs2ConsumerHealthCheckIAMProfileCredsTest.java b/components/camel-aws/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/Sqs2ConsumerHealthCheckIAMProfileCredsTest.java
index 2dea2b580ea..156f869049d 100644
--- a/components/camel-aws/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/Sqs2ConsumerHealthCheckIAMProfileCredsTest.java
+++ b/components/camel-aws/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/Sqs2ConsumerHealthCheckIAMProfileCredsTest.java
@@ -16,6 +16,9 @@
  */
 package org.apache.camel.component.aws2.sqs;
 
+import java.util.Collection;
+import java.util.concurrent.TimeUnit;
+
 import org.apache.camel.CamelContext;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.health.HealthCheck;
@@ -32,9 +35,6 @@ import org.junit.jupiter.api.extension.RegisterExtension;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.Collection;
-import java.util.concurrent.TimeUnit;
-
 import static org.testcontainers.shaded.org.awaitility.Awaitility.await;
 
 public class Sqs2ConsumerHealthCheckIAMProfileCredsTest extends CamelTestSupport {
diff --git a/components/camel-aws/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/SqsClientFactoryTest.java b/components/camel-aws/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/SqsClientFactoryTest.java
index e9db9f6b3ea..0648749214c 100644
--- a/components/camel-aws/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/SqsClientFactoryTest.java
+++ b/components/camel-aws/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/SqsClientFactoryTest.java
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.component.aws2.sqs;
 
-
 import org.apache.camel.component.aws2.sqs.client.Sqs2ClientFactory;
 import org.apache.camel.component.aws2.sqs.client.Sqs2InternalClient;
 import org.apache.camel.component.aws2.sqs.client.impl.Sqs2ClientIAMOptimized;


[camel] 06/08: CAMEL-19159 - Camel-AWS: Support Profile Credential provider as configuration - AWS SQS

Posted by ac...@apache.org.
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 3fb1add9c346ce1e8eee8adba43cc637dd8a6da4
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Mar 21 11:11:22 2023 +0100

    CAMEL-19159 - Camel-AWS: Support Profile Credential provider as configuration - AWS SQS
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 ...Sqs2ConsumerHealthCheckIAMProfileCredsTest.java | 107 +++++++++++++++++++++
 1 file changed, 107 insertions(+)

diff --git a/components/camel-aws/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/Sqs2ConsumerHealthCheckIAMProfileCredsTest.java b/components/camel-aws/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/Sqs2ConsumerHealthCheckIAMProfileCredsTest.java
new file mode 100644
index 00000000000..2dea2b580ea
--- /dev/null
+++ b/components/camel-aws/camel-aws2-sqs/src/test/java/org/apache/camel/component/aws2/sqs/Sqs2ConsumerHealthCheckIAMProfileCredsTest.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws2.sqs;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.health.HealthCheck;
+import org.apache.camel.health.HealthCheckHelper;
+import org.apache.camel.health.HealthCheckRegistry;
+import org.apache.camel.impl.health.DefaultHealthCheckRegistry;
+import org.apache.camel.test.infra.aws.common.services.AWSService;
+import org.apache.camel.test.infra.aws2.clients.AWSSDKClientUtils;
+import org.apache.camel.test.infra.aws2.services.AWSServiceFactory;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collection;
+import java.util.concurrent.TimeUnit;
+
+import static org.testcontainers.shaded.org.awaitility.Awaitility.await;
+
+public class Sqs2ConsumerHealthCheckIAMProfileCredsTest extends CamelTestSupport {
+
+    @RegisterExtension
+    public static AWSService service = AWSServiceFactory.createSQSService();
+
+    private static final Logger LOG = LoggerFactory.getLogger(Sqs2ConsumerHealthCheckProfileCredsTest.class);
+
+    CamelContext context;
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        context = super.createCamelContext();
+        context.getPropertiesComponent().setLocation("ref:prop");
+        Sqs2Component component = new Sqs2Component(context);
+        component.getConfiguration().setAmazonSQSClient(AWSSDKClientUtils.newSQSClient());
+        component.init();
+        context.addComponent("aws2-sqs", component);
+
+        // install health check manually (yes a bit cumbersome)
+        HealthCheckRegistry registry = new DefaultHealthCheckRegistry();
+        registry.setCamelContext(context);
+        Object hc = registry.resolveById("context");
+        registry.register(hc);
+        hc = registry.resolveById("routes");
+        registry.register(hc);
+        hc = registry.resolveById("consumers");
+        registry.register(hc);
+        context.setExtension(HealthCheckRegistry.class, registry);
+
+        return context;
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+
+            @Override
+            public void configure() {
+                from("aws2-sqs://queue1?region=l&useProfileCredentialsProvider=true&autoCreateQueue=true")
+                        .startupOrder(2).log("${body}").routeId("test-health-it");
+            }
+        };
+    }
+
+    @Test
+    public void testConnectivity() {
+
+        Collection<HealthCheck.Result> res = HealthCheckHelper.invokeLiveness(context);
+        boolean up = res.stream().allMatch(r -> r.getState().equals(HealthCheck.State.UP));
+        Assertions.assertTrue(up, "liveness check");
+
+        // health-check readiness should be down
+        await().atMost(20, TimeUnit.SECONDS).untilAsserted(() -> {
+            Collection<HealthCheck.Result> res2 = HealthCheckHelper.invokeReadiness(context);
+            boolean down = res2.stream().allMatch(r -> r.getState().equals(HealthCheck.State.DOWN));
+            boolean containsAws2SqsHealthCheck = res2.stream()
+                    .filter(result -> result.getCheck().getId().startsWith("aws2-sqs-consumer"))
+                    .findAny()
+                    .isPresent();
+            boolean hasRegionMessage = res2.stream()
+                    .anyMatch(r -> r.getMessage().stream().anyMatch(msg -> msg.contains("region")));
+            Assertions.assertTrue(down, "liveness check");
+            Assertions.assertTrue(containsAws2SqsHealthCheck, "aws2-sqs check");
+            Assertions.assertTrue(hasRegionMessage, "aws2-sqs check error message");
+        });
+
+    }
+}


[camel] 07/08: CAMEL-19159 - Camel-AWS: Support Profile Credential provider as configuration - AWS SQS

Posted by ac...@apache.org.
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 49225ccaa1e1f3b89bcd6edc4cf2b5db5a439937
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Mar 21 11:12:14 2023 +0100

    CAMEL-19159 - Camel-AWS: Support Profile Credential provider as configuration - AWS SQS
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../main/java/org/apache/camel/component/aws2/sqs/Sqs2Component.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Component.java b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Component.java
index 284714bfcd5..224e327e74b 100644
--- a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Component.java
+++ b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Component.java
@@ -66,7 +66,7 @@ public class Sqs2Component extends DefaultComponent {
         // - covered by SqsDeadletterWithClientRegistryLocalstackIT
         if (!configuration.isUseDefaultCredentialsProvider()  && !configuration.isUseProfileCredentialsProvider() && configuration.getAmazonSQSClient() == null
                 && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
-            throw new IllegalArgumentException("AmazonSQSClient or accessKey and secretKey must be specified.");
+            throw new IllegalArgumentException("useDefaultCredentialsProvider is set to false, useProfileCredentialsProvider is set to false, AmazonSQSClient or accessKey and secretKey must be specified");
         }
         // Verify that visibilityTimeout is set if extendMessageVisibility is
         // set to true.


[camel] 04/08: CAMEL-19159 - Camel-AWS: Support Profile Credential provider as configuration - AWS SQS

Posted by ac...@apache.org.
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 8cc1c3f580b8e11ed9b64b9b699bebf1677ee71a
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Mar 21 10:39:40 2023 +0100

    CAMEL-19159 - Camel-AWS: Support Profile Credential provider as configuration - AWS SQS
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../main/java/org/apache/camel/component/aws2/sqs/Sqs2Component.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Component.java b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Component.java
index 070095d3943..284714bfcd5 100644
--- a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Component.java
+++ b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Component.java
@@ -64,7 +64,7 @@ public class Sqs2Component extends DefaultComponent {
 
         //validation of client has to be done after endpoint initialization (in case that sqs client is autowired)
         // - covered by SqsDeadletterWithClientRegistryLocalstackIT
-        if (!configuration.isUseDefaultCredentialsProvider() && configuration.getAmazonSQSClient() == null
+        if (!configuration.isUseDefaultCredentialsProvider()  && !configuration.isUseProfileCredentialsProvider() && configuration.getAmazonSQSClient() == null
                 && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
             throw new IllegalArgumentException("AmazonSQSClient or accessKey and secretKey must be specified.");
         }


[camel] 01/08: CAMEL-19159 - Camel-AWS: Support Profile Credential provider as configuration - AWS SQS

Posted by ac...@apache.org.
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 0eb391575ce41e20a8d50273c341c2de29cec54f
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Mar 21 10:20:40 2023 +0100

    CAMEL-19159 - Camel-AWS: Support Profile Credential provider as configuration - AWS SQS
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../component/aws2/sqs/Sqs2Configuration.java      |  27 ++++
 .../aws2/sqs/client/Sqs2ClientFactory.java         |  10 +-
 .../impl/Sqs2ClientIAMProfileOptimizedImpl.java    | 142 +++++++++++++++++++++
 3 files changed, 177 insertions(+), 2 deletions(-)

diff --git a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Configuration.java b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Configuration.java
index 908a7d25f4f..4cbac3f2b88 100644
--- a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Configuration.java
+++ b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Configuration.java
@@ -122,6 +122,11 @@ public class Sqs2Configuration implements Cloneable {
     @UriParam(defaultValue = "false")
     private boolean useDefaultCredentialsProvider;
 
+    @UriParam(defaultValue = "false")
+    private boolean useProfileCredentialsProvider;
+    @UriParam
+    private String profileCredentialsName;
+
     /**
      * Whether or not the queue is a FIFO queue
      */
@@ -578,6 +583,17 @@ public class Sqs2Configuration implements Cloneable {
         this.useDefaultCredentialsProvider = useDefaultCredentialsProvider;
     }
 
+    /**
+     * Set whether the SQS client should expect to load credentials through a profile credentials provider.
+     */
+    public void setUseProfileCredentialsProvider(boolean useProfileCredentialsProvider) {
+        this.useProfileCredentialsProvider = useProfileCredentialsProvider;
+    }
+
+    public boolean isUseProfileCredentialsProvider() {
+        return useProfileCredentialsProvider;
+    }
+
     public String getBatchSeparator() {
         return batchSeparator;
     }
@@ -629,6 +645,17 @@ public class Sqs2Configuration implements Cloneable {
         this.uriEndpointOverride = uriEndpointOverride;
     }
 
+    public String getProfileCredentialsName() {
+        return profileCredentialsName;
+    }
+
+    /**
+     * If using a profile credentials provider this parameter will set the profile name
+     */
+    public void setProfileCredentialsName(String profileCredentialsName) {
+        this.profileCredentialsName = profileCredentialsName;
+    }
+
     // *************************************************
     //
     // *************************************************
diff --git a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/Sqs2ClientFactory.java b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/Sqs2ClientFactory.java
index 9b87a1c261b..0ae106f0d90 100644
--- a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/Sqs2ClientFactory.java
+++ b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/Sqs2ClientFactory.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.aws2.sqs.client;
 
 import org.apache.camel.component.aws2.sqs.Sqs2Configuration;
 import org.apache.camel.component.aws2.sqs.client.impl.Sqs2ClientIAMOptimized;
+import org.apache.camel.component.aws2.sqs.client.impl.Sqs2ClientIAMProfileOptimizedImpl;
 import org.apache.camel.component.aws2.sqs.client.impl.Sqs2ClientStandardImpl;
 
 /**
@@ -35,7 +36,12 @@ public final class Sqs2ClientFactory {
      * @return               SqsClient
      */
     public static Sqs2InternalClient getSqsClient(Sqs2Configuration configuration) {
-        return configuration.isUseDefaultCredentialsProvider()
-                ? new Sqs2ClientIAMOptimized(configuration) : new Sqs2ClientStandardImpl(configuration);
+        if (Boolean.TRUE.equals(configuration.isUseDefaultCredentialsProvider())) {
+            return new Sqs2ClientIAMOptimized(configuration);
+        } else if (Boolean.TRUE.equals(configuration.isUseProfileCredentialsProvider())) {
+            return new Sqs2ClientIAMProfileOptimizedImpl(configuration);
+        } else {
+            return new Sqs2ClientStandardImpl(configuration);
+        }
     }
 }
diff --git a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/impl/Sqs2ClientIAMProfileOptimizedImpl.java b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/impl/Sqs2ClientIAMProfileOptimizedImpl.java
new file mode 100644
index 00000000000..1ccbc587487
--- /dev/null
+++ b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/impl/Sqs2ClientIAMProfileOptimizedImpl.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws2.sqs.client.impl;
+
+import org.apache.camel.component.aws2.sqs.Sqs2Configuration;
+import org.apache.camel.component.aws2.sqs.client.Sqs2InternalClient;
+import org.apache.camel.util.FileUtil;
+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;
+import software.amazon.awssdk.http.apache.ProxyConfiguration;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.sqs.SqsClient;
+import software.amazon.awssdk.services.sqs.SqsClientBuilder;
+import software.amazon.awssdk.utils.AttributeMap;
+
+import java.net.URI;
+
+/**
+ * Manage an AWS SQS client for all users to use. This implementation is for local instances to use a static and solid
+ * credential set.
+ */
+public class Sqs2ClientIAMProfileOptimizedImpl implements Sqs2InternalClient {
+    private static final Logger LOG = LoggerFactory.getLogger(Sqs2ClientStandardImpl.class);
+    private Sqs2Configuration configuration;
+
+    /**
+     * Constructor that uses the config file.
+     */
+    public Sqs2ClientIAMProfileOptimizedImpl(Sqs2Configuration configuration) {
+        LOG.trace("Creating an AWS SQS manager using static credentials.");
+        this.configuration = configuration;
+    }
+
+    /**
+     * Getting the s3 aws client that is used.
+     *
+     * @return Amazon S3 Client.
+     */
+    @Override
+    public SqsClient getSQSClient() {
+        SqsClient client = null;
+        SqsClientBuilder clientBuilder = SqsClient.builder();
+        ProxyConfiguration.Builder proxyConfig = null;
+        ApacheHttpClient.Builder httpClientBuilder = null;
+        boolean isClientConfigFound = false;
+        if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
+            proxyConfig = ProxyConfiguration.builder();
+            URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":"
+                                           + configuration.getProxyPort());
+            proxyConfig.endpoint(proxyEndpoint);
+            httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build());
+            isClientConfigFound = true;
+        }
+        if (configuration.getProfileCredentialsName() != null) {
+            if (isClientConfigFound) {
+                clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder)
+                        .credentialsProvider(ProfileCredentialsProvider.create(configuration.getProfileCredentialsName()));
+            } else {
+                clientBuilder = clientBuilder
+                        .credentialsProvider(ProfileCredentialsProvider.create(configuration.getProfileCredentialsName()));
+            }
+        } else {
+            if (!isClientConfigFound) {
+                clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder);
+            }
+        }
+
+        if (!isDefaultAwsHost()) {
+            String endpointOverrideUri = getAwsEndpointUri();
+            clientBuilder.endpointOverride(URI.create(endpointOverrideUri));
+        }
+
+        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
+            clientBuilder = clientBuilder.region(Region.of(configuration.getRegion()));
+        }
+        if (configuration.isOverrideEndpoint()) {
+            clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride()));
+        }
+        if (configuration.isTrustAllCertificates()) {
+            SdkHttpClient ahc = ApacheHttpClient.builder().buildWithDefaults(AttributeMap
+                    .builder()
+                    .put(
+                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
+                            Boolean.TRUE)
+                    .build());
+            clientBuilder.httpClient(ahc);
+        }
+        client = clientBuilder.build();
+        return client;
+    }
+
+    private boolean isDefaultAwsHost() {
+        return configuration.getAmazonAWSHost().equals("amazonaws.com");
+    }
+
+    /*
+     * Gets the base endpoint for AWS (ie.: http(s)://host:port.
+     *
+     * Do not confuse with other Camel endpoint methods: this one is named after AWS'
+     * own endpoint terminology and can also be used for the endpoint override in the
+     * client builder.
+     */
+    private String getAwsEndpointUri() {
+        return configuration.getProtocol() + "://" + getFullyQualifiedAWSHost();
+    }
+
+    /*
+     * If using a different AWS host, do not assume specific parts of the AWS
+     * host and, instead, just return whatever is provided as the host.
+     */
+    private String getFullyQualifiedAWSHost() {
+        String host = configuration.getAmazonAWSHost();
+        host = FileUtil.stripTrailingSeparator(host);
+
+        if (isDefaultAwsHost()) {
+            return "sqs." + Region.of(configuration.getRegion()).id() + "." + host;
+        }
+
+        return host;
+    }
+}


[camel] 05/08: CAMEL-19159 - Camel-AWS: Support Profile Credential provider as configuration - AWS SQS

Posted by ac...@apache.org.
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 74614d5ba7595b9742d39e1ce102a276253169c1
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Mar 21 11:05:05 2023 +0100

    CAMEL-19159 - Camel-AWS: Support Profile Credential provider as configuration - AWS SQS
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../camel-aws2-sqs/src/main/docs/aws2-sqs-component.adoc          | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/components/camel-aws/camel-aws2-sqs/src/main/docs/aws2-sqs-component.adoc b/components/camel-aws/camel-aws2-sqs/src/main/docs/aws2-sqs-component.adoc
index 4c83f65dbc3..0a16d641a75 100644
--- a/components/camel-aws/camel-aws2-sqs/src/main/docs/aws2-sqs-component.adoc
+++ b/components/camel-aws/camel-aws2-sqs/src/main/docs/aws2-sqs-component.adoc
@@ -64,16 +64,22 @@ aggregate this number of messages.
 
 == Usage
 
-=== Static credentials vs Default Credential Provider
+=== Static credentials, Default Credential Provider and Profile Credentials Provider
 
 You have the possibility of avoiding the usage of explicit static credentials, by specifying the useDefaultCredentialsProvider option and set it to true.
 
+The order of evaluation for Default Credentials Provider is the following:
+
  - Java system properties - aws.accessKeyId and aws.secretKey
  - Environment variables - AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
  - Web Identity Token from AWS STS.
  - The shared credentials and config files.
  - Amazon ECS container credentials - loaded from the Amazon ECS if the environment variable AWS_CONTAINER_CREDENTIALS_RELATIVE_URI is set.
  - Amazon EC2 Instance profile credentials. 
+ 
+You have also the possibility of using Profile Credentials Provider, by specifying the useProfileCredentialsProvider option to true and profileCredentialsName to the profile name.
+
+Only one of static, default and profile credentials could be used at the same time.
 
 For more information about this you can look at https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/credentials.html[AWS credentials documentation]