Repository: camel Updated Branches: refs/heads/master 183d642c5 -> ac5ab2b10
CAMEL-11611 - Adjusted the code to reflect the use of Apache Sshd 1.6.0 Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ac5ab2b1 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ac5ab2b1 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ac5ab2b1 Branch: refs/heads/master Commit: ac5ab2b10299d98ced34f2a06e39430f31aabefa Parents: be592e5 Author: Andrea Cosentino <anco...@gmail.com> Authored: Tue Aug 22 08:51:32 2017 +0200 Committer: Andrea Cosentino <anco...@gmail.com> Committed: Tue Aug 22 08:55:06 2017 +0200 ---------------------------------------------------------------------- .../ssh/ResourceBasedSSHKeyVerifier.java | 4 +- .../apache/camel/component/ssh/SshProducer.java | 2 - .../ssh/SshComponentKnownHostTest.java | 18 ++--- .../springboot/SshComponentConfiguration.java | 72 ++++++++++++++------ 4 files changed, 61 insertions(+), 35 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/ac5ab2b1/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/ResourceBasedSSHKeyVerifier.java ---------------------------------------------------------------------- diff --git a/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/ResourceBasedSSHKeyVerifier.java b/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/ResourceBasedSSHKeyVerifier.java index 63a1317..508e16e 100644 --- a/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/ResourceBasedSSHKeyVerifier.java +++ b/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/ResourceBasedSSHKeyVerifier.java @@ -33,8 +33,8 @@ import java.util.List; import org.apache.camel.CamelContext; import org.apache.camel.util.ResourceHelper; -import org.apache.sshd.ClientSession; -import org.apache.sshd.client.ServerKeyVerifier; +import org.apache.sshd.client.keyverifier.ServerKeyVerifier; +import org.apache.sshd.client.session.ClientSession; import org.bouncycastle.util.Arrays; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/camel/blob/ac5ab2b1/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshProducer.java ---------------------------------------------------------------------- diff --git a/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshProducer.java b/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshProducer.java index 434349e..04193bd 100644 --- a/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshProducer.java +++ b/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshProducer.java @@ -16,7 +16,6 @@ */ package org.apache.camel.component.ssh; -import java.io.InputStream; import java.util.Map; import org.apache.camel.CamelExchangeException; @@ -24,7 +23,6 @@ import org.apache.camel.Exchange; import org.apache.camel.Message; import org.apache.camel.impl.DefaultProducer; import org.apache.sshd.client.SshClient; -import org.apache.camel.util.ResourceHelper; public class SshProducer extends DefaultProducer { private SshEndpoint endpoint; http://git-wip-us.apache.org/repos/asf/camel/blob/ac5ab2b1/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentKnownHostTest.java ---------------------------------------------------------------------- diff --git a/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentKnownHostTest.java b/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentKnownHostTest.java index 7465b07..06a4242 100644 --- a/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentKnownHostTest.java +++ b/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentKnownHostTest.java @@ -24,13 +24,13 @@ public class SshComponentKnownHostTest extends SshComponentTestSupport { @Test public void testProducerWithValidFile() throws Exception { - final String msg = "test\n"; + final String msg = "test"; MockEndpoint mock = getMockEndpoint("mock:password"); mock.expectedMinimumMessageCount(1); mock.expectedBodiesReceived(msg); mock.expectedHeaderReceived(SshResult.EXIT_VALUE, 0); - mock.expectedHeaderReceived(SshResult.STDERR, "Error:test\n"); + mock.expectedHeaderReceived(SshResult.STDERR, "Error:test"); template.sendBody("direct:ssh", msg); @@ -39,7 +39,7 @@ public class SshComponentKnownHostTest extends SshComponentTestSupport { @Test public void testProducerWithInvalidFile() throws Exception { - final String msg = "test\n"; + final String msg = "test"; MockEndpoint mock = getMockEndpoint("mock:password"); mock.expectedMessageCount(0); @@ -51,13 +51,13 @@ public class SshComponentKnownHostTest extends SshComponentTestSupport { @Test public void testProducerWithInvalidFileWarnOnly() throws Exception { - final String msg = "test\n"; + final String msg = "test"; MockEndpoint mock = getMockEndpoint("mock:password"); mock.expectedMinimumMessageCount(1); mock.expectedBodiesReceived(msg); mock.expectedHeaderReceived(SshResult.EXIT_VALUE, 0); - mock.expectedHeaderReceived(SshResult.STDERR, "Error:test\n"); + mock.expectedHeaderReceived(SshResult.STDERR, "Error:test"); template.sendBody("direct:sshInvalidWarnOnly", msg); @@ -68,9 +68,9 @@ public class SshComponentKnownHostTest extends SshComponentTestSupport { public void testPollingConsumerWithValidKnownHostFile() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMinimumMessageCount(1); - mock.expectedBodiesReceived("test\r"); + mock.expectedBodiesReceived("test"); mock.expectedHeaderReceived(SshResult.EXIT_VALUE, 0); - mock.expectedHeaderReceived(SshResult.STDERR, "Error:test\r"); + mock.expectedHeaderReceived(SshResult.STDERR, "Error:test"); assertMockEndpointsSatisfied(); } @@ -85,9 +85,9 @@ public class SshComponentKnownHostTest extends SshComponentTestSupport { public void testPollingConsumerWithInvalidKnownHostFileWarnOnly() throws Exception { MockEndpoint mock = getMockEndpoint("mock:resultInvalidWarnOnly"); mock.expectedMinimumMessageCount(1); - mock.expectedBodiesReceived("test\r"); + mock.expectedBodiesReceived("test"); mock.expectedHeaderReceived(SshResult.EXIT_VALUE, 0); - mock.expectedHeaderReceived(SshResult.STDERR, "Error:test\r"); + mock.expectedHeaderReceived(SshResult.STDERR, "Error:test"); assertMockEndpointsSatisfied(); } http://git-wip-us.apache.org/repos/asf/camel/blob/ac5ab2b1/platforms/spring-boot/components-starter/camel-ssh-starter/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-ssh-starter/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-ssh-starter/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentConfiguration.java index 5a09a0c..f7ec676 100644 --- a/platforms/spring-boot/components-starter/camel-ssh-starter/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-ssh-starter/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentConfiguration.java @@ -204,31 +204,30 @@ public class SshComponentConfiguration /** * Sets the username to use in logging into the remote SSH server. * - * @param username - * String representing login username. + * @param usernameString + * representing login username. */ private String username; /** * Sets the hostname of the remote SSH server. * - * @param host - * String representing hostname of SSH server. + * @param hostString + * representing hostname of SSH server. */ private String host; /** * Sets the port number for the remote SSH server. * - * @param port - * int representing port number on remote host. Defaults to - * 22. + * @param portint + * representing port number on remote host. Defaults to 22. */ private Integer port = 22; /** * Sets the password to use in connecting to remote SSH server. Requires * keyPairProvider to be set to null. * - * @param password - * String representing password for username at remote host. + * @param passwordString + * representing password for username at remote host. */ private String password; /** @@ -237,18 +236,17 @@ public class SshComponentConfiguration * consumer, i.e. from("ssh://...") You may need to end your command * with a newline, and that must be URL encoded %0A * - * @param pollCommand - * String representing the command to send. + * @param pollCommandString + * representing the command to send. */ private String pollCommand; /** * Sets the KeyPairProvider reference to use when connecting using * Certificates to the remote SSH Server. * - * @param keyPairProvider - * KeyPairProvider reference to use in authenticating. If set - * to 'null', then will attempt to connect using - * username/password settings. + * @param keyPairProviderKeyPairProvider + * reference to use in authenticating. If set to 'null', then + * will attempt to connect using username/password settings. * @see KeyPairProvider */ private KeyPairProvider keyPairProvider; @@ -257,9 +255,8 @@ public class SshComponentConfiguration * authentication. KeyPairProvider.loadKey(...) will be passed this * value. Defaults to "ssh-rsa". * - * @param keyType - * String defining the type of KeyPair to use for - * authentication. + * @param keyTypeString + * defining the type of KeyPair to use for authentication. * @see KeyPairProvider */ private String keyType = "ssh-rsa"; @@ -267,8 +264,8 @@ public class SshComponentConfiguration * Sets the timeout in milliseconds to wait in establishing the remote * SSH server connection. Defaults to 30000 milliseconds. * - * @param timeout - * long milliseconds to wait. + * @param timeoutlong + * milliseconds to wait. */ private Long timeout = 30000L; /** @@ -282,10 +279,25 @@ public class SshComponentConfiguration * Will use {@link ResourceHelperKeyPairProvider} to resolve file based * certificate, and depends on keyType setting. * - * @param certResource - * String file, classpath, or http url for the certificate + * @param certResourceString + * file, classpath, or http url for the certificate */ private String certResource; + /** + * Sets the resource path for a known_hosts file + * + * @param knownHostsString + * file, classpath, or http url for the certificate + */ + private String knownHostsResource; + /** + * Specifies whether a connection to an unknown host should fail or not. + * This value is only checked when the property knownHosts is set. + * + * @param boolean boolean flag, whether a connection to an unknown host + * should fail + */ + private Boolean failOnUnknownHost = false; public String getUsername() { return username; @@ -369,5 +381,21 @@ public class SshComponentConfiguration public void setCertResource(String certResource) { this.certResource = certResource; } + + public String getKnownHostsResource() { + return knownHostsResource; + } + + public void setKnownHostsResource(String knownHostsResource) { + this.knownHostsResource = knownHostsResource; + } + + public Boolean getFailOnUnknownHost() { + return failOnUnknownHost; + } + + public void setFailOnUnknownHost(Boolean failOnUnknownHost) { + this.failOnUnknownHost = failOnUnknownHost; + } } } \ No newline at end of file