diff options
author | Mat Booth | 2020-04-07 13:14:27 +0000 |
---|---|---|
committer | Mat Booth | 2020-04-07 13:14:27 +0000 |
commit | b12e3e1e8ce4a40a10b59861027ddd6dce0cd28a (patch) | |
tree | 01a3ff4a2d8f2ba102d1e878a02292a0969c4d85 | |
parent | 4d64b3ef43e0b5eb34b9f5b900a7436432b79664 (diff) | |
download | rt.equinox.bundles-b12e3e1e8ce4a40a10b59861027ddd6dce0cd28a.tar.gz rt.equinox.bundles-b12e3e1e8ce4a40a10b59861027ddd6dce0cd28a.tar.xz rt.equinox.bundles-b12e3e1e8ce4a40a10b59861027ddd6dce0cd28a.zip |
Bug 561862 - Update console.ssh should to use sshd.osgi 2.4.0S4_16_0_M1I20200412-1800I20200411-1800I20200411-0950I20200411-0720I20200411-0510I20200411-0300I20200410-2300I20200410-1800I20200409-0200I20200408-1800
Change-Id: I443188250e377f3cf169a0974541d8106261c7bb
Signed-off-by: Mat Booth <mat.booth@redhat.com>
6 files changed, 51 insertions, 51 deletions
diff --git a/bundles/org.eclipse.equinox.console.ssh.tests/src/org/eclipse/equinox/console/ssh/SshShellTests.java b/bundles/org.eclipse.equinox.console.ssh.tests/src/org/eclipse/equinox/console/ssh/SshShellTests.java index 9534b0383..8e3a84c0e 100755 --- a/bundles/org.eclipse.equinox.console.ssh.tests/src/org/eclipse/equinox/console/ssh/SshShellTests.java +++ b/bundles/org.eclipse.equinox.console.ssh.tests/src/org/eclipse/equinox/console/ssh/SshShellTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2018 SAP AG and others. + * Copyright (c) 2011, 2020 SAP AG and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -28,6 +28,7 @@ import java.util.Map; import org.apache.felix.service.command.CommandProcessor; import org.apache.felix.service.command.CommandSession; import org.apache.sshd.server.Environment; +import org.apache.sshd.server.channel.ChannelSession; import org.easymock.EasyMock; import org.eclipse.equinox.console.common.ConsoleInputStream; import org.eclipse.equinox.console.storage.DigestUtil; @@ -94,7 +95,7 @@ public class SshShellTests { shell = new SshShell(processors, context); shell.setInputStream(socketServer.getInputStream()); shell.setOutputStream(socketServer.getOutputStream()); - shell.start(env); + shell.start(new ChannelSession(), env); } try (OutputStream outClient = socketClient.getOutputStream()) { diff --git a/bundles/org.eclipse.equinox.console.ssh/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.console.ssh/META-INF/MANIFEST.MF index 47d889ae6..e092a3d27 100644 --- a/bundles/org.eclipse.equinox.console.ssh/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.console.ssh/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %bundleName Bundle-SymbolicName: org.eclipse.equinox.console.ssh -Bundle-Version: 1.2.500.qualifier +Bundle-Version: 1.2.600.qualifier Bundle-Activator: org.eclipse.equinox.console.ssh.Activator Bundle-Vendor: %bundleVendor Bundle-Localization: plugin @@ -13,17 +13,19 @@ Import-Package: javax.security.auth;resolution:=optional, javax.security.auth.login;resolution:=optional, javax.security.auth.spi;resolution:=optional, org.apache.felix.service.command;status=provisional;version="0.8.0", - org.apache.sshd.common;version="2.2.0";resolution:=optional, - org.apache.sshd.common.kex;version="2.2.0";resolution:=optional, - org.apache.sshd.common.keyprovider;version="2.2.0";resolution:=optional, - org.apache.sshd.server;version="2.2.0";resolution:=optional, - org.apache.sshd.server.auth;version="2.2.0";resolution:=optional, - org.apache.sshd.server.auth.password;version="2.2.0";resolution:=optional, - org.apache.sshd.server.auth.pubkey;version="2.2.0";resolution:=optional, - org.apache.sshd.server.command;version="2.2.0";resolution:=optional, - org.apache.sshd.server.jaas;version="2.2.0";resolution:=optional, - org.apache.sshd.server.keyprovider;version="2.2.0";resolution:=optional, - org.apache.sshd.server.session;version="2.2.0";resolution:=optional, + org.apache.sshd.common;version="2.4.0";resolution:=optional, + org.apache.sshd.common.kex;version="2.4.0";resolution:=optional, + org.apache.sshd.common.keyprovider;version="2.4.0";resolution:=optional, + org.apache.sshd.server;version="2.4.0";resolution:=optional, + org.apache.sshd.server.auth;version="2.4.0";resolution:=optional, + org.apache.sshd.server.auth.password;version="2.4.0";resolution:=optional, + org.apache.sshd.server.auth.pubkey;version="2.4.0";resolution:=optional, + org.apache.sshd.server.channel;version="2.4.0";resolution:=optional, + org.apache.sshd.server.command;version="2.4.0";resolution:=optional, + org.apache.sshd.server.jaas;version="2.4.0";resolution:=optional, + org.apache.sshd.server.keyprovider;version="2.4.0";resolution:=optional, + org.apache.sshd.server.session;version="2.4.0";resolution:=optional, + org.apache.sshd.server.shell;version="2.4.0";resolution:=optional, org.eclipse.equinox.console.common, org.eclipse.equinox.console.common.terminal, org.osgi.framework, diff --git a/bundles/org.eclipse.equinox.console.ssh/pom.xml b/bundles/org.eclipse.equinox.console.ssh/pom.xml index 049d89b6c..511ad10e4 100644 --- a/bundles/org.eclipse.equinox.console.ssh/pom.xml +++ b/bundles/org.eclipse.equinox.console.ssh/pom.xml @@ -19,6 +19,6 @@ </parent> <groupId>org.eclipse.equinox</groupId> <artifactId>org.eclipse.equinox.console.ssh</artifactId> - <version>1.2.500-SNAPSHOT</version> + <version>1.2.600-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project> diff --git a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshShell.java b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshShell.java index 4f0e9def3..2d1a2c510 100755 --- a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshShell.java +++ b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshShell.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2017 SAP AG + * Copyright (c) 2011, 2020 SAP AG and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Lazar Kirchev, SAP AG - initial API and implementation *******************************************************************************/ @@ -23,9 +23,10 @@ import java.util.List; import java.util.Map; import org.apache.felix.service.command.CommandProcessor; -import org.apache.sshd.server.command.Command; import org.apache.sshd.server.Environment; import org.apache.sshd.server.ExitCallback; +import org.apache.sshd.server.channel.ChannelSession; +import org.apache.sshd.server.command.Command; import org.eclipse.equinox.console.common.KEYS; import org.eclipse.equinox.console.common.terminal.ANSITerminalTypeMappings; import org.eclipse.equinox.console.common.terminal.SCOTerminalTypeMappings; @@ -36,25 +37,25 @@ import org.eclipse.equinox.console.common.terminal.VT320TerminalTypeMappings; import org.osgi.framework.BundleContext; /** - * This class manages a ssh connection. It is responsible for starting a sessions to execute commands + * This class manages a ssh connection. It is responsible for starting a sessions to execute commands * from the ssh. If there are multiple CommandProcessors, a session is started for each of them. * */ public class SshShell implements Command { - + private List<CommandProcessor> processors; private BundleContext context; private InputStream in; private OutputStream out; private ExitCallback callback; private Map<CommandProcessor, SshSession> commandProcessorToConsoleThreadMap = new HashMap<>(); - + private final Map<String, TerminalTypeMappings> supportedEscapeSequences; private static final String DEFAULT_TTYPE = File.separatorChar == '/' ? "XTERM" : "ANSI"; private TerminalTypeMappings currentMappings; private Map<String, KEYS> currentEscapesToKey; private static final String TERMINAL_PROPERTY = "TERM"; - + public SshShell(List<CommandProcessor> processors, BundleContext context) { this.processors = processors; this.context = context; @@ -67,7 +68,7 @@ public class SshShell implements Command { supportedEscapeSequences.put("XTERM", vtMappings); supportedEscapeSequences.put("VT320", new VT320TerminalTypeMappings()); supportedEscapeSequences.put("SCO", new SCOTerminalTypeMappings()); - + currentMappings = supportedEscapeSequences.get(DEFAULT_TTYPE); currentEscapesToKey = currentMappings.getEscapesToKey(); } @@ -93,40 +94,40 @@ public class SshShell implements Command { } @Override - public synchronized void start(Environment env) throws IOException { + public synchronized void start(ChannelSession channel, Environment env) throws IOException { String term = env.getEnv().get(TERMINAL_PROPERTY); TerminalTypeMappings mapping = supportedEscapeSequences.get(term.toUpperCase()); if(mapping != null) { currentMappings = mapping; currentEscapesToKey = mapping.getEscapesToKey(); } - + for (CommandProcessor processor : processors) { createNewSession(processor); } } - + public synchronized void addCommandProcessor(CommandProcessor processor) { createNewSession(processor); } - + public synchronized void removeCommandProcessor(CommandProcessor processor) { Thread consoleSession = commandProcessorToConsoleThreadMap.get(processor); if (consoleSession != null) { consoleSession.interrupt(); } } - + private void createNewSession(CommandProcessor processor) { SshSession consoleSession = startNewConsoleSession(processor); commandProcessorToConsoleThreadMap.put(processor, consoleSession); } @Override - public void destroy() { + public void destroy(ChannelSession channel) { return; } - + public void onExit() { if (commandProcessorToConsoleThreadMap.values() != null) { for (Thread consoleSession : commandProcessorToConsoleThreadMap.values()) { @@ -135,26 +136,26 @@ public class SshShell implements Command { } callback.onExit(0); } - + public void removeSession(SshSession session) { CommandProcessor processorToRemove = null; for (java.util.Map.Entry<CommandProcessor, SshSession> entry : commandProcessorToConsoleThreadMap.entrySet()) { - CommandProcessor processor = entry.getKey(); + CommandProcessor processor = entry.getKey(); if (session.equals(entry.getValue())) { processorToRemove = processor; break; } } - + if (processorToRemove != null) { commandProcessorToConsoleThreadMap.remove(processorToRemove); } - + if (commandProcessorToConsoleThreadMap.size() == 0) { onExit(); } } - + private SshSession startNewConsoleSession(CommandProcessor processor) { SshSession consoleSession = new SshSession(processor, context, this, in, out, currentMappings, currentEscapesToKey); consoleSession.start(); diff --git a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshShellFactory.java b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshShellFactory.java index 5a9e31d44..1fec80087 100755 --- a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshShellFactory.java +++ b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshShellFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2017 SAP AG + * Copyright (c) 2011, 2020 SAP AG and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Lazar Kirchev, SAP AG - initial API and implementation *******************************************************************************/ @@ -19,46 +19,47 @@ import java.util.List; import java.util.Set; import org.apache.felix.service.command.CommandProcessor; -import org.apache.sshd.common.Factory; +import org.apache.sshd.server.channel.ChannelSession; import org.apache.sshd.server.command.Command; +import org.apache.sshd.server.shell.ShellFactory; import org.osgi.framework.BundleContext; /** * Shell factory used by the SSH server to create a SSH shell * */ -public class SshShellFactory implements Factory<Command> { - +public class SshShellFactory implements ShellFactory { + private List<CommandProcessor> processors; private BundleContext context; private Set<SshShell> shells = new HashSet<>(); - + public SshShellFactory(List<CommandProcessor> processors, BundleContext context) { this.processors = processors; this.context = context; } - + @Override - public synchronized Command create() { + public synchronized Command createShell(ChannelSession channel) { SshShell shell = new SshShell(processors, context); shells.add(shell); return shell; } - + public synchronized void addCommandProcessor (CommandProcessor processor) { processors.add(processor); for (SshShell shell : shells) { shell.addCommandProcessor(processor); } } - + public synchronized void removeCommandProcessor (CommandProcessor processor) { processors.remove(processor); for (SshShell shell : shells) { shell.removeCommandProcessor(processor); } } - + public void exit() { for(SshShell shell : shells) { shell.onExit(); @@ -70,11 +70,6 @@ <module>bundles/org.eclipse.equinox.cm.test</module> <module>bundles/org.eclipse.equinox.common.tests</module> -<!-- no longer built in M6 - <module>bundles/org.eclipse.equinox.console.ssh.tests</module> - <module>bundles/org.eclipse.equinox.console.tests</module> ---> - <module>bundles/org.eclipse.equinox.ds.tests</module> <module>bundles/org.eclipse.equinox.preferences.tests</module> <!-- removed until the dependency on aspectj is removed. see bug 470000 |