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 2017/11/30 09:23:57 UTC

[camel] branch master updated (9bb9372 -> cc05317)

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 9bb9372  Upgrade Gson to version 2.8.2
     new e7eab52  CAMEL-12051 - Camel-Jsch: Allow to pass the privateKey as byte[] and not only via file
     new cc05317  CAMEL-12051 - Regen docs

The 2 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-jsch/src/main/docs/scp-component.adoc    |  3 ++-
 .../camel/component/scp/ScpConfiguration.java      | 14 ++++++++++++
 .../apache/camel/component/scp/ScpOperations.java  | 13 +++++++++++
 .../camel/component/scp/ScpSimpleProduceTest.java  | 25 ++++++++++++++++++++++
 4 files changed, 54 insertions(+), 1 deletion(-)

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

[camel] 02/02: CAMEL-12051 - 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 cc05317b3ecdea1bfa41cd6ab501e1e869ca7ebe
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Nov 30 09:58:45 2017 +0100

    CAMEL-12051 - Regen docs
---
 components/camel-jsch/src/main/docs/scp-component.adoc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/components/camel-jsch/src/main/docs/scp-component.adoc b/components/camel-jsch/src/main/docs/scp-component.adoc
index d887ae3..bf02944 100644
--- a/components/camel-jsch/src/main/docs/scp-component.adoc
+++ b/components/camel-jsch/src/main/docs/scp-component.adoc
@@ -80,7 +80,7 @@ with the following path and query parameters:
 | *directoryName* | The starting directory |  | String
 |===
 
-==== Query Parameters (19 parameters):
+==== Query Parameters (20 parameters):
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
@@ -99,6 +99,7 @@ with the following path and query parameters:
 | *knownHostsFile* (security) | Sets the known_hosts file so that the jsch endpoint can do host key verification. You can prefix with classpath: to load the file from classpath instead of file system. |  | String
 | *password* (security) | Password to use for login |  | String
 | *preferredAuthentications* (security) | Set a comma separated list of authentications that will be used in order of preference. Possible authentication methods are defined by JCraft JSCH. Some examples include: gssapi-with-micpublickeykeyboard-interactivepassword If not specified the JSCH and/or system defaults will be used. |  | String
+| *privateKeyBytes* (security) | Set the private key bytes to that the endpoint can do private key verification. This must be used only if privateKeyFile wasn't set. Otherwise the file will have the priority. |  | byte[]
 | *privateKeyFile* (security) | Set the private key file to that the endpoint can do private key verification. You can prefix with classpath: to load the file from classpath instead of file system. |  | String
 | *privateKeyFilePassphrase* (security) | Set the private key file passphrase to that the endpoint can do private key verification. |  | String
 | *username* (security) | Username to use for login |  | String

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

[camel] 01/02: CAMEL-12051 - Camel-Jsch: Allow to pass the privateKey as byte[] and not only via file

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 e7eab52012fbe67715a7aeebbf02eac824ba5384
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Nov 30 09:56:55 2017 +0100

    CAMEL-12051 - Camel-Jsch: Allow to pass the privateKey as byte[] and not only via file
---
 .../camel/component/scp/ScpConfiguration.java      | 14 ++++++++++++
 .../apache/camel/component/scp/ScpOperations.java  | 13 +++++++++++
 .../camel/component/scp/ScpSimpleProduceTest.java  | 25 ++++++++++++++++++++++
 3 files changed, 52 insertions(+)

diff --git a/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpConfiguration.java b/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpConfiguration.java
index 2df5a3e..762b746 100644
--- a/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpConfiguration.java
+++ b/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpConfiguration.java
@@ -37,6 +37,8 @@ public class ScpConfiguration extends RemoteFileConfiguration {
     @UriParam(label = "security", secret = true)
     private String privateKeyFile;
     @UriParam(label = "security", secret = true)
+    private byte[] privateKeyBytes;
+    @UriParam(label = "security", secret = true)
     private String privateKeyFilePassphrase;
     @UriParam(enums = "no,yes", defaultValue = "no")
     private String strictHostKeyChecking;
@@ -95,6 +97,18 @@ public class ScpConfiguration extends RemoteFileConfiguration {
      */
     public void setPrivateKeyFile(String privateKeyFile) {
         this.privateKeyFile = privateKeyFile;
+    }    
+
+    public byte[] getPrivateKeyBytes() {
+        return privateKeyBytes;
+    }
+
+    /**
+     * Set the private key bytes to that the endpoint can do private key verification.
+     * This must be used only if privateKeyFile wasn't set. Otherwise the file will have the priority.
+     */
+    public void setPrivateKeyBytes(byte[] privateKeyBytes) {
+        this.privateKeyBytes = privateKeyBytes;
     }
 
     public String getPrivateKeyFilePassphrase() {
diff --git a/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpOperations.java b/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpOperations.java
index 3b35167..efd1eca 100644
--- a/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpOperations.java
+++ b/components/camel-jsch/src/main/java/org/apache/camel/component/scp/ScpOperations.java
@@ -238,8 +238,21 @@ public class ScpOperations implements RemoteFileOperations<ScpFile> {
                 } catch (Exception e) {
                     throw new GenericFileOperationFailedException("Cannot load private keyfile: " + config.getPrivateKeyFile(), e);
                 }
+            } else if (ObjectHelper.isNotEmpty(config.getPrivateKeyBytes())) {
+                LOG.trace("Using private key bytes: {}", config.getPrivateKeyBytes());
+
+                String pkfp = config.getPrivateKeyFilePassphrase();
+
+                byte[] data = config.getPrivateKeyBytes();
+                
+                try {
+                    jsch.addIdentity("camel-jsch", data, null, pkfp != null ? pkfp.getBytes() : null);
+                } catch (Exception e) {
+                    throw new GenericFileOperationFailedException("Cannot load private key bytes: " + config.getPrivateKeyBytes(), e);
+                }                
             }
 
+
             String knownHostsFile = config.getKnownHostsFile();
             if (knownHostsFile == null && config.isUseUserKnownHostsFile()) {
                 if (userKnownHostFile == null) {
diff --git a/components/camel-jsch/src/test/java/org/apache/camel/component/scp/ScpSimpleProduceTest.java b/components/camel-jsch/src/test/java/org/apache/camel/component/scp/ScpSimpleProduceTest.java
index 634d252..0fe2f17 100644
--- a/components/camel-jsch/src/test/java/org/apache/camel/component/scp/ScpSimpleProduceTest.java
+++ b/components/camel-jsch/src/test/java/org/apache/camel/component/scp/ScpSimpleProduceTest.java
@@ -16,8 +16,12 @@
  */
 package org.apache.camel.component.scp;
 
+import java.io.File;
+import java.nio.file.Files;
+
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.JndiRegistry;
 import org.junit.Assume;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -122,4 +126,25 @@ public class ScpSimpleProduceTest extends ScpServerTestSupport {
 
         assertMockEndpointsSatisfied();
     }
+  
+    @Test
+    @Ignore("Fails on CI servers")
+    public void testScpProducePrivateKeyByte() throws Exception {
+        Assume.assumeTrue(this.isSetupComplete());
+
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+
+        String uri = getScpUri() + "?username=admin&privateKeyBytes=#privKey&privateKeyFilePassphrase=password&knownHostsFile=" + getKnownHostsFile();
+        template.sendBodyAndHeader(uri, "Hallo Welt", Exchange.FILE_NAME, "welt.txt");
+
+        assertMockEndpointsSatisfied();
+    }
+    
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry registry = super.createRegistry();
+        byte[] privKey = Files.readAllBytes(new File("src/test/resources/camel-key.priv").toPath());
+        registry.bind("privKey", privKey);
+        return registry;
+    }
 }

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