You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2012/01/30 12:12:51 UTC
svn commit: r1237603 [1/2] - in /camel/trunk: apache-camel/
apache-camel/src/main/descriptors/ components/ components/camel-routebox/
components/camel-routebox/src/test/resources/ components/camel-ssh/
components/camel-ssh/src/ components/camel-ssh/src...
Author: davsclaus
Date: Mon Jan 30 11:12:49 2012
New Revision: 1237603
URL: http://svn.apache.org/viewvc?rev=1237603&view=rev
Log:
CAMEL-4713: New camel-ssh component. Thanks to Scott and Jason for their contribution.
Added:
camel/trunk/components/camel-ssh/ (with props)
camel/trunk/components/camel-ssh/pom.xml (with props)
camel/trunk/components/camel-ssh/src/
camel/trunk/components/camel-ssh/src/main/
camel/trunk/components/camel-ssh/src/main/java/
camel/trunk/components/camel-ssh/src/main/java/org/
camel/trunk/components/camel-ssh/src/main/java/org/apache/
camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/
camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/
camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/
camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshComponent.java (with props)
camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshConfiguration.java (with props)
camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshConsumer.java (with props)
camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshEndpoint.java (with props)
camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshProducer.java (with props)
camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/package.html (with props)
camel/trunk/components/camel-ssh/src/main/resources/
camel/trunk/components/camel-ssh/src/main/resources/META-INF/
camel/trunk/components/camel-ssh/src/main/resources/META-INF/services/
camel/trunk/components/camel-ssh/src/main/resources/META-INF/services/org/
camel/trunk/components/camel-ssh/src/main/resources/META-INF/services/org/apache/
camel/trunk/components/camel-ssh/src/main/resources/META-INF/services/org/apache/camel/
camel/trunk/components/camel-ssh/src/main/resources/META-INF/services/org/apache/camel/component/
camel/trunk/components/camel-ssh/src/main/resources/META-INF/services/org/apache/camel/component/ssh
camel/trunk/components/camel-ssh/src/test/
camel/trunk/components/camel-ssh/src/test/java/
camel/trunk/components/camel-ssh/src/test/java/org/
camel/trunk/components/camel-ssh/src/test/java/org/apache/
camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/
camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/
camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/
camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/BogusPasswordAuthenticator.java (with props)
camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/BogusPublickeyAuthenticator.java (with props)
camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/EchoCommandFactory.java (with props)
camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentConsumerTest.java (with props)
camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentErrorHandlingTest.java (with props)
camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentProducerTest.java (with props)
camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentTestSupport.java (with props)
camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/TestEchoCommandFactory.java (with props)
camel/trunk/components/camel-ssh/src/test/resources/
camel/trunk/components/camel-ssh/src/test/resources/dsaprivkey.pem
camel/trunk/components/camel-ssh/src/test/resources/hostkey.pem
camel/trunk/components/camel-ssh/src/test/resources/log4j.properties (with props)
camel/trunk/examples/camel-example-ssh/ (with props)
camel/trunk/examples/camel-example-ssh/README.txt (with props)
camel/trunk/examples/camel-example-ssh/pom.xml (with props)
camel/trunk/examples/camel-example-ssh/src/
camel/trunk/examples/camel-example-ssh/src/main/
camel/trunk/examples/camel-example-ssh/src/main/resources/
camel/trunk/examples/camel-example-ssh/src/main/resources/META-INF/
camel/trunk/examples/camel-example-ssh/src/main/resources/META-INF/LICENSE.txt (with props)
camel/trunk/examples/camel-example-ssh/src/main/resources/META-INF/NOTICE.txt (with props)
camel/trunk/examples/camel-example-ssh/src/main/resources/META-INF/spring/
camel/trunk/examples/camel-example-ssh/src/main/resources/META-INF/spring/camelContext.xml (with props)
camel/trunk/examples/camel-example-ssh/src/main/resources/features.xml (with props)
camel/trunk/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelSshTest.java
- copied, changed from r1237572, camel/trunk/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelSqlTest.java
Modified:
camel/trunk/apache-camel/pom.xml
camel/trunk/apache-camel/src/main/descriptors/common-bin.xml
camel/trunk/components/camel-routebox/ (props changed)
camel/trunk/components/camel-routebox/src/test/resources/log4j.properties
camel/trunk/components/pom.xml
camel/trunk/examples/pom.xml
camel/trunk/parent/pom.xml
camel/trunk/platforms/karaf/features/src/main/resources/features.xml
Modified: camel/trunk/apache-camel/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/apache-camel/pom.xml?rev=1237603&r1=1237602&r2=1237603&view=diff
==============================================================================
--- camel/trunk/apache-camel/pom.xml (original)
+++ camel/trunk/apache-camel/pom.xml Mon Jan 30 11:12:49 2012
@@ -439,6 +439,10 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-ssh</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-stax</artifactId>
</dependency>
<dependency>
Modified: camel/trunk/apache-camel/src/main/descriptors/common-bin.xml
URL: http://svn.apache.org/viewvc/camel/trunk/apache-camel/src/main/descriptors/common-bin.xml?rev=1237603&r1=1237602&r2=1237603&view=diff
==============================================================================
--- camel/trunk/apache-camel/src/main/descriptors/common-bin.xml (original)
+++ camel/trunk/apache-camel/src/main/descriptors/common-bin.xml Mon Jan 30 11:12:49 2012
@@ -128,6 +128,7 @@
<include>org.apache.camel:camel-spring-security</include>
<include>org.apache.camel:camel-spring-ws</include>
<include>org.apache.camel:camel-sql</include>
+ <include>org.apache.camel:camel-ssh</include>
<include>org.apache.camel:camel-stax</include>
<include>org.apache.camel:camel-stream</include>
<include>org.apache.camel:camel-stringtemplate</include>
Propchange: camel/trunk/components/camel-routebox/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Jan 30 11:12:49 2012
@@ -14,3 +14,4 @@ eclipse-classes
*.ipr
*.iml
*.iws
+*.idea
Modified: camel/trunk/components/camel-routebox/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-routebox/src/test/resources/log4j.properties?rev=1237603&r1=1237602&r2=1237603&view=diff
==============================================================================
--- camel/trunk/components/camel-routebox/src/test/resources/log4j.properties (original)
+++ camel/trunk/components/camel-routebox/src/test/resources/log4j.properties Mon Jan 30 11:12:49 2012
@@ -1,20 +1,35 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
#
-# The logging properties used for eclipse testing, We want to see debug output on the console.
+# The logging properties used during tests..
#
-log4j.rootLogger=INFO, file
+log4j.rootLogger=INFO, out
-log4j.logger.org.springframework=WARN
-#log4j.logger.org.apache.camel=DEBUG
+#log4j.logger.org.apache.camel.component.routebox=DEBUG
# CONSOLE appender not used by default
-log4j.appender.out=org.apache.log4j.ConsoleAppender
-log4j.appender.out.layout=org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
-#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
# File appender
-log4j.appender.file=org.apache.log4j.FileAppender
-log4j.appender.file.layout=org.apache.log4j.PatternLayout
-log4j.appender.file.layout.ConversionPattern=%d %-5p %c{1} - %m %n
-log4j.appender.file.file=target/camel-routebox.log
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.out.file=target/camel-routebox-test.log
+log4j.appender.out.append=true
Propchange: camel/trunk/components/camel-ssh/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jan 30 11:12:49 2012
@@ -0,0 +1,17 @@
+.pmd
+.checkstyle
+.ruleset
+target
+.settings
+.classpath
+.project
+.wtpmodules
+prj.el
+.jdee_classpath
+.jdee_sources
+velocity.log
+eclipse-classes
+*.ipr
+*.iml
+*.iws
+*.idea
Added: camel/trunk/components/camel-ssh/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ssh/pom.xml?rev=1237603&view=auto
==============================================================================
--- camel/trunk/components/camel-ssh/pom.xml (added)
+++ camel/trunk/components/camel-ssh/pom.xml Mon Jan 30 11:12:49 2012
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-parent</artifactId>
+ <version>2.10-SNAPSHOT</version>
+ <relativePath>../../parent</relativePath>
+ </parent>
+
+ <artifactId>camel-ssh</artifactId>
+ <packaging>bundle</packaging>
+ <name>Camel :: SSH</name>
+ <description>Camel SSH support</description>
+
+ <properties>
+ <camel.osgi.export.pkg>org.apache.camel.component.ssh.*</camel.osgi.export.pkg>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.mina</groupId>
+ <artifactId>mina-core</artifactId>
+ <version>${mina2-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sshd</groupId>
+ <artifactId>sshd-core</artifactId>
+ <version>${sshd-version}</version>
+ </dependency>
+
+ <!-- for testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcpg-jdk16</artifactId>
+ <version>${bouncycastle-version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- logging -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
Propchange: camel/trunk/components/camel-ssh/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-ssh/pom.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: camel/trunk/components/camel-ssh/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshComponent.java?rev=1237603&view=auto
==============================================================================
--- camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshComponent.java (added)
+++ camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshComponent.java Mon Jan 30 11:12:49 2012
@@ -0,0 +1,121 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ssh;
+
+import java.net.URI;
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.DefaultComponent;
+import org.apache.sshd.common.KeyPairProvider;
+
+/**
+ * Represents the component that manages {@link SshEndpoint}.
+ */
+public class SshComponent extends DefaultComponent {
+ private SshConfiguration configuration;
+
+ @Override
+ protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+ SshConfiguration newConfig;
+
+ if (configuration == null) {
+ newConfig = new SshConfiguration(new URI(uri));
+ } else {
+ newConfig = configuration.copy();
+ }
+
+ SshEndpoint endpoint = new SshEndpoint(uri, this, newConfig);
+ setProperties(endpoint.getConfiguration(), parameters);
+ return endpoint;
+ }
+
+ public SshConfiguration getConfiguration() {
+ if (configuration == null) {
+ configuration = new SshConfiguration();
+ }
+ return configuration;
+ }
+
+ public void setConfiguration(SshConfiguration configuration) {
+ this.configuration = configuration;
+ }
+
+ public String getHost() {
+ return getConfiguration().getHost();
+ }
+
+ public void setHost(String host) {
+ getConfiguration().setHost(host);
+ }
+
+ public int getPort() {
+ return getConfiguration().getPort();
+ }
+
+ public void setPort(int port) {
+ getConfiguration().setPort(port);
+ }
+
+ public String getUsername() {
+ return getConfiguration().getUsername();
+ }
+
+ public void setUsername(String username) {
+ getConfiguration().setUsername(username);
+ }
+
+ public String getPassword() {
+ return getConfiguration().getPassword();
+ }
+
+ public void setPassword(String password) {
+ getConfiguration().setPassword(password);
+ }
+
+ public String getPollCommand() {
+ return getConfiguration().getPollCommand();
+ }
+
+ public void setPollCommand(String pollCommand) {
+ getConfiguration().setPollCommand(pollCommand);
+ }
+
+ public KeyPairProvider getKeyPairProvider() {
+ return getConfiguration().getKeyPairProvider();
+ }
+
+ public void setKeyPairProvider(KeyPairProvider keyPairProvider) {
+ getConfiguration().setKeyPairProvider(keyPairProvider);
+ }
+
+ public String getKeyType() {
+ return getConfiguration().getKeyType();
+ }
+
+ public void setKeyType(String keyType) {
+ getConfiguration().setKeyType(keyType);
+ }
+
+ public long getTimeout() {
+ return getConfiguration().getTimeout();
+ }
+
+ public void setTimeout(long timeout) {
+ getConfiguration().setTimeout(timeout);
+ }
+}
Propchange: camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshComponent.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshComponent.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshConfiguration.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshConfiguration.java?rev=1237603&view=auto
==============================================================================
--- camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshConfiguration.java (added)
+++ camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshConfiguration.java Mon Jan 30 11:12:49 2012
@@ -0,0 +1,189 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ssh;
+
+import java.net.URI;
+
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.sshd.common.KeyPairProvider;
+
+public class SshConfiguration implements Cloneable {
+ public static final int DEFAULT_SSH_PORT = 22;
+
+ private String username;
+ private String host;
+ private int port = DEFAULT_SSH_PORT;
+ private String password;
+ private String pollCommand;
+ private KeyPairProvider keyPairProvider;
+ private String keyType;
+ private long timeout = 30000;
+
+ public SshConfiguration() {
+ }
+
+ public SshConfiguration(URI uri) {
+ configure(uri);
+ }
+
+ public void configure(URI uri) {
+ // UserInfo can contain both username and password as: user:pwd@sshserver
+ // see: http://en.wikipedia.org/wiki/URI_scheme
+ String username = uri.getUserInfo();
+ String pw = null;
+ if (username != null && username.contains(":")) {
+ pw = ObjectHelper.after(username, ":");
+ username = ObjectHelper.before(username, ":");
+ }
+ if (username != null) {
+ setUsername(username);
+ }
+ if (pw != null) {
+ setPassword(pw);
+ }
+
+ setHost(uri.getHost());
+
+ // URI.getPort returns -1 if port not defined, else use default port
+ int uriPort = uri.getPort();
+ if (uriPort != -1) {
+ setPort(uriPort);
+ }
+ }
+
+ public SshConfiguration copy() {
+ try {
+ return (SshConfiguration) clone();
+ } catch (CloneNotSupportedException e) {
+ throw new RuntimeCamelException(e);
+ }
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ /**
+ * Sets the username to use in logging into the remote SSH server.
+ *
+ * @param username String representing login username.
+ */
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ /**
+ * Sets the hostname of the remote SSH server.
+ *
+ * @param host String representing hostname of SSH server.
+ */
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ /**
+ * Sets the port number for the remote SSH server.
+ *
+ * @param port int representing port number on remote host. Defaults to 22.
+ */
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ /**
+ * 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.
+ */
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getPollCommand() {
+ return pollCommand;
+ }
+
+ /**
+ * Sets the command string to send to the remote SSH server during every poll cycle.
+ * Only works with camel-ssh component being used as a consumer, i.e. from("ssh://...")
+ *
+ * @param pollCommand String representing the command to send.
+ */
+ public void setPollCommand(String pollCommand) {
+ this.pollCommand = pollCommand;
+ }
+
+ public KeyPairProvider getKeyPairProvider() {
+ return keyPairProvider;
+ }
+
+ /**
+ * 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.
+ *
+ * @see KeyPairProvider
+ */
+ public void setKeyPairProvider(KeyPairProvider keyPairProvider) {
+ this.keyPairProvider = keyPairProvider;
+ }
+
+ public String getKeyType() {
+ return keyType;
+ }
+
+ /**
+ * Sets the key type to pass to the KeyPairProvider as part of authentication.
+ * KeyPairProvider.loadKey(...) will be passed this value.
+ *
+ * @param keyType String defining the type of KeyPair to use for authentication.
+ *
+ * @see KeyPairProvider
+ */
+ public void setKeyType(String keyType) {
+ this.keyType = keyType;
+ }
+
+ public long getTimeout() {
+ return timeout;
+ }
+
+ /**
+ * Sets the timeout in milliseconds to wait in establishing the remote SSH server connection.
+ * Defaults to 30000 milliseconds.
+ *
+ * @param timeout long millisconeds to wait.
+ */
+ public void setTimeout(long timeout) {
+ this.timeout = timeout;
+ }
+}
Propchange: camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshConfiguration.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshConfiguration.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshConsumer.java?rev=1237603&view=auto
==============================================================================
--- camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshConsumer.java (added)
+++ camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshConsumer.java Mon Jan 30 11:12:49 2012
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ssh;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.impl.ScheduledPollConsumer;
+
+public class SshConsumer extends ScheduledPollConsumer {
+ private final SshEndpoint endpoint;
+
+ public SshConsumer(SshEndpoint endpoint, Processor processor) {
+ super(endpoint, processor);
+ this.endpoint = endpoint;
+ }
+
+ @Override
+ protected int poll() throws Exception {
+ String command = endpoint.getPollCommand();
+ byte[] result = endpoint.sendExecCommand(command);
+
+ Exchange exchange = endpoint.createExchange();
+ exchange.getIn().setBody(result);
+
+ try {
+ // send message to next processor in the route
+ getProcessor().process(exchange);
+ return 1; // number of messages polled
+ } finally {
+ // log exception if an exception occurred and was not handled
+ if (exchange.getException() != null) {
+ getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException());
+ }
+ }
+ }
+}
Propchange: camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshConsumer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshEndpoint.java?rev=1237603&view=auto
==============================================================================
--- camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshEndpoint.java (added)
+++ camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshEndpoint.java Mon Jan 30 11:12:49 2012
@@ -0,0 +1,227 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ssh;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.security.KeyPair;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.impl.ScheduledPollEndpoint;
+import org.apache.sshd.ClientChannel;
+import org.apache.sshd.ClientSession;
+import org.apache.sshd.SshClient;
+import org.apache.sshd.client.future.AuthFuture;
+import org.apache.sshd.client.future.ConnectFuture;
+import org.apache.sshd.client.future.OpenFuture;
+import org.apache.sshd.common.KeyPairProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Represents an SSH endpoint.
+ */
+public class SshEndpoint extends ScheduledPollEndpoint {
+ protected final transient Logger log = LoggerFactory.getLogger(getClass());
+
+ private SshClient client;
+ private SshConfiguration sshConfiguration;
+
+ public SshEndpoint() {
+ }
+
+ public SshEndpoint(String uri, SshComponent component) {
+ super(uri, component);
+ }
+
+ public SshEndpoint(String uri, SshComponent component, SshConfiguration configuration) {
+ super(uri, component);
+ this.sshConfiguration = configuration;
+ }
+
+ @Override
+ public Producer createProducer() throws Exception {
+ return new SshProducer(this);
+ }
+
+ @Override
+ public Consumer createConsumer(Processor processor) throws Exception {
+ SshConsumer consumer = new SshConsumer(this, processor);
+ configureConsumer(consumer);
+ return consumer;
+ }
+
+ @Override
+ public boolean isSingleton() {
+ // SshClient is not thread-safe to be shared
+ return false;
+ }
+
+ public byte[] sendExecCommand(String command) throws Exception {
+ byte[] result = null;
+
+ if (getConfiguration() == null) {
+ throw new IllegalStateException("Configuration must be set");
+ }
+
+ ConnectFuture connectFuture = client.connect(getHost(), getPort());
+
+ // Wait getTimeout milliseconds for connect operation to complete
+ connectFuture.await(getTimeout());
+
+ if (!connectFuture.isDone() || !connectFuture.isConnected()) {
+ final String msg = "Failed to connect to " + getHost() + ":" + getPort() + " within timeout " + getTimeout() + "ms";
+ log.debug(msg);
+ throw new RuntimeCamelException(msg);
+ }
+
+ log.debug("Connected to {}:{}", getHost(), getPort());
+
+ AuthFuture authResult;
+ ClientSession session = connectFuture.getSession();
+
+ final KeyPairProvider keyPairProvider = getKeyPairProvider();
+ if (keyPairProvider != null) {
+ log.debug("Attempting to authenticate username '{}' using Key...", getUsername());
+ KeyPair pair = keyPairProvider.loadKey(getKeyType());
+ authResult = session.authPublicKey(getUsername(), pair);
+ } else {
+ log.debug("Attempting to authenticate username '{}' using Password...", getUsername());
+ authResult = session.authPassword(getUsername(), getPassword());
+ }
+
+ authResult.await(getTimeout());
+
+ if (!authResult.isDone() || authResult.isFailure()) {
+ log.debug("Failed to authenticate");
+ throw new RuntimeCamelException("Failed to authenticate username " + getUsername());
+ }
+
+ ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_EXEC, command);
+
+ ByteArrayInputStream in = new ByteArrayInputStream(new byte[]{0});
+ channel.setIn(in);
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ channel.setOut(out);
+
+ ByteArrayOutputStream err = new ByteArrayOutputStream();
+ channel.setErr(err);
+
+ OpenFuture openFuture = channel.open();
+ openFuture.await(getTimeout());
+ if (openFuture.isOpened()) {
+ channel.waitFor(ClientChannel.CLOSED, 0);
+ result = out.toByteArray();
+ }
+
+ return result;
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ super.doStart();
+
+ client = SshClient.setUpDefaultClient();
+ client.start();
+ }
+
+ @Override
+ protected void doStop() throws Exception {
+ if (client != null) {
+ client.stop();
+ client = null;
+ }
+
+ super.doStop();
+ }
+
+ public SshConfiguration getConfiguration() {
+ return sshConfiguration;
+ }
+
+ public void setConfiguration(SshConfiguration configuration) {
+ this.sshConfiguration = configuration;
+ }
+
+ public String getHost() {
+ return getConfiguration().getHost();
+ }
+
+ public void setHost(String host) {
+ getConfiguration().setHost(host);
+ }
+
+ public int getPort() {
+ return getConfiguration().getPort();
+ }
+
+ public void setPort(int port) {
+ getConfiguration().setPort(port);
+ }
+
+ public String getUsername() {
+ return getConfiguration().getUsername();
+ }
+
+ public void setUsername(String username) {
+ getConfiguration().setUsername(username);
+ }
+
+ public String getPassword() {
+ return getConfiguration().getPassword();
+ }
+
+ public void setPassword(String password) {
+ getConfiguration().setPassword(password);
+ }
+
+ public String getPollCommand() {
+ return getConfiguration().getPollCommand();
+ }
+
+ public void setPollCommand(String pollCommand) {
+ getConfiguration().setPollCommand(pollCommand);
+ }
+
+ public KeyPairProvider getKeyPairProvider() {
+ return getConfiguration().getKeyPairProvider();
+ }
+
+ public void setKeyPairProvider(KeyPairProvider keyPairProvider) {
+ getConfiguration().setKeyPairProvider(keyPairProvider);
+ }
+
+ public String getKeyType() {
+ return getConfiguration().getKeyType();
+ }
+
+ public void setKeyType(String keyType) {
+ getConfiguration().setKeyType(keyType);
+ }
+
+ public long getTimeout() {
+ return getConfiguration().getTimeout();
+ }
+
+ public void setTimeout(long timeout) {
+ getConfiguration().setTimeout(timeout);
+ }
+}
Propchange: camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshEndpoint.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshEndpoint.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshProducer.java?rev=1237603&view=auto
==============================================================================
--- camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshProducer.java (added)
+++ camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshProducer.java Mon Jan 30 11:12:49 2012
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ssh;
+
+import org.apache.camel.CamelExchangeException;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.impl.DefaultProducer;
+
+public class SshProducer extends DefaultProducer {
+ private SshEndpoint endpoint;
+
+ public SshProducer(SshEndpoint endpoint) {
+ super(endpoint);
+ this.endpoint = endpoint;
+ }
+
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ final Message in = exchange.getIn();
+ String command = in.getMandatoryBody(String.class);
+
+ try {
+ byte[] result = endpoint.sendExecCommand(command);
+ exchange.getOut().setBody(result);
+ } catch (Exception e) {
+ throw new CamelExchangeException("Cannot execute command: " + command, exchange, e);
+ }
+
+ // propagate headers and attachments
+ exchange.getOut().getHeaders().putAll(in.getHeaders());
+ exchange.getOut().setAttachments(in.getAttachments());
+ }
+}
\ No newline at end of file
Propchange: camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshProducer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshProducer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/package.html
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/package.html?rev=1237603&view=auto
==============================================================================
--- camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/package.html (added)
+++ camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/package.html Mon Jan 30 11:12:49 2012
@@ -0,0 +1,25 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<html>
+<head>
+</head>
+<body>
+
+Defines the <a href="http://camel.apache.org/ssh.html">SSH Component</a>
+
+</body>
+</html>
Propchange: camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/package.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/package.html
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: camel/trunk/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/package.html
------------------------------------------------------------------------------
svn:mime-type = text/html
Added: camel/trunk/components/camel-ssh/src/main/resources/META-INF/services/org/apache/camel/component/ssh
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ssh/src/main/resources/META-INF/services/org/apache/camel/component/ssh?rev=1237603&view=auto
==============================================================================
--- camel/trunk/components/camel-ssh/src/main/resources/META-INF/services/org/apache/camel/component/ssh (added)
+++ camel/trunk/components/camel-ssh/src/main/resources/META-INF/services/org/apache/camel/component/ssh Mon Jan 30 11:12:49 2012
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+class=org.apache.camel.component.ssh.SshComponent
Added: camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/BogusPasswordAuthenticator.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/BogusPasswordAuthenticator.java?rev=1237603&view=auto
==============================================================================
--- camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/BogusPasswordAuthenticator.java (added)
+++ camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/BogusPasswordAuthenticator.java Mon Jan 30 11:12:49 2012
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ssh;
+
+import org.apache.sshd.server.PasswordAuthenticator;
+import org.apache.sshd.server.session.ServerSession;
+
+public class BogusPasswordAuthenticator implements PasswordAuthenticator {
+
+ @Override
+ public boolean authenticate(String username, String password, ServerSession session) {
+ return username != null && username.equals(password);
+ }
+}
Propchange: camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/BogusPasswordAuthenticator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/BogusPasswordAuthenticator.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/BogusPublickeyAuthenticator.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/BogusPublickeyAuthenticator.java?rev=1237603&view=auto
==============================================================================
--- camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/BogusPublickeyAuthenticator.java (added)
+++ camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/BogusPublickeyAuthenticator.java Mon Jan 30 11:12:49 2012
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ssh;
+
+import java.security.PublicKey;
+
+import org.apache.sshd.server.PublickeyAuthenticator;
+import org.apache.sshd.server.session.ServerSession;
+
+public class BogusPublickeyAuthenticator implements PublickeyAuthenticator {
+
+ @Override
+ public boolean authenticate(String username, PublicKey key, ServerSession session) {
+ return true;
+ }
+}
Propchange: camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/BogusPublickeyAuthenticator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/BogusPublickeyAuthenticator.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/EchoCommandFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/EchoCommandFactory.java?rev=1237603&view=auto
==============================================================================
--- camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/EchoCommandFactory.java (added)
+++ camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/EchoCommandFactory.java Mon Jan 30 11:12:49 2012
@@ -0,0 +1,90 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ssh;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.sshd.server.Command;
+import org.apache.sshd.server.CommandFactory;
+import org.apache.sshd.server.Environment;
+import org.apache.sshd.server.ExitCallback;
+
+public class EchoCommandFactory implements CommandFactory {
+
+ @Override
+ public Command createCommand(String command) {
+ return new EchoCommand(command);
+ }
+
+ protected static class EchoCommand implements Command, Runnable {
+ private String command;
+ private InputStream in;
+ private OutputStream out;
+ private OutputStream err;
+ private ExitCallback callback;
+ private Thread thread;
+
+ public EchoCommand(String command) {
+ this.command = command;
+ }
+
+ @Override
+ public void setInputStream(InputStream in) {
+ this.in = in;
+ }
+
+ @Override
+ public void setOutputStream(OutputStream out) {
+ this.out = out;
+ }
+
+ @Override
+ public void setErrorStream(OutputStream err) {
+ this.err = err;
+ }
+
+ @Override
+ public void setExitCallback(ExitCallback callback) {
+ this.callback = callback;
+ }
+
+ @Override
+ public void start(Environment env) throws IOException {
+ thread = new Thread(this, "EchoCommand");
+ thread.start();
+ }
+
+ @Override
+ public void destroy() {
+ thread.interrupt();
+ }
+
+ @Override
+ public void run() {
+ try {
+ out.write(command.getBytes());
+ out.flush();
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ callback.onExit(0);
+ }
+ }
+ }
+}
Propchange: camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/EchoCommandFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/EchoCommandFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentConsumerTest.java?rev=1237603&view=auto
==============================================================================
--- camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentConsumerTest.java (added)
+++ camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentConsumerTest.java Mon Jan 30 11:12:49 2012
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ssh;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+public class SshComponentConsumerTest extends SshComponentTestSupport {
+
+ @Test
+ public void testPollingConsumer() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMinimumMessageCount(1);
+ mock.expectedBodiesReceived("test\r");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("ssh://smx:smx@localhost:" + port + "?useFixedDelay=true&delay=5000&pollCommand=test%0D")
+ .to("mock:result");
+ }
+ };
+ }
+}
Propchange: camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentConsumerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentConsumerTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentErrorHandlingTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentErrorHandlingTest.java?rev=1237603&view=auto
==============================================================================
--- camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentErrorHandlingTest.java (added)
+++ camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentErrorHandlingTest.java Mon Jan 30 11:12:49 2012
@@ -0,0 +1,81 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ssh;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+public class SshComponentErrorHandlingTest extends SshComponentTestSupport {
+
+ @Test
+ public void testRedelivery() throws Exception {
+ final String msg = "test\n";
+
+ MockEndpoint mockError = getMockEndpoint("mock:error");
+ mockError.expectedMinimumMessageCount(0);
+
+ MockEndpoint mock = getMockEndpoint("mock:success");
+ mock.expectedMinimumMessageCount(1);
+ mock.expectedBodiesReceived(msg);
+ mock.expectedHeaderReceived(Exchange.REDELIVERED, true);
+
+ sshd.stop();
+
+ template.sendBody("direct:redeliver", msg);
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ errorHandler(deadLetterChannel("mock:error")
+ .maximumRedeliveries(3)
+ .redeliveryDelay(0L) // speedup unit test by not waiting between redeliveries
+ .onRedelivery(new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ final Message in = exchange.getIn();
+ final int count = in.getHeader(Exchange.REDELIVERY_COUNTER, Integer.class);
+ final int maxCount = in.getHeader(Exchange.REDELIVERY_MAX_COUNTER, Integer.class);
+
+ log.info("Redelivery count = {}", count);
+
+ // Restart the sshd server before the last redelivery attempt
+ if (count >= (maxCount - 1)) {
+ if (sshd != null) {
+ sshd.start();
+ log.info("Restarting SSHD");
+ }
+ }
+ }
+ }));
+
+ from("direct:redeliver")
+ .tracing()
+ .to("ssh://smx:smx@localhost:" + port)
+ .to("mock:success");
+ }
+ };
+ }
+}
Propchange: camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentErrorHandlingTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentErrorHandlingTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentProducerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentProducerTest.java?rev=1237603&view=auto
==============================================================================
--- camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentProducerTest.java (added)
+++ camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentProducerTest.java Mon Jan 30 11:12:49 2012
@@ -0,0 +1,123 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ssh;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.sshd.common.KeyPairProvider;
+import org.apache.sshd.common.keyprovider.FileKeyPairProvider;
+import org.junit.Test;
+
+public class SshComponentProducerTest extends SshComponentTestSupport {
+
+ @Test
+ public void testProducer() throws Exception {
+ final String msg = "test\n";
+
+ MockEndpoint mock = getMockEndpoint("mock:password");
+ mock.expectedMinimumMessageCount(1);
+ mock.expectedBodiesReceived(msg);
+
+ template.sendBody("direct:ssh", msg);
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Test
+ public void testReconnect() throws Exception {
+ final String msg = "test\n";
+
+ MockEndpoint mock = getMockEndpoint("mock:password");
+ mock.expectedMinimumMessageCount(1);
+ mock.expectedBodiesReceived(msg);
+
+ template.sendBody("direct:ssh", msg);
+
+ assertMockEndpointsSatisfied();
+
+ sshd.stop();
+ sshd.start();
+
+ mock.reset();
+ mock.expectedMinimumMessageCount(1);
+ mock.expectedBodiesReceived(msg);
+
+ template.sendBody("direct:ssh", msg);
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Test
+ public void testRsa() throws Exception {
+ final String msg = "test\n";
+
+ MockEndpoint mock = getMockEndpoint("mock:rsa");
+ mock.expectedMinimumMessageCount(1);
+ mock.expectedBodiesReceived(msg);
+
+ template.sendBody("direct:ssh-rsa", msg);
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Test
+ public void testConnectionTimeout() throws Exception {
+ final String msg = "test\n";
+
+ MockEndpoint mock = getMockEndpoint("mock:password");
+ mock.expectedMinimumMessageCount(0);
+
+ MockEndpoint mockError = getMockEndpoint("mock:error");
+ mockError.expectedMinimumMessageCount(1);
+
+ sshd.stop();
+ sshd = null;
+
+ template.sendBody("direct:ssh", msg);
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ onException(Exception.class)
+ .handled(true)
+ .to("mock:error");
+
+ from("direct:ssh")
+ .to("ssh://smx:smx@localhost:" + port + "?timeout=3000")
+ .to("mock:password");
+
+ SshComponent sshComponent = new SshComponent();
+ sshComponent.setHost("localhost");
+ sshComponent.setPort(port);
+ sshComponent.setUsername("smx");
+ sshComponent.setKeyPairProvider(new FileKeyPairProvider(new String[]{"src/test/resources/hostkey.pem"}));
+ sshComponent.setKeyType(KeyPairProvider.SSH_RSA);
+
+ getContext().addComponent("ssh-rsa", sshComponent);
+
+ from("direct:ssh-rsa")
+ .to("ssh-rsa:test")
+ .to("mock:rsa");
+ }
+ };
+ }
+}
Propchange: camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentProducerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentProducerTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentTestSupport.java?rev=1237603&view=auto
==============================================================================
--- camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentTestSupport.java (added)
+++ camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentTestSupport.java Mon Jan 30 11:12:49 2012
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ssh;
+
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.sshd.SshServer;
+import org.apache.sshd.common.keyprovider.FileKeyPairProvider;
+
+public class SshComponentTestSupport extends CamelTestSupport {
+ protected SshServer sshd;
+ protected int port;
+
+ @Override
+ public void setUp() throws Exception {
+ port = AvailablePortFinder.getNextAvailable(22000);
+
+ sshd = SshServer.setUpDefaultServer();
+ sshd.setPort(port);
+ sshd.setKeyPairProvider(new FileKeyPairProvider(new String[]{"src/test/resources/hostkey.pem"}));
+ sshd.setCommandFactory(new TestEchoCommandFactory());
+ sshd.setPasswordAuthenticator(new BogusPasswordAuthenticator());
+ sshd.setPublickeyAuthenticator(new BogusPublickeyAuthenticator());
+ sshd.start();
+
+ super.setUp();
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ if (sshd != null) {
+ sshd.stop(true);
+ Thread.sleep(50);
+ }
+ }
+}
Propchange: camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentTestSupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/SshComponentTestSupport.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/TestEchoCommandFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/TestEchoCommandFactory.java?rev=1237603&view=auto
==============================================================================
--- camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/TestEchoCommandFactory.java (added)
+++ camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/TestEchoCommandFactory.java Mon Jan 30 11:12:49 2012
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ssh;
+
+import java.util.concurrent.CountDownLatch;
+
+import org.apache.sshd.server.Command;
+
+public class TestEchoCommandFactory extends EchoCommandFactory {
+
+ @Override
+ public Command createCommand(String command) {
+ return new TestEchoCommand(command);
+ }
+
+ public static class TestEchoCommand extends EchoCommand {
+ public static CountDownLatch latch = new CountDownLatch(1);
+
+ public TestEchoCommand(String command) {
+ super(command);
+ }
+
+ @Override
+ public void destroy() {
+ if (latch != null) {
+ latch.countDown();
+ }
+ super.destroy();
+ }
+ }
+}
\ No newline at end of file
Propchange: camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/TestEchoCommandFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/TestEchoCommandFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-ssh/src/test/resources/dsaprivkey.pem
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ssh/src/test/resources/dsaprivkey.pem?rev=1237603&view=auto
==============================================================================
--- camel/trunk/components/camel-ssh/src/test/resources/dsaprivkey.pem (added)
+++ camel/trunk/components/camel-ssh/src/test/resources/dsaprivkey.pem Mon Jan 30 11:12:49 2012
@@ -0,0 +1,12 @@
+-----BEGIN DSA PRIVATE KEY-----
+MIIBuwIBAAKBgQDEA7leYDKyJOFJU3h0uPpWN52iTpJk8+IM53Vc/91k7pBIjjka
++MP24BMh+sI2SRhxg2AtvwnzRRBVJWzEA4+tuCI6WukgeDQtSNp3YuWzOMefZ6Wb
+SAk1Y4goZb7nyqV9HZSFNSqUFQRZM10L768VURBlerNqR//GqdVd8bp7lwIVAM39
+h6x2DeXbqUM8iOi01bh5jpLFAoGAEi1oFGFMEZXH/hCX+Y2VE5WvR+fBaoS9WuZl
+3E0wsWPzQhbL13yD+6Htxd3XoQvrHnzyrIgi2AiAmr3mLokQbZ3d92IxEBcNB/0p
+nVi020TXSeD/lWkpk5FRvgBiJ82/LeC2Lj6cssznX73aLUhR0tsSoJoXxas0sQKa
+/UJgq5wCgYAtgeY99J0JxplWGSyGY/1DUpgzhdgpLdDA/o/qIjBEeHXN0QX4Ajoa
+vHggJ2SwNtAxbQedBxqmB3mquFRtpfEP5zGzsVx5HHnljSH8u0SqEoLnYKFpluwh
+tZ/Q3F2NHslXw8Hw+pIaPe4PAINQPAu3U+BknNUkGpLg8zU6h5+B+wIVAKRqeps1
+Xl7MxZcSZp7FnmmmMecB
+-----END DSA PRIVATE KEY-----
Added: camel/trunk/components/camel-ssh/src/test/resources/hostkey.pem
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ssh/src/test/resources/hostkey.pem?rev=1237603&view=auto
==============================================================================
--- camel/trunk/components/camel-ssh/src/test/resources/hostkey.pem (added)
+++ camel/trunk/components/camel-ssh/src/test/resources/hostkey.pem Mon Jan 30 11:12:49 2012
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICXAIBAAKBgQDdfIWeSV4o68dRrKSzFd/Bk51E65UTmmSrmW0O1ohtzi6HzsDP
+jXgCtlTt3FqTcfFfI92IlTr4JWqC9UK1QT1ZTeng0MkPQmv68hDANHbt5CpETZHj
+W5q4OOgWhVvj5IyOC2NZHtKlJBkdsMAa15ouOOJLzBvAvbqOR/yUROsEiQIDAQAB
+AoGBANG3JDW6NoP8rF/zXoeLgLCj+tfVUPSczhGFVrQkAk4mWfyRkhN0WlwHFOec
+K89MpkV1ij/XPVzU4MNbQ2yod1KiDylzvweYv+EaEhASCmYNs6LS03punml42SL9
+97tOmWfVJXxlQoLiY6jHPU97vTc65k8gL+gmmrpchsW0aqmZAkEA/c8zfmKvY37T
+cxcLLwzwsqqH7g2KZGTf9aRmx2ebdW+QKviJJhbdluDgl1TNNFj5vCLznFDRHiqJ
+wq0wkZ39cwJBAN9l5v3kdXj21UrurNPdlV0n2GZBt2vblooQC37XHF97r2zM7Ou+
+Lg6MyfJClyguhWL9dxnGbf3btQ0l3KDstxMCQCRaiEqjAfIjWVATzeNIXDWLHXso
+b1kf5cA+cwY+vdKdTy4IeUR+Y/DXdvPWDqpf0C11aCVMohdLCn5a5ikFUycCQDhV
+K/BuAallJNfmY7JxN87r00fF3ojWMJnT/fIYMFFrkQrwifXQWTDWE76BSDibsosJ
+u1TGksnm8zrDh2UVC/0CQFrHTiSl/3DHvWAbOJawGKg46cnlDcAhSyV8Frs8/dlP
+7YGG3eqkw++lsghqmFO6mRUTKsBmiiB2wgLGhL5pyYY=
+-----END RSA PRIVATE KEY-----
Added: camel/trunk/components/camel-ssh/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ssh/src/test/resources/log4j.properties?rev=1237603&view=auto
==============================================================================
--- camel/trunk/components/camel-ssh/src/test/resources/log4j.properties (added)
+++ camel/trunk/components/camel-ssh/src/test/resources/log4j.properties Mon Jan 30 11:12:49 2012
@@ -0,0 +1,35 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=INFO, out
+
+#log4j.logger.org.apache.camel.component.ssh=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.out.file=target/camel-ssh-test.log
+log4j.appender.out.append=true
Propchange: camel/trunk/components/camel-ssh/src/test/resources/log4j.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-ssh/src/test/resources/log4j.properties
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: camel/trunk/components/camel-ssh/src/test/resources/log4j.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: camel/trunk/components/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/pom.xml?rev=1237603&r1=1237602&r2=1237603&view=diff
==============================================================================
--- camel/trunk/components/pom.xml (original)
+++ camel/trunk/components/pom.xml Mon Jan 30 11:12:49 2012
@@ -136,6 +136,7 @@
<module>camel-spring-security</module>
<module>camel-spring-ws</module>
<module>camel-sql</module>
+ <module>camel-ssh</module>
<module>camel-stax</module>
<module>camel-stream</module>
<module>camel-stringtemplate</module>
Propchange: camel/trunk/examples/camel-example-ssh/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jan 30 11:12:49 2012
@@ -0,0 +1,17 @@
+.pmd
+.checkstyle
+.ruleset
+target
+.settings
+.classpath
+.project
+.wtpmodules
+prj.el
+.jdee_classpath
+.jdee_sources
+velocity.log
+eclipse-classes
+*.ipr
+*.iml
+*.iws
+*.idea
Added: camel/trunk/examples/camel-example-ssh/README.txt
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-ssh/README.txt?rev=1237603&view=auto
==============================================================================
--- camel/trunk/examples/camel-example-ssh/README.txt (added)
+++ camel/trunk/examples/camel-example-ssh/README.txt Mon Jan 30 11:12:49 2012
@@ -0,0 +1,42 @@
+SSH Example
+=====================
+
+This example shows how use SSH with Camel. It can be run using Maven.
+
+This example is built assuming you have a running Apache ServiceMix container with the default SSH port 8101 and
+username / password of smx/smx.
+
+Running from cmd line outside OSGi container
+============================================
+
+You will need to compile this example first:
+ mvn compile
+
+To run the example using Maven type
+ mvn camel:run
+
+To stop the example hit ctrl + c
+
+
+
+Running inside OSGi container
+=============================
+
+You will need to compile and install this example first:
+ mvn compile install
+
+If using Apache Karaf / Apache ServiceMix you can install this example
+from the shell
+
+ > features:addurl mvn:org.apache.camel/camel-example-ssh/<camel version>/xml/features
+ > features:install camel-example-ssh
+
+If you hit any problems please let us know on the Camel Forums
+ http://camel.apache.org/discussion-forums.html
+
+Please help us make Apache Camel better - we appreciate any feedback you
+may have. Enjoy!
+
+------------------------
+The Camel riders!
+
Propchange: camel/trunk/examples/camel-example-ssh/README.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/examples/camel-example-ssh/README.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: camel/trunk/examples/camel-example-ssh/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-ssh/pom.xml?rev=1237603&view=auto
==============================================================================
--- camel/trunk/examples/camel-example-ssh/pom.xml (added)
+++ camel/trunk/examples/camel-example-ssh/pom.xml Mon Jan 30 11:12:49 2012
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>examples</artifactId>
+ <version>2.10-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <artifactId>camel-example-ssh</artifactId>
+ <packaging>bundle</packaging>
+ <name>Camel :: Example :: SSH</name>
+ <description>A simple SSH example which creates a bundle that can be dropped into any OSGi container</description>
+
+ <properties>
+ <camel.osgi.export.pkg>org.apache.camel.example.ssh.*</camel.osgi.export.pkg>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-ssh</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.mina</groupId>
+ <artifactId>mina-core</artifactId>
+ <version>${mina2-version}</version>
+ </dependency>
+
+ <!-- used for mvn camel:run -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>${slf4j-version}</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <!-- to generate the MANIFEST-FILE of the bundle -->
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Import-Package>
+ org.apache.camel.component.ssh,
+ *
+ </Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-artifacts</id>
+ <phase>package</phase>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>target/classes/features.xml</file>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- Allows the routes to be run via 'mvn camel:run' -->
+ <plugin>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+
+ </build>
+
+</project>
Propchange: camel/trunk/examples/camel-example-ssh/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/examples/camel-example-ssh/pom.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: camel/trunk/examples/camel-example-ssh/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml