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 2024/01/19 09:54:43 UTC

(camel) 01/02: CAMEL-20281 - Camel-AWS Components: Make it possible to use AwsSessionCredentials to support temporary credentials - AWS SNS

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

acosentino pushed a commit to branch CAMEL-20281-sns
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 592a423bde6b260e9c7c4c9e2028de54b8092833
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Jan 19 10:45:39 2024 +0100

    CAMEL-20281 - Camel-AWS Components: Make it possible to use AwsSessionCredentials to support temporary credentials - AWS SNS
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../aws2/sns/Sns2ComponentConfigurer.java          |  12 +++
 .../component/aws2/sns/Sns2EndpointConfigurer.java |  12 +++
 .../component/aws2/sns/Sns2EndpointUriFactory.java |   7 +-
 .../apache/camel/component/aws2/sns/aws2-sns.json  |  16 +--
 .../camel/component/aws2/sns/Sns2Component.java    |   3 +-
 .../component/aws2/sns/Sns2Configuration.java      |  27 +++++
 .../aws2/sns/client/Sns2ClientFactory.java         |   3 +
 .../client/impl/Sns2ClientSessionTokenImpl.java    | 110 +++++++++++++++++++++
 8 files changed, 181 insertions(+), 9 deletions(-)

diff --git a/components/camel-aws/camel-aws2-sns/src/generated/java/org/apache/camel/component/aws2/sns/Sns2ComponentConfigurer.java b/components/camel-aws/camel-aws2-sns/src/generated/java/org/apache/camel/component/aws2/sns/Sns2ComponentConfigurer.java
index 0e27d28e3e5..0963b845f23 100644
--- a/components/camel-aws/camel-aws2-sns/src/generated/java/org/apache/camel/component/aws2/sns/Sns2ComponentConfigurer.java
+++ b/components/camel-aws/camel-aws2-sns/src/generated/java/org/apache/camel/component/aws2/sns/Sns2ComponentConfigurer.java
@@ -69,6 +69,8 @@ public class Sns2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "secretKey": getOrCreateConfiguration(target).setSecretKey(property(camelContext, java.lang.String.class, value)); return true;
         case "serversideencryptionenabled":
         case "serverSideEncryptionEnabled": getOrCreateConfiguration(target).setServerSideEncryptionEnabled(property(camelContext, boolean.class, value)); return true;
+        case "sessiontoken":
+        case "sessionToken": getOrCreateConfiguration(target).setSessionToken(property(camelContext, java.lang.String.class, value)); return true;
         case "subject": getOrCreateConfiguration(target).setSubject(property(camelContext, java.lang.String.class, value)); return true;
         case "subscribesnstosqs":
         case "subscribeSNStoSQS": getOrCreateConfiguration(target).setSubscribeSNStoSQS(property(camelContext, boolean.class, value)); return true;
@@ -80,6 +82,8 @@ public class Sns2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "useDefaultCredentialsProvider": getOrCreateConfiguration(target).setUseDefaultCredentialsProvider(property(camelContext, boolean.class, value)); return true;
         case "useprofilecredentialsprovider":
         case "useProfileCredentialsProvider": getOrCreateConfiguration(target).setUseProfileCredentialsProvider(property(camelContext, boolean.class, value)); return true;
+        case "usesessioncredentials":
+        case "useSessionCredentials": getOrCreateConfiguration(target).setUseSessionCredentials(property(camelContext, boolean.class, value)); return true;
         default: return false;
         }
     }
@@ -133,6 +137,8 @@ public class Sns2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "secretKey": return java.lang.String.class;
         case "serversideencryptionenabled":
         case "serverSideEncryptionEnabled": return boolean.class;
+        case "sessiontoken":
+        case "sessionToken": return java.lang.String.class;
         case "subject": return java.lang.String.class;
         case "subscribesnstosqs":
         case "subscribeSNStoSQS": return boolean.class;
@@ -144,6 +150,8 @@ public class Sns2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "useDefaultCredentialsProvider": return boolean.class;
         case "useprofilecredentialsprovider":
         case "useProfileCredentialsProvider": return boolean.class;
+        case "usesessioncredentials":
+        case "useSessionCredentials": return boolean.class;
         default: return null;
         }
     }
@@ -193,6 +201,8 @@ public class Sns2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "secretKey": return getOrCreateConfiguration(target).getSecretKey();
         case "serversideencryptionenabled":
         case "serverSideEncryptionEnabled": return getOrCreateConfiguration(target).isServerSideEncryptionEnabled();
+        case "sessiontoken":
+        case "sessionToken": return getOrCreateConfiguration(target).getSessionToken();
         case "subject": return getOrCreateConfiguration(target).getSubject();
         case "subscribesnstosqs":
         case "subscribeSNStoSQS": return getOrCreateConfiguration(target).isSubscribeSNStoSQS();
@@ -204,6 +214,8 @@ public class Sns2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "useDefaultCredentialsProvider": return getOrCreateConfiguration(target).isUseDefaultCredentialsProvider();
         case "useprofilecredentialsprovider":
         case "useProfileCredentialsProvider": return getOrCreateConfiguration(target).isUseProfileCredentialsProvider();
+        case "usesessioncredentials":
+        case "useSessionCredentials": return getOrCreateConfiguration(target).isUseSessionCredentials();
         default: return null;
         }
     }
diff --git a/components/camel-aws/camel-aws2-sns/src/generated/java/org/apache/camel/component/aws2/sns/Sns2EndpointConfigurer.java b/components/camel-aws/camel-aws2-sns/src/generated/java/org/apache/camel/component/aws2/sns/Sns2EndpointConfigurer.java
index ad8b9a1dbd4..faad218719e 100644
--- a/components/camel-aws/camel-aws2-sns/src/generated/java/org/apache/camel/component/aws2/sns/Sns2EndpointConfigurer.java
+++ b/components/camel-aws/camel-aws2-sns/src/generated/java/org/apache/camel/component/aws2/sns/Sns2EndpointConfigurer.java
@@ -57,6 +57,8 @@ public class Sns2EndpointConfigurer extends PropertyConfigurerSupport implements
         case "secretKey": target.getConfiguration().setSecretKey(property(camelContext, java.lang.String.class, value)); return true;
         case "serversideencryptionenabled":
         case "serverSideEncryptionEnabled": target.getConfiguration().setServerSideEncryptionEnabled(property(camelContext, boolean.class, value)); return true;
+        case "sessiontoken":
+        case "sessionToken": target.getConfiguration().setSessionToken(property(camelContext, java.lang.String.class, value)); return true;
         case "subject": target.getConfiguration().setSubject(property(camelContext, java.lang.String.class, value)); return true;
         case "subscribesnstosqs":
         case "subscribeSNStoSQS": target.getConfiguration().setSubscribeSNStoSQS(property(camelContext, boolean.class, value)); return true;
@@ -68,6 +70,8 @@ public class Sns2EndpointConfigurer extends PropertyConfigurerSupport implements
         case "useDefaultCredentialsProvider": target.getConfiguration().setUseDefaultCredentialsProvider(property(camelContext, boolean.class, value)); return true;
         case "useprofilecredentialsprovider":
         case "useProfileCredentialsProvider": target.getConfiguration().setUseProfileCredentialsProvider(property(camelContext, boolean.class, value)); return true;
+        case "usesessioncredentials":
+        case "useSessionCredentials": target.getConfiguration().setUseSessionCredentials(property(camelContext, boolean.class, value)); return true;
         default: return false;
         }
     }
@@ -116,6 +120,8 @@ public class Sns2EndpointConfigurer extends PropertyConfigurerSupport implements
         case "secretKey": return java.lang.String.class;
         case "serversideencryptionenabled":
         case "serverSideEncryptionEnabled": return boolean.class;
+        case "sessiontoken":
+        case "sessionToken": return java.lang.String.class;
         case "subject": return java.lang.String.class;
         case "subscribesnstosqs":
         case "subscribeSNStoSQS": return boolean.class;
@@ -127,6 +133,8 @@ public class Sns2EndpointConfigurer extends PropertyConfigurerSupport implements
         case "useDefaultCredentialsProvider": return boolean.class;
         case "useprofilecredentialsprovider":
         case "useProfileCredentialsProvider": return boolean.class;
+        case "usesessioncredentials":
+        case "useSessionCredentials": return boolean.class;
         default: return null;
         }
     }
@@ -171,6 +179,8 @@ public class Sns2EndpointConfigurer extends PropertyConfigurerSupport implements
         case "secretKey": return target.getConfiguration().getSecretKey();
         case "serversideencryptionenabled":
         case "serverSideEncryptionEnabled": return target.getConfiguration().isServerSideEncryptionEnabled();
+        case "sessiontoken":
+        case "sessionToken": return target.getConfiguration().getSessionToken();
         case "subject": return target.getConfiguration().getSubject();
         case "subscribesnstosqs":
         case "subscribeSNStoSQS": return target.getConfiguration().isSubscribeSNStoSQS();
@@ -182,6 +192,8 @@ public class Sns2EndpointConfigurer extends PropertyConfigurerSupport implements
         case "useDefaultCredentialsProvider": return target.getConfiguration().isUseDefaultCredentialsProvider();
         case "useprofilecredentialsprovider":
         case "useProfileCredentialsProvider": return target.getConfiguration().isUseProfileCredentialsProvider();
+        case "usesessioncredentials":
+        case "useSessionCredentials": return target.getConfiguration().isUseSessionCredentials();
         default: return null;
         }
     }
diff --git a/components/camel-aws/camel-aws2-sns/src/generated/java/org/apache/camel/component/aws2/sns/Sns2EndpointUriFactory.java b/components/camel-aws/camel-aws2-sns/src/generated/java/org/apache/camel/component/aws2/sns/Sns2EndpointUriFactory.java
index 8e761cb6bfc..7b770ea9779 100644
--- a/components/camel-aws/camel-aws2-sns/src/generated/java/org/apache/camel/component/aws2/sns/Sns2EndpointUriFactory.java
+++ b/components/camel-aws/camel-aws2-sns/src/generated/java/org/apache/camel/component/aws2/sns/Sns2EndpointUriFactory.java
@@ -21,7 +21,7 @@ public class Sns2EndpointUriFactory extends org.apache.camel.support.component.E
     private static final Set<String> SECRET_PROPERTY_NAMES;
     private static final Set<String> MULTI_VALUE_PREFIXES;
     static {
-        Set<String> props = new HashSet<>(26);
+        Set<String> props = new HashSet<>(28);
         props.add("accessKey");
         props.add("amazonSNSClient");
         props.add("autoCreateTopic");
@@ -41,6 +41,7 @@ public class Sns2EndpointUriFactory extends org.apache.camel.support.component.E
         props.add("region");
         props.add("secretKey");
         props.add("serverSideEncryptionEnabled");
+        props.add("sessionToken");
         props.add("subject");
         props.add("subscribeSNStoSQS");
         props.add("topicNameOrArn");
@@ -48,10 +49,12 @@ public class Sns2EndpointUriFactory extends org.apache.camel.support.component.E
         props.add("uriEndpointOverride");
         props.add("useDefaultCredentialsProvider");
         props.add("useProfileCredentialsProvider");
+        props.add("useSessionCredentials");
         PROPERTY_NAMES = Collections.unmodifiableSet(props);
-        Set<String> secretProps = new HashSet<>(2);
+        Set<String> secretProps = new HashSet<>(3);
         secretProps.add("accessKey");
         secretProps.add("secretKey");
+        secretProps.add("sessionToken");
         SECRET_PROPERTY_NAMES = Collections.unmodifiableSet(secretProps);
         MULTI_VALUE_PREFIXES = Collections.emptySet();
     }
diff --git a/components/camel-aws/camel-aws2-sns/src/generated/resources/org/apache/camel/component/aws2/sns/aws2-sns.json b/components/camel-aws/camel-aws2-sns/src/generated/resources/org/apache/camel/component/aws2/sns/aws2-sns.json
index d82bb2d78ef..3f9d1a809eb 100644
--- a/components/camel-aws/camel-aws2-sns/src/generated/resources/org/apache/camel/component/aws2/sns/aws2-sns.json
+++ b/components/camel-aws/camel-aws2-sns/src/generated/resources/org/apache/camel/component/aws2/sns/aws2-sns.json
@@ -48,9 +48,11 @@
     "accessKey": { "index": 22, "kind": "property", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.sns.Sns2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
     "profileCredentialsName": { "index": 23, "kind": "property", "displayName": "Profile Credentials Name", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.sns.Sns2Configuration", "configurationField": "configuration", "description": "If using a profile credentials provider this parameter will set the profile name" },
     "secretKey": { "index": 24, "kind": "property", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.sns.Sns2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" },
-    "trustAllCertificates": { "index": 25, "kind": "property", "displayName": "Trust All Certificates", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.sns.Sns2Configuration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overriding the endpoint" },
-    "useDefaultCredentialsProvider": { "index": 26, "kind": "property", "displayName": "Use Default Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.sns.Sns2Configuration", "configurationField": "configuration", "description": "Set whether the SNS client should expect to load cr [...]
-    "useProfileCredentialsProvider": { "index": 27, "kind": "property", "displayName": "Use Profile Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.sns.Sns2Configuration", "configurationField": "configuration", "description": "Set whether the SNS client should expect to load cr [...]
+    "sessionToken": { "index": 25, "kind": "property", "displayName": "Session Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.sns.Sns2Configuration", "configurationField": "configuration", "description": "Amazon AWS Session Token used when the user needs to assume a IAM role" },
+    "trustAllCertificates": { "index": 26, "kind": "property", "displayName": "Trust All Certificates", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.sns.Sns2Configuration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overriding the endpoint" },
+    "useDefaultCredentialsProvider": { "index": 27, "kind": "property", "displayName": "Use Default Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.sns.Sns2Configuration", "configurationField": "configuration", "description": "Set whether the SNS client should expect to load cr [...]
+    "useProfileCredentialsProvider": { "index": 28, "kind": "property", "displayName": "Use Profile Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.sns.Sns2Configuration", "configurationField": "configuration", "description": "Set whether the SNS client should expect to load cr [...]
+    "useSessionCredentials": { "index": 29, "kind": "property", "displayName": "Use Session Credentials", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.sns.Sns2Configuration", "configurationField": "configuration", "description": "Set whether the SNS client should expect to use Session Credentials. [...]
   },
   "headers": {
     "CamelAwsSnsMessageId": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The Amazon SNS message ID.", "constantName": "org.apache.camel.component.aws2.sns.Sns2Constants#MESSAGE_ID" },
@@ -81,8 +83,10 @@
     "accessKey": { "index": 20, "kind": "parameter", "displayName": "Access Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.sns.Sns2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
     "profileCredentialsName": { "index": 21, "kind": "parameter", "displayName": "Profile Credentials Name", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.sns.Sns2Configuration", "configurationField": "configuration", "description": "If using a profile credentials provider this parameter will set the profile name" },
     "secretKey": { "index": 22, "kind": "parameter", "displayName": "Secret Key", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.sns.Sns2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" },
-    "trustAllCertificates": { "index": 23, "kind": "parameter", "displayName": "Trust All Certificates", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.sns.Sns2Configuration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overriding the endpoint" },
-    "useDefaultCredentialsProvider": { "index": 24, "kind": "parameter", "displayName": "Use Default Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.sns.Sns2Configuration", "configurationField": "configuration", "description": "Set whether the SNS client should expect to load c [...]
-    "useProfileCredentialsProvider": { "index": 25, "kind": "parameter", "displayName": "Use Profile Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.sns.Sns2Configuration", "configurationField": "configuration", "description": "Set whether the SNS client should expect to load c [...]
+    "sessionToken": { "index": 23, "kind": "parameter", "displayName": "Session Token", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.sns.Sns2Configuration", "configurationField": "configuration", "description": "Amazon AWS Session Token used when the user needs to assume a IAM role" },
+    "trustAllCertificates": { "index": 24, "kind": "parameter", "displayName": "Trust All Certificates", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.sns.Sns2Configuration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overriding the endpoint" },
+    "useDefaultCredentialsProvider": { "index": 25, "kind": "parameter", "displayName": "Use Default Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.sns.Sns2Configuration", "configurationField": "configuration", "description": "Set whether the SNS client should expect to load c [...]
+    "useProfileCredentialsProvider": { "index": 26, "kind": "parameter", "displayName": "Use Profile Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.sns.Sns2Configuration", "configurationField": "configuration", "description": "Set whether the SNS client should expect to load c [...]
+    "useSessionCredentials": { "index": 27, "kind": "parameter", "displayName": "Use Session Credentials", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.sns.Sns2Configuration", "configurationField": "configuration", "description": "Set whether the SNS client should expect to use Session Credentials [...]
   }
 }
diff --git a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Component.java b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Component.java
index c966d7541dd..076372eaf4f 100644
--- a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Component.java
+++ b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Component.java
@@ -71,10 +71,11 @@ public class Sns2Component extends HealthCheckComponent {
         setProperties(endpoint, nonTransientParameters);
 
         if (!epConfiguration.isUseDefaultCredentialsProvider() && !epConfiguration.isUseProfileCredentialsProvider()
+                && !epConfiguration.isUseSessionCredentials()
                 && epConfiguration.getAmazonSNSClient() == null
                 && (epConfiguration.getAccessKey() == null || epConfiguration.getSecretKey() == null)) {
             throw new IllegalArgumentException(
-                    "useDefaultCredentialsProvider is set to false, useProfileCredentialsProvider is set to false, AmazonSNSClient or accessKey and secretKey must be specified");
+                    "useDefaultCredentialsProvider is set to false, useProfileCredentialsProvider is set to false, useSessionCredentials is set to false, AmazonSNSClient or accessKey and secretKey must be specified");
         }
 
         return endpoint;
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 a510ee5403b..38314bc0764 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
@@ -38,6 +38,8 @@ public class Sns2Configuration implements Cloneable {
     private String accessKey;
     @UriParam(label = "security", secret = true)
     private String secretKey;
+    @UriParam(label = "security", secret = true)
+    private String sessionToken;
     @UriParam(label = "proxy", enums = "HTTP,HTTPS", defaultValue = "HTTPS")
     private Protocol proxyProtocol = Protocol.HTTPS;
     @UriParam(label = "proxy")
@@ -76,6 +78,8 @@ public class Sns2Configuration implements Cloneable {
     @UriParam(label = "security")
     private boolean useProfileCredentialsProvider;
     @UriParam(label = "security")
+    private boolean useSessionCredentials;
+    @UriParam(label = "security")
     private String profileCredentialsName;
     @UriParam(label = "producer", javaType = "java.lang.String", enums = "useConstant,useExchangeId,usePropertyValue")
     private MessageGroupIdStrategy messageGroupIdStrategy;
@@ -127,6 +131,17 @@ public class Sns2Configuration implements Cloneable {
         this.secretKey = secretKey;
     }
 
+    public String getSessionToken() {
+        return sessionToken;
+    }
+
+    /**
+     * Amazon AWS Session Token used when the user needs to assume a IAM role
+     */
+    public void setSessionToken(String sessionToken) {
+        this.sessionToken = sessionToken;
+    }
+
     public SnsClient getAmazonSNSClient() {
         return amazonSNSClient;
     }
@@ -306,6 +321,18 @@ public class Sns2Configuration implements Cloneable {
         return useProfileCredentialsProvider;
     }
 
+    public boolean isUseSessionCredentials() {
+        return useSessionCredentials;
+    }
+
+    /**
+     * Set whether the SNS client should expect to use Session Credentials. This is useful in situation in which the
+     * user needs to assume a IAM role for doing operations in SNS.
+     */
+    public void setUseSessionCredentials(boolean useSessionCredentials) {
+        this.useSessionCredentials = useSessionCredentials;
+    }
+
     public String getProfileCredentialsName() {
         return profileCredentialsName;
     }
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 c079e520e1e..a146d0c82c7 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
@@ -19,6 +19,7 @@ package org.apache.camel.component.aws2.sns.client;
 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;
 
 /**
@@ -40,6 +41,8 @@ public final class Sns2ClientFactory {
             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);
         }
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
new file mode 100644
index 00000000000..350f3e59543
--- /dev/null
+++ b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/client/impl/Sns2ClientSessionTokenImpl.java
@@ -0,0 +1,110 @@
+/*
+ * 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;
+    }
+}