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

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 8b8496b6777f9a7210d489611e974e71bb83250e
Author: Andrea Cosentino <[email protected]>
AuthorDate: Fri Feb 28 15:52:32 2020 +0100

    CAMEL-14568 - Fixed AWS IAM
---
 .../component/aws/iam/IAMComponentConfigurer.java  |  7 ++--
 .../apache/camel/component/aws/iam/aws-iam.json    |  8 ++--
 .../src/main/docs/aws-iam-component.adoc           |  2 +-
 .../camel/component/aws/iam/IAMComponent.java      | 46 +---------------------
 .../aws/iam/IAMComponentConfigurationTest.java     | 16 ++++----
 .../dsl/AwsIamComponentBuilderFactory.java         | 34 ++++++++--------
 6 files changed, 35 insertions(+), 78 deletions(-)

diff --git 
a/components/camel-aws-iam/src/generated/java/org/apache/camel/component/aws/iam/IAMComponentConfigurer.java
 
b/components/camel-aws-iam/src/generated/java/org/apache/camel/component/aws/iam/IAMComponentConfigurer.java
index baee3e5..332711d 100644
--- 
a/components/camel-aws-iam/src/generated/java/org/apache/camel/component/aws/iam/IAMComponentConfigurer.java
+++ 
b/components/camel-aws-iam/src/generated/java/org/apache/camel/component/aws/iam/IAMComponentConfigurer.java
@@ -23,7 +23,8 @@ public class IAMComponentConfigurer extends 
PropertyConfigurerSupport implements
         IAMComponent target = (IAMComponent) obj;
         switch (ignoreCase ? name.toLowerCase() : name) {
         case "accesskey":
-        case "accessKey": target.setAccessKey(property(camelContext, 
java.lang.String.class, value)); return true;
+        case "accessKey": 
getOrCreateConfiguration(target).setAccessKey(property(camelContext, 
java.lang.String.class, value)); return true;
+        case "configuration": target.setConfiguration(property(camelContext, 
org.apache.camel.component.aws.iam.IAMConfiguration.class, value)); return true;
         case "iamclient":
         case "iamClient": 
getOrCreateConfiguration(target).setIamClient(property(camelContext, 
com.amazonaws.services.identitymanagement.AmazonIdentityManagement.class, 
value)); return true;
         case "lazystartproducer":
@@ -35,13 +36,11 @@ public class IAMComponentConfigurer extends 
PropertyConfigurerSupport implements
         case "proxyPort": 
getOrCreateConfiguration(target).setProxyPort(property(camelContext, 
java.lang.Integer.class, value)); return true;
         case "proxyprotocol":
         case "proxyProtocol": 
getOrCreateConfiguration(target).setProxyProtocol(property(camelContext, 
com.amazonaws.Protocol.class, value)); return true;
-        case "region": target.setRegion(property(camelContext, 
java.lang.String.class, value)); return true;
         case "region": 
getOrCreateConfiguration(target).setRegion(property(camelContext, 
java.lang.String.class, value)); return true;
         case "secretkey":
-        case "secretKey": target.setSecretKey(property(camelContext, 
java.lang.String.class, value)); return true;
+        case "secretKey": 
getOrCreateConfiguration(target).setSecretKey(property(camelContext, 
java.lang.String.class, value)); return true;
         case "basicpropertybinding":
         case "basicPropertyBinding": 
target.setBasicPropertyBinding(property(camelContext, boolean.class, value)); 
return true;
-        case "configuration": target.setConfiguration(property(camelContext, 
org.apache.camel.component.aws.iam.IAMConfiguration.class, value)); return true;
         default: return false;
         }
     }
diff --git 
a/components/camel-aws-iam/src/generated/resources/org/apache/camel/component/aws/iam/aws-iam.json
 
b/components/camel-aws-iam/src/generated/resources/org/apache/camel/component/aws/iam/aws-iam.json
index 30a11fb..2f52d08 100644
--- 
a/components/camel-aws-iam/src/generated/resources/org/apache/camel/component/aws/iam/aws-iam.json
+++ 
b/components/camel-aws-iam/src/generated/resources/org/apache/camel/component/aws/iam/aws-iam.json
@@ -19,7 +19,8 @@
     "version": "3.2.0-SNAPSHOT"
   },
   "componentProperties": {
-    "accessKey": { "kind": "property", "displayName": "Access Key", "group": 
"producer", "label": "", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "secret": false, "description": 
"Amazon AWS Access Key" },
+    "accessKey": { "kind": "property", "displayName": "Access Key", "group": 
"producer", "label": "producer", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "secret": true, 
"configurationClass": "org.apache.camel.component.aws.iam.IAMConfiguration", 
"configurationField": "configuration", "description": "Amazon AWS Access Key" },
+    "configuration": { "kind": "property", "displayName": "Configuration", 
"group": "producer", "label": "", "required": false, "type": "object", 
"javaType": "org.apache.camel.component.aws.iam.IAMConfiguration", 
"deprecated": false, "secret": false, "description": "The component 
configuration" },
     "iamClient": { "kind": "property", "displayName": "Iam Client", "group": 
"producer", "label": "producer", "required": false, "type": "object", 
"javaType": 
"com.amazonaws.services.identitymanagement.AmazonIdentityManagement", 
"deprecated": false, "secret": false, "configurationClass": 
"org.apache.camel.component.aws.iam.IAMConfiguration", "configurationField": 
"configuration", "description": "To use a existing configured AWS IAM as 
client" },
     "lazyStartProducer": { "kind": "property", "displayName": "Lazy Start 
Producer", "group": "producer", "label": "producer", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "secret": false, 
"defaultValue": false, "description": "Whether the producer should be started 
lazy (on the first message). By starting lazy you can use this to allow 
CamelContext and routes to startup in situations where a producer may otherwise 
fail during starting and cause the r [...]
     "operation": { "kind": "property", "displayName": "Operation", "group": 
"producer", "label": "producer", "required": true, "type": "object", 
"javaType": "org.apache.camel.component.aws.iam.IAMOperations", "enum": [ 
"listAccessKeys", "createUser", "deleteUser", "getUser", "listUsers", 
"createAccessKey", "deleteAccessKey", "updateAccessKey", "createGroup", 
"deleteGroup", "listGroups", "addUserToGroup", "removeUserFromGroup" ], 
"deprecated": false, "deprecationNote": "", "secret": false [...]
@@ -27,9 +28,8 @@
     "proxyPort": { "kind": "property", "displayName": "Proxy Port", "group": 
"producer", "label": "producer", "required": false, "type": "integer", 
"javaType": "java.lang.Integer", "deprecated": false, "secret": false, 
"configurationClass": "org.apache.camel.component.aws.iam.IAMConfiguration", 
"configurationField": "configuration", "description": "To define a proxy port 
when instantiating the IAM client" },
     "proxyProtocol": { "kind": "property", "displayName": "Proxy Protocol", 
"group": "producer", "label": "", "required": false, "type": "object", 
"javaType": "com.amazonaws.Protocol", "enum": [ "HTTP", "HTTPS" ], 
"deprecated": false, "secret": false, "defaultValue": "HTTPS", 
"configurationClass": "org.apache.camel.component.aws.iam.IAMConfiguration", 
"configurationField": "configuration", "description": "To define a proxy 
protocol when instantiating the IAM client" },
     "region": { "kind": "property", "displayName": "Region", "group": 
"producer", "label": "", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "secret": false, "configurationClass": 
"org.apache.camel.component.aws.iam.IAMConfiguration", "configurationField": 
"configuration", "description": "The region in which IAM client needs to work. 
When using this parameter, the configuration will expect the capitalized name 
of the region (for example AP_EAST [...]
-    "secretKey": { "kind": "property", "displayName": "Secret Key", "group": 
"producer", "label": "", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "secret": false, "description": 
"Amazon AWS Secret Key" },
-    "basicPropertyBinding": { "kind": "property", "displayName": "Basic 
Property Binding", "group": "advanced", "label": "advanced", "required": false, 
"type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, 
"defaultValue": false, "description": "Whether the component should use basic 
property binding (Camel 2.x) or the newer property binding with additional 
capabilities" },
-    "configuration": { "kind": "property", "displayName": "Configuration", 
"group": "advanced", "label": "advanced", "required": false, "type": "object", 
"javaType": "org.apache.camel.component.aws.iam.IAMConfiguration", 
"deprecated": false, "secret": false, "description": "The AWS IAM default 
configuration" }
+    "secretKey": { "kind": "property", "displayName": "Secret Key", "group": 
"producer", "label": "producer", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "secret": true, 
"configurationClass": "org.apache.camel.component.aws.iam.IAMConfiguration", 
"configurationField": "configuration", "description": "Amazon AWS Secret Key" },
+    "basicPropertyBinding": { "kind": "property", "displayName": "Basic 
Property Binding", "group": "advanced", "label": "advanced", "required": false, 
"type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, 
"defaultValue": false, "description": "Whether the component should use basic 
property binding (Camel 2.x) or the newer property binding with additional 
capabilities" }
   },
   "properties": {
     "label": { "kind": "path", "displayName": "Label", "group": "producer", 
"label": "", "required": true, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "deprecationNote": "", "secret": 
false, "configurationClass": 
"org.apache.camel.component.aws.iam.IAMConfiguration", "configurationField": 
"configuration", "description": "Logical name" },
diff --git a/components/camel-aws-iam/src/main/docs/aws-iam-component.adoc 
b/components/camel-aws-iam/src/main/docs/aws-iam-component.adoc
index 52b3493..82093c8 100644
--- a/components/camel-aws-iam/src/main/docs/aws-iam-component.adoc
+++ b/components/camel-aws-iam/src/main/docs/aws-iam-component.adoc
@@ -38,6 +38,7 @@ The AWS IAM component supports 11 options, which are listed 
below.
 |===
 | Name | Description | Default | Type
 | *accessKey* (producer) | Amazon AWS Access Key |  | String
+| *configuration* (producer) | The component configuration |  | 
IAMConfiguration
 | *iamClient* (producer) | To use a existing configured AWS IAM as client |  | 
AmazonIdentityManagement
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy 
(on the first message). By starting lazy you can use this to allow CamelContext 
and routes to startup in situations where a producer may otherwise fail during 
starting and cause the route to fail being started. By deferring this startup 
to be lazy then the startup failure can be handled during routing messages via 
Camel's routing error handlers. Beware that when the first message is processed 
then creating and [...]
 | *operation* (producer) | *Required* The operation to perform. The value can 
be one of: listAccessKeys, createUser, deleteUser, getUser, listUsers, 
createAccessKey, deleteAccessKey, updateAccessKey, createGroup, deleteGroup, 
listGroups, addUserToGroup, removeUserFromGroup |  | IAMOperations
@@ -47,7 +48,6 @@ The AWS IAM component supports 11 options, which are listed 
below.
 | *region* (producer) | The region in which IAM client needs to work. When 
using this parameter, the configuration will expect the capitalized name of the 
region (for example AP_EAST_1) You'll need to use the name 
Regions.EU_WEST_1.name() |  | String
 | *secretKey* (producer) | Amazon AWS Secret Key |  | String
 | *basicPropertyBinding* (advanced) | Whether the component should use basic 
property binding (Camel 2.x) or the newer property binding with additional 
capabilities | false | boolean
-| *configuration* (advanced) | The AWS IAM default configuration |  | 
IAMConfiguration
 |===
 // component options: END
 
diff --git 
a/components/camel-aws-iam/src/main/java/org/apache/camel/component/aws/iam/IAMComponent.java
 
b/components/camel-aws-iam/src/main/java/org/apache/camel/component/aws/iam/IAMComponent.java
index 410410c..44d6d1d 100644
--- 
a/components/camel-aws-iam/src/main/java/org/apache/camel/component/aws/iam/IAMComponent.java
+++ 
b/components/camel-aws-iam/src/main/java/org/apache/camel/component/aws/iam/IAMComponent.java
@@ -33,13 +33,7 @@ import org.apache.camel.support.DefaultComponent;
 public class IAMComponent extends DefaultComponent {
 
     @Metadata
-    private String accessKey;
-    @Metadata
-    private String secretKey;
-    @Metadata
-    private String region;
-    @Metadata(label = "advanced")
-    private IAMConfiguration configuration;
+    private IAMConfiguration configuration = new IAMConfiguration();
 
     public IAMComponent() {
         this(null);
@@ -55,9 +49,6 @@ public class IAMComponent extends DefaultComponent {
     protected Endpoint createEndpoint(String uri, String remaining, 
Map<String, Object> parameters) throws Exception {
         IAMConfiguration configuration = this.configuration != null ? 
this.configuration.copy() : new IAMConfiguration();
         IAMEndpoint endpoint = new IAMEndpoint(uri, this, configuration);
-        endpoint.getConfiguration().setAccessKey(accessKey);
-        endpoint.getConfiguration().setSecretKey(secretKey);
-        endpoint.getConfiguration().setRegion(region);
         setProperties(endpoint, parameters);
         checkAndSetRegistryClient(configuration);
         if (configuration.getIamClient() == null && 
(configuration.getAccessKey() == null || configuration.getSecretKey() == null)) 
{
@@ -72,45 +63,12 @@ public class IAMComponent extends DefaultComponent {
     }
 
     /**
-     * The AWS IAM default configuration
+     * The component configuration
      */
     public void setConfiguration(IAMConfiguration configuration) {
         this.configuration = configuration;
     }
 
-    public String getAccessKey() {
-        return accessKey;
-    }
-
-    /**
-     * Amazon AWS Access Key
-     */
-    public void setAccessKey(String accessKey) {
-        this.accessKey = accessKey;
-    }
-
-    public String getSecretKey() {
-        return secretKey;
-    }
-
-    /**
-     * Amazon AWS Secret Key
-     */
-    public void setSecretKey(String secretKey) {
-        this.secretKey = secretKey;
-    }
-
-    public String getRegion() {
-        return region;
-    }
-
-    /**
-     * The region in which IAM client needs to work
-     */
-    public void setRegion(String region) {
-        this.region = region;
-    }
-
     private void checkAndSetRegistryClient(IAMConfiguration configuration) {
         Set<AmazonIdentityManagement> clients = 
getCamelContext().getRegistry().findByType(AmazonIdentityManagement.class);
         if (clients.size() == 1) {
diff --git 
a/components/camel-aws-iam/src/test/java/org/apache/camel/component/aws/iam/IAMComponentConfigurationTest.java
 
b/components/camel-aws-iam/src/test/java/org/apache/camel/component/aws/iam/IAMComponentConfigurationTest.java
index 6668ced..a94ec10 100644
--- 
a/components/camel-aws-iam/src/test/java/org/apache/camel/component/aws/iam/IAMComponentConfigurationTest.java
+++ 
b/components/camel-aws-iam/src/test/java/org/apache/camel/component/aws/iam/IAMComponentConfigurationTest.java
@@ -27,8 +27,8 @@ public class IAMComponentConfigurationTest extends 
CamelTestSupport {
     @Test
     public void createEndpointWithComponentElements() throws Exception {
         IAMComponent component = context.getComponent("aws-iam", 
IAMComponent.class);
-        component.setAccessKey("XXX");
-        component.setSecretKey("YYY");
+        component.getConfiguration().setAccessKey("XXX");
+        component.getConfiguration().setSecretKey("YYY");
         IAMEndpoint endpoint = 
(IAMEndpoint)component.createEndpoint("aws-iam://label");
         
         assertEquals("XXX", endpoint.getConfiguration().getAccessKey());
@@ -38,9 +38,9 @@ public class IAMComponentConfigurationTest extends 
CamelTestSupport {
     @Test
     public void createEndpointWithComponentAndEndpointElements() throws 
Exception {
         IAMComponent component = context.getComponent("aws-iam", 
IAMComponent.class);
-        component.setAccessKey("XXX");
-        component.setSecretKey("YYY");
-        component.setRegion(Regions.US_WEST_1.toString());
+        component.getConfiguration().setAccessKey("XXX");
+        component.getConfiguration().setSecretKey("YYY");
+        component.getConfiguration().setRegion(Regions.US_WEST_1.toString());
         IAMEndpoint endpoint = 
(IAMEndpoint)component.createEndpoint("aws-iam://label?accessKey=xxxxxx&secretKey=yyyyy&region=US_EAST_1");
         
         assertEquals("xxxxxx", endpoint.getConfiguration().getAccessKey());
@@ -51,9 +51,9 @@ public class IAMComponentConfigurationTest extends 
CamelTestSupport {
     @Test
     public void createEndpointWithComponentEndpointElementsAndProxy() throws 
Exception {
         IAMComponent component = context.getComponent("aws-iam", 
IAMComponent.class);
-        component.setAccessKey("XXX");
-        component.setSecretKey("YYY");
-        component.setRegion(Regions.US_WEST_1.toString());
+        component.getConfiguration().setAccessKey("XXX");
+        component.getConfiguration().setSecretKey("YYY");
+        component.getConfiguration().setRegion(Regions.US_WEST_1.toString());
         IAMEndpoint endpoint = 
(IAMEndpoint)component.createEndpoint("aws-iam://label?accessKey=xxxxxx&secretKey=yyyyy&region=US_EAST_1&proxyHost=localhost&proxyPort=9000&proxyProtocol=HTTP");
         
         assertEquals("xxxxxx", endpoint.getConfiguration().getAccessKey());
diff --git 
a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsIamComponentBuilderFactory.java
 
b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsIamComponentBuilderFactory.java
index e264b7f..327ac80 100644
--- 
a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsIamComponentBuilderFactory.java
+++ 
b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsIamComponentBuilderFactory.java
@@ -58,6 +58,20 @@ public interface AwsIamComponentBuilderFactory {
             return this;
         }
         /**
+         * The component configuration.
+         * 
+         * The option is a:
+         * <code>org.apache.camel.component.aws.iam.IAMConfiguration</code>
+         * type.
+         * 
+         * Group: producer
+         */
+        default AwsIamComponentBuilder configuration(
+                org.apache.camel.component.aws.iam.IAMConfiguration 
configuration) {
+            doSetProperty("configuration", configuration);
+            return this;
+        }
+        /**
          * To use a existing configured AWS IAM as client.
          * 
          * The option is a:
@@ -178,20 +192,6 @@ public interface AwsIamComponentBuilderFactory {
             doSetProperty("basicPropertyBinding", basicPropertyBinding);
             return this;
         }
-        /**
-         * The AWS IAM default configuration.
-         * 
-         * The option is a:
-         * <code>org.apache.camel.component.aws.iam.IAMConfiguration</code>
-         * type.
-         * 
-         * Group: advanced
-         */
-        default AwsIamComponentBuilder configuration(
-                org.apache.camel.component.aws.iam.IAMConfiguration 
configuration) {
-            doSetProperty("configuration", configuration);
-            return this;
-        }
     }
 
     class AwsIamComponentBuilderImpl
@@ -216,7 +216,8 @@ public interface AwsIamComponentBuilderFactory {
                 String name,
                 Object value) {
             switch (name) {
-            case "accessKey": ((IAMComponent) 
component).setAccessKey((java.lang.String) value); return true;
+            case "accessKey": getOrCreateConfiguration((IAMComponent) 
component).setAccessKey((java.lang.String) value); return true;
+            case "configuration": ((IAMComponent) 
component).setConfiguration((org.apache.camel.component.aws.iam.IAMConfiguration)
 value); return true;
             case "iamClient": getOrCreateConfiguration((IAMComponent) 
component).setIamClient((com.amazonaws.services.identitymanagement.AmazonIdentityManagement)
 value); return true;
             case "lazyStartProducer": ((IAMComponent) 
component).setLazyStartProducer((boolean) value); return true;
             case "operation": getOrCreateConfiguration((IAMComponent) 
component).setOperation((org.apache.camel.component.aws.iam.IAMOperations) 
value); return true;
@@ -224,9 +225,8 @@ public interface AwsIamComponentBuilderFactory {
             case "proxyPort": getOrCreateConfiguration((IAMComponent) 
component).setProxyPort((java.lang.Integer) value); return true;
             case "proxyProtocol": getOrCreateConfiguration((IAMComponent) 
component).setProxyProtocol((com.amazonaws.Protocol) value); return true;
             case "region": getOrCreateConfiguration((IAMComponent) 
component).setRegion((java.lang.String) value); return true;
-            case "secretKey": ((IAMComponent) 
component).setSecretKey((java.lang.String) value); return true;
+            case "secretKey": getOrCreateConfiguration((IAMComponent) 
component).setSecretKey((java.lang.String) value); return true;
             case "basicPropertyBinding": ((IAMComponent) 
component).setBasicPropertyBinding((boolean) value); return true;
-            case "configuration": ((IAMComponent) 
component).setConfiguration((org.apache.camel.component.aws.iam.IAMConfiguration)
 value); return true;
             default: return false;
             }
         }

Reply via email to