camel-spark-rest allow to configure it some more

Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/418c2e36
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/418c2e36
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/418c2e36

Branch: refs/heads/master
Commit: 418c2e366e112c9582864e03146d19b3286822a2
Parents: e413ac7
Author: Claus Ibsen <[email protected]>
Authored: Sun Feb 21 14:19:20 2016 +0100
Committer: Claus Ibsen <[email protected]>
Committed: Sun Feb 21 14:19:20 2016 +0100

----------------------------------------------------------------------
 .../camel/component/sparkrest/CamelSpark.java   |  7 +++
 .../component/sparkrest/SparkComponent.java     | 55 ++++++++++++++++++++
 2 files changed, 62 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/418c2e36/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/CamelSpark.java
----------------------------------------------------------------------
diff --git 
a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/CamelSpark.java
 
b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/CamelSpark.java
index 8cdfd41..c5e317d 100644
--- 
a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/CamelSpark.java
+++ 
b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/CamelSpark.java
@@ -57,6 +57,13 @@ public final class CamelSpark {
     }
 
     /**
+     * Configures connection to be secure
+     */
+    public static void security(String keystoreFile, String keystorePassword, 
String truststoreFile, String truststorePassword) {
+        Spark.secure(keystoreFile, keystorePassword, truststoreFile, 
truststorePassword);
+    }
+
+    /**
      * Adds a Spark REST verb that routes to the given spark route
      *
      * @param verb   the HTTP verb

http://git-wip-us.apache.org/repos/asf/camel/blob/418c2e36/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkComponent.java
----------------------------------------------------------------------
diff --git 
a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkComponent.java
 
b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkComponent.java
index 30f3db8..51c553f 100644
--- 
a/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkComponent.java
+++ 
b/components/camel-spark-rest/src/main/java/org/apache/camel/component/sparkrest/SparkComponent.java
@@ -38,9 +38,16 @@ public class SparkComponent extends UriEndpointComponent 
implements RestConsumer
 
     private int port = 4567;
     private String ipAddress;
+
     private int minThreads;
     private int maxThreads;
     private int timeOutMillis;
+
+    private String keystoreFile;
+    private String keystorePassword;
+    private String truststoreFile;
+    private String truststorePassword;
+
     private SparkConfiguration sparkConfiguration = new SparkConfiguration();
     private SparkBinding sparkBinding = new DefaultSparkBinding();
 
@@ -105,6 +112,50 @@ public class SparkComponent extends UriEndpointComponent 
implements RestConsumer
         this.timeOutMillis = timeOutMillis;
     }
 
+    public String getKeystoreFile() {
+        return keystoreFile;
+    }
+
+    /**
+     * Configures connection to be secure to use the keystore file
+     */
+    public void setKeystoreFile(String keystoreFile) {
+        this.keystoreFile = keystoreFile;
+    }
+
+    public String getKeystorePassword() {
+        return keystorePassword;
+    }
+
+    /**
+     * Configures connection to be secure to use the keystore password
+     */
+    public void setKeystorePassword(String keystorePassword) {
+        this.keystorePassword = keystorePassword;
+    }
+
+    public String getTruststoreFile() {
+        return truststoreFile;
+    }
+
+    /**
+     * Configures connection to be secure to use the truststore file
+     */
+    public void setTruststoreFile(String truststoreFile) {
+        this.truststoreFile = truststoreFile;
+    }
+
+    public String getTruststorePassword() {
+        return truststorePassword;
+    }
+
+    /**
+     * Configures connection to be secure to use the truststore password
+     */
+    public void setTruststorePassword(String truststorePassword) {
+        this.truststorePassword = truststorePassword;
+    }
+
     public SparkConfiguration getSparkConfiguration() {
         return sparkConfiguration;
     }
@@ -165,6 +216,10 @@ public class SparkComponent extends UriEndpointComponent 
implements RestConsumer
             CamelSpark.ipAddress(getIpAddress());
         }
 
+        if (keystoreFile != null || truststoreFile != null) {
+            CamelSpark.security(keystoreFile, keystorePassword, 
truststoreFile, truststorePassword);
+        }
+
         // configure component options
         RestConfiguration config = 
getCamelContext().getRestConfiguration("spark-rest", true);
         // configure additional options on spark configuration

Reply via email to