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 2021/05/13 14:54:52 UTC

[camel] branch main updated (93da8d6 -> 492b7e3)

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 93da8d6  Regen for commit 50f88832b63d4ca16c0bf1cbf6646d2c5da69a9a (#5558)
     new 667d017  CAMEL-16465 - Camel-AWS: Add useDefaultCredentialProvider option to all the components - IAM Component
     new fd98196  CAMEL-16465 - Camel-AWS: Add useDefaultCredentialProvider option to all the components - IAM Component
     new d9aad5e  CAMEL-16465 - Camel-AWS: Add useDefaultCredentialProvider option to all the components - IAM Component
     new 8c3ccce  CAMEL-16465 - Camel-AWS: Add useDefaultCredentialProvider option to all the components - IAM Component
     new 492b7e3  Regen

The 5 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:
 .../apache/camel/catalog/components/aws2-iam.json  |  2 +
 .../camel/catalog/docs/aws2-iam-component.adoc     |  6 ++-
 .../aws2/iam/IAM2ComponentConfigurer.java          |  6 +++
 .../component/aws2/iam/IAM2EndpointConfigurer.java |  6 +++
 .../component/aws2/iam/IAM2EndpointUriFactory.java |  3 +-
 .../apache/camel/component/aws2/iam/aws2-iam.json  |  2 +
 .../src/main/docs/aws2-iam-component.adoc          |  6 ++-
 .../camel/component/aws2/iam/IAM2Component.java    |  5 +-
 .../component/aws2/iam/IAM2Configuration.java      | 13 +++++
 .../camel/component/aws2/iam/IAM2Endpoint.java     | 62 ++--------------------
 .../aws2/iam/client/IAM2ClientFactory.java}        | 22 ++++----
 .../aws2/iam/client/IAM2InternalClient.java}       | 14 ++---
 .../iam/client/impl/IAM2ClientOptimizedImpl.java}  | 32 +++++------
 .../iam/client/impl/IAM2ClientStandardImpl.java}   | 30 +++++------
 .../dsl/Aws2IamComponentBuilderFactory.java        | 19 +++++++
 .../endpoint/dsl/IAM2EndpointBuilderFactory.java   | 37 +++++++++++++
 .../modules/ROOT/pages/aws2-iam-component.adoc     |  6 ++-
 17 files changed, 155 insertions(+), 116 deletions(-)
 copy components/camel-aws/{camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/client/Sns2ClientFactory.java => camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/IAM2ClientFactory.java} (59%)
 copy components/camel-aws/{camel-aws2-ecs/src/main/java/org/apache/camel/component/aws2/ecs/client/ECS2InternalClient.java => camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/IAM2InternalClient.java} (72%)
 copy components/camel-aws/{camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/client/impl/EKS2ClientIAMOptimizedImpl.java => camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/impl/IAM2ClientOptimizedImpl.java} (77%)
 copy components/camel-aws/{camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/client/impl/EKS2ClientStandardImpl.java => camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/impl/IAM2ClientStandardImpl.java} (82%)

[camel] 03/05: CAMEL-16465 - Camel-AWS: Add useDefaultCredentialProvider option to all the components - IAM Component

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 d9aad5e96954bba2cf6297a7086f38d5c4e8811c
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu May 13 15:26:38 2021 +0200

    CAMEL-16465 - Camel-AWS: Add useDefaultCredentialProvider option to all the components - IAM Component
---
 .../main/java/org/apache/camel/component/aws2/iam/IAM2Component.java  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Component.java b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Component.java
index c621af4..a13ca64 100644
--- a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Component.java
+++ b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Component.java
@@ -52,9 +52,9 @@ public class IAM2Component extends DefaultComponent {
         IAM2Configuration configuration = this.configuration != null ? this.configuration.copy() : new IAM2Configuration();
         IAM2Endpoint endpoint = new IAM2Endpoint(uri, this, configuration);
         setProperties(endpoint, parameters);
-        if (configuration.getIamClient() == null
+        if (!configuration.isUseDefaultCredentialsProvider() && configuration.getIamClient() == null
                 && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
-            throw new IllegalArgumentException("Amazon IAM client or accessKey and secretKey must be specified");
+            throw new IllegalArgumentException("seDefaultCredentialsProvider is set to false, Amazon IAM client or accessKey and secretKey must be specified");
         }
 
         return endpoint;

[camel] 02/05: CAMEL-16465 - Camel-AWS: Add useDefaultCredentialProvider option to all the components - IAM Component

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 fd981968efb86d1a2919d79eda2e352083b23f75
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu May 13 15:24:23 2021 +0200

    CAMEL-16465 - Camel-AWS: Add useDefaultCredentialProvider option to all the components - IAM Component
---
 .../camel/component/aws2/iam/IAM2Endpoint.java     | 51 ++--------------------
 .../aws2/iam/client/IAM2ClientFactory.java         |  2 +-
 2 files changed, 5 insertions(+), 48 deletions(-)

diff --git a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Endpoint.java b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Endpoint.java
index 782250e..c2fc046 100644
--- a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Endpoint.java
+++ b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Endpoint.java
@@ -23,6 +23,7 @@ import org.apache.camel.Component;
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
+import org.apache.camel.component.aws2.iam.client.IAM2ClientFactory;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.support.ScheduledPollEndpoint;
@@ -69,7 +70,9 @@ public class IAM2Endpoint extends ScheduledPollEndpoint {
     public void doStart() throws Exception {
         super.doStart();
 
-        iamClient = configuration.getIamClient() != null ? configuration.getIamClient() : createIAMClient();
+        iamClient = configuration.getIamClient() != null
+                ? configuration.getIamClient()
+                : IAM2ClientFactory.getIamClient(configuration).getIamClient();
     }
 
     @Override
@@ -89,50 +92,4 @@ public class IAM2Endpoint extends ScheduledPollEndpoint {
     public IamClient getIamClient() {
         return iamClient;
     }
-
-    IamClient createIAMClient() {
-        IamClient client = null;
-        IamClientBuilder clientBuilder = IamClient.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()) {
-            SdkHttpClient ahc = ApacheHttpClient.builder().buildWithDefaults(AttributeMap
-                    .builder()
-                    .put(
-                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
-                            Boolean.TRUE)
-                    .build());
-            clientBuilder.httpClient(ahc);
-        }
-        client = clientBuilder.build();
-        return client;
-    }
 }
diff --git a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/IAM2ClientFactory.java b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/IAM2ClientFactory.java
index 3fb113f..4f99bd1 100644
--- a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/IAM2ClientFactory.java
+++ b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/IAM2ClientFactory.java
@@ -34,7 +34,7 @@ public final class IAM2ClientFactory {
      * @param  configuration configuration
      * @return               IamClient
      */
-    public static IAM2InternalClient getEventbridgeClient(IAM2Configuration configuration) {
+    public static IAM2InternalClient getIamClient(IAM2Configuration configuration) {
         return configuration.isUseDefaultCredentialsProvider()
                 ? new IAM2ClientOptimizedImpl(configuration) : new IAM2ClientStandardImpl(configuration);
     }

[camel] 04/05: CAMEL-16465 - Camel-AWS: Add useDefaultCredentialProvider option to all the components - IAM Component

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 8c3ccceb6303aab06bcc72b6a728dbbf1f41ca3f
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu May 13 15:29:30 2021 +0200

    CAMEL-16465 - Camel-AWS: Add useDefaultCredentialProvider option to all the components - IAM Component
---
 .../camel/catalog/docs/aws2-iam-component.adoc     |  6 ++--
 .../aws2/iam/IAM2ComponentConfigurer.java          |  6 ++++
 .../component/aws2/iam/IAM2EndpointConfigurer.java |  6 ++++
 .../component/aws2/iam/IAM2EndpointUriFactory.java |  3 +-
 .../apache/camel/component/aws2/iam/aws2-iam.json  |  2 ++
 .../src/main/docs/aws2-iam-component.adoc          |  6 ++--
 .../camel/component/aws2/iam/IAM2Component.java    |  3 +-
 .../component/aws2/iam/IAM2Configuration.java      |  4 +--
 .../camel/component/aws2/iam/IAM2Endpoint.java     | 11 -------
 .../iam/client/impl/IAM2ClientOptimizedImpl.java   |  8 ++---
 .../iam/client/impl/IAM2ClientStandardImpl.java    |  4 +--
 .../dsl/Aws2IamComponentBuilderFactory.java        | 19 +++++++++++
 .../endpoint/dsl/IAM2EndpointBuilderFactory.java   | 37 ++++++++++++++++++++++
 .../modules/ROOT/pages/aws2-iam-component.adoc     |  6 ++--
 14 files changed, 94 insertions(+), 27 deletions(-)

diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-iam-component.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-iam-component.adoc
index f2dca9b..066a948 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-iam-component.adoc
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-iam-component.adoc
@@ -42,7 +42,7 @@ You can append query options to the URI in the following format,
 
 
 // component options: START
-The AWS 2 Identity and Access Management (IAM) component supports 15 options, which are listed below.
+The AWS 2 Identity and Access Management (IAM) component supports 16 options, which are listed below.
 
 
 
@@ -61,6 +61,7 @@ The AWS 2 Identity and Access Management (IAM) component supports 15 options, wh
 | *region* (producer) | The region in which IAM client needs to work. When using this parameter, the configuration will expect the lowercase name of the region (for example ap-east-1) You'll need to use the name Region.EU_WEST_1.id() | aws-global | String
 | *trustAllCertificates* (producer) | If we want to trust all certificates in case of overriding the endpoint | false | boolean
 | *uriEndpointOverride* (producer) | Set the overriding uri endpoint. This option needs to be used in combination with overrideEndpoint option |  | String
+| *useDefaultCredentialsProvider* (producer) | Set whether the IAM client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in. | false | boolean
 | *autowiredEnabled* (advanced) | Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. | true | boolean
 | *accessKey* (security) | Amazon AWS Access Key |  | String
 | *secretKey* (security) | Amazon AWS Secret Key |  | String
@@ -89,7 +90,7 @@ with the following path and query parameters:
 |===
 
 
-=== Query Parameters (13 parameters):
+=== Query Parameters (14 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
@@ -106,6 +107,7 @@ with the following path and query parameters:
 | *region* (producer) | The region in which IAM client needs to work. When using this parameter, the configuration will expect the lowercase name of the region (for example ap-east-1) You'll need to use the name Region.EU_WEST_1.id() | aws-global | String
 | *trustAllCertificates* (producer) | If we want to trust all certificates in case of overriding the endpoint | false | boolean
 | *uriEndpointOverride* (producer) | Set the overriding uri endpoint. This option needs to be used in combination with overrideEndpoint option |  | String
+| *useDefaultCredentialsProvider* (producer) | Set whether the IAM client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in. | false | boolean
 | *accessKey* (security) | Amazon AWS Access Key |  | String
 | *secretKey* (security) | Amazon AWS Secret Key |  | String
 |===
diff --git a/components/camel-aws/camel-aws2-iam/src/generated/java/org/apache/camel/component/aws2/iam/IAM2ComponentConfigurer.java b/components/camel-aws/camel-aws2-iam/src/generated/java/org/apache/camel/component/aws2/iam/IAM2ComponentConfigurer.java
index 55b2711..1eb0387 100644
--- a/components/camel-aws/camel-aws2-iam/src/generated/java/org/apache/camel/component/aws2/iam/IAM2ComponentConfigurer.java
+++ b/components/camel-aws/camel-aws2-iam/src/generated/java/org/apache/camel/component/aws2/iam/IAM2ComponentConfigurer.java
@@ -55,6 +55,8 @@ public class IAM2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "trustAllCertificates": getOrCreateConfiguration(target).setTrustAllCertificates(property(camelContext, boolean.class, value)); return true;
         case "uriendpointoverride":
         case "uriEndpointOverride": getOrCreateConfiguration(target).setUriEndpointOverride(property(camelContext, java.lang.String.class, value)); return true;
+        case "usedefaultcredentialsprovider":
+        case "useDefaultCredentialsProvider": getOrCreateConfiguration(target).setUseDefaultCredentialsProvider(property(camelContext, boolean.class, value)); return true;
         default: return false;
         }
     }
@@ -94,6 +96,8 @@ public class IAM2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "trustAllCertificates": return boolean.class;
         case "uriendpointoverride":
         case "uriEndpointOverride": return java.lang.String.class;
+        case "usedefaultcredentialsprovider":
+        case "useDefaultCredentialsProvider": return boolean.class;
         default: return null;
         }
     }
@@ -129,6 +133,8 @@ public class IAM2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "trustAllCertificates": return getOrCreateConfiguration(target).isTrustAllCertificates();
         case "uriendpointoverride":
         case "uriEndpointOverride": return getOrCreateConfiguration(target).getUriEndpointOverride();
+        case "usedefaultcredentialsprovider":
+        case "useDefaultCredentialsProvider": return getOrCreateConfiguration(target).isUseDefaultCredentialsProvider();
         default: return null;
         }
     }
diff --git a/components/camel-aws/camel-aws2-iam/src/generated/java/org/apache/camel/component/aws2/iam/IAM2EndpointConfigurer.java b/components/camel-aws/camel-aws2-iam/src/generated/java/org/apache/camel/component/aws2/iam/IAM2EndpointConfigurer.java
index 98a8c26..59b54ee 100644
--- a/components/camel-aws/camel-aws2-iam/src/generated/java/org/apache/camel/component/aws2/iam/IAM2EndpointConfigurer.java
+++ b/components/camel-aws/camel-aws2-iam/src/generated/java/org/apache/camel/component/aws2/iam/IAM2EndpointConfigurer.java
@@ -45,6 +45,8 @@ public class IAM2EndpointConfigurer extends PropertyConfigurerSupport implements
         case "trustAllCertificates": target.getConfiguration().setTrustAllCertificates(property(camelContext, boolean.class, value)); return true;
         case "uriendpointoverride":
         case "uriEndpointOverride": target.getConfiguration().setUriEndpointOverride(property(camelContext, java.lang.String.class, value)); return true;
+        case "usedefaultcredentialsprovider":
+        case "useDefaultCredentialsProvider": target.getConfiguration().setUseDefaultCredentialsProvider(property(camelContext, boolean.class, value)); return true;
         default: return false;
         }
     }
@@ -81,6 +83,8 @@ public class IAM2EndpointConfigurer extends PropertyConfigurerSupport implements
         case "trustAllCertificates": return boolean.class;
         case "uriendpointoverride":
         case "uriEndpointOverride": return java.lang.String.class;
+        case "usedefaultcredentialsprovider":
+        case "useDefaultCredentialsProvider": return boolean.class;
         default: return null;
         }
     }
@@ -113,6 +117,8 @@ public class IAM2EndpointConfigurer extends PropertyConfigurerSupport implements
         case "trustAllCertificates": return target.getConfiguration().isTrustAllCertificates();
         case "uriendpointoverride":
         case "uriEndpointOverride": return target.getConfiguration().getUriEndpointOverride();
+        case "usedefaultcredentialsprovider":
+        case "useDefaultCredentialsProvider": return target.getConfiguration().isUseDefaultCredentialsProvider();
         default: return null;
         }
     }
diff --git a/components/camel-aws/camel-aws2-iam/src/generated/java/org/apache/camel/component/aws2/iam/IAM2EndpointUriFactory.java b/components/camel-aws/camel-aws2-iam/src/generated/java/org/apache/camel/component/aws2/iam/IAM2EndpointUriFactory.java
index 3587e9e..13ed243 100644
--- a/components/camel-aws/camel-aws2-iam/src/generated/java/org/apache/camel/component/aws2/iam/IAM2EndpointUriFactory.java
+++ b/components/camel-aws/camel-aws2-iam/src/generated/java/org/apache/camel/component/aws2/iam/IAM2EndpointUriFactory.java
@@ -20,11 +20,12 @@ public class IAM2EndpointUriFactory extends org.apache.camel.support.component.E
     private static final Set<String> PROPERTY_NAMES;
     private static final Set<String> SECRET_PROPERTY_NAMES;
     static {
-        Set<String> props = new HashSet<>(14);
+        Set<String> props = new HashSet<>(15);
         props.add("iamClient");
         props.add("proxyProtocol");
         props.add("secretKey");
         props.add("uriEndpointOverride");
+        props.add("useDefaultCredentialsProvider");
         props.add("label");
         props.add("pojoRequest");
         props.add("proxyHost");
diff --git a/components/camel-aws/camel-aws2-iam/src/generated/resources/org/apache/camel/component/aws2/iam/aws2-iam.json b/components/camel-aws/camel-aws2-iam/src/generated/resources/org/apache/camel/component/aws2/iam/aws2-iam.json
index 7f3f00d..de021e9 100644
--- a/components/camel-aws/camel-aws2-iam/src/generated/resources/org/apache/camel/component/aws2/iam/aws2-iam.json
+++ b/components/camel-aws/camel-aws2-iam/src/generated/resources/org/apache/camel/component/aws2/iam/aws2-iam.json
@@ -34,6 +34,7 @@
     "region": { "kind": "property", "displayName": "Region", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "aws-global", "configurationClass": "org.apache.camel.component.aws2.iam.IAM2Configuration", "configurationField": "configuration", "description": "The region in which IAM client needs to work. When using this parameter, the configuration will expect the [...]
     "trustAllCertificates": { "kind": "property", "displayName": "Trust All Certificates", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.iam.IAM2Configuration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overriding the endpoint" },
     "uriEndpointOverride": { "kind": "property", "displayName": "Uri Endpoint Override", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.iam.IAM2Configuration", "configurationField": "configuration", "description": "Set the overriding uri endpoint. This option needs to be used in combination with overrideEndpoint option" },
+    "useDefaultCredentialsProvider": { "kind": "property", "displayName": "Use Default Credentials Provider", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.iam.IAM2Configuration", "configurationField": "configuration", "description": "Set whether the IAM client should expect to load credentials through a d [...]
     "autowiredEnabled": { "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which t [...]
     "accessKey": { "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.iam.IAM2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
     "secretKey": { "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.iam.IAM2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
@@ -51,6 +52,7 @@
     "region": { "kind": "parameter", "displayName": "Region", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "aws-global", "configurationClass": "org.apache.camel.component.aws2.iam.IAM2Configuration", "configurationField": "configuration", "description": "The region in which IAM client needs to work. When using this parameter, the configuration will expect th [...]
     "trustAllCertificates": { "kind": "parameter", "displayName": "Trust All Certificates", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.iam.IAM2Configuration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overriding the endpoint" },
     "uriEndpointOverride": { "kind": "parameter", "displayName": "Uri Endpoint Override", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.iam.IAM2Configuration", "configurationField": "configuration", "description": "Set the overriding uri endpoint. This option needs to be used in combination with overrideEndpoint option" },
+    "useDefaultCredentialsProvider": { "kind": "parameter", "displayName": "Use Default Credentials Provider", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.iam.IAM2Configuration", "configurationField": "configuration", "description": "Set whether the IAM client should expect to load credentials through a  [...]
     "accessKey": { "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.iam.IAM2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
     "secretKey": { "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.iam.IAM2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
   }
diff --git a/components/camel-aws/camel-aws2-iam/src/main/docs/aws2-iam-component.adoc b/components/camel-aws/camel-aws2-iam/src/main/docs/aws2-iam-component.adoc
index f2dca9b..066a948 100644
--- a/components/camel-aws/camel-aws2-iam/src/main/docs/aws2-iam-component.adoc
+++ b/components/camel-aws/camel-aws2-iam/src/main/docs/aws2-iam-component.adoc
@@ -42,7 +42,7 @@ You can append query options to the URI in the following format,
 
 
 // component options: START
-The AWS 2 Identity and Access Management (IAM) component supports 15 options, which are listed below.
+The AWS 2 Identity and Access Management (IAM) component supports 16 options, which are listed below.
 
 
 
@@ -61,6 +61,7 @@ The AWS 2 Identity and Access Management (IAM) component supports 15 options, wh
 | *region* (producer) | The region in which IAM client needs to work. When using this parameter, the configuration will expect the lowercase name of the region (for example ap-east-1) You'll need to use the name Region.EU_WEST_1.id() | aws-global | String
 | *trustAllCertificates* (producer) | If we want to trust all certificates in case of overriding the endpoint | false | boolean
 | *uriEndpointOverride* (producer) | Set the overriding uri endpoint. This option needs to be used in combination with overrideEndpoint option |  | String
+| *useDefaultCredentialsProvider* (producer) | Set whether the IAM client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in. | false | boolean
 | *autowiredEnabled* (advanced) | Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. | true | boolean
 | *accessKey* (security) | Amazon AWS Access Key |  | String
 | *secretKey* (security) | Amazon AWS Secret Key |  | String
@@ -89,7 +90,7 @@ with the following path and query parameters:
 |===
 
 
-=== Query Parameters (13 parameters):
+=== Query Parameters (14 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
@@ -106,6 +107,7 @@ with the following path and query parameters:
 | *region* (producer) | The region in which IAM client needs to work. When using this parameter, the configuration will expect the lowercase name of the region (for example ap-east-1) You'll need to use the name Region.EU_WEST_1.id() | aws-global | String
 | *trustAllCertificates* (producer) | If we want to trust all certificates in case of overriding the endpoint | false | boolean
 | *uriEndpointOverride* (producer) | Set the overriding uri endpoint. This option needs to be used in combination with overrideEndpoint option |  | String
+| *useDefaultCredentialsProvider* (producer) | Set whether the IAM client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in. | false | boolean
 | *accessKey* (security) | Amazon AWS Access Key |  | String
 | *secretKey* (security) | Amazon AWS Secret Key |  | String
 |===
diff --git a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Component.java b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Component.java
index a13ca64..48b48ca 100644
--- a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Component.java
+++ b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Component.java
@@ -54,7 +54,8 @@ public class IAM2Component extends DefaultComponent {
         setProperties(endpoint, parameters);
         if (!configuration.isUseDefaultCredentialsProvider() && configuration.getIamClient() == null
                 && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
-            throw new IllegalArgumentException("seDefaultCredentialsProvider is set to false, Amazon IAM client or accessKey and secretKey must be specified");
+            throw new IllegalArgumentException(
+                    "seDefaultCredentialsProvider is set to false, Amazon IAM client or accessKey and secretKey must be specified");
         }
 
         return endpoint;
diff --git a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Configuration.java b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Configuration.java
index 09bc4dc..fb6c8b1 100644
--- a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Configuration.java
+++ b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Configuration.java
@@ -197,8 +197,8 @@ public class IAM2Configuration implements Cloneable {
     }
 
     /**
-     * Set whether the IAM client should expect to load credentials through a default credentials provider or to
-     * expect static credentials to be passed in.
+     * Set whether the IAM client should expect to load credentials through a default credentials provider or to expect
+     * static credentials to be passed in.
      */
     public void setUseDefaultCredentialsProvider(Boolean useDefaultCredentialsProvider) {
         this.useDefaultCredentialsProvider = useDefaultCredentialsProvider;
diff --git a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Endpoint.java b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Endpoint.java
index c2fc046..fed0b39 100644
--- a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Endpoint.java
+++ b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Endpoint.java
@@ -16,8 +16,6 @@
  */
 package org.apache.camel.component.aws2.iam;
 
-import java.net.URI;
-
 import org.apache.camel.Category;
 import org.apache.camel.Component;
 import org.apache.camel.Consumer;
@@ -28,16 +26,7 @@ import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.support.ScheduledPollEndpoint;
 import org.apache.camel.util.ObjectHelper;
-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.iam.IamClient;
-import software.amazon.awssdk.services.iam.IamClientBuilder;
-import software.amazon.awssdk.utils.AttributeMap;
 
 /**
  * Manage AWS IAM instances using AWS SDK version 2.x.
diff --git a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/impl/IAM2ClientOptimizedImpl.java b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/impl/IAM2ClientOptimizedImpl.java
index 03cd74c..16da615 100644
--- a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/impl/IAM2ClientOptimizedImpl.java
+++ b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/impl/IAM2ClientOptimizedImpl.java
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.component.aws2.iam.client.impl;
 
+import java.net.URI;
+
 import org.apache.camel.component.aws2.iam.IAM2Configuration;
 import org.apache.camel.component.aws2.iam.client.IAM2InternalClient;
 import org.apache.camel.util.ObjectHelper;
@@ -30,11 +32,9 @@ import software.amazon.awssdk.services.iam.IamClient;
 import software.amazon.awssdk.services.iam.IamClientBuilder;
 import software.amazon.awssdk.utils.AttributeMap;
 
-import java.net.URI;
-
 /**
- * Manage an AWS IAM 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)
+ * Manage an AWS IAM 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 IAM2ClientOptimizedImpl implements IAM2InternalClient {
     private static final Logger LOG = LoggerFactory.getLogger(IAM2ClientOptimizedImpl.class);
diff --git a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/impl/IAM2ClientStandardImpl.java b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/impl/IAM2ClientStandardImpl.java
index bcec215..91f1b59 100644
--- a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/impl/IAM2ClientStandardImpl.java
+++ b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/impl/IAM2ClientStandardImpl.java
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.component.aws2.iam.client.impl;
 
+import java.net.URI;
+
 import org.apache.camel.component.aws2.iam.IAM2Configuration;
 import org.apache.camel.component.aws2.iam.client.IAM2InternalClient;
 import org.apache.camel.util.ObjectHelper;
@@ -32,8 +34,6 @@ import software.amazon.awssdk.services.iam.IamClient;
 import software.amazon.awssdk.services.iam.IamClientBuilder;
 import software.amazon.awssdk.utils.AttributeMap;
 
-import java.net.URI;
-
 /**
  * Manage an AWS EKS client for all users to use. This implementation is for local instances to use a static and solid
  * credential set.
diff --git a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2IamComponentBuilderFactory.java b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2IamComponentBuilderFactory.java
index 181c72c..f34f092 100644
--- a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2IamComponentBuilderFactory.java
+++ b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2IamComponentBuilderFactory.java
@@ -251,6 +251,24 @@ public interface Aws2IamComponentBuilderFactory {
             return this;
         }
         /**
+         * Set whether the IAM client should expect to load credentials through
+         * a default credentials provider or to expect static credentials to be
+         * passed in.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: false
+         * Group: producer
+         * 
+         * @param useDefaultCredentialsProvider the value to set
+         * @return the dsl builder
+         */
+        default Aws2IamComponentBuilder useDefaultCredentialsProvider(
+                boolean useDefaultCredentialsProvider) {
+            doSetProperty("useDefaultCredentialsProvider", useDefaultCredentialsProvider);
+            return this;
+        }
+        /**
          * Whether autowiring is enabled. This is used for automatic autowiring
          * options (the option must be marked as autowired) by looking up in the
          * registry to find if there is a single instance of matching type,
@@ -335,6 +353,7 @@ public interface Aws2IamComponentBuilderFactory {
             case "region": getOrCreateConfiguration((IAM2Component) component).setRegion((java.lang.String) value); return true;
             case "trustAllCertificates": getOrCreateConfiguration((IAM2Component) component).setTrustAllCertificates((boolean) value); return true;
             case "uriEndpointOverride": getOrCreateConfiguration((IAM2Component) component).setUriEndpointOverride((java.lang.String) value); return true;
+            case "useDefaultCredentialsProvider": getOrCreateConfiguration((IAM2Component) component).setUseDefaultCredentialsProvider((boolean) value); return true;
             case "autowiredEnabled": ((IAM2Component) component).setAutowiredEnabled((boolean) value); return true;
             case "accessKey": getOrCreateConfiguration((IAM2Component) component).setAccessKey((java.lang.String) value); return true;
             case "secretKey": getOrCreateConfiguration((IAM2Component) component).setSecretKey((java.lang.String) value); return true;
diff --git a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/IAM2EndpointBuilderFactory.java b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/IAM2EndpointBuilderFactory.java
index b6b435e..ecc1ede 100644
--- a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/IAM2EndpointBuilderFactory.java
+++ b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/IAM2EndpointBuilderFactory.java
@@ -355,6 +355,43 @@ public interface IAM2EndpointBuilderFactory {
             return this;
         }
         /**
+         * Set whether the IAM client should expect to load credentials through
+         * a default credentials provider or to expect static credentials to be
+         * passed in.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: false
+         * Group: producer
+         * 
+         * @param useDefaultCredentialsProvider the value to set
+         * @return the dsl builder
+         */
+        default IAM2EndpointBuilder useDefaultCredentialsProvider(
+                boolean useDefaultCredentialsProvider) {
+            doSetProperty("useDefaultCredentialsProvider", useDefaultCredentialsProvider);
+            return this;
+        }
+        /**
+         * Set whether the IAM client should expect to load credentials through
+         * a default credentials provider or to expect static credentials to be
+         * passed in.
+         * 
+         * The option will be converted to a &lt;code&gt;boolean&lt;/code&gt;
+         * type.
+         * 
+         * Default: false
+         * Group: producer
+         * 
+         * @param useDefaultCredentialsProvider the value to set
+         * @return the dsl builder
+         */
+        default IAM2EndpointBuilder useDefaultCredentialsProvider(
+                String useDefaultCredentialsProvider) {
+            doSetProperty("useDefaultCredentialsProvider", useDefaultCredentialsProvider);
+            return this;
+        }
+        /**
          * Amazon AWS Access Key.
          * 
          * The option is a: &lt;code&gt;java.lang.String&lt;/code&gt; type.
diff --git a/docs/components/modules/ROOT/pages/aws2-iam-component.adoc b/docs/components/modules/ROOT/pages/aws2-iam-component.adoc
index bee6689..359b12f 100644
--- a/docs/components/modules/ROOT/pages/aws2-iam-component.adoc
+++ b/docs/components/modules/ROOT/pages/aws2-iam-component.adoc
@@ -44,7 +44,7 @@ You can append query options to the URI in the following format,
 
 
 // component options: START
-The AWS 2 Identity and Access Management (IAM) component supports 15 options, which are listed below.
+The AWS 2 Identity and Access Management (IAM) component supports 16 options, which are listed below.
 
 
 
@@ -63,6 +63,7 @@ The AWS 2 Identity and Access Management (IAM) component supports 15 options, wh
 | *region* (producer) | The region in which IAM client needs to work. When using this parameter, the configuration will expect the lowercase name of the region (for example ap-east-1) You'll need to use the name Region.EU_WEST_1.id() | aws-global | String
 | *trustAllCertificates* (producer) | If we want to trust all certificates in case of overriding the endpoint | false | boolean
 | *uriEndpointOverride* (producer) | Set the overriding uri endpoint. This option needs to be used in combination with overrideEndpoint option |  | String
+| *useDefaultCredentialsProvider* (producer) | Set whether the IAM client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in. | false | boolean
 | *autowiredEnabled* (advanced) | Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. | true | boolean
 | *accessKey* (security) | Amazon AWS Access Key |  | String
 | *secretKey* (security) | Amazon AWS Secret Key |  | String
@@ -91,7 +92,7 @@ with the following path and query parameters:
 |===
 
 
-=== Query Parameters (13 parameters):
+=== Query Parameters (14 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
@@ -108,6 +109,7 @@ with the following path and query parameters:
 | *region* (producer) | The region in which IAM client needs to work. When using this parameter, the configuration will expect the lowercase name of the region (for example ap-east-1) You'll need to use the name Region.EU_WEST_1.id() | aws-global | String
 | *trustAllCertificates* (producer) | If we want to trust all certificates in case of overriding the endpoint | false | boolean
 | *uriEndpointOverride* (producer) | Set the overriding uri endpoint. This option needs to be used in combination with overrideEndpoint option |  | String
+| *useDefaultCredentialsProvider* (producer) | Set whether the IAM client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in. | false | boolean
 | *accessKey* (security) | Amazon AWS Access Key |  | String
 | *secretKey* (security) | Amazon AWS Secret Key |  | String
 |===

[camel] 01/05: CAMEL-16465 - Camel-AWS: Add useDefaultCredentialProvider option to all the components - IAM Component

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 667d01735e9a317587551e69c1457cbb27870d75
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu May 13 15:23:05 2021 +0200

    CAMEL-16465 - Camel-AWS: Add useDefaultCredentialProvider option to all the components - IAM Component
---
 .../component/aws2/iam/IAM2Configuration.java      |  13 +++
 .../aws2/iam/client/IAM2ClientFactory.java         |  41 ++++++++
 .../aws2/iam/client/IAM2InternalClient.java        |  32 +++++++
 .../iam/client/impl/IAM2ClientOptimizedImpl.java   |  88 +++++++++++++++++
 .../iam/client/impl/IAM2ClientStandardImpl.java    | 104 +++++++++++++++++++++
 5 files changed, 278 insertions(+)

diff --git a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Configuration.java b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Configuration.java
index f0981c3..09bc4dc 100644
--- a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Configuration.java
+++ b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Configuration.java
@@ -56,6 +56,8 @@ public class IAM2Configuration implements Cloneable {
     private boolean overrideEndpoint;
     @UriParam
     private String uriEndpointOverride;
+    @UriParam(defaultValue = "false")
+    private boolean useDefaultCredentialsProvider;
 
     public IamClient getIamClient() {
         return iamClient;
@@ -194,6 +196,17 @@ public class IAM2Configuration implements Cloneable {
         this.uriEndpointOverride = uriEndpointOverride;
     }
 
+    /**
+     * Set whether the IAM client should expect to load credentials through a default credentials provider or to
+     * expect static credentials to be passed in.
+     */
+    public void setUseDefaultCredentialsProvider(Boolean useDefaultCredentialsProvider) {
+        this.useDefaultCredentialsProvider = useDefaultCredentialsProvider;
+    }
+
+    public Boolean isUseDefaultCredentialsProvider() {
+        return useDefaultCredentialsProvider;
+    }
     // *************************************************
     //
     // *************************************************
diff --git a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/IAM2ClientFactory.java b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/IAM2ClientFactory.java
new file mode 100644
index 0000000..3fb113f
--- /dev/null
+++ b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/IAM2ClientFactory.java
@@ -0,0 +1,41 @@
+/*
+ * 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.iam.client;
+
+import org.apache.camel.component.aws2.iam.IAM2Configuration;
+import org.apache.camel.component.aws2.iam.client.impl.IAM2ClientOptimizedImpl;
+import org.apache.camel.component.aws2.iam.client.impl.IAM2ClientStandardImpl;
+
+/**
+ * Factory class to return the correct type of AWS Eventbridge client.
+ */
+public final class IAM2ClientFactory {
+
+    private IAM2ClientFactory() {
+    }
+
+    /**
+     * Return the correct AWS IAM client (based on remote vs local).
+     * 
+     * @param  configuration configuration
+     * @return               IamClient
+     */
+    public static IAM2InternalClient getEventbridgeClient(IAM2Configuration configuration) {
+        return configuration.isUseDefaultCredentialsProvider()
+                ? new IAM2ClientOptimizedImpl(configuration) : new IAM2ClientStandardImpl(configuration);
+    }
+}
diff --git a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/IAM2InternalClient.java b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/IAM2InternalClient.java
new file mode 100644
index 0000000..82725f1
--- /dev/null
+++ b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/IAM2InternalClient.java
@@ -0,0 +1,32 @@
+/*
+ * 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.iam.client;
+
+import software.amazon.awssdk.services.iam.IamClient;
+
+/**
+ * Manage the required actions of an IAM client for either local or remote.
+ */
+public interface IAM2InternalClient {
+
+    /**
+     * Returns an IAM client after a factory method determines which one to return.
+     * 
+     * @return IamClient IamClient
+     */
+    IamClient getIamClient();
+}
diff --git a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/impl/IAM2ClientOptimizedImpl.java b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/impl/IAM2ClientOptimizedImpl.java
new file mode 100644
index 0000000..03cd74c
--- /dev/null
+++ b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/impl/IAM2ClientOptimizedImpl.java
@@ -0,0 +1,88 @@
+/*
+ * 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.iam.client.impl;
+
+import org.apache.camel.component.aws2.iam.IAM2Configuration;
+import org.apache.camel.component.aws2.iam.client.IAM2InternalClient;
+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.iam.IamClient;
+import software.amazon.awssdk.services.iam.IamClientBuilder;
+import software.amazon.awssdk.utils.AttributeMap;
+
+import java.net.URI;
+
+/**
+ * Manage an AWS IAM 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 IAM2ClientOptimizedImpl implements IAM2InternalClient {
+    private static final Logger LOG = LoggerFactory.getLogger(IAM2ClientOptimizedImpl.class);
+    private IAM2Configuration configuration;
+
+    /**
+     * Constructor that uses the config file.
+     */
+    public IAM2ClientOptimizedImpl(IAM2Configuration configuration) {
+        LOG.trace("Creating an AWS IAM client for an ec2 instance with IAM temporary credentials (normal for ec2s).");
+        this.configuration = configuration;
+    }
+
+    /**
+     * Getting the IAM aws client that is used.
+     * 
+     * @return IAM Client.
+     */
+    @Override
+    public IamClient getIamClient() {
+        IamClient client = null;
+        IamClientBuilder clientBuilder = IamClient.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()) {
+            SdkHttpClient ahc = ApacheHttpClient.builder().buildWithDefaults(AttributeMap
+                    .builder()
+                    .put(
+                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
+                            Boolean.TRUE)
+                    .build());
+            clientBuilder.httpClient(ahc);
+        }
+        client = clientBuilder.build();
+        return client;
+    }
+}
diff --git a/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/impl/IAM2ClientStandardImpl.java b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/impl/IAM2ClientStandardImpl.java
new file mode 100644
index 0000000..bcec215
--- /dev/null
+++ b/components/camel-aws/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/client/impl/IAM2ClientStandardImpl.java
@@ -0,0 +1,104 @@
+/*
+ * 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.iam.client.impl;
+
+import org.apache.camel.component.aws2.iam.IAM2Configuration;
+import org.apache.camel.component.aws2.iam.client.IAM2InternalClient;
+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.iam.IamClient;
+import software.amazon.awssdk.services.iam.IamClientBuilder;
+import software.amazon.awssdk.utils.AttributeMap;
+
+import java.net.URI;
+
+/**
+ * Manage an AWS EKS client for all users to use. This implementation is for local instances to use a static and solid
+ * credential set.
+ */
+public class IAM2ClientStandardImpl implements IAM2InternalClient {
+    private static final Logger LOG = LoggerFactory.getLogger(IAM2ClientStandardImpl.class);
+    private IAM2Configuration configuration;
+
+    /**
+     * Constructor that uses the config file.
+     */
+    public IAM2ClientStandardImpl(IAM2Configuration configuration) {
+        LOG.trace("Creating an AWS IAM manager using static credentials.");
+        this.configuration = configuration;
+    }
+
+    /**
+     * Getting the IAM AWS client that is used.
+     * 
+     * @return Amazon IAM Client.
+     */
+    @Override
+    public IamClient getIamClient() {
+        IamClient client = null;
+        IamClientBuilder clientBuilder = IamClient.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()) {
+            SdkHttpClient ahc = ApacheHttpClient.builder().buildWithDefaults(AttributeMap
+                    .builder()
+                    .put(
+                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
+                            Boolean.TRUE)
+                    .build());
+            clientBuilder.httpClient(ahc);
+        }
+        client = clientBuilder.build();
+        return client;
+    }
+}

[camel] 05/05: Regen

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 492b7e36b614c3b369353e5b00cc49fc2a89b7aa
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu May 13 16:16:50 2021 +0200

    Regen
---
 .../resources/org/apache/camel/catalog/components/aws2-iam.json         | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-iam.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-iam.json
index 7f3f00d..de021e9 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-iam.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-iam.json
@@ -34,6 +34,7 @@
     "region": { "kind": "property", "displayName": "Region", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "aws-global", "configurationClass": "org.apache.camel.component.aws2.iam.IAM2Configuration", "configurationField": "configuration", "description": "The region in which IAM client needs to work. When using this parameter, the configuration will expect the [...]
     "trustAllCertificates": { "kind": "property", "displayName": "Trust All Certificates", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.iam.IAM2Configuration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overriding the endpoint" },
     "uriEndpointOverride": { "kind": "property", "displayName": "Uri Endpoint Override", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.iam.IAM2Configuration", "configurationField": "configuration", "description": "Set the overriding uri endpoint. This option needs to be used in combination with overrideEndpoint option" },
+    "useDefaultCredentialsProvider": { "kind": "property", "displayName": "Use Default Credentials Provider", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.iam.IAM2Configuration", "configurationField": "configuration", "description": "Set whether the IAM client should expect to load credentials through a d [...]
     "autowiredEnabled": { "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which t [...]
     "accessKey": { "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.iam.IAM2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
     "secretKey": { "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.iam.IAM2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
@@ -51,6 +52,7 @@
     "region": { "kind": "parameter", "displayName": "Region", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "aws-global", "configurationClass": "org.apache.camel.component.aws2.iam.IAM2Configuration", "configurationField": "configuration", "description": "The region in which IAM client needs to work. When using this parameter, the configuration will expect th [...]
     "trustAllCertificates": { "kind": "parameter", "displayName": "Trust All Certificates", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.iam.IAM2Configuration", "configurationField": "configuration", "description": "If we want to trust all certificates in case of overriding the endpoint" },
     "uriEndpointOverride": { "kind": "parameter", "displayName": "Uri Endpoint Override", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.iam.IAM2Configuration", "configurationField": "configuration", "description": "Set the overriding uri endpoint. This option needs to be used in combination with overrideEndpoint option" },
+    "useDefaultCredentialsProvider": { "kind": "parameter", "displayName": "Use Default Credentials Provider", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.iam.IAM2Configuration", "configurationField": "configuration", "description": "Set whether the IAM client should expect to load credentials through a  [...]
     "accessKey": { "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.iam.IAM2Configuration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
     "secretKey": { "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.iam.IAM2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" }
   }