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
The following commit(s) were added to refs/heads/main by this push:
new b77317b807f CAMEL-20281 - Camel-AWS Components: Make it possible to
use AwsSessionCredentials to support temporary credentials - AWS SES (#12861)
b77317b807f is described below
commit b77317b807ffe61b04e426d5d0d493ed73dfa1ec
Author: Andrea Cosentino <[email protected]>
AuthorDate: Mon Jan 22 12:50:07 2024 +0100
CAMEL-20281 - Camel-AWS Components: Make it possible to use
AwsSessionCredentials to support temporary credentials - AWS SES (#12861)
* CAMEL-20281 - Camel-AWS Components: Make it possible to use
AwsSessionCredentials to support temporary credentials - AWS SES
Signed-off-by: Andrea Cosentino <[email protected]>
* CAMEL-20281 - Camel-AWS Components: Make it possible to use
AwsSessionCredentials to support temporary credentials - AWS SES
Signed-off-by: Andrea Cosentino <[email protected]>
---------
Signed-off-by: Andrea Cosentino <[email protected]>
---
.../apache/camel/catalog/components/aws2-ses.json | 16 +--
.../aws2/ses/Ses2ComponentConfigurer.java | 12 +++
.../component/aws2/ses/Ses2EndpointConfigurer.java | 12 +++
.../component/aws2/ses/Ses2EndpointUriFactory.java | 7 +-
.../apache/camel/component/aws2/ses/aws2-ses.json | 16 +--
.../camel/component/aws2/ses/Ses2Component.java | 3 +-
.../component/aws2/ses/Ses2Configuration.java | 28 ++++++
.../aws2/ses/client/Ses2ClientFactory.java | 3 +
.../client/impl/Ses2ClientSessionTokenImpl.java | 110 +++++++++++++++++++++
.../component/aws2/ses/Ses2ClientFactoryTest.java | 9 ++
10 files changed, 201 insertions(+), 15 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-ses.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-ses.json
index 53129adafb4..380c483c6ea 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-ses.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-ses.json
@@ -45,9 +45,11 @@
"accessKey": { "index": 19, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Amazon AWS Access Key" },
"profileCredentialsName": { "index": 20, "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.ses.Ses2Configuration",
"configurationField": "configuration", "description": "If using a profile
credentials provider this parameter will set the profile name" },
"secretKey": { "index": 21, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Amazon AWS Secret Key" },
- "trustAllCertificates": { "index": 22, "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.ses.Ses2Configuration",
"configurationField": "configuration", "description": "If we want to trust all
certificates in case of overriding the endpoint" },
- "useDefaultCredentialsProvider": { "index": 23, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Set whether the Ses client should expect to
load cr [...]
- "useProfileCredentialsProvider": { "index": 24, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Set whether the SES client should expect to
load cr [...]
+ "sessionToken": { "index": 22, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Amazon AWS Session Token used when the user
needs to assume a IAM role" },
+ "trustAllCertificates": { "index": 23, "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.ses.Ses2Configuration",
"configurationField": "configuration", "description": "If we want to trust all
certificates in case of overriding the endpoint" },
+ "useDefaultCredentialsProvider": { "index": 24, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Set whether the Ses client should expect to
load cr [...]
+ "useProfileCredentialsProvider": { "index": 25, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Set whether the SES client should expect to
load cr [...]
+ "useSessionCredentials": { "index": 26, "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.ses.Ses2Configuration",
"configurationField": "configuration", "description": "Set whether the SES
client should expect to use Session Credentials. [...]
},
"headers": {
"CamelAwsSesFrom": { "index": 0, "kind": "header", "displayName": "",
"group": "producer", "label": "", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "The sender's email address.", "constantName":
"org.apache.camel.component.aws2.ses.Ses2Constants#FROM" },
@@ -81,8 +83,10 @@
"accessKey": { "index": 16, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Amazon AWS Access Key" },
"profileCredentialsName": { "index": 17, "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.ses.Ses2Configuration",
"configurationField": "configuration", "description": "If using a profile
credentials provider this parameter will set the profile name" },
"secretKey": { "index": 18, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Amazon AWS Secret Key" },
- "trustAllCertificates": { "index": 19, "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.ses.Ses2Configuration",
"configurationField": "configuration", "description": "If we want to trust all
certificates in case of overriding the endpoint" },
- "useDefaultCredentialsProvider": { "index": 20, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Set whether the Ses client should expect to
load c [...]
- "useProfileCredentialsProvider": { "index": 21, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Set whether the SES client should expect to
load c [...]
+ "sessionToken": { "index": 19, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Amazon AWS Session Token used when the user
needs to assume a IAM role" },
+ "trustAllCertificates": { "index": 20, "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.ses.Ses2Configuration",
"configurationField": "configuration", "description": "If we want to trust all
certificates in case of overriding the endpoint" },
+ "useDefaultCredentialsProvider": { "index": 21, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Set whether the Ses client should expect to
load c [...]
+ "useProfileCredentialsProvider": { "index": 22, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Set whether the SES client should expect to
load c [...]
+ "useSessionCredentials": { "index": 23, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Set whether the SES client should expect to
use Session Credentials [...]
}
}
diff --git
a/components/camel-aws/camel-aws2-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2ComponentConfigurer.java
b/components/camel-aws/camel-aws2-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2ComponentConfigurer.java
index 89623d34cc7..3317272b082 100644
---
a/components/camel-aws/camel-aws2-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2ComponentConfigurer.java
+++
b/components/camel-aws/camel-aws2-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2ComponentConfigurer.java
@@ -62,6 +62,8 @@ public class Ses2ComponentConfigurer extends
PropertyConfigurerSupport implement
case "returnPath":
getOrCreateConfiguration(target).setReturnPath(property(camelContext,
java.lang.String.class, value)); return true;
case "secretkey":
case "secretKey":
getOrCreateConfiguration(target).setSecretKey(property(camelContext,
java.lang.String.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 "to":
getOrCreateConfiguration(target).setTo(property(camelContext,
java.lang.String.class, value)); return true;
case "trustallcertificates":
@@ -72,6 +74,8 @@ public class Ses2ComponentConfigurer 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;
}
}
@@ -118,6 +122,8 @@ public class Ses2ComponentConfigurer extends
PropertyConfigurerSupport implement
case "returnPath": return java.lang.String.class;
case "secretkey":
case "secretKey": return java.lang.String.class;
+ case "sessiontoken":
+ case "sessionToken": return java.lang.String.class;
case "subject": return java.lang.String.class;
case "to": return java.lang.String.class;
case "trustallcertificates":
@@ -128,6 +134,8 @@ public class Ses2ComponentConfigurer 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;
}
}
@@ -170,6 +178,8 @@ public class Ses2ComponentConfigurer extends
PropertyConfigurerSupport implement
case "returnPath": return
getOrCreateConfiguration(target).getReturnPath();
case "secretkey":
case "secretKey": return
getOrCreateConfiguration(target).getSecretKey();
+ case "sessiontoken":
+ case "sessionToken": return
getOrCreateConfiguration(target).getSessionToken();
case "subject": return getOrCreateConfiguration(target).getSubject();
case "to": return getOrCreateConfiguration(target).getTo();
case "trustallcertificates":
@@ -180,6 +190,8 @@ public class Ses2ComponentConfigurer 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-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2EndpointConfigurer.java
b/components/camel-aws/camel-aws2-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2EndpointConfigurer.java
index fd0e6fee436..8aab4ac2f0e 100644
---
a/components/camel-aws/camel-aws2-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2EndpointConfigurer.java
+++
b/components/camel-aws/camel-aws2-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2EndpointConfigurer.java
@@ -48,6 +48,8 @@ public class Ses2EndpointConfigurer extends
PropertyConfigurerSupport implements
case "returnPath":
target.getConfiguration().setReturnPath(property(camelContext,
java.lang.String.class, value)); return true;
case "secretkey":
case "secretKey":
target.getConfiguration().setSecretKey(property(camelContext,
java.lang.String.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 "to": target.getConfiguration().setTo(property(camelContext,
java.lang.String.class, value)); return true;
case "trustallcertificates":
@@ -58,6 +60,8 @@ public class Ses2EndpointConfigurer 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;
}
}
@@ -97,6 +101,8 @@ public class Ses2EndpointConfigurer extends
PropertyConfigurerSupport implements
case "returnPath": return java.lang.String.class;
case "secretkey":
case "secretKey": return java.lang.String.class;
+ case "sessiontoken":
+ case "sessionToken": return java.lang.String.class;
case "subject": return java.lang.String.class;
case "to": return java.lang.String.class;
case "trustallcertificates":
@@ -107,6 +113,8 @@ public class Ses2EndpointConfigurer 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;
}
}
@@ -142,6 +150,8 @@ public class Ses2EndpointConfigurer extends
PropertyConfigurerSupport implements
case "returnPath": return target.getConfiguration().getReturnPath();
case "secretkey":
case "secretKey": return target.getConfiguration().getSecretKey();
+ case "sessiontoken":
+ case "sessionToken": return
target.getConfiguration().getSessionToken();
case "subject": return target.getConfiguration().getSubject();
case "to": return target.getConfiguration().getTo();
case "trustallcertificates":
@@ -152,6 +162,8 @@ public class Ses2EndpointConfigurer 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-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2EndpointUriFactory.java
b/components/camel-aws/camel-aws2-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2EndpointUriFactory.java
index f7e7d42cff4..7fc9a75eb22 100644
---
a/components/camel-aws/camel-aws2-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2EndpointUriFactory.java
+++
b/components/camel-aws/camel-aws2-ses/src/generated/java/org/apache/camel/component/aws2/ses/Ses2EndpointUriFactory.java
@@ -21,7 +21,7 @@ public class Ses2EndpointUriFactory 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<>(22);
+ Set<String> props = new HashSet<>(24);
props.add("accessKey");
props.add("amazonSESClient");
props.add("bcc");
@@ -38,16 +38,19 @@ public class Ses2EndpointUriFactory extends
org.apache.camel.support.component.E
props.add("replyToAddresses");
props.add("returnPath");
props.add("secretKey");
+ props.add("sessionToken");
props.add("subject");
props.add("to");
props.add("trustAllCertificates");
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-ses/src/generated/resources/org/apache/camel/component/aws2/ses/aws2-ses.json
b/components/camel-aws/camel-aws2-ses/src/generated/resources/org/apache/camel/component/aws2/ses/aws2-ses.json
index 53129adafb4..380c483c6ea 100644
---
a/components/camel-aws/camel-aws2-ses/src/generated/resources/org/apache/camel/component/aws2/ses/aws2-ses.json
+++
b/components/camel-aws/camel-aws2-ses/src/generated/resources/org/apache/camel/component/aws2/ses/aws2-ses.json
@@ -45,9 +45,11 @@
"accessKey": { "index": 19, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Amazon AWS Access Key" },
"profileCredentialsName": { "index": 20, "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.ses.Ses2Configuration",
"configurationField": "configuration", "description": "If using a profile
credentials provider this parameter will set the profile name" },
"secretKey": { "index": 21, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Amazon AWS Secret Key" },
- "trustAllCertificates": { "index": 22, "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.ses.Ses2Configuration",
"configurationField": "configuration", "description": "If we want to trust all
certificates in case of overriding the endpoint" },
- "useDefaultCredentialsProvider": { "index": 23, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Set whether the Ses client should expect to
load cr [...]
- "useProfileCredentialsProvider": { "index": 24, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Set whether the SES client should expect to
load cr [...]
+ "sessionToken": { "index": 22, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Amazon AWS Session Token used when the user
needs to assume a IAM role" },
+ "trustAllCertificates": { "index": 23, "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.ses.Ses2Configuration",
"configurationField": "configuration", "description": "If we want to trust all
certificates in case of overriding the endpoint" },
+ "useDefaultCredentialsProvider": { "index": 24, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Set whether the Ses client should expect to
load cr [...]
+ "useProfileCredentialsProvider": { "index": 25, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Set whether the SES client should expect to
load cr [...]
+ "useSessionCredentials": { "index": 26, "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.ses.Ses2Configuration",
"configurationField": "configuration", "description": "Set whether the SES
client should expect to use Session Credentials. [...]
},
"headers": {
"CamelAwsSesFrom": { "index": 0, "kind": "header", "displayName": "",
"group": "producer", "label": "", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "The sender's email address.", "constantName":
"org.apache.camel.component.aws2.ses.Ses2Constants#FROM" },
@@ -81,8 +83,10 @@
"accessKey": { "index": 16, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Amazon AWS Access Key" },
"profileCredentialsName": { "index": 17, "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.ses.Ses2Configuration",
"configurationField": "configuration", "description": "If using a profile
credentials provider this parameter will set the profile name" },
"secretKey": { "index": 18, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Amazon AWS Secret Key" },
- "trustAllCertificates": { "index": 19, "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.ses.Ses2Configuration",
"configurationField": "configuration", "description": "If we want to trust all
certificates in case of overriding the endpoint" },
- "useDefaultCredentialsProvider": { "index": 20, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Set whether the Ses client should expect to
load c [...]
- "useProfileCredentialsProvider": { "index": 21, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Set whether the SES client should expect to
load c [...]
+ "sessionToken": { "index": 19, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Amazon AWS Session Token used when the user
needs to assume a IAM role" },
+ "trustAllCertificates": { "index": 20, "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.ses.Ses2Configuration",
"configurationField": "configuration", "description": "If we want to trust all
certificates in case of overriding the endpoint" },
+ "useDefaultCredentialsProvider": { "index": 21, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Set whether the Ses client should expect to
load c [...]
+ "useProfileCredentialsProvider": { "index": 22, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Set whether the SES client should expect to
load c [...]
+ "useSessionCredentials": { "index": 23, "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.ses.Ses2Configuration", "configurationField":
"configuration", "description": "Set whether the SES client should expect to
use Session Credentials [...]
}
}
diff --git
a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java
b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java
index f82895d0e03..5e3796f2c61 100644
---
a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java
+++
b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java
@@ -53,10 +53,11 @@ public class Ses2Component extends HealthCheckComponent {
setProperties(endpoint, parameters);
if
(Boolean.FALSE.equals(configuration.isUseDefaultCredentialsProvider())
&&
Boolean.FALSE.equals(configuration.isUseProfileCredentialsProvider())
+ &&
Boolean.FALSE.equals(configuration.isUseSessionCredentials())
&& configuration.getAmazonSESClient() == null
&& (configuration.getAccessKey() == null ||
configuration.getSecretKey() == null)) {
throw new IllegalArgumentException(
- "useDefaultCredentialsProvider is set to false,
useProfileCredentialsProvider is set to false, AmazonSESClient or accessKey and
secretKey must be specified");
+ "useDefaultCredentialsProvider is set to false,
useProfileCredentialsProvider is set to false, useSessionCredentials is set to
false, AmazonSESClient or accessKey and secretKey must be specified");
}
return endpoint;
diff --git
a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Configuration.java
b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Configuration.java
index 6039573b509..e20dee33ef4 100644
---
a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Configuration.java
+++
b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Configuration.java
@@ -37,6 +37,9 @@ public class Ses2Configuration implements Cloneable {
private String accessKey;
@UriParam(label = "security", secret = true)
private String secretKey;
+
+ @UriParam(label = "security", secret = true)
+ private String sessionToken;
@UriParam
private String subject;
@UriParam
@@ -70,6 +73,8 @@ public class Ses2Configuration implements Cloneable {
@UriParam(label = "security")
private boolean useProfileCredentialsProvider;
@UriParam(label = "security")
+ private boolean useSessionCredentials;
+ @UriParam(label = "security")
private String profileCredentialsName;
public String getAccessKey() {
@@ -151,6 +156,17 @@ public class Ses2Configuration 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 String getSubject() {
return subject;
}
@@ -302,6 +318,18 @@ public class Ses2Configuration implements Cloneable {
this.useProfileCredentialsProvider = useProfileCredentialsProvider;
}
+ public boolean isUseSessionCredentials() {
+ return useSessionCredentials;
+ }
+
+ /**
+ * Set whether the SES 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 SES.
+ */
+ public void setUseSessionCredentials(boolean useSessionCredentials) {
+ this.useSessionCredentials = useSessionCredentials;
+ }
+
public String getProfileCredentialsName() {
return profileCredentialsName;
}
diff --git
a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/client/Ses2ClientFactory.java
b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/client/Ses2ClientFactory.java
index 890c7964ce4..985a0379f2d 100644
---
a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/client/Ses2ClientFactory.java
+++
b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/client/Ses2ClientFactory.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.aws2.ses.client;
import org.apache.camel.component.aws2.ses.Ses2Configuration;
import org.apache.camel.component.aws2.ses.client.impl.Ses2ClientOptimizedImpl;
import
org.apache.camel.component.aws2.ses.client.impl.Ses2ClientProfileOptimizedImpl;
+import
org.apache.camel.component.aws2.ses.client.impl.Ses2ClientSessionTokenImpl;
import org.apache.camel.component.aws2.ses.client.impl.Ses2ClientStandardImpl;
/**
@@ -40,6 +41,8 @@ public final class Ses2ClientFactory {
return new Ses2ClientOptimizedImpl(configuration);
} else if
(Boolean.TRUE.equals(configuration.isUseProfileCredentialsProvider())) {
return new Ses2ClientProfileOptimizedImpl(configuration);
+ } else if
(Boolean.TRUE.equals(configuration.isUseSessionCredentials())) {
+ return new Ses2ClientSessionTokenImpl(configuration);
} else {
return new Ses2ClientStandardImpl(configuration);
}
diff --git
a/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/client/impl/Ses2ClientSessionTokenImpl.java
b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/client/impl/Ses2ClientSessionTokenImpl.java
new file mode 100644
index 00000000000..3f06b70cf3b
--- /dev/null
+++
b/components/camel-aws/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/client/impl/Ses2ClientSessionTokenImpl.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.ses.client.impl;
+
+import java.net.URI;
+
+import org.apache.camel.component.aws2.ses.Ses2Configuration;
+import org.apache.camel.component.aws2.ses.client.Ses2InternalClient;
+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.ses.SesClient;
+import software.amazon.awssdk.services.ses.SesClientBuilder;
+import software.amazon.awssdk.utils.AttributeMap;
+
+/**
+ * Manage an AWS SES client for all users to use. This implementation is for
local instances to use a static and solid
+ * credential set.
+ */
+public class Ses2ClientSessionTokenImpl implements Ses2InternalClient {
+ private static final Logger LOG =
LoggerFactory.getLogger(Ses2ClientSessionTokenImpl.class);
+ private Ses2Configuration configuration;
+
+ /**
+ * Constructor that uses the config file.
+ */
+ public Ses2ClientSessionTokenImpl(Ses2Configuration configuration) {
+ LOG.trace("Creating an AWS SES manager using static credentials.");
+ this.configuration = configuration;
+ }
+
+ /**
+ * Getting the SES AWS client that is used.
+ *
+ * @return Amazon SES Client.
+ */
+ @Override
+ public SesClient getSesClient() {
+ SesClient client = null;
+ SesClientBuilder clientBuilder = SesClient.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-ses/src/test/java/org/apache/camel/component/aws2/ses/Ses2ClientFactoryTest.java
b/components/camel-aws/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/Ses2ClientFactoryTest.java
index 55266ab18ee..b194e8787e4 100644
---
a/components/camel-aws/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/Ses2ClientFactoryTest.java
+++
b/components/camel-aws/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/Ses2ClientFactoryTest.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.aws2.ses;
import org.apache.camel.component.aws2.ses.client.Ses2ClientFactory;
import org.apache.camel.component.aws2.ses.client.Ses2InternalClient;
import org.apache.camel.component.aws2.ses.client.impl.Ses2ClientOptimizedImpl;
+import
org.apache.camel.component.aws2.ses.client.impl.Ses2ClientSessionTokenImpl;
import org.apache.camel.component.aws2.ses.client.impl.Ses2ClientStandardImpl;
import org.junit.jupiter.api.Test;
@@ -48,4 +49,12 @@ public class Ses2ClientFactoryTest {
Ses2InternalClient sesClient =
Ses2ClientFactory.getSesClient(ses2Configuration);
assertTrue(sesClient instanceof Ses2ClientOptimizedImpl);
}
+
+ @Test
+ public void getSESSessionTokenImplClient() {
+ Ses2Configuration ses2Configuration = new Ses2Configuration();
+ ses2Configuration.setUseSessionCredentials(true);
+ Ses2InternalClient sesClient =
Ses2ClientFactory.getSesClient(ses2Configuration);
+ assertTrue(sesClient instanceof Ses2ClientSessionTokenImpl);
+ }
}