(GSHELL-163) Upgrade to org.apache.sshd 0.1.0
git-svn-id: https://svn.apache.org/repos/asf/geronimo/gshell/trunk@787966 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/gshell-assembly/src/main/underlay/etc/application.xml b/gshell-assembly/src/main/underlay/etc/application.xml
index 131ae8b..1330794 100644
--- a/gshell-assembly/src/main/underlay/etc/application.xml
+++ b/gshell-assembly/src/main/underlay/etc/application.xml
@@ -29,7 +29,10 @@
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="properties">
<props>
- <prop key="gshell.version">1.0-alpha-2-SNAPSHOT</prop>
+ <!--
+ FIXME: Use filtering to automatically keep this updated.
+ -->
+ <prop key="gshell.version">1.0-alpha-3-SNAPSHOT</prop>
</props>
</property>
</bean>
diff --git a/gshell-commands/gshell-ssh/pom.xml b/gshell-commands/gshell-ssh/pom.xml
index 38a0947..dce8265 100644
--- a/gshell-commands/gshell-ssh/pom.xml
+++ b/gshell-commands/gshell-ssh/pom.xml
@@ -37,35 +37,6 @@
SSH support.
</description>
- <repositories>
- <repository>
- <id>sshd.releases</id>
- <name>SSHD Repository</name>
- <url>http://sshd.googlecode.com/svn/m2-repo/</url>
- <layout>default</layout>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <releases>
- <enabled>true</enabled>
- </releases>
- </repository>
- <repository>
- <id>sshd.snapshots</id>
- <name>SSHD Repository</name>
- <url>http://sshd.googlecode.com/svn/m2-snapshot-repo/</url>
- <layout>default</layout>
- <snapshots>
- <enabled>true</enabled>
- <updatePolicy>daily</updatePolicy>
- <checksumPolicy>ignore</checksumPolicy>
- </snapshots>
- <releases>
- <enabled>false</enabled>
- </releases>
- </repository>
- </repositories>
-
<dependencies>
<dependency>
<groupId>org.apache.geronimo.gshell</groupId>
@@ -88,9 +59,9 @@
</dependency>
<dependency>
- <groupId>com.google.code.sshd</groupId>
- <artifactId>sshd</artifactId>
- <version>0.1</version>
+ <groupId>org.apache.sshd</groupId>
+ <artifactId>sshd-core</artifactId>
+ <version>0.1.0</version>
</dependency>
</dependencies>
diff --git a/gshell-commands/gshell-ssh/src/main/java/org/apache/geronimo/gshell/commands/ssh/JSecurityPasswordAuthenticator.java b/gshell-commands/gshell-ssh/src/main/java/org/apache/geronimo/gshell/commands/ssh/JSecurityPasswordAuthenticator.java
index a036904..33b719c 100644
--- a/gshell-commands/gshell-ssh/src/main/java/org/apache/geronimo/gshell/commands/ssh/JSecurityPasswordAuthenticator.java
+++ b/gshell-commands/gshell-ssh/src/main/java/org/apache/geronimo/gshell/commands/ssh/JSecurityPasswordAuthenticator.java
@@ -19,7 +19,6 @@
package org.apache.geronimo.gshell.commands.ssh;
-import com.google.code.sshd.server.PasswordAuthenticator;
import org.jsecurity.SecurityUtils;
import org.jsecurity.authc.AuthenticationException;
import org.jsecurity.authc.UsernamePasswordToken;
@@ -27,6 +26,7 @@
import org.jsecurity.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.apache.sshd.server.PasswordAuthenticator;
/**
* <a href="http://jsecurity.org">JSecurity</a> {@link PasswordAuthenticator}.
diff --git a/gshell-commands/gshell-ssh/src/main/java/org/apache/geronimo/gshell/commands/ssh/ShellFactoryImpl.java b/gshell-commands/gshell-ssh/src/main/java/org/apache/geronimo/gshell/commands/ssh/ShellFactoryImpl.java
index 3306e42..d0d4660 100644
--- a/gshell-commands/gshell-ssh/src/main/java/org/apache/geronimo/gshell/commands/ssh/ShellFactoryImpl.java
+++ b/gshell-commands/gshell-ssh/src/main/java/org/apache/geronimo/gshell/commands/ssh/ShellFactoryImpl.java
@@ -19,9 +19,9 @@
package org.apache.geronimo.gshell.commands.ssh;
-import com.google.code.sshd.server.ShellFactory;
import jline.Completor;
import jline.History;
+import org.apache.geronimo.gshell.application.Application;
import org.apache.geronimo.gshell.command.Variables;
import org.apache.geronimo.gshell.commandline.CommandLineExecutor;
import org.apache.geronimo.gshell.console.Console;
@@ -30,10 +30,10 @@
import org.apache.geronimo.gshell.io.Closer;
import org.apache.geronimo.gshell.io.IO;
import org.apache.geronimo.gshell.notification.ExitNotification;
+import org.apache.geronimo.gshell.registry.CommandResolver;
import org.apache.geronimo.gshell.shell.ShellContext;
import org.apache.geronimo.gshell.shell.ShellContextHolder;
-import org.apache.geronimo.gshell.registry.CommandResolver;
-import org.apache.geronimo.gshell.application.Application;
+import org.apache.sshd.server.ShellFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -118,7 +118,7 @@
}
public class ShellImpl
- implements ShellFactory.DirectShell, org.apache.geronimo.gshell.shell.Shell, ShellContext, Runnable
+ implements ShellFactory.Shell, org.apache.geronimo.gshell.shell.Shell, ShellContext, Runnable
{
private InputStream in;
@@ -146,24 +146,26 @@
this.err = err;
}
- public void setExitCallback(ExitCallback callback) {
+ public void setExitCallback(final ExitCallback callback) {
this.callback = callback;
}
- public void start(final Map<String,String> env) throws IOException {
+ public void start(final Environment env) throws IOException {
this.io = new IO(in, out, err, false);
// Create variables, inheriting the application ones
this.variables = new Variables(application.getVariables());
// Set up additional env
if (env != null) {
- for (Map.Entry<String,String> entry : env.entrySet()) {
+ for (Map.Entry<String,String> entry : env.getEnv().entrySet()) {
this.variables.set(entry.getKey(), entry.getValue());
}
}
this.variables.set("gshell.prompt", application.getModel().getBranding().getPrompt());
this.variables.set(CommandResolver.GROUP, "/");
- this.variables.set("gshell.username", env.get("USER"));
+ if (env != null) {
+ this.variables.set("gshell.username", env.getEnv().get("USER"));
+ }
this.variables.set("gshell.hostname", application.getLocalHost());
// HACK: Add history for the 'history' command, since its not part of the Shell intf it can't really access it
this.variables.set("gshell.internal.history", getHistory(), true);
@@ -179,7 +181,6 @@
}
public Object execute(final String line) throws Exception {
-
return executor.execute(getContext(), line);
}
@@ -196,9 +197,11 @@
}
public void close() {
- closed = true;
- Closer.close(in, out, err);
- callback.onExit(0);
+ if (!closed) {
+ closed = true;
+ Closer.close(in, out, err);
+ callback.onExit(0);
+ }
}
public boolean isInteractive() {
diff --git a/gshell-commands/gshell-ssh/src/main/java/org/apache/geronimo/gshell/commands/ssh/SshAction.java b/gshell-commands/gshell-ssh/src/main/java/org/apache/geronimo/gshell/commands/ssh/SshAction.java
index 4897601..fea96c5 100644
--- a/gshell-commands/gshell-ssh/src/main/java/org/apache/geronimo/gshell/commands/ssh/SshAction.java
+++ b/gshell-commands/gshell-ssh/src/main/java/org/apache/geronimo/gshell/commands/ssh/SshAction.java
@@ -19,11 +19,6 @@
package org.apache.geronimo.gshell.commands.ssh;
-import com.google.code.sshd.ClientChannel;
-import com.google.code.sshd.ClientSession;
-import com.google.code.sshd.SshClient;
-import com.google.code.sshd.common.util.NoCloseInputStream;
-import com.google.code.sshd.common.util.NoCloseOutputStream;
import org.apache.geronimo.gshell.clp.Argument;
import org.apache.geronimo.gshell.clp.Option;
import org.apache.geronimo.gshell.command.CommandAction;
@@ -33,6 +28,13 @@
import org.apache.geronimo.gshell.io.PromptReader;
import org.apache.geronimo.gshell.spring.BeanContainer;
import org.apache.geronimo.gshell.spring.BeanContainerAware;
+import org.apache.sshd.SshClient;
+import org.apache.sshd.ClientSession;
+import org.apache.sshd.ClientChannel;
+import org.apache.sshd.client.future.ConnectFuture;
+import org.apache.sshd.common.util.NoCloseInputStream;
+import org.apache.sshd.common.util.NoCloseOutputStream;
+import org.apache.sshd.common.future.CloseFuture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -130,10 +132,13 @@
// Create the client from prototype
SshClient client = container.getBean(SshClient.class);
log.debug("Created client: {}", client);
- client.start();;
+ client.start();
try {
- ClientSession session = client.connect(hostname, port);
+ ConnectFuture future = client.connect(hostname, port);
+ future.await();
+ ClientSession session = future.getSession();
+
try {
io.info(messages.getMessage("info.connected"));
@@ -151,7 +156,8 @@
channel.open();
channel.waitFor(ClientChannel.CLOSED, 0);
} finally {
- session.close();
+ session.close(false);
+
}
} finally {
client.stop();
diff --git a/gshell-commands/gshell-ssh/src/main/java/org/apache/geronimo/gshell/commands/ssh/SshServerAction.java b/gshell-commands/gshell-ssh/src/main/java/org/apache/geronimo/gshell/commands/ssh/SshServerAction.java
index 49caadb..09ac568 100644
--- a/gshell-commands/gshell-ssh/src/main/java/org/apache/geronimo/gshell/commands/ssh/SshServerAction.java
+++ b/gshell-commands/gshell-ssh/src/main/java/org/apache/geronimo/gshell/commands/ssh/SshServerAction.java
@@ -19,7 +19,6 @@
package org.apache.geronimo.gshell.commands.ssh;
-import com.google.code.sshd.SshServer;
import org.apache.geronimo.gshell.clp.Option;
import org.apache.geronimo.gshell.command.CommandAction;
import org.apache.geronimo.gshell.command.CommandContext;
@@ -27,6 +26,7 @@
import org.apache.geronimo.gshell.io.IO;
import org.apache.geronimo.gshell.spring.BeanContainer;
import org.apache.geronimo.gshell.spring.BeanContainerAware;
+import org.apache.sshd.SshServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/gshell-commands/gshell-ssh/src/main/resources/META-INF/gshell/components.xml b/gshell-commands/gshell-ssh/src/main/resources/META-INF/gshell/components.xml
index 79188f4..3334121 100644
--- a/gshell-commands/gshell-ssh/src/main/resources/META-INF/gshell/components.xml
+++ b/gshell-commands/gshell-ssh/src/main/resources/META-INF/gshell/components.xml
@@ -45,10 +45,10 @@
</gshell:command-bundle>
</gshell:plugin>
- <bean name="sshClient" class="com.google.code.sshd.SshClient" factory-method="setUpDefaultClient" scope="prototype">
+ <bean name="sshClient" class="org.apache.sshd.SshClient" factory-method="setUpDefaultClient" scope="prototype">
</bean>
- <bean name="sshServer" class="com.google.code.sshd.SshServer" factory-method="setUpDefaultServer" scope="prototype">
+ <bean name="sshServer" class="org.apache.sshd.SshServer" factory-method="setUpDefaultServer" scope="prototype">
<property name="shellFactory">
<bean class="org.apache.geronimo.gshell.commands.ssh.ShellFactoryImpl">
<property name="application" ref="application" />
@@ -78,7 +78,7 @@
<property name="passwordAuthenticator" ref="passwordAuthenticator"/>
</bean>
- <bean name="keyPairProvider" class="com.google.code.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider"/>
+ <bean name="keyPairProvider" class="org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider"/>
<bean name="passwordAuthenticator" class="org.apache.geronimo.gshell.commands.ssh.JSecurityPasswordAuthenticator">
<constructor-arg ref="securityManager"/>