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 417aa403285 CAMEL-20423 - AWS STS Component: Provide a way of setting
the duration of AssumeRoleRequest through header (#13130)
417aa403285 is described below
commit 417aa4032850da63b50683dd5fe878b547dc6991
Author: Andrea Cosentino <[email protected]>
AuthorDate: Thu Feb 15 13:08:49 2024 +0100
CAMEL-20423 - AWS STS Component: Provide a way of setting the duration of
AssumeRoleRequest through header (#13130)
Signed-off-by: Andrea Cosentino <[email protected]>
---
.../resources/org/apache/camel/catalog/components/aws2-sts.json | 3 ++-
.../resources/org/apache/camel/component/aws2/sts/aws2-sts.json | 3 ++-
.../main/java/org/apache/camel/component/aws2/sts/STS2Constants.java | 4 ++++
.../main/java/org/apache/camel/component/aws2/sts/STS2Producer.java | 5 +++++
4 files changed, 13 insertions(+), 2 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-sts.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-sts.json
index 7e021c70c5d..ac2fa2657ea 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-sts.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-sts.json
@@ -46,7 +46,8 @@
"CamelAwsStsOperation": { "index": 0, "kind": "header", "displayName": "",
"group": "producer", "label": "", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "The operation we want to perform", "constantName":
"org.apache.camel.component.aws2.sts.STS2Constants#OPERATION" },
"CamelAwsStsRoleArn": { "index": 1, "kind": "header", "displayName": "",
"group": "producer", "label": "", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "The Amazon Resource Name (ARN) of the role to assume.",
"constantName": "org.apache.camel.component.aws2.sts.STS2Constants#ROLE_ARN" },
"CamelAwsStsRoleSessionName": { "index": 2, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "An identifier for the assumed role
session.", "constantName":
"org.apache.camel.component.aws2.sts.STS2Constants#ROLE_SESSION_NAME" },
- "CamelAwsStsFederatedName": { "index": 3, "kind": "header", "displayName":
"", "group": "producer", "label": "", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "The name of the federated user.", "constantName":
"org.apache.camel.component.aws2.sts.STS2Constants#FEDERATED_NAME" }
+ "CamelAwsStsFederatedName": { "index": 3, "kind": "header", "displayName":
"", "group": "producer", "label": "", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "The name of the federated user.", "constantName":
"org.apache.camel.component.aws2.sts.STS2Constants#FEDERATED_NAME" },
+ "CamelAwsStsAssumeRoleDurationSeconds": { "index": 4, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "The duration, in seconds, of the role
session. It could go from 900 seconds, to 1 to 12 hours (dependent on
administrator settings. The default if not specified is 3600 seconds.",
"constantName": "org.apache.camel.component. [...]
},
"properties": {
"label": { "index": 0, "kind": "path", "displayName": "Label", "group":
"producer", "label": "", "required": true, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.aws2.sts.STS2Configuration", "configurationField":
"configuration", "description": "Logical name" },
diff --git
a/components/camel-aws/camel-aws2-sts/src/generated/resources/org/apache/camel/component/aws2/sts/aws2-sts.json
b/components/camel-aws/camel-aws2-sts/src/generated/resources/org/apache/camel/component/aws2/sts/aws2-sts.json
index 7e021c70c5d..ac2fa2657ea 100644
---
a/components/camel-aws/camel-aws2-sts/src/generated/resources/org/apache/camel/component/aws2/sts/aws2-sts.json
+++
b/components/camel-aws/camel-aws2-sts/src/generated/resources/org/apache/camel/component/aws2/sts/aws2-sts.json
@@ -46,7 +46,8 @@
"CamelAwsStsOperation": { "index": 0, "kind": "header", "displayName": "",
"group": "producer", "label": "", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "The operation we want to perform", "constantName":
"org.apache.camel.component.aws2.sts.STS2Constants#OPERATION" },
"CamelAwsStsRoleArn": { "index": 1, "kind": "header", "displayName": "",
"group": "producer", "label": "", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "The Amazon Resource Name (ARN) of the role to assume.",
"constantName": "org.apache.camel.component.aws2.sts.STS2Constants#ROLE_ARN" },
"CamelAwsStsRoleSessionName": { "index": 2, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "An identifier for the assumed role
session.", "constantName":
"org.apache.camel.component.aws2.sts.STS2Constants#ROLE_SESSION_NAME" },
- "CamelAwsStsFederatedName": { "index": 3, "kind": "header", "displayName":
"", "group": "producer", "label": "", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "The name of the federated user.", "constantName":
"org.apache.camel.component.aws2.sts.STS2Constants#FEDERATED_NAME" }
+ "CamelAwsStsFederatedName": { "index": 3, "kind": "header", "displayName":
"", "group": "producer", "label": "", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "The name of the federated user.", "constantName":
"org.apache.camel.component.aws2.sts.STS2Constants#FEDERATED_NAME" },
+ "CamelAwsStsAssumeRoleDurationSeconds": { "index": 4, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "The duration, in seconds, of the role
session. It could go from 900 seconds, to 1 to 12 hours (dependent on
administrator settings. The default if not specified is 3600 seconds.",
"constantName": "org.apache.camel.component. [...]
},
"properties": {
"label": { "index": 0, "kind": "path", "displayName": "Label", "group":
"producer", "label": "", "required": true, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.aws2.sts.STS2Configuration", "configurationField":
"configuration", "description": "Logical name" },
diff --git
a/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Constants.java
b/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Constants.java
index ea486a6d9d3..2f764d89272 100644
---
a/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Constants.java
+++
b/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Constants.java
@@ -30,6 +30,10 @@ public interface STS2Constants {
String ROLE_SESSION_NAME = "CamelAwsStsRoleSessionName";
@Metadata(description = "The name of the federated user.", javaType =
"String")
String FEDERATED_NAME = "CamelAwsStsFederatedName";
+ @Metadata(description = "The duration, in seconds, of the role session. It
could go from 900 seconds, to 1 to 12 hours (dependent on administrator
settings. The default if not specified is 3600 seconds.",
+ javaType = "Integer")
+ String ASSUME_ROLE_DURATION_SECONDS =
"CamelAwsStsAssumeRoleDurationSeconds";
+
String ACCESS_KEY_ID = "CamelAwsStsAccessKeyId";
String SECRET_KEY_ID = "CamelAwsStsSecretKey";
}
diff --git
a/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Producer.java
b/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Producer.java
index 5254d1c4942..478c9e6e6cd 100644
---
a/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Producer.java
+++
b/components/camel-aws/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Producer.java
@@ -119,6 +119,11 @@ public class STS2Producer extends DefaultProducer {
} else {
throw new IllegalArgumentException("Role Session Name needs to
be specified for assumeRole operation");
}
+ if
(ObjectHelper.isNotEmpty(exchange.getIn().getHeader(STS2Constants.ASSUME_ROLE_DURATION_SECONDS)))
{
+ Integer durationInSeconds
+ =
exchange.getIn().getHeader(STS2Constants.ASSUME_ROLE_DURATION_SECONDS,
Integer.class);
+ builder.durationSeconds(durationInSeconds);
+ }
AssumeRoleResponse result;
try {
result = stsClient.assumeRole(builder.build());