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 2018/01/15 10:18:00 UTC

[camel] branch master updated (fd9924a -> 33b23c7)

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

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


    from fd9924a  Upgrade ftp server for testing camel-ftp that fixes an internal WARN due older version was not compatible with newer mina version
     new be3f177  CAMEL-12143 - Camel-AWS SES: Add the ability to specify credentials and region at component level
     new 05ea5c1  Camel-AWS SES: secretKey and accessKey are secret
     new b245277  Regen docs
     new b058e02  Removed unused imports
     new d9c96a3  CAMEL-12144 - Camel-AWS SNS: Add the ability to specify credentials and region at component level
     new 2e6d78a  Camel-AWS SNS: secretKey and accessKey are secret
     new 33b23c7  Regen docs

The 7 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:
 .../camel-aws/src/main/docs/aws-ses-component.adoc |  18 +-
 .../camel-aws/src/main/docs/aws-sns-component.adoc |  18 +-
 .../camel/component/aws/ses/SesComponent.java      |  70 +++++++-
 .../camel/component/aws/ses/SesConfiguration.java  |  19 +-
 .../camel/component/aws/sns/SnsComponent.java      |  69 +++++++-
 .../aws/sns/SnsComponentVerifierExtension.java     |   2 -
 .../camel/component/aws/sns/SnsConfiguration.java  |  18 +-
 .../aws/ses/SesComponentConfigurationTest.java     |  28 +++
 .../aws/sns/SnsComponentConfigurationTest.java     |  28 +++
 .../ses/springboot/SesComponentConfiguration.java  | 194 +++++++++++++++++++++
 .../sns/springboot/SnsComponentConfiguration.java  | 190 ++++++++++++++++++++
 11 files changed, 637 insertions(+), 17 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
['"commits@camel.apache.org" <co...@camel.apache.org>'].

[camel] 06/07: Camel-AWS SNS: secretKey and accessKey are secret

Posted by ac...@apache.org.
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 2e6d78a2f878d90991aaf7a62761d1e871fc72a3
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Jan 15 11:12:51 2018 +0100

    Camel-AWS SNS: secretKey and accessKey are secret
---
 .../java/org/apache/camel/component/aws/sns/SnsConfiguration.java     | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsConfiguration.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsConfiguration.java
index 0dc6446..691fecf 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsConfiguration.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsConfiguration.java
@@ -31,9 +31,9 @@ public class SnsConfiguration implements Cloneable {
     private String topicName;
     @UriParam
     private AmazonSNS amazonSNSClient;
-    @UriParam
+    @UriParam(label = "security", secret = true)
     private String accessKey;
-    @UriParam
+    @UriParam(label = "security", secret = true)
     private String secretKey;
     @UriParam
     private String amazonSNSEndpoint;

-- 
To stop receiving notification emails like this one, please contact
"commits@camel.apache.org" <co...@camel.apache.org>.

[camel] 07/07: Regen docs

Posted by ac...@apache.org.
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 33b23c7ec9443977bdb12ed3c4c140b676aaaaed
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Jan 15 11:16:42 2018 +0100

    Regen docs
---
 components/camel-aws/src/main/docs/aws-sns-component.adoc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/components/camel-aws/src/main/docs/aws-sns-component.adoc b/components/camel-aws/src/main/docs/aws-sns-component.adoc
index 9ed31c1..76235de 100644
--- a/components/camel-aws/src/main/docs/aws-sns-component.adoc
+++ b/components/camel-aws/src/main/docs/aws-sns-component.adoc
@@ -69,7 +69,6 @@ with the following path and query parameters:
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *accessKey* (producer) | Amazon AWS Access Key |  | String
 | *amazonSNSClient* (producer) | To use the AmazonSNS as the client |  | AmazonSNS
 | *amazonSNSEndpoint* (producer) | The region with which the AWS-SNS client wants to work with. |  | String
 | *headerFilterStrategy* (producer) | To use a custom HeaderFilterStrategy to map headers to/from Camel. |  | HeaderFilterStrategy
@@ -78,9 +77,10 @@ with the following path and query parameters:
 | *proxyHost* (producer) | To define a proxy host when instantiating the SNS client |  | String
 | *proxyPort* (producer) | To define a proxy port when instantiating the SNS client |  | Integer
 | *region* (producer) | The region in which SNS client needs to work |  | String
-| *secretKey* (producer) | Amazon AWS Secret Key |  | String
 | *subject* (producer) | The subject which is used if the message header 'CamelAwsSnsSubject' is not present. |  | String
 | *synchronous* (advanced) | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). | false | boolean
+| *accessKey* (security) | Amazon AWS Access Key |  | String
+| *secretKey* (security) | Amazon AWS Secret Key |  | String
 |===
 // endpoint options: END
 

-- 
To stop receiving notification emails like this one, please contact
"commits@camel.apache.org" <co...@camel.apache.org>.

[camel] 04/07: Removed unused imports

Posted by ac...@apache.org.
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 b058e0241635752c171ac6ec0ff5e737d36cc61a
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Jan 15 10:58:05 2018 +0100

    Removed unused imports
---
 .../src/main/java/org/apache/camel/component/aws/sns/SnsComponent.java  | 1 -
 .../apache/camel/component/aws/sns/SnsComponentVerifierExtension.java   | 2 --
 2 files changed, 3 deletions(-)

diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsComponent.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsComponent.java
index 449b6f9..b410805 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsComponent.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsComponent.java
@@ -21,7 +21,6 @@ import java.util.Map;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.impl.DefaultComponent;
-import org.apache.camel.impl.UriEndpointComponent;
 
 public class SnsComponent extends DefaultComponent {
     
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsComponentVerifierExtension.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsComponentVerifierExtension.java
index c72a563..27ccb3b 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsComponentVerifierExtension.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsComponentVerifierExtension.java
@@ -23,8 +23,6 @@ import com.amazonaws.auth.AWSCredentials;
 import com.amazonaws.auth.AWSCredentialsProvider;
 import com.amazonaws.auth.AWSStaticCredentialsProvider;
 import com.amazonaws.auth.BasicAWSCredentials;
-import com.amazonaws.services.s3.AmazonS3;
-import com.amazonaws.services.s3.AmazonS3ClientBuilder;
 import com.amazonaws.services.sns.AmazonSNS;
 import com.amazonaws.services.sns.AmazonSNSClientBuilder;
 

-- 
To stop receiving notification emails like this one, please contact
"commits@camel.apache.org" <co...@camel.apache.org>.

[camel] 02/07: Camel-AWS SES: secretKey and accessKey are secret

Posted by ac...@apache.org.
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 05ea5c109bfb2ab1f16e742f59db192b7e94914e
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Jan 15 10:54:28 2018 +0100

    Camel-AWS SES: secretKey and accessKey are secret
---
 .../java/org/apache/camel/component/aws/ses/SesConfiguration.java    | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesConfiguration.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesConfiguration.java
index fac1dd8..3616b69 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesConfiguration.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesConfiguration.java
@@ -22,7 +22,6 @@ import java.util.List;
 import com.amazonaws.services.simpleemail.AmazonSimpleEmailService;
 
 import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.component.aws.s3.S3Configuration;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
@@ -35,9 +34,9 @@ public class SesConfiguration implements Cloneable {
     private String from;
     @UriParam
     private AmazonSimpleEmailService amazonSESClient;
-    @UriParam
+    @UriParam(label = "security", secret = true)
     private String accessKey;
-    @UriParam
+    @UriParam(label = "security", secret = true)
     private String secretKey;
     @UriParam
     private String amazonSESEndpoint;

-- 
To stop receiving notification emails like this one, please contact
"commits@camel.apache.org" <co...@camel.apache.org>.

[camel] 03/07: Regen docs

Posted by ac...@apache.org.
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 b245277211b68f5df639e8348f2e4496cd191fd2
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Jan 15 10:56:44 2018 +0100

    Regen docs
---
 components/camel-aws/src/main/docs/aws-ses-component.adoc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/components/camel-aws/src/main/docs/aws-ses-component.adoc b/components/camel-aws/src/main/docs/aws-ses-component.adoc
index 545909e..06511f8 100644
--- a/components/camel-aws/src/main/docs/aws-ses-component.adoc
+++ b/components/camel-aws/src/main/docs/aws-ses-component.adoc
@@ -65,7 +65,6 @@ with the following path and query parameters:
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *accessKey* (producer) | Amazon AWS Access Key |  | String
 | *amazonSESClient* (producer) | To use the AmazonSimpleEmailService as the client |  | AmazonSimpleEmail Service
 | *amazonSESEndpoint* (producer) | The region with which the AWS-SES client wants to work with. |  | String
 | *proxyHost* (producer) | To define a proxy host when instantiating the SES client |  | String
@@ -73,10 +72,11 @@ with the following path and query parameters:
 | *region* (producer) | The region in which SES client needs to work |  | String
 | *replyToAddresses* (producer) | List of reply-to email address(es) for the message override it using 'CamelAwsSesReplyToAddresses' header. |  | List
 | *returnPath* (producer) | The email address to which bounce notifications are to be forwarded override it using 'CamelAwsSesReturnPath' header. |  | String
-| *secretKey* (producer) | Amazon AWS Secret Key |  | String
 | *subject* (producer) | The subject which is used if the message header 'CamelAwsSesSubject' is not present. |  | String
 | *to* (producer) | List of destination email address. Can be overriden with 'CamelAwsSesTo' header. |  | List
 | *synchronous* (advanced) | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). | false | boolean
+| *accessKey* (security) | Amazon AWS Access Key |  | String
+| *secretKey* (security) | Amazon AWS Secret Key |  | String
 |===
 // endpoint options: END
 

-- 
To stop receiving notification emails like this one, please contact
"commits@camel.apache.org" <co...@camel.apache.org>.

[camel] 05/07: CAMEL-12144 - Camel-AWS SNS: Add the ability to specify credentials and region at component level

Posted by ac...@apache.org.
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 d9c96a34ef47d877cd1162f183f7164e6cf68427
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Jan 15 11:12:18 2018 +0100

    CAMEL-12144 - Camel-AWS SNS: Add the ability to specify credentials and region at component level
---
 .../camel-aws/src/main/docs/aws-sns-component.adoc |  14 +-
 .../camel/component/aws/sns/SnsComponent.java      |  68 +++++++-
 .../camel/component/aws/sns/SnsConfiguration.java  |  14 ++
 .../aws/sns/SnsComponentConfigurationTest.java     |  28 +++
 .../sns/springboot/SnsComponentConfiguration.java  | 190 +++++++++++++++++++++
 5 files changed, 312 insertions(+), 2 deletions(-)

diff --git a/components/camel-aws/src/main/docs/aws-sns-component.adoc b/components/camel-aws/src/main/docs/aws-sns-component.adoc
index 2009e5f..9ed31c1 100644
--- a/components/camel-aws/src/main/docs/aws-sns-component.adoc
+++ b/components/camel-aws/src/main/docs/aws-sns-component.adoc
@@ -28,7 +28,19 @@ The topic will be created if they don't already exists. +
 
 
 // component options: START
-The AWS Simple Notification System component has no options.
+The AWS Simple Notification System component supports 5 options which are listed below.
+
+
+
+[width="100%",cols="2,5,^1,2",options="header"]
+|===
+| Name | Description | Default | Type
+| *configuration* (advanced) | The AWS SNS default configuration |  | SnsConfiguration
+| *accessKey* (producer) | Amazon AWS Access Key |  | String
+| *secretKey* (producer) | Amazon AWS Secret Key |  | String
+| *region* (producer) | The region in which SNS client needs to work |  | String
+| *resolveProperty Placeholders* (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean
+|===
 // component options: END
 
 
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsComponent.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsComponent.java
index b410805..655f92e 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsComponent.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsComponent.java
@@ -21,9 +21,20 @@ import java.util.Map;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.util.ObjectHelper;
 
 public class SnsComponent extends DefaultComponent {
     
+    @Metadata
+    private String accessKey;
+    @Metadata
+    private String secretKey;
+    @Metadata
+    private String region;
+    @Metadata(label = "advanced")    
+    private SnsConfiguration configuration;
+    
     public SnsComponent() {
         this(null);
     }
@@ -31,11 +42,12 @@ public class SnsComponent extends DefaultComponent {
     public SnsComponent(CamelContext context) {
         super(context);
         
+        this.configuration = new SnsConfiguration();
         registerExtension(new SnsComponentVerifierExtension());
     }
 
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
-        SnsConfiguration configuration = new SnsConfiguration();
+        SnsConfiguration configuration = this.configuration.copy();
         setProperties(configuration, parameters);
 
         if (remaining == null || remaining.trim().length() == 0) {
@@ -47,6 +59,16 @@ public class SnsComponent extends DefaultComponent {
             configuration.setTopicName(remaining);
         }
 
+        if (ObjectHelper.isEmpty(configuration.getAccessKey())) {
+            setAccessKey(accessKey);
+        }
+        if (ObjectHelper.isEmpty(configuration.getSecretKey())) {
+            setSecretKey(secretKey);
+        }
+        if (ObjectHelper.isEmpty(configuration.getRegion())) {
+            setRegion(region);
+        }
+        
         if (configuration.getAmazonSNSClient() == null && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
             throw new IllegalArgumentException("AmazonSNSClient or accessKey and secretKey must be specified");
         }
@@ -54,4 +76,48 @@ public class SnsComponent extends DefaultComponent {
         SnsEndpoint endpoint = new SnsEndpoint(uri, this, configuration);
         return endpoint;
     }
+    
+    public SnsConfiguration getConfiguration() {
+        return configuration;
+    }
+
+    /**
+     * The AWS SNS default configuration
+     */
+    public void setConfiguration(SnsConfiguration configuration) {
+        this.configuration = configuration;
+    }
+
+    public String getAccessKey() {
+        return configuration.getAccessKey();
+    }
+
+    /**
+     * Amazon AWS Access Key
+     */
+    public void setAccessKey(String accessKey) {
+        configuration.setAccessKey(accessKey);
+    }
+
+    public String getSecretKey() {
+        return configuration.getSecretKey();
+    }
+
+    /**
+     * Amazon AWS Secret Key
+     */
+    public void setSecretKey(String secretKey) {
+        configuration.setSecretKey(secretKey);
+    }
+    
+    /**
+     * The region in which SNS client needs to work
+     */
+    public String getRegion() {
+        return configuration.getRegion();
+    }
+
+    public void setRegion(String region) {
+        configuration.setRegion(region);
+    }
 }
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsConfiguration.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsConfiguration.java
index 3253bea..0dc6446 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsConfiguration.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsConfiguration.java
@@ -17,6 +17,8 @@
 package org.apache.camel.component.aws.sns;
 
 import com.amazonaws.services.sns.AmazonSNS;
+
+import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
 
@@ -181,4 +183,16 @@ public class SnsConfiguration implements Cloneable {
     public void setRegion(String region) {
         this.region = region;
     }
+    
+    // *************************************************
+    //
+    // *************************************************
+
+    public SnsConfiguration copy() {
+        try {
+            return (SnsConfiguration)super.clone();
+        } catch (CloneNotSupportedException e) {
+            throw new RuntimeCamelException(e);
+        }
+    }
 }
\ No newline at end of file
diff --git a/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java
index 8c1374b..52077c6 100644
--- a/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java
+++ b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.component.aws.sns;
 
+import com.amazonaws.regions.Regions;
+
 import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.impl.PropertyPlaceholderDelegateRegistry;
 import org.apache.camel.test.junit4.CamelTestSupport;
@@ -129,6 +131,32 @@ public class SnsComponentConfigurationTest extends CamelTestSupport {
     }
     
     @Test
+    public void createEndpointWithComponentElements() throws Exception {
+        SnsComponent component = new SnsComponent(context);
+        component.setAccessKey("XXX");
+        component.setSecretKey("YYY");
+        SnsEndpoint endpoint = (SnsEndpoint)component.createEndpoint("aws-sns://MyTopic");
+        
+        assertEquals("MyTopic", endpoint.getConfiguration().getTopicName());
+        assertEquals("XXX", endpoint.getConfiguration().getAccessKey());
+        assertEquals("YYY", endpoint.getConfiguration().getSecretKey());
+    }
+    
+    @Test
+    public void createEndpointWithComponentAndEndpointElements() throws Exception {
+        SnsComponent component = new SnsComponent(context);
+        component.setAccessKey("XXX");
+        component.setSecretKey("YYY");
+        component.setRegion(Regions.US_WEST_1.toString());
+        SnsEndpoint endpoint = (SnsEndpoint)component.createEndpoint("aws-sns://MyTopic?accessKey=xxxxxx&secretKey=yyyyy&region=US_EAST_1");
+        
+        assertEquals("MyTopic", endpoint.getConfiguration().getTopicName());
+        assertEquals("xxxxxx", endpoint.getConfiguration().getAccessKey());
+        assertEquals("yyyyy", endpoint.getConfiguration().getSecretKey());
+        assertEquals("US_EAST_1", endpoint.getConfiguration().getRegion());
+    }
+    
+    @Test
     public void createEndpointWithoutSecretKeyAndAccessKeyConfiguration() throws Exception {
         AmazonSNSClientMock mock = new AmazonSNSClientMock();
         
diff --git a/platforms/spring-boot/components-starter/camel-aws-starter/src/main/java/org/apache/camel/component/aws/sns/springboot/SnsComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-aws-starter/src/main/java/org/apache/camel/component/aws/sns/springboot/SnsComponentConfiguration.java
index f9c59f2..b5962a2 100644
--- a/platforms/spring-boot/components-starter/camel-aws-starter/src/main/java/org/apache/camel/component/aws/sns/springboot/SnsComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-aws-starter/src/main/java/org/apache/camel/component/aws/sns/springboot/SnsComponentConfiguration.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.aws.sns.springboot;
 
 import javax.annotation.Generated;
+import com.amazonaws.services.sns.AmazonSNS;
 import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 
@@ -33,12 +34,61 @@ public class SnsComponentConfiguration
             ComponentConfigurationPropertiesCommon {
 
     /**
+     * The AWS SNS default configuration
+     */
+    private SnsConfigurationNestedConfiguration configuration;
+    /**
+     * Amazon AWS Access Key
+     */
+    private String accessKey;
+    /**
+     * Amazon AWS Secret Key
+     */
+    private String secretKey;
+    /**
+     * The region in which SNS client needs to work
+     */
+    private String region;
+    /**
      * Whether the component should resolve property placeholders on itself when
      * starting. Only properties which are of String type can use property
      * placeholders.
      */
     private Boolean resolvePropertyPlaceholders = true;
 
+    public SnsConfigurationNestedConfiguration getConfiguration() {
+        return configuration;
+    }
+
+    public void setConfiguration(
+            SnsConfigurationNestedConfiguration configuration) {
+        this.configuration = configuration;
+    }
+
+    public String getAccessKey() {
+        return accessKey;
+    }
+
+    public void setAccessKey(String accessKey) {
+        this.accessKey = accessKey;
+    }
+
+    public String getSecretKey() {
+        return secretKey;
+    }
+
+    public void setSecretKey(String secretKey) {
+        this.secretKey = secretKey;
+    }
+
+    public String getRegion() {
+        return region;
+    }
+
+    public void setRegion(String region) {
+        this.region = region;
+    }
+
     public Boolean getResolvePropertyPlaceholders() {
         return resolvePropertyPlaceholders;
     }
@@ -47,4 +97,144 @@ public class SnsComponentConfiguration
             Boolean resolvePropertyPlaceholders) {
         this.resolvePropertyPlaceholders = resolvePropertyPlaceholders;
     }
+
+    public static class SnsConfigurationNestedConfiguration {
+        public static final Class CAMEL_NESTED_CLASS = org.apache.camel.component.aws.sns.SnsConfiguration.class;
+        /**
+         * The region with which the AWS-SNS client wants to work with.
+         */
+        private String amazonSNSEndpoint;
+        /**
+         * The subject which is used if the message header 'CamelAwsSnsSubject'
+         * is not present.
+         */
+        private String subject;
+        /**
+         * The Amazon Resource Name (ARN) assigned to the created topic.
+         */
+        private String topicArn;
+        /**
+         * Amazon AWS Access Key
+         */
+        private String accessKey;
+        /**
+         * Amazon AWS Secret Key
+         */
+        private String secretKey;
+        /**
+         * To use the AmazonSNS as the client
+         */
+        private AmazonSNS amazonSNSClient;
+        /**
+         * The name of the topic
+         */
+        private String topicName;
+        /**
+         * The policy for this queue
+         */
+        private String policy;
+        /**
+         * The message structure to use such as json
+         */
+        private String messageStructure;
+        private String proxyHost;
+        private Integer proxyPort;
+        private String region;
+
+        public String getAmazonSNSEndpoint() {
+            return amazonSNSEndpoint;
+        }
+
+        public void setAmazonSNSEndpoint(String amazonSNSEndpoint) {
+            this.amazonSNSEndpoint = amazonSNSEndpoint;
+        }
+
+        public String getSubject() {
+            return subject;
+        }
+
+        public void setSubject(String subject) {
+            this.subject = subject;
+        }
+
+        public String getTopicArn() {
+            return topicArn;
+        }
+
+        public void setTopicArn(String topicArn) {
+            this.topicArn = topicArn;
+        }
+
+        public String getAccessKey() {
+            return accessKey;
+        }
+
+        public void setAccessKey(String accessKey) {
+            this.accessKey = accessKey;
+        }
+
+        public String getSecretKey() {
+            return secretKey;
+        }
+
+        public void setSecretKey(String secretKey) {
+            this.secretKey = secretKey;
+        }
+
+        public AmazonSNS getAmazonSNSClient() {
+            return amazonSNSClient;
+        }
+
+        public void setAmazonSNSClient(AmazonSNS amazonSNSClient) {
+            this.amazonSNSClient = amazonSNSClient;
+        }
+
+        public String getTopicName() {
+            return topicName;
+        }
+
+        public void setTopicName(String topicName) {
+            this.topicName = topicName;
+        }
+
+        public String getPolicy() {
+            return policy;
+        }
+
+        public void setPolicy(String policy) {
+            this.policy = policy;
+        }
+
+        public String getMessageStructure() {
+            return messageStructure;
+        }
+
+        public void setMessageStructure(String messageStructure) {
+            this.messageStructure = messageStructure;
+        }
+
+        public String getProxyHost() {
+            return proxyHost;
+        }
+
+        public void setProxyHost(String proxyHost) {
+            this.proxyHost = proxyHost;
+        }
+
+        public Integer getProxyPort() {
+            return proxyPort;
+        }
+
+        public void setProxyPort(Integer proxyPort) {
+            this.proxyPort = proxyPort;
+        }
+
+        public String getRegion() {
+            return region;
+        }
+
+        public void setRegion(String region) {
+            this.region = region;
+        }
+    }
 }
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
"commits@camel.apache.org" <co...@camel.apache.org>.

[camel] 01/07: CAMEL-12143 - Camel-AWS SES: Add the ability to specify credentials and region at component level

Posted by ac...@apache.org.
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 be3f177afbbc9a76547c5de7932f27589be3fbd5
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Jan 15 10:52:55 2018 +0100

    CAMEL-12143 - Camel-AWS SES: Add the ability to specify credentials and region at component level
---
 .../camel-aws/src/main/docs/aws-ses-component.adoc |  14 +-
 .../camel/component/aws/ses/SesComponent.java      |  70 +++++++-
 .../camel/component/aws/ses/SesConfiguration.java  |  16 +-
 .../aws/ses/SesComponentConfigurationTest.java     |  28 +++
 .../ses/springboot/SesComponentConfiguration.java  | 194 +++++++++++++++++++++
 5 files changed, 318 insertions(+), 4 deletions(-)

diff --git a/components/camel-aws/src/main/docs/aws-ses-component.adoc b/components/camel-aws/src/main/docs/aws-ses-component.adoc
index 9893b08..545909e 100644
--- a/components/camel-aws/src/main/docs/aws-ses-component.adoc
+++ b/components/camel-aws/src/main/docs/aws-ses-component.adoc
@@ -25,7 +25,19 @@ You can append query options to the URI in the following format,
 
 
 // component options: START
-The AWS Simple Email Service component has no options.
+The AWS Simple Email Service component supports 5 options which are listed below.
+
+
+
+[width="100%",cols="2,5,^1,2",options="header"]
+|===
+| Name | Description | Default | Type
+| *configuration* (advanced) | The AWS SES default configuration |  | SesConfiguration
+| *accessKey* (producer) | Amazon AWS Access Key |  | String
+| *secretKey* (producer) | Amazon AWS Secret Key |  | String
+| *region* (producer) | The region in which SES client needs to work |  | String
+| *resolveProperty Placeholders* (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean
+|===
 // component options: END
 
 
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesComponent.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesComponent.java
index 9cf4be9..fa64d8a 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesComponent.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesComponent.java
@@ -21,21 +21,33 @@ import java.util.Map;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.util.ObjectHelper;
 
 public class SesComponent extends DefaultComponent {
 
+    @Metadata
+    private String accessKey;
+    @Metadata
+    private String secretKey;
+    @Metadata
+    private String region;
+    @Metadata(label = "advanced")
+    private SesConfiguration configuration;
+
     public SesComponent() {
         this(null);
     }
 
     public SesComponent(CamelContext context) {
         super(context);
-        
+
+        this.configuration = new SesConfiguration();
         registerExtension(new SesComponentVerifierExtension());
     }
 
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
-        SesConfiguration configuration = new SesConfiguration();
+        SesConfiguration configuration = this.configuration.copy();
         setProperties(configuration, parameters);
 
         if (remaining == null || remaining.trim().length() == 0) {
@@ -43,10 +55,64 @@ public class SesComponent extends DefaultComponent {
         }
         configuration.setFrom(remaining);
 
+        if (ObjectHelper.isEmpty(configuration.getAccessKey())) {
+            setAccessKey(accessKey);
+        }
+        if (ObjectHelper.isEmpty(configuration.getSecretKey())) {
+            setSecretKey(secretKey);
+        }
+        if (ObjectHelper.isEmpty(configuration.getRegion())) {
+            setRegion(region);
+        }
+
         if (configuration.getAmazonSESClient() == null && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
             throw new IllegalArgumentException("AmazonSESClient or accessKey and secretKey must be specified");
         }
 
         return new SesEndpoint(uri, this, configuration);
     }
+
+    public SesConfiguration getConfiguration() {
+        return configuration;
+    }
+
+    /**
+     * The AWS SES default configuration
+     */
+    public void setConfiguration(SesConfiguration configuration) {
+        this.configuration = configuration;
+    }
+
+    public String getAccessKey() {
+        return configuration.getAccessKey();
+    }
+
+    /**
+     * Amazon AWS Access Key
+     */
+    public void setAccessKey(String accessKey) {
+        configuration.setAccessKey(accessKey);
+    }
+
+    public String getSecretKey() {
+        return configuration.getSecretKey();
+    }
+
+    /**
+     * Amazon AWS Secret Key
+     */
+    public void setSecretKey(String secretKey) {
+        configuration.setSecretKey(secretKey);
+    }
+
+    /**
+     * The region in which SES client needs to work
+     */
+    public String getRegion() {
+        return configuration.getRegion();
+    }
+
+    public void setRegion(String region) {
+        configuration.setRegion(region);
+    }
 }
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesConfiguration.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesConfiguration.java
index ea80a71..fac1dd8 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesConfiguration.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ses/SesConfiguration.java
@@ -21,13 +21,15 @@ import java.util.List;
 
 import com.amazonaws.services.simpleemail.AmazonSimpleEmailService;
 
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.component.aws.s3.S3Configuration;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
 import org.apache.camel.spi.UriPath;
 
 @UriParams
-public class SesConfiguration {
+public class SesConfiguration implements Cloneable {
 
     @UriPath @Metadata(required = "true")
     private String from;
@@ -196,4 +198,16 @@ public class SesConfiguration {
     public void setRegion(String region) {
         this.region = region;
     }
+    
+    // *************************************************
+    //
+    // *************************************************
+
+    public SesConfiguration copy() {
+        try {
+            return (SesConfiguration)super.clone();
+        } catch (CloneNotSupportedException e) {
+            throw new RuntimeCamelException(e);
+        }
+    }
 }
diff --git a/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/SesComponentConfigurationTest.java b/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/SesComponentConfigurationTest.java
index 8873a9c..9c118aa 100644
--- a/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/SesComponentConfigurationTest.java
+++ b/components/camel-aws/src/test/java/org/apache/camel/component/aws/ses/SesComponentConfigurationTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.component.aws.ses;
 
+import com.amazonaws.regions.Regions;
+
 import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.impl.PropertyPlaceholderDelegateRegistry;
 import org.apache.camel.test.junit4.CamelTestSupport;
@@ -134,6 +136,32 @@ public class SesComponentConfigurationTest extends CamelTestSupport {
     }
     
     @Test
+    public void createEndpointWithComponentElements() throws Exception {
+        SesComponent component = new SesComponent(context);
+        component.setAccessKey("XXX");
+        component.setSecretKey("YYY");
+        SesEndpoint endpoint = (SesEndpoint)component.createEndpoint("aws-ses://from@example.com");
+        
+        assertEquals("from@example.com", endpoint.getConfiguration().getFrom());
+        assertEquals("XXX", endpoint.getConfiguration().getAccessKey());
+        assertEquals("YYY", endpoint.getConfiguration().getSecretKey());
+    }
+    
+    @Test
+    public void createEndpointWithComponentAndEndpointElements() throws Exception {
+        SesComponent component = new SesComponent(context);
+        component.setAccessKey("XXX");
+        component.setSecretKey("YYY");
+        component.setRegion(Regions.US_WEST_1.toString());
+        SesEndpoint endpoint = (SesEndpoint)component.createEndpoint("aws-ses://from@example.com?accessKey=xxxxxx&secretKey=yyyyy&region=US_EAST_1");
+        
+        assertEquals("from@example.com", endpoint.getConfiguration().getFrom());
+        assertEquals("xxxxxx", endpoint.getConfiguration().getAccessKey());
+        assertEquals("yyyyy", endpoint.getConfiguration().getSecretKey());
+        assertEquals("US_EAST_1", endpoint.getConfiguration().getRegion());
+    }
+    
+    @Test
     public void createEndpointWithoutSecretKeyAndAccessKeyConfiguration() throws Exception {
         AmazonSESClientMock mock = new AmazonSESClientMock();
         
diff --git a/platforms/spring-boot/components-starter/camel-aws-starter/src/main/java/org/apache/camel/component/aws/ses/springboot/SesComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-aws-starter/src/main/java/org/apache/camel/component/aws/ses/springboot/SesComponentConfiguration.java
index 6ee80dc..42c61a0 100644
--- a/platforms/spring-boot/components-starter/camel-aws-starter/src/main/java/org/apache/camel/component/aws/ses/springboot/SesComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-aws-starter/src/main/java/org/apache/camel/component/aws/ses/springboot/SesComponentConfiguration.java
@@ -16,7 +16,9 @@
  */
 package org.apache.camel.component.aws.ses.springboot;
 
+import java.util.List;
 import javax.annotation.Generated;
+import com.amazonaws.services.simpleemail.AmazonSimpleEmailService;
 import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 
@@ -32,12 +34,61 @@ public class SesComponentConfiguration
             ComponentConfigurationPropertiesCommon {
 
     /**
+     * The AWS SES default configuration
+     */
+    private SesConfigurationNestedConfiguration configuration;
+    /**
+     * Amazon AWS Access Key
+     */
+    private String accessKey;
+    /**
+     * Amazon AWS Secret Key
+     */
+    private String secretKey;
+    /**
+     * The region in which SES client needs to work
+     */
+    private String region;
+    /**
      * Whether the component should resolve property placeholders on itself when
      * starting. Only properties which are of String type can use property
      * placeholders.
      */
     private Boolean resolvePropertyPlaceholders = true;
 
+    public SesConfigurationNestedConfiguration getConfiguration() {
+        return configuration;
+    }
+
+    public void setConfiguration(
+            SesConfigurationNestedConfiguration configuration) {
+        this.configuration = configuration;
+    }
+
+    public String getAccessKey() {
+        return accessKey;
+    }
+
+    public void setAccessKey(String accessKey) {
+        this.accessKey = accessKey;
+    }
+
+    public String getSecretKey() {
+        return secretKey;
+    }
+
+    public void setSecretKey(String secretKey) {
+        this.secretKey = secretKey;
+    }
+
+    public String getRegion() {
+        return region;
+    }
+
+    public void setRegion(String region) {
+        this.region = region;
+    }
+
     public Boolean getResolvePropertyPlaceholders() {
         return resolvePropertyPlaceholders;
     }
@@ -46,4 +97,147 @@ public class SesComponentConfiguration
             Boolean resolvePropertyPlaceholders) {
         this.resolvePropertyPlaceholders = resolvePropertyPlaceholders;
     }
+
+    public static class SesConfigurationNestedConfiguration {
+        public static final Class CAMEL_NESTED_CLASS = org.apache.camel.component.aws.ses.SesConfiguration.class;
+        /**
+         * Amazon AWS Access Key
+         */
+        private String accessKey;
+        /**
+         * To use the AmazonSimpleEmailService as the client
+         */
+        private AmazonSimpleEmailService amazonSESClient;
+        /**
+         * The sender's email address.
+         */
+        private String from;
+        /**
+         * List of destination email address. Can be overriden with
+         * 'CamelAwsSesTo' header.
+         */
+        private List to;
+        /**
+         * Amazon AWS Secret Key
+         */
+        private String secretKey;
+        /**
+         * The subject which is used if the message header 'CamelAwsSesSubject'
+         * is not present.
+         */
+        private String subject;
+        /**
+         * The email address to which bounce notifications are to be forwarded,
+         * override it using 'CamelAwsSesReturnPath' header.
+         */
+        private String returnPath;
+        /**
+         * List of reply-to email address(es) for the message, override it using
+         * 'CamelAwsSesReplyToAddresses' header.
+         */
+        private List replyToAddresses;
+        /**
+         * The region with which the AWS-SES client wants to work with.
+         */
+        private String amazonSESEndpoint;
+        private String proxyHost;
+        private Integer proxyPort;
+        private String region;
+
+        public String getAccessKey() {
+            return accessKey;
+        }
+
+        public void setAccessKey(String accessKey) {
+            this.accessKey = accessKey;
+        }
+
+        public AmazonSimpleEmailService getAmazonSESClient() {
+            return amazonSESClient;
+        }
+
+        public void setAmazonSESClient(AmazonSimpleEmailService amazonSESClient) {
+            this.amazonSESClient = amazonSESClient;
+        }
+
+        public String getFrom() {
+            return from;
+        }
+
+        public void setFrom(String from) {
+            this.from = from;
+        }
+
+        public List getTo() {
+            return to;
+        }
+
+        public void setTo(List to) {
+            this.to = to;
+        }
+
+        public String getSecretKey() {
+            return secretKey;
+        }
+
+        public void setSecretKey(String secretKey) {
+            this.secretKey = secretKey;
+        }
+
+        public String getSubject() {
+            return subject;
+        }
+
+        public void setSubject(String subject) {
+            this.subject = subject;
+        }
+
+        public String getReturnPath() {
+            return returnPath;
+        }
+
+        public void setReturnPath(String returnPath) {
+            this.returnPath = returnPath;
+        }
+
+        public List getReplyToAddresses() {
+            return replyToAddresses;
+        }
+
+        public void setReplyToAddresses(List replyToAddresses) {
+            this.replyToAddresses = replyToAddresses;
+        }
+
+        public String getAmazonSESEndpoint() {
+            return amazonSESEndpoint;
+        }
+
+        public void setAmazonSESEndpoint(String amazonSESEndpoint) {
+            this.amazonSESEndpoint = amazonSESEndpoint;
+        }
+
+        public String getProxyHost() {
+            return proxyHost;
+        }
+
+        public void setProxyHost(String proxyHost) {
+            this.proxyHost = proxyHost;
+        }
+
+        public Integer getProxyPort() {
+            return proxyPort;
+        }
+
+        public void setProxyPort(Integer proxyPort) {
+            this.proxyPort = proxyPort;
+        }
+
+        public String getRegion() {
+            return region;
+        }
+
+        public void setRegion(String region) {
+            this.region = region;
+        }
+    }
 }
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
"commits@camel.apache.org" <co...@camel.apache.org>.