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 2025/12/15 14:32:07 UTC

(camel) branch main updated (57d127fe4b86 -> 2ee78558ae04)

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 57d127fe4b86 RocketMQ support enable for PPC64le (#20435)
     new f2f7e583a831 CAMEL-22786 - Camel-AWS: Extract common logic for clients instantiation in a separated module - AWS SQS
     new 5894395497f7 CAMEL-22786 - Camel-AWS: Extract common logic for clients instantiation in a separated module - AWS SNS
     new 2ee78558ae04 CAMEL-22786 - Camel-AWS: Extract common logic for clients instantiation in a separated module - AWS Lambda

The 3 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:
 .../component/aws/common/AwsClientBuilderUtil.java |   2 +-
 .../aws/common/AwsCommonConfiguration.java         |   2 +-
 components/camel-aws/camel-aws2-lambda/pom.xml     |   4 +
 .../aws2/lambda/Lambda2Configuration.java          |   5 +-
 .../component/aws2/lambda/Lambda2Endpoint.java     |   2 +-
 .../aws2/lambda/client/Lambda2ClientFactory.java   |  28 ++--
 .../aws2/lambda/client/Lambda2InternalClient.java  |  32 -----
 .../impl/Lambda2ClientIAMProfileOptimizedImpl.java |  93 -------------
 .../client/impl/Lambda2ClientOptimizedImpl.java    |  93 -------------
 .../client/impl/Lambda2ClientSessionTokenImpl.java | 111 ----------------
 .../client/impl/Lambda2ClientStandardImpl.java     | 109 ---------------
 .../aws2/lambda/LambdaClientFactoryTest.java       |  45 +++----
 .../component/aws2/s3/AWS2S3Configuration.java     |   2 +-
 components/camel-aws/camel-aws2-sns/pom.xml        |   4 +
 .../component/aws2/sns/Sns2Configuration.java      |   3 +-
 .../camel/component/aws2/sns/Sns2Endpoint.java     |   2 +-
 .../aws2/sns/client/Sns2ClientFactory.java         |  28 ++--
 .../aws2/sns/client/Sns2InternalClient.java        |  30 -----
 .../sns/client/impl/Sns2ClientIAMOptimized.java    |  94 -------------
 .../client/impl/Sns2ClientIAMProfileOptimized.java |  99 --------------
 .../client/impl/Sns2ClientSessionTokenImpl.java    | 110 ---------------
 .../sns/client/impl/Sns2ClientStandardImpl.java    | 109 ---------------
 components/camel-aws/camel-aws2-sqs/pom.xml        |   4 +
 .../component/aws2/sqs/Sqs2Configuration.java      |   3 +-
 .../camel/component/aws2/sqs/Sqs2Endpoint.java     |   2 +-
 .../aws2/sqs/client/Sqs2ClientFactory.java         |  58 +++++---
 .../aws2/sqs/client/Sqs2InternalClient.java        |  30 -----
 .../sqs/client/impl/Sqs2ClientIAMOptimized.java    |  94 -------------
 .../impl/Sqs2ClientIAMProfileOptimizedImpl.java    | 148 ---------------------
 .../client/impl/Sqs2ClientSessionTokenImpl.java    | 147 --------------------
 .../sqs/client/impl/Sqs2ClientStandardImpl.java    | 146 --------------------
 .../component/aws2/sqs/SqsClientFactoryTest.java   |  58 ++++----
 32 files changed, 138 insertions(+), 1559 deletions(-)
 delete mode 100644 components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/client/Lambda2InternalClient.java
 delete mode 100644 components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/client/impl/Lambda2ClientIAMProfileOptimizedImpl.java
 delete mode 100644 components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/client/impl/Lambda2ClientOptimizedImpl.java
 delete mode 100644 components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/client/impl/Lambda2ClientSessionTokenImpl.java
 delete mode 100644 components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/client/impl/Lambda2ClientStandardImpl.java
 delete mode 100644 components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/client/Sns2InternalClient.java
 delete mode 100644 components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/client/impl/Sns2ClientIAMOptimized.java
 delete mode 100644 components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/client/impl/Sns2ClientIAMProfileOptimized.java
 delete mode 100644 components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/client/impl/Sns2ClientSessionTokenImpl.java
 delete mode 100644 components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/client/impl/Sns2ClientStandardImpl.java
 delete mode 100644 components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/Sqs2InternalClient.java
 delete mode 100644 components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/impl/Sqs2ClientIAMOptimized.java
 delete mode 100644 components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/impl/Sqs2ClientIAMProfileOptimizedImpl.java
 delete mode 100644 components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/impl/Sqs2ClientSessionTokenImpl.java
 delete mode 100644 components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/impl/Sqs2ClientStandardImpl.java


(camel) 02/03: CAMEL-22786 - Camel-AWS: Extract common logic for clients instantiation in a separated module - AWS SNS

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 5894395497f7870587feb47006cb1f93a5302d1f
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Dec 15 14:41:41 2025 +0100

    CAMEL-22786 - Camel-AWS: Extract common logic for clients instantiation in a separated module - AWS SNS
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 components/camel-aws/camel-aws2-sns/pom.xml        |   4 +
 .../component/aws2/sns/Sns2Configuration.java      |   3 +-
 .../camel/component/aws2/sns/Sns2Endpoint.java     |   2 +-
 .../aws2/sns/client/Sns2ClientFactory.java         |  28 ++----
 .../aws2/sns/client/Sns2InternalClient.java        |  30 ------
 .../sns/client/impl/Sns2ClientIAMOptimized.java    |  94 ------------------
 .../client/impl/Sns2ClientIAMProfileOptimized.java |  99 -------------------
 .../client/impl/Sns2ClientSessionTokenImpl.java    | 110 ---------------------
 .../sns/client/impl/Sns2ClientStandardImpl.java    | 109 --------------------
 9 files changed, 17 insertions(+), 462 deletions(-)

diff --git a/components/camel-aws/camel-aws2-sns/pom.xml b/components/camel-aws/camel-aws2-sns/pom.xml
index c0e71e731bc6..5b76ba28f83c 100644
--- a/components/camel-aws/camel-aws2-sns/pom.xml
+++ b/components/camel-aws/camel-aws2-sns/pom.xml
@@ -38,6 +38,10 @@
     </properties>
 
     <dependencies>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-aws-common</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-support</artifactId>
diff --git a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Configuration.java b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Configuration.java
index b58f5af58a80..d5f94a2ed24a 100644
--- a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Configuration.java
+++ b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Configuration.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.aws2.sns;
 
 import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.component.aws.common.AwsCommonConfiguration;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
@@ -25,7 +26,7 @@ import software.amazon.awssdk.core.Protocol;
 import software.amazon.awssdk.services.sns.SnsClient;
 
 @UriParams
-public class Sns2Configuration implements Cloneable {
+public class Sns2Configuration implements Cloneable, AwsCommonConfiguration {
 
     private String topicArn;
 
diff --git a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Endpoint.java b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Endpoint.java
index 52d9c1b26912..8d18e5df017c 100644
--- a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Endpoint.java
+++ b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Endpoint.java
@@ -102,7 +102,7 @@ public class Sns2Endpoint extends DefaultEndpoint implements HeaderFilterStrateg
     public void doInit() throws Exception {
         super.doInit();
         snsClient = configuration.getAmazonSNSClient() != null
-                ? configuration.getAmazonSNSClient() : Sns2ClientFactory.getSnsClient(configuration).getSNSClient();
+                ? configuration.getAmazonSNSClient() : Sns2ClientFactory.getSnsClient(configuration);
 
         // check the setting the headerFilterStrategy
         if (headerFilterStrategy == null) {
diff --git a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/client/Sns2ClientFactory.java b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/client/Sns2ClientFactory.java
index a146d0c82c7a..f42db5578608 100644
--- a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/client/Sns2ClientFactory.java
+++ b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/client/Sns2ClientFactory.java
@@ -16,14 +16,12 @@
  */
 package org.apache.camel.component.aws2.sns.client;
 
+import org.apache.camel.component.aws.common.AwsClientBuilderUtil;
 import org.apache.camel.component.aws2.sns.Sns2Configuration;
-import org.apache.camel.component.aws2.sns.client.impl.Sns2ClientIAMOptimized;
-import org.apache.camel.component.aws2.sns.client.impl.Sns2ClientIAMProfileOptimized;
-import org.apache.camel.component.aws2.sns.client.impl.Sns2ClientSessionTokenImpl;
-import org.apache.camel.component.aws2.sns.client.impl.Sns2ClientStandardImpl;
+import software.amazon.awssdk.services.sns.SnsClient;
 
 /**
- * Factory class to return the correct type of AWS SNS aws.
+ * Factory class to create AWS SNS clients using common configuration.
  */
 public final class Sns2ClientFactory {
 
@@ -31,20 +29,14 @@ public final class Sns2ClientFactory {
     }
 
     /**
-     * Return the correct aws SNS client (based on remote vs local).
+     * Create an SNS client based on configuration.
      *
-     * @param  configuration configuration
-     * @return               SNSClient
+     * @param  configuration The SNS configuration
+     * @return               Configured SnsClient
      */
-    public static Sns2InternalClient getSnsClient(Sns2Configuration configuration) {
-        if (Boolean.TRUE.equals(configuration.isUseDefaultCredentialsProvider())) {
-            return new Sns2ClientIAMOptimized(configuration);
-        } else if (Boolean.TRUE.equals(configuration.isUseProfileCredentialsProvider())) {
-            return new Sns2ClientIAMProfileOptimized(configuration);
-        } else if (Boolean.TRUE.equals(configuration.isUseSessionCredentials())) {
-            return new Sns2ClientSessionTokenImpl(configuration);
-        } else {
-            return new Sns2ClientStandardImpl(configuration);
-        }
+    public static SnsClient getSnsClient(Sns2Configuration configuration) {
+        return AwsClientBuilderUtil.buildClient(
+                configuration,
+                SnsClient::builder);
     }
 }
diff --git a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/client/Sns2InternalClient.java b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/client/Sns2InternalClient.java
deleted file mode 100644
index 5510ec597dc0..000000000000
--- a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/client/Sns2InternalClient.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.sns.client;
-
-import software.amazon.awssdk.services.sns.SnsClient;
-
-public interface Sns2InternalClient {
-
-    /**
-     * Returns an sns client after a factory method determines which one to return.
-     *
-     * @return SnsClient snsClient
-     */
-    SnsClient getSNSClient();
-
-}
diff --git a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/client/impl/Sns2ClientIAMOptimized.java b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/client/impl/Sns2ClientIAMOptimized.java
deleted file mode 100644
index b00335e2efaa..000000000000
--- a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/client/impl/Sns2ClientIAMOptimized.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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.sns.client.impl;
-
-import java.net.URI;
-
-import org.apache.camel.component.aws2.sns.Sns2Configuration;
-import org.apache.camel.component.aws2.sns.client.Sns2InternalClient;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-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.sns.SnsClient;
-import software.amazon.awssdk.services.sns.SnsClientBuilder;
-import software.amazon.awssdk.utils.AttributeMap;
-
-/**
- * Manage an AWS SNS client for all users to use. This implementation is for remote instances to manage the credentials
- * on their own (eliminating credential rotations)
- */
-public class Sns2ClientIAMOptimized implements Sns2InternalClient {
-    private static final Logger LOG = LoggerFactory.getLogger(Sns2ClientIAMOptimized.class);
-    private Sns2Configuration configuration;
-
-    /**
-     * Constructor that uses the config file.
-     */
-    public Sns2ClientIAMOptimized(Sns2Configuration configuration) {
-        LOG.trace("Creating an AWS SNS client for working on AWS Services");
-        this.configuration = configuration;
-    }
-
-    /**
-     * Getting the SNS AWS client that is used.
-     *
-     * @return Amazon SNS Client.
-     */
-    @Override
-    public SnsClient getSNSClient() {
-        SnsClient client = null;
-        SnsClientBuilder clientBuilder = SnsClient.builder();
-        ProxyConfiguration.Builder proxyConfig = null;
-        ApacheHttpClient.Builder httpClientBuilder = null;
-
-        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());
-            clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder);
-        }
-        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
-            clientBuilder = clientBuilder.region(Region.of(configuration.getRegion()));
-        }
-        if (configuration.isOverrideEndpoint()) {
-            clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride()));
-        }
-        if (configuration.isTrustAllCertificates()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        client = clientBuilder.build();
-        return client;
-    }
-}
diff --git a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/client/impl/Sns2ClientIAMProfileOptimized.java b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/client/impl/Sns2ClientIAMProfileOptimized.java
deleted file mode 100644
index 4ee52ba887ab..000000000000
--- a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/client/impl/Sns2ClientIAMProfileOptimized.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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.sns.client.impl;
-
-import java.net.URI;
-
-import org.apache.camel.component.aws2.sns.Sns2Configuration;
-import org.apache.camel.component.aws2.sns.client.Sns2InternalClient;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
-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.sns.SnsClient;
-import software.amazon.awssdk.services.sns.SnsClientBuilder;
-import software.amazon.awssdk.utils.AttributeMap;
-
-/**
- * Manage an AWS SNS client for all users to use. This implementation is for remote instances to manage the credentials
- * on their own (eliminating credential rotations)
- */
-public class Sns2ClientIAMProfileOptimized implements Sns2InternalClient {
-    private static final Logger LOG = LoggerFactory.getLogger(Sns2ClientIAMProfileOptimized.class);
-    private Sns2Configuration configuration;
-
-    /**
-     * Constructor that uses the config file.
-     */
-    public Sns2ClientIAMProfileOptimized(Sns2Configuration configuration) {
-        LOG.trace("Creating an AWS SNS client for working on AWS Services");
-        this.configuration = configuration;
-    }
-
-    /**
-     * Getting the SNS AWS client that is used.
-     *
-     * @return Amazon SNS Client.
-     */
-    @Override
-    public SnsClient getSNSClient() {
-        SnsClient client = null;
-        SnsClientBuilder clientBuilder = SnsClient.builder();
-        ProxyConfiguration.Builder proxyConfig = null;
-        ApacheHttpClient.Builder httpClientBuilder = null;
-
-        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());
-            clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder);
-        }
-        if (configuration.getProfileCredentialsName() != null) {
-            clientBuilder = clientBuilder
-                    .credentialsProvider(ProfileCredentialsProvider.create(configuration.getProfileCredentialsName()));
-        }
-        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
-            clientBuilder = clientBuilder.region(Region.of(configuration.getRegion()));
-        }
-        if (configuration.isOverrideEndpoint()) {
-            clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride()));
-        }
-        if (configuration.isTrustAllCertificates()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        client = clientBuilder.build();
-        return client;
-    }
-}
diff --git a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/client/impl/Sns2ClientSessionTokenImpl.java b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/client/impl/Sns2ClientSessionTokenImpl.java
deleted file mode 100644
index 350f3e595438..000000000000
--- a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/client/impl/Sns2ClientSessionTokenImpl.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * 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.sns.client.impl;
-
-import java.net.URI;
-
-import org.apache.camel.component.aws2.sns.Sns2Configuration;
-import org.apache.camel.component.aws2.sns.client.Sns2InternalClient;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import software.amazon.awssdk.auth.credentials.AwsSessionCredentials;
-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.sns.SnsClient;
-import software.amazon.awssdk.services.sns.SnsClientBuilder;
-import software.amazon.awssdk.utils.AttributeMap;
-
-/**
- * Manage an AWS SNS client for all users to use. This implementation is for local instances to use a static and solid
- * credential set.
- */
-public class Sns2ClientSessionTokenImpl implements Sns2InternalClient {
-    private static final Logger LOG = LoggerFactory.getLogger(Sns2ClientSessionTokenImpl.class);
-    private Sns2Configuration configuration;
-
-    /**
-     * Constructor that uses the config file.
-     */
-    public Sns2ClientSessionTokenImpl(Sns2Configuration configuration) {
-        LOG.trace("Creating an AWS SNS manager using static credentials.");
-        this.configuration = configuration;
-    }
-
-    /**
-     * Getting the SNS aws client that is used.
-     *
-     * @return Amazon SNS Client.
-     */
-    @Override
-    public SnsClient getSNSClient() {
-        SnsClient client = null;
-        SnsClientBuilder clientBuilder = SnsClient.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.getAccessKey() != null && configuration.getSecretKey() != null) {
-            AwsSessionCredentials cred = AwsSessionCredentials.create(configuration.getAccessKey(),
-                    configuration.getSecretKey(), configuration.getSessionToken());
-            if (isClientConfigFound) {
-                clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder)
-                        .credentialsProvider(StaticCredentialsProvider.create(cred));
-            } else {
-                clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred));
-            }
-        } else {
-            if (!isClientConfigFound) {
-                clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder);
-            }
-        }
-        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
-            clientBuilder = clientBuilder.region(Region.of(configuration.getRegion()));
-        }
-        if (configuration.isOverrideEndpoint()) {
-            clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride()));
-        }
-        if (configuration.isTrustAllCertificates()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        client = clientBuilder.build();
-        return client;
-    }
-}
diff --git a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/client/impl/Sns2ClientStandardImpl.java b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/client/impl/Sns2ClientStandardImpl.java
deleted file mode 100644
index b70259618f3f..000000000000
--- a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/client/impl/Sns2ClientStandardImpl.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.sns.client.impl;
-
-import java.net.URI;
-
-import org.apache.camel.component.aws2.sns.Sns2Configuration;
-import org.apache.camel.component.aws2.sns.client.Sns2InternalClient;
-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.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.sns.SnsClient;
-import software.amazon.awssdk.services.sns.SnsClientBuilder;
-import software.amazon.awssdk.utils.AttributeMap;
-
-/**
- * Manage an AWS SNS client for all users to use. This implementation is for local instances to use a static and solid
- * credential set.
- */
-public class Sns2ClientStandardImpl implements Sns2InternalClient {
-    private static final Logger LOG = LoggerFactory.getLogger(Sns2ClientStandardImpl.class);
-    private Sns2Configuration configuration;
-
-    /**
-     * Constructor that uses the config file.
-     */
-    public Sns2ClientStandardImpl(Sns2Configuration configuration) {
-        LOG.trace("Creating an AWS SNS manager using static credentials.");
-        this.configuration = configuration;
-    }
-
-    /**
-     * Getting the SNS aws client that is used.
-     *
-     * @return Amazon SNS Client.
-     */
-    @Override
-    public SnsClient getSNSClient() {
-        SnsClient client = null;
-        SnsClientBuilder clientBuilder = SnsClient.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.getAccessKey() != null && configuration.getSecretKey() != null) {
-            AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey());
-            if (isClientConfigFound) {
-                clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder)
-                        .credentialsProvider(StaticCredentialsProvider.create(cred));
-            } else {
-                clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred));
-            }
-        } else {
-            if (!isClientConfigFound) {
-                clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder);
-            }
-        }
-        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
-            clientBuilder = clientBuilder.region(Region.of(configuration.getRegion()));
-        }
-        if (configuration.isOverrideEndpoint()) {
-            clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride()));
-        }
-        if (configuration.isTrustAllCertificates()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        client = clientBuilder.build();
-        return client;
-    }
-}


(camel) 01/03: CAMEL-22786 - Camel-AWS: Extract common logic for clients instantiation in a separated module - 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 f2f7e583a831d69e2c03f85128475d200a5b3efd
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Dec 15 14:34:06 2025 +0100

    CAMEL-22786 - Camel-AWS: Extract common logic for clients instantiation in a separated module - AWS SQS
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../component/aws/common/AwsClientBuilderUtil.java |   2 +-
 .../aws/common/AwsCommonConfiguration.java         |   2 +-
 .../component/aws2/s3/AWS2S3Configuration.java     |   2 +-
 components/camel-aws/camel-aws2-sqs/pom.xml        |   4 +
 .../component/aws2/sqs/Sqs2Configuration.java      |   3 +-
 .../camel/component/aws2/sqs/Sqs2Endpoint.java     |   2 +-
 .../aws2/sqs/client/Sqs2ClientFactory.java         |  58 +++++---
 .../aws2/sqs/client/Sqs2InternalClient.java        |  30 -----
 .../sqs/client/impl/Sqs2ClientIAMOptimized.java    |  94 -------------
 .../impl/Sqs2ClientIAMProfileOptimizedImpl.java    | 148 ---------------------
 .../client/impl/Sqs2ClientSessionTokenImpl.java    | 147 --------------------
 .../sqs/client/impl/Sqs2ClientStandardImpl.java    | 146 --------------------
 .../component/aws2/sqs/SqsClientFactoryTest.java   |  58 ++++----
 13 files changed, 81 insertions(+), 615 deletions(-)

diff --git a/components/camel-aws/camel-aws-common/src/main/java/org/apache/camel/component/aws/common/AwsClientBuilderUtil.java b/components/camel-aws/camel-aws-common/src/main/java/org/apache/camel/component/aws/common/AwsClientBuilderUtil.java
index 00858a7ae496..cf08b59fb76f 100644
--- a/components/camel-aws/camel-aws-common/src/main/java/org/apache/camel/component/aws/common/AwsClientBuilderUtil.java
+++ b/components/camel-aws/camel-aws-common/src/main/java/org/apache/camel/component/aws/common/AwsClientBuilderUtil.java
@@ -161,7 +161,7 @@ public final class AwsClientBuilderUtil {
     private static AwsCredentialsProvider resolveCredentialsProvider(AwsCommonConfiguration config) {
 
         // Priority 1: Default credentials provider (IAM roles, env vars, etc.)
-        if (Boolean.TRUE.equals(config.isUseDefaultCredentialsProvider())) {
+        if (config.isUseDefaultCredentialsProvider()) {
             LOG.trace("Using default credentials provider (IAM)");
             return DefaultCredentialsProvider.create();
         }
diff --git a/components/camel-aws/camel-aws-common/src/main/java/org/apache/camel/component/aws/common/AwsCommonConfiguration.java b/components/camel-aws/camel-aws-common/src/main/java/org/apache/camel/component/aws/common/AwsCommonConfiguration.java
index 61295244a9db..8c829c93bede 100644
--- a/components/camel-aws/camel-aws-common/src/main/java/org/apache/camel/component/aws/common/AwsCommonConfiguration.java
+++ b/components/camel-aws/camel-aws-common/src/main/java/org/apache/camel/component/aws/common/AwsCommonConfiguration.java
@@ -49,7 +49,7 @@ public interface AwsCommonConfiguration {
     /**
      * Set whether the client should expect to load credentials through a default credentials provider.
      */
-    Boolean isUseDefaultCredentialsProvider();
+    boolean isUseDefaultCredentialsProvider();
 
     /**
      * Set whether the client should expect to load credentials through a profile credentials provider.
diff --git a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Configuration.java b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Configuration.java
index 039572e79f9f..241412a5fd4c 100644
--- a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Configuration.java
+++ b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Configuration.java
@@ -587,7 +587,7 @@ public class AWS2S3Configuration implements Cloneable, AwsCommonConfiguration {
         this.useDefaultCredentialsProvider = useDefaultCredentialsProvider;
     }
 
-    public Boolean isUseDefaultCredentialsProvider() {
+    public boolean isUseDefaultCredentialsProvider() {
         return useDefaultCredentialsProvider;
     }
 
diff --git a/components/camel-aws/camel-aws2-sqs/pom.xml b/components/camel-aws/camel-aws2-sqs/pom.xml
index d3fd12ccd90f..ad1329ce8092 100644
--- a/components/camel-aws/camel-aws2-sqs/pom.xml
+++ b/components/camel-aws/camel-aws2-sqs/pom.xml
@@ -36,6 +36,10 @@
     </properties>
 
     <dependencies>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-aws-common</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-support</artifactId>
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 d9e3d7aa3858..11e2a4f6b941 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
@@ -17,6 +17,7 @@
 package org.apache.camel.component.aws2.sqs;
 
 import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.component.aws.common.AwsCommonConfiguration;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
@@ -24,7 +25,7 @@ import software.amazon.awssdk.core.Protocol;
 import software.amazon.awssdk.services.sqs.SqsClient;
 
 @UriParams
-public class Sqs2Configuration implements Cloneable {
+public class Sqs2Configuration implements Cloneable, AwsCommonConfiguration {
 
     // common properties
     private String queueName;
diff --git a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Endpoint.java b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Endpoint.java
index b043c865e5f9..2883f097b752 100644
--- a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Endpoint.java
+++ b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Endpoint.java
@@ -148,7 +148,7 @@ public class Sqs2Endpoint extends ScheduledPollEndpoint implements HeaderFilterS
         super.doInit();
 
         client = configuration.getAmazonSQSClient() != null
-                ? configuration.getAmazonSQSClient() : Sqs2ClientFactory.getSqsClient(configuration).getSQSClient();
+                ? configuration.getAmazonSQSClient() : Sqs2ClientFactory.getSqsClient(configuration);
 
         // check the setting the headerFilterStrategy
         if (headerFilterStrategy == null) {
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 d06021c618af..4f9c778f902d 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
@@ -16,35 +16,59 @@
  */
 package org.apache.camel.component.aws2.sqs.client;
 
+import java.net.URI;
+
+import org.apache.camel.component.aws.common.AwsClientBuilderUtil;
 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.Sqs2ClientSessionTokenImpl;
-import org.apache.camel.component.aws2.sqs.client.impl.Sqs2ClientStandardImpl;
+import org.apache.camel.util.FileUtil;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.sqs.SqsClient;
 
 /**
- * Factory class to return the correct type of AWS SQS aws.
+ * Factory class to create AWS SQS clients using common configuration.
  */
 public final class Sqs2ClientFactory {
 
+    private static final String DEFAULT_AWS_HOST = "amazonaws.com";
+
     private Sqs2ClientFactory() {
     }
 
     /**
-     * Return the correct aws SQS client (based on remote vs local).
+     * Create an SQS client based on configuration.
      *
-     * @param  configuration configuration
-     * @return               SqsClient
+     * @param  configuration The SQS configuration
+     * @return               Configured SqsClient
      */
-    public static Sqs2InternalClient getSqsClient(Sqs2Configuration configuration) {
-        if (Boolean.TRUE.equals(configuration.isUseDefaultCredentialsProvider())) {
-            return new Sqs2ClientIAMOptimized(configuration);
-        } else if (Boolean.TRUE.equals(configuration.isUseProfileCredentialsProvider())) {
-            return new Sqs2ClientIAMProfileOptimizedImpl(configuration);
-        } else if (Boolean.TRUE.equals(configuration.isUseSessionCredentials())) {
-            return new Sqs2ClientSessionTokenImpl(configuration);
-        } else {
-            return new Sqs2ClientStandardImpl(configuration);
+    public static SqsClient getSqsClient(Sqs2Configuration configuration) {
+        return AwsClientBuilderUtil.buildClient(
+                configuration,
+                SqsClient::builder,
+                builder -> {
+                    // SQS-specific: Handle custom AWS host (non-amazonaws.com endpoints)
+                    if (!isDefaultAwsHost(configuration) && !configuration.isOverrideEndpoint()) {
+                        String endpointOverrideUri = getAwsEndpointUri(configuration);
+                        builder.endpointOverride(URI.create(endpointOverrideUri));
+                    }
+                });
+    }
+
+    private static boolean isDefaultAwsHost(Sqs2Configuration configuration) {
+        return DEFAULT_AWS_HOST.equals(configuration.getAmazonAWSHost());
+    }
+
+    private static String getAwsEndpointUri(Sqs2Configuration configuration) {
+        return configuration.getProtocol() + "://" + getFullyQualifiedAWSHost(configuration);
+    }
+
+    private static String getFullyQualifiedAWSHost(Sqs2Configuration configuration) {
+        String host = configuration.getAmazonAWSHost();
+        host = FileUtil.stripTrailingSeparator(host);
+
+        if (isDefaultAwsHost(configuration)) {
+            return "sqs." + Region.of(configuration.getRegion()).id() + "." + host;
         }
+
+        return host;
     }
 }
diff --git a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/Sqs2InternalClient.java b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/Sqs2InternalClient.java
deleted file mode 100644
index 2a46ceaff7dc..000000000000
--- a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/Sqs2InternalClient.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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;
-
-import software.amazon.awssdk.services.sqs.SqsClient;
-
-public interface Sqs2InternalClient {
-
-    /**
-     * Returns an sqs client after a factory method determines which one to return.
-     *
-     * @return SqsClient sqsClient
-     */
-    SqsClient getSQSClient();
-
-}
diff --git a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/impl/Sqs2ClientIAMOptimized.java b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/impl/Sqs2ClientIAMOptimized.java
deleted file mode 100644
index fc2ec15cef96..000000000000
--- a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/impl/Sqs2ClientIAMOptimized.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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 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.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-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;
-
-/**
- * Manage an AWS SQS client for all users to use. This implementation is for remote instances to manage the credentials
- * on their own (eliminating credential rotations)
- */
-public class Sqs2ClientIAMOptimized implements Sqs2InternalClient {
-    private static final Logger LOG = LoggerFactory.getLogger(Sqs2ClientIAMOptimized.class);
-    private Sqs2Configuration configuration;
-
-    /**
-     * Constructor that uses the config file.
-     */
-    public Sqs2ClientIAMOptimized(Sqs2Configuration configuration) {
-        LOG.trace("Creating an AWS SQS client for working on AWS Services");
-        this.configuration = configuration;
-    }
-
-    /**
-     * Getting the sqs aws client that is used.
-     *
-     * @return Amazon SQS Client.
-     */
-    @Override
-    public SqsClient getSQSClient() {
-        SqsClient client = null;
-        SqsClientBuilder clientBuilder = SqsClient.builder();
-        ProxyConfiguration.Builder proxyConfig = null;
-        ApacheHttpClient.Builder httpClientBuilder = null;
-
-        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());
-            clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder);
-        }
-        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
-            clientBuilder = clientBuilder.region(Region.of(configuration.getRegion()));
-        }
-        if (configuration.isOverrideEndpoint()) {
-            clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride()));
-        }
-        if (configuration.isTrustAllCertificates()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        client = clientBuilder.build();
-        return client;
-    }
-}
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
deleted file mode 100644
index b6a2c6a12661..000000000000
--- a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/impl/Sqs2ClientIAMProfileOptimizedImpl.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * 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 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.ProfileCredentialsProvider;
-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;
-
-/**
- * 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(Sqs2ClientIAMProfileOptimizedImpl.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()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        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;
-    }
-}
diff --git a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/impl/Sqs2ClientSessionTokenImpl.java b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/impl/Sqs2ClientSessionTokenImpl.java
deleted file mode 100644
index d237ab4bc223..000000000000
--- a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/impl/Sqs2ClientSessionTokenImpl.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * 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 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.AwsSessionCredentials;
-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;
-
-/**
- * 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 Sqs2ClientSessionTokenImpl implements Sqs2InternalClient {
-    private static final Logger LOG = LoggerFactory.getLogger(Sqs2ClientStandardImpl.class);
-    private Sqs2Configuration configuration;
-
-    /**
-     * Constructor that uses the config file.
-     */
-    public Sqs2ClientSessionTokenImpl(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.getAccessKey() != null && configuration.getSecretKey() != null) {
-            AwsSessionCredentials cred = AwsSessionCredentials.create(configuration.getAccessKey(),
-                    configuration.getSecretKey(), configuration.getSessionToken());
-            if (isClientConfigFound) {
-                clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder)
-                        .credentialsProvider(StaticCredentialsProvider.create(cred));
-            } else {
-                clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred));
-            }
-        } 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()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        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;
-    }
-}
diff --git a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/impl/Sqs2ClientStandardImpl.java b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/impl/Sqs2ClientStandardImpl.java
deleted file mode 100644
index cf9259c948ee..000000000000
--- a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/client/impl/Sqs2ClientStandardImpl.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * 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 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.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;
-
-/**
- * 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 Sqs2ClientStandardImpl implements Sqs2InternalClient {
-    private static final Logger LOG = LoggerFactory.getLogger(Sqs2ClientStandardImpl.class);
-    private Sqs2Configuration configuration;
-
-    /**
-     * Constructor that uses the config file.
-     */
-    public Sqs2ClientStandardImpl(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.getAccessKey() != null && configuration.getSecretKey() != null) {
-            AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey());
-            if (isClientConfigFound) {
-                clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder)
-                        .credentialsProvider(StaticCredentialsProvider.create(cred));
-            } else {
-                clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred));
-            }
-        } 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()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        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;
-    }
-}
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 7b9f389c14a8..a42c54b1e30e 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
@@ -17,53 +17,55 @@
 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.Sqs2ClientSessionTokenImpl;
-import org.apache.camel.component.aws2.sqs.client.impl.Sqs2ClientStandardImpl;
 import org.junit.jupiter.api.Test;
+import software.amazon.awssdk.services.sqs.SqsClient;
 
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 public class SqsClientFactoryTest {
 
     @Test
-    public void getStandardSqsClientDefault() {
+    public void getSqsClientWithDefaultCredentials() {
         Sqs2Configuration sqsConfiguration = new Sqs2Configuration();
-        Sqs2InternalClient awsssqsClient = Sqs2ClientFactory.getSqsClient(sqsConfiguration);
-        assertTrue(awsssqsClient instanceof Sqs2ClientStandardImpl);
+        sqsConfiguration.setUseDefaultCredentialsProvider(true);
+        sqsConfiguration.setRegion("eu-west-1");
+        SqsClient sqsClient = Sqs2ClientFactory.getSqsClient(sqsConfiguration);
+        assertNotNull(sqsClient);
+        sqsClient.close();
     }
 
     @Test
-    public void getStandardSqsClient() {
+    public void getSqsClientWithStaticCredentials() {
         Sqs2Configuration sqsConfiguration = new Sqs2Configuration();
-        sqsConfiguration.setUseDefaultCredentialsProvider(false);
-        Sqs2InternalClient awsssqsClient = Sqs2ClientFactory.getSqsClient(sqsConfiguration);
-        assertTrue(awsssqsClient instanceof Sqs2ClientStandardImpl);
+        sqsConfiguration.setAccessKey("testAccessKey");
+        sqsConfiguration.setSecretKey("testSecretKey");
+        sqsConfiguration.setRegion("eu-west-1");
+        SqsClient sqsClient = Sqs2ClientFactory.getSqsClient(sqsConfiguration);
+        assertNotNull(sqsClient);
+        sqsClient.close();
     }
 
     @Test
-    public void getIAMOptimizedSqsClient() {
+    public void getSqsClientWithEndpointOverride() {
         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);
+        sqsConfiguration.setRegion("eu-west-1");
+        sqsConfiguration.setOverrideEndpoint(true);
+        sqsConfiguration.setUriEndpointOverride("http://localhost:4566");
+        SqsClient sqsClient = Sqs2ClientFactory.getSqsClient(sqsConfiguration);
+        assertNotNull(sqsClient);
+        sqsClient.close();
     }
 
     @Test
-    public void getSessionTokenSqsClient() {
+    public void getSqsClientWithCustomHost() {
         Sqs2Configuration sqsConfiguration = new Sqs2Configuration();
-        sqsConfiguration.setUseSessionCredentials(true);
-        Sqs2InternalClient awsssqsClient = Sqs2ClientFactory.getSqsClient(sqsConfiguration);
-        assertTrue(awsssqsClient instanceof Sqs2ClientSessionTokenImpl);
+        sqsConfiguration.setUseDefaultCredentialsProvider(true);
+        sqsConfiguration.setRegion("eu-west-1");
+        sqsConfiguration.setAmazonAWSHost("localhost:4566");
+        sqsConfiguration.setProtocol("http");
+        SqsClient sqsClient = Sqs2ClientFactory.getSqsClient(sqsConfiguration);
+        assertNotNull(sqsClient);
+        sqsClient.close();
     }
 }


(camel) 03/03: CAMEL-22786 - Camel-AWS: Extract common logic for clients instantiation in a separated module - AWS Lambda

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 2ee78558ae04160da1936c3a7fcbf7f9a295b546
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Dec 15 15:00:37 2025 +0100

    CAMEL-22786 - Camel-AWS: Extract common logic for clients instantiation in a separated module - AWS Lambda
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 components/camel-aws/camel-aws2-lambda/pom.xml     |   4 +
 .../aws2/lambda/Lambda2Configuration.java          |   5 +-
 .../component/aws2/lambda/Lambda2Endpoint.java     |   2 +-
 .../aws2/lambda/client/Lambda2ClientFactory.java   |  28 ++----
 .../aws2/lambda/client/Lambda2InternalClient.java  |  32 ------
 .../impl/Lambda2ClientIAMProfileOptimizedImpl.java |  93 -----------------
 .../client/impl/Lambda2ClientOptimizedImpl.java    |  93 -----------------
 .../client/impl/Lambda2ClientSessionTokenImpl.java | 111 ---------------------
 .../client/impl/Lambda2ClientStandardImpl.java     | 109 --------------------
 .../aws2/lambda/LambdaClientFactoryTest.java       |  45 ++++-----
 10 files changed, 40 insertions(+), 482 deletions(-)

diff --git a/components/camel-aws/camel-aws2-lambda/pom.xml b/components/camel-aws/camel-aws2-lambda/pom.xml
index 064e307ec5b4..f8c98448b7c5 100644
--- a/components/camel-aws/camel-aws2-lambda/pom.xml
+++ b/components/camel-aws/camel-aws2-lambda/pom.xml
@@ -38,6 +38,10 @@
     </properties>
 
     <dependencies>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-aws-common</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-support</artifactId>
diff --git a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Configuration.java b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Configuration.java
index 06032b7cbd73..8b067e01aefe 100644
--- a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Configuration.java
+++ b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Configuration.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.aws2.lambda;
 
 import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.component.aws.common.AwsCommonConfiguration;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
@@ -24,7 +25,7 @@ import software.amazon.awssdk.core.Protocol;
 import software.amazon.awssdk.services.lambda.LambdaClient;
 
 @UriParams
-public class Lambda2Configuration implements Cloneable {
+public class Lambda2Configuration implements Cloneable, AwsCommonConfiguration {
 
     @UriParam(defaultValue = "invokeFunction")
     private Lambda2Operations operation = Lambda2Operations.invokeFunction;
@@ -215,7 +216,7 @@ public class Lambda2Configuration implements Cloneable {
         this.useDefaultCredentialsProvider = useDefaultCredentialsProvider;
     }
 
-    public Boolean isUseDefaultCredentialsProvider() {
+    public boolean isUseDefaultCredentialsProvider() {
         return useDefaultCredentialsProvider;
     }
 
diff --git a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Endpoint.java b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Endpoint.java
index de4afe2afe6c..f7469271ef6d 100644
--- a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Endpoint.java
+++ b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Endpoint.java
@@ -79,7 +79,7 @@ public class Lambda2Endpoint extends DefaultEndpoint implements EndpointServiceL
         super.doStart();
         awsLambdaClient = configuration.getAwsLambdaClient() != null
                 ? configuration.getAwsLambdaClient()
-                : Lambda2ClientFactory.getLambdaClient(configuration).getLambdaClient();
+                : Lambda2ClientFactory.getLambdaClient(configuration);
     }
 
     @Override
diff --git a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/client/Lambda2ClientFactory.java b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/client/Lambda2ClientFactory.java
index 810092b3b4db..d11e6b05f599 100644
--- a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/client/Lambda2ClientFactory.java
+++ b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/client/Lambda2ClientFactory.java
@@ -16,14 +16,12 @@
  */
 package org.apache.camel.component.aws2.lambda.client;
 
+import org.apache.camel.component.aws.common.AwsClientBuilderUtil;
 import org.apache.camel.component.aws2.lambda.Lambda2Configuration;
-import org.apache.camel.component.aws2.lambda.client.impl.Lambda2ClientIAMProfileOptimizedImpl;
-import org.apache.camel.component.aws2.lambda.client.impl.Lambda2ClientOptimizedImpl;
-import org.apache.camel.component.aws2.lambda.client.impl.Lambda2ClientSessionTokenImpl;
-import org.apache.camel.component.aws2.lambda.client.impl.Lambda2ClientStandardImpl;
+import software.amazon.awssdk.services.lambda.LambdaClient;
 
 /**
- * Factory class to return the correct type of AWS Lambda client.
+ * Factory class to create AWS Lambda clients using common configuration.
  */
 public final class Lambda2ClientFactory {
 
@@ -31,20 +29,14 @@ public final class Lambda2ClientFactory {
     }
 
     /**
-     * Return the correct AWS Lambda client (based on remote vs local).
+     * Create a Lambda client based on configuration.
      *
-     * @param  configuration configuration
-     * @return               LambdaClient
+     * @param  configuration The Lambda configuration
+     * @return               Configured LambdaClient
      */
-    public static Lambda2InternalClient getLambdaClient(Lambda2Configuration configuration) {
-        if (Boolean.TRUE.equals(configuration.isUseDefaultCredentialsProvider())) {
-            return new Lambda2ClientOptimizedImpl(configuration);
-        } else if (Boolean.TRUE.equals(configuration.isUseProfileCredentialsProvider())) {
-            return new Lambda2ClientIAMProfileOptimizedImpl(configuration);
-        } else if (Boolean.TRUE.equals(configuration.isUseSessionCredentials())) {
-            return new Lambda2ClientSessionTokenImpl(configuration);
-        } else {
-            return new Lambda2ClientStandardImpl(configuration);
-        }
+    public static LambdaClient getLambdaClient(Lambda2Configuration configuration) {
+        return AwsClientBuilderUtil.buildClient(
+                configuration,
+                LambdaClient::builder);
     }
 }
diff --git a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/client/Lambda2InternalClient.java b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/client/Lambda2InternalClient.java
deleted file mode 100644
index eb662dbc72fe..000000000000
--- a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/client/Lambda2InternalClient.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.lambda.client;
-
-import software.amazon.awssdk.services.lambda.LambdaClient;
-
-/**
- * Manage the required actions of an Lambda client for either local or remote.
- */
-public interface Lambda2InternalClient {
-
-    /**
-     * Returns an Lambda client after a factory method determines which one to return.
-     *
-     * @return LambdaClient LambdaClient
-     */
-    LambdaClient getLambdaClient();
-}
diff --git a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/client/impl/Lambda2ClientIAMProfileOptimizedImpl.java b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/client/impl/Lambda2ClientIAMProfileOptimizedImpl.java
deleted file mode 100644
index 8ab02725b2b5..000000000000
--- a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/client/impl/Lambda2ClientIAMProfileOptimizedImpl.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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.lambda.client.impl;
-
-import java.net.URI;
-
-import org.apache.camel.component.aws2.lambda.Lambda2Configuration;
-import org.apache.camel.component.aws2.lambda.client.Lambda2InternalClient;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
-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.lambda.LambdaClient;
-import software.amazon.awssdk.services.lambda.LambdaClientBuilder;
-import software.amazon.awssdk.utils.AttributeMap;
-
-/**
- * Manage an AWS Lambda client for all users to use. This implementation is for local instances to use a static and
- * solid credential set.
- */
-public class Lambda2ClientIAMProfileOptimizedImpl implements Lambda2InternalClient {
-    private static final Logger LOG = LoggerFactory.getLogger(Lambda2ClientIAMProfileOptimizedImpl.class);
-    private Lambda2Configuration configuration;
-
-    /**
-     * Constructor that uses the config file.
-     */
-    public Lambda2ClientIAMProfileOptimizedImpl(Lambda2Configuration configuration) {
-        LOG.trace("Creating an AWS Lambda manager using profile credentials.");
-        this.configuration = configuration;
-    }
-
-    @Override
-    public LambdaClient getLambdaClient() {
-        LambdaClient client = null;
-        LambdaClientBuilder clientBuilder = LambdaClient.builder();
-        ProxyConfiguration.Builder proxyConfig = null;
-        ApacheHttpClient.Builder httpClientBuilder = null;
-        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());
-            clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder);
-        }
-        if (configuration.getProfileCredentialsName() != null) {
-            clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder)
-                    .credentialsProvider(ProfileCredentialsProvider.create(configuration.getProfileCredentialsName()));
-        }
-        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
-            clientBuilder = clientBuilder.region(Region.of(configuration.getRegion()));
-        }
-        if (configuration.isOverrideEndpoint()) {
-            clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride()));
-        }
-        if (configuration.isTrustAllCertificates()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        client = clientBuilder.build();
-        return client;
-    }
-}
diff --git a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/client/impl/Lambda2ClientOptimizedImpl.java b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/client/impl/Lambda2ClientOptimizedImpl.java
deleted file mode 100644
index 1e626f6bb4a4..000000000000
--- a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/client/impl/Lambda2ClientOptimizedImpl.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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.lambda.client.impl;
-
-import java.net.URI;
-
-import org.apache.camel.component.aws2.lambda.Lambda2Configuration;
-import org.apache.camel.component.aws2.lambda.client.Lambda2InternalClient;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-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.lambda.LambdaClient;
-import software.amazon.awssdk.services.lambda.LambdaClientBuilder;
-import software.amazon.awssdk.utils.AttributeMap;
-
-/**
- * Manage an AWS Lambda client for all users to use (enabling temporary creds). This implementation is for remote
- * instances to manage the credentials on their own (eliminating credential rotations)
- */
-public class Lambda2ClientOptimizedImpl implements Lambda2InternalClient {
-    private static final Logger LOG = LoggerFactory.getLogger(Lambda2ClientOptimizedImpl.class);
-    private Lambda2Configuration configuration;
-
-    /**
-     * Constructor that uses the config file.
-     */
-    public Lambda2ClientOptimizedImpl(Lambda2Configuration configuration) {
-        LOG.trace("Creating an AWS Lambda client for an ec2 instance with IAM temporary credentials (normal for ec2s).");
-        this.configuration = configuration;
-    }
-
-    /**
-     * Getting the Lambda aws client that is used.
-     *
-     * @return Lambda Client.
-     */
-    @Override
-    public LambdaClient getLambdaClient() {
-        LambdaClient client = null;
-        LambdaClientBuilder clientBuilder = LambdaClient.builder();
-        ProxyConfiguration.Builder proxyConfig = null;
-        ApacheHttpClient.Builder httpClientBuilder = null;
-        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());
-            clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder);
-        }
-        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
-            clientBuilder = clientBuilder.region(Region.of(configuration.getRegion()));
-        }
-        if (configuration.isOverrideEndpoint()) {
-            clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride()));
-        }
-        if (configuration.isTrustAllCertificates()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        client = clientBuilder.build();
-        return client;
-    }
-}
diff --git a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/client/impl/Lambda2ClientSessionTokenImpl.java b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/client/impl/Lambda2ClientSessionTokenImpl.java
deleted file mode 100644
index 96c69bbcb594..000000000000
--- a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/client/impl/Lambda2ClientSessionTokenImpl.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * 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.lambda.client.impl;
-
-import java.net.URI;
-
-import org.apache.camel.component.aws2.lambda.Lambda2Configuration;
-import org.apache.camel.component.aws2.lambda.client.Lambda2InternalClient;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import software.amazon.awssdk.auth.credentials.AwsSessionCredentials;
-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.lambda.LambdaClient;
-import software.amazon.awssdk.services.lambda.LambdaClientBuilder;
-import software.amazon.awssdk.utils.AttributeMap;
-
-/**
- * Manage an AWS Lambda client for all users to use. This implementation is for local instances to use a static and
- * solid credential set.
- */
-public class Lambda2ClientSessionTokenImpl implements Lambda2InternalClient {
-    private static final Logger LOG = LoggerFactory.getLogger(Lambda2ClientSessionTokenImpl.class);
-    private Lambda2Configuration configuration;
-
-    /**
-     * Constructor that uses the config file.
-     */
-    public Lambda2ClientSessionTokenImpl(Lambda2Configuration configuration) {
-        LOG.trace("Creating an AWS Lambda manager using static credentials.");
-        this.configuration = configuration;
-    }
-
-    /**
-     * Getting the Lambda AWS client that is used.
-     *
-     * @return Amazon Lambda Client.
-     */
-    @Override
-    public LambdaClient getLambdaClient() {
-        LambdaClient client = null;
-        LambdaClientBuilder clientBuilder = LambdaClient.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.getAccessKey() != null && configuration.getSecretKey() != null
-                && configuration.getSessionToken() != null) {
-            AwsSessionCredentials cred = AwsSessionCredentials.create(configuration.getAccessKey(),
-                    configuration.getSecretKey(), configuration.getSessionToken());
-            if (isClientConfigFound) {
-                clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder)
-                        .credentialsProvider(StaticCredentialsProvider.create(cred));
-            } else {
-                clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred));
-            }
-        } else {
-            if (!isClientConfigFound) {
-                clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder);
-            }
-        }
-        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
-            clientBuilder = clientBuilder.region(Region.of(configuration.getRegion()));
-        }
-        if (configuration.isOverrideEndpoint()) {
-            clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride()));
-        }
-        if (configuration.isTrustAllCertificates()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        client = clientBuilder.build();
-        return client;
-    }
-}
diff --git a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/client/impl/Lambda2ClientStandardImpl.java b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/client/impl/Lambda2ClientStandardImpl.java
deleted file mode 100644
index f16f06f49253..000000000000
--- a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/client/impl/Lambda2ClientStandardImpl.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.lambda.client.impl;
-
-import java.net.URI;
-
-import org.apache.camel.component.aws2.lambda.Lambda2Configuration;
-import org.apache.camel.component.aws2.lambda.client.Lambda2InternalClient;
-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.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.lambda.LambdaClient;
-import software.amazon.awssdk.services.lambda.LambdaClientBuilder;
-import software.amazon.awssdk.utils.AttributeMap;
-
-/**
- * Manage an AWS Lambda client for all users to use. This implementation is for local instances to use a static and
- * solid credential set.
- */
-public class Lambda2ClientStandardImpl implements Lambda2InternalClient {
-    private static final Logger LOG = LoggerFactory.getLogger(Lambda2ClientStandardImpl.class);
-    private Lambda2Configuration configuration;
-
-    /**
-     * Constructor that uses the config file.
-     */
-    public Lambda2ClientStandardImpl(Lambda2Configuration configuration) {
-        LOG.trace("Creating an AWS Lambda manager using static credentials.");
-        this.configuration = configuration;
-    }
-
-    /**
-     * Getting the Lambda AWS client that is used.
-     *
-     * @return Amazon Lambda Client.
-     */
-    @Override
-    public LambdaClient getLambdaClient() {
-        LambdaClient client = null;
-        LambdaClientBuilder clientBuilder = LambdaClient.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.getAccessKey() != null && configuration.getSecretKey() != null) {
-            AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey());
-            if (isClientConfigFound) {
-                clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder)
-                        .credentialsProvider(StaticCredentialsProvider.create(cred));
-            } else {
-                clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred));
-            }
-        } else {
-            if (!isClientConfigFound) {
-                clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder);
-            }
-        }
-        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
-            clientBuilder = clientBuilder.region(Region.of(configuration.getRegion()));
-        }
-        if (configuration.isOverrideEndpoint()) {
-            clientBuilder.endpointOverride(URI.create(configuration.getUriEndpointOverride()));
-        }
-        if (configuration.isTrustAllCertificates()) {
-            if (httpClientBuilder == null) {
-                httpClientBuilder = ApacheHttpClient.builder();
-            }
-            SdkHttpClient ahc = httpClientBuilder.buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            // set created http client to use instead of builder
-            clientBuilder.httpClient(ahc);
-            clientBuilder.httpClientBuilder(null);
-        }
-        client = clientBuilder.build();
-        return client;
-    }
-}
diff --git a/components/camel-aws/camel-aws2-lambda/src/test/java/org/apache/camel/component/aws2/lambda/LambdaClientFactoryTest.java b/components/camel-aws/camel-aws2-lambda/src/test/java/org/apache/camel/component/aws2/lambda/LambdaClientFactoryTest.java
index 08db3694bff7..1e7cd73c5e68 100644
--- a/components/camel-aws/camel-aws2-lambda/src/test/java/org/apache/camel/component/aws2/lambda/LambdaClientFactoryTest.java
+++ b/components/camel-aws/camel-aws2-lambda/src/test/java/org/apache/camel/component/aws2/lambda/LambdaClientFactoryTest.java
@@ -17,44 +17,43 @@
 package org.apache.camel.component.aws2.lambda;
 
 import org.apache.camel.component.aws2.lambda.client.Lambda2ClientFactory;
-import org.apache.camel.component.aws2.lambda.client.Lambda2InternalClient;
-import org.apache.camel.component.aws2.lambda.client.impl.Lambda2ClientOptimizedImpl;
-import org.apache.camel.component.aws2.lambda.client.impl.Lambda2ClientSessionTokenImpl;
-import org.apache.camel.component.aws2.lambda.client.impl.Lambda2ClientStandardImpl;
 import org.junit.jupiter.api.Test;
+import software.amazon.awssdk.services.lambda.LambdaClient;
 
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 public class LambdaClientFactoryTest {
 
     @Test
-    public void getStandardLambdaClientDefault() {
+    public void getLambdaClientWithDefaultCredentials() {
         Lambda2Configuration lambda2Configuration = new Lambda2Configuration();
-        Lambda2InternalClient lambdaClient = Lambda2ClientFactory.getLambdaClient(lambda2Configuration);
-        assertTrue(lambdaClient instanceof Lambda2ClientStandardImpl);
+        lambda2Configuration.setUseDefaultCredentialsProvider(true);
+        lambda2Configuration.setRegion("eu-west-1");
+        LambdaClient lambdaClient = Lambda2ClientFactory.getLambdaClient(lambda2Configuration);
+        assertNotNull(lambdaClient);
+        lambdaClient.close();
     }
 
     @Test
-    public void getStandardLambdaClient() {
+    public void getLambdaClientWithStaticCredentials() {
         Lambda2Configuration lambda2Configuration = new Lambda2Configuration();
-        lambda2Configuration.setUseDefaultCredentialsProvider(false);
-        Lambda2InternalClient lambdaClient = Lambda2ClientFactory.getLambdaClient(lambda2Configuration);
-        assertTrue(lambdaClient instanceof Lambda2ClientStandardImpl);
+        lambda2Configuration.setAccessKey("testAccessKey");
+        lambda2Configuration.setSecretKey("testSecretKey");
+        lambda2Configuration.setRegion("eu-west-1");
+        LambdaClient lambdaClient = Lambda2ClientFactory.getLambdaClient(lambda2Configuration);
+        assertNotNull(lambdaClient);
+        lambdaClient.close();
     }
 
     @Test
-    public void getIAMOptimizedLambdaClient() {
+    public void getLambdaClientWithEndpointOverride() {
         Lambda2Configuration lambda2Configuration = new Lambda2Configuration();
         lambda2Configuration.setUseDefaultCredentialsProvider(true);
-        Lambda2InternalClient lambdaClient = Lambda2ClientFactory.getLambdaClient(lambda2Configuration);
-        assertTrue(lambdaClient instanceof Lambda2ClientOptimizedImpl);
-    }
-
-    @Test
-    public void getSessionTokenLambdaClient() {
-        Lambda2Configuration lambda2Configuration = new Lambda2Configuration();
-        lambda2Configuration.setUseSessionCredentials(true);
-        Lambda2InternalClient lambdaClient = Lambda2ClientFactory.getLambdaClient(lambda2Configuration);
-        assertTrue(lambdaClient instanceof Lambda2ClientSessionTokenImpl);
+        lambda2Configuration.setRegion("eu-west-1");
+        lambda2Configuration.setOverrideEndpoint(true);
+        lambda2Configuration.setUriEndpointOverride("http://localhost:4566");
+        LambdaClient lambdaClient = Lambda2ClientFactory.getLambdaClient(lambda2Configuration);
+        assertNotNull(lambdaClient);
+        lambdaClient.close();
     }
 }