Repository: karaf
Updated Branches:
  refs/heads/master 7fb258ab5 -> 23023e72d


[KARAF-4461] Upgrade to sshd 1.2.0


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/23023e72
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/23023e72
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/23023e72

Branch: refs/heads/master
Commit: 23023e72df6b8c2ed3949af4c30f88fe3bc67692
Parents: 7fb258a
Author: Guillaume Nodet <[email protected]>
Authored: Wed Mar 16 15:06:34 2016 +0100
Committer: Guillaume Nodet <[email protected]>
Committed: Fri Apr 1 14:08:15 2016 +0200

----------------------------------------------------------------------
 .../main/java/org/apache/karaf/client/Main.java | 77 ++++++++++++--------
 .../apache/karaf/itests/SshCommandTestBase.java | 23 +++---
 .../apache/karaf/itests/SshKeyFormatTest.java   | 20 +++--
 pom.xml                                         |  2 +-
 .../org/apache/karaf/shell/ssh/Activator.java   | 19 ++---
 .../karaf/shell/ssh/KarafAgentFactory.java      | 16 ++--
 .../karaf/shell/ssh/KarafFileSystemFactory.java | 42 -----------
 .../karaf/shell/ssh/KarafJaasAuthenticator.java |  6 +-
 .../ssh/OpenSSHGeneratorFileKeyProvider.java    | 16 ++--
 .../karaf/shell/ssh/ServerKeyVerifierImpl.java  |  4 +-
 .../org/apache/karaf/shell/ssh/SshAction.java   | 62 +++++++++++-----
 .../apache/karaf/shell/ssh/SshServerAction.java |  2 +-
 .../org/apache/karaf/shell/ssh/SshTerminal.java |  2 +-
 .../org/apache/karaf/shell/ssh/SshUtils.java    | 45 +++++-------
 .../shell/ssh/UserAuthFactoriesFactory.java     | 21 +++---
 .../apache/karaf/tooling/client/ClientMojo.java | 41 ++++++++---
 .../apache/karaf/tooling/client/DeployMojo.java | 38 +++++++---
 17 files changed, 240 insertions(+), 196 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/23023e72/client/src/main/java/org/apache/karaf/client/Main.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/karaf/client/Main.java 
b/client/src/main/java/org/apache/karaf/client/Main.java
index 7a01299..89cb9f4 100644
--- a/client/src/main/java/org/apache/karaf/client/Main.java
+++ b/client/src/main/java/org/apache/karaf/client/Main.java
@@ -23,10 +23,14 @@ import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.net.URL;
+import java.nio.file.Paths;
 import java.security.KeyPair;
 import java.nio.charset.Charset;
 import java.util.Arrays;
+import java.util.EnumSet;
 import java.util.HashMap;
+import java.util.Collections;
+import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.concurrent.ArrayBlockingQueue;
@@ -38,24 +42,34 @@ import jline.TerminalFactory;
 
 import jline.UnixTerminal;
 import jline.internal.TerminalLineSettings;
-import org.apache.sshd.ClientChannel;
-import org.apache.sshd.ClientSession;
-import org.apache.sshd.SshBuilder;
-import org.apache.sshd.SshClient;
 import org.apache.sshd.agent.SshAgent;
 import org.apache.sshd.agent.local.AgentImpl;
 import org.apache.sshd.agent.local.LocalAgentFactory;
-import org.apache.sshd.client.UserInteraction;
+import org.apache.sshd.client.ClientBuilder;
+import org.apache.sshd.client.SshClient;
+import org.apache.sshd.client.auth.keyboard.UserInteraction;
 import org.apache.sshd.client.channel.ChannelShell;
+import org.apache.sshd.client.channel.ClientChannelEvent;
 import org.apache.sshd.client.channel.PtyCapableChannelSession;
 import org.apache.sshd.client.future.ConnectFuture;
-import org.apache.sshd.client.kex.ECDHP256;
-import org.apache.sshd.client.kex.ECDHP384;
-import org.apache.sshd.client.kex.ECDHP521;
-import org.apache.sshd.common.*;
-import org.apache.sshd.common.keyprovider.FileKeyPairProvider;
-import org.apache.sshd.common.util.Buffer;
+import org.apache.sshd.common.FactoryManager;
+import org.apache.sshd.common.NamedFactory;
+import org.apache.sshd.common.RuntimeSshException;
+import org.apache.sshd.common.SshConstants;
+import org.apache.sshd.client.channel.ClientChannel;
+import org.apache.sshd.client.channel.PtyCapableChannelSession;
+import org.apache.sshd.client.future.ConnectFuture;
+import org.apache.sshd.client.session.ClientSession;
+import org.apache.sshd.common.RuntimeSshException;
+import org.apache.sshd.common.SshConstants;
+import org.apache.sshd.common.channel.PtyMode;
+import org.apache.sshd.common.kex.KeyExchange;
+import org.apache.sshd.common.keyprovider.AbstractFileKeyPairProvider;
+import org.apache.sshd.common.session.Session;
+import org.apache.sshd.common.util.SecurityUtils;
+import org.apache.sshd.common.util.buffer.Buffer;
 import org.fusesource.jansi.AnsiConsole;
+import org.fusesource.jansi.internal.CLibrary;
 import org.slf4j.impl.SimpleLogger;
 
 /**
@@ -93,16 +107,7 @@ public class Main {
         Terminal terminal = null;
         int exitStatus = 0;
         try {
-            SshBuilder.ClientBuilder clientBuilder = SshBuilder.client();
-            
clientBuilder.keyExchangeFactories(Arrays.<NamedFactory<KeyExchange>>asList(
-                     new ECDHP256.Factory(),
-                     new ECDHP256.Factory(),
-                     new ECDHP384.Factory(),
-                     new ECDHP384.Factory(),
-                     new ECDHP521.Factory(),
-                     new ECDHP521.Factory()
-                     )
-                );
+            ClientBuilder clientBuilder = ClientBuilder.builder();
 
             client = clientBuilder.build();
             setupAgent(config.getUser(), config.getKeyFile(), client);
@@ -110,11 +115,12 @@ public class Main {
             final Console console = System.console();
             if (console != null) {
                 client.setUserInteraction(new UserInteraction() {
-                    public void welcome(String banner) {
+                    @Override
+                    public void welcome(ClientSession s, String banner, String 
lang) {
                         System.out.println(banner);
                     }
-
-                    public String[] interactive(String destination, String 
name, String instruction, String[] prompt, boolean[] echo) {
+                    @Override
+                    public String[] interactive(ClientSession s, String name, 
String instruction, String lang, String[] prompt, boolean[] echo) {
                         String[] answers = new String[prompt.length];
                         try {
                             for (int i = 0; i < prompt.length; i++) {
@@ -132,6 +138,17 @@ public class Main {
                             return null;
                         }
                     }
+                    @Override
+                    public boolean isInteractionAllowed(ClientSession session) 
{
+                        return true;
+                    }
+                    @Override
+                    public void serverVersionInfo(ClientSession session, 
List<String> lines) {
+                    }
+                    @Override
+                    public String getUpdatedPassword(ClientSession session, 
String prompt, String lang) {
+                        return null;
+                    }
                 });
             }
             client.start();
@@ -149,10 +166,12 @@ public class Main {
                 channel = session.createChannel("exec", config.getCommand() + 
"\n");
                 channel.setIn(new ByteArrayInputStream(new byte[0]));
             } else {
-                TerminalFactory.registerFlavor(TerminalFactory.Flavor.UNIX, 
NoInterruptUnixTerminal.class);
+                TerminalFactory.registerFlavor(TerminalFactory.Flavor.UNIX, 
UnixTerminal.class);
                 terminal = TerminalFactory.create();
                 if (terminal instanceof UnixTerminal) {
-                    ((UnixTerminal) terminal).disableLitteralNextCharacter();
+                    TerminalLineSettings settings = ((UnixTerminal) 
terminal).getSettings();
+                    settings.undef("vlnext");
+                    settings.undef("vintr");
                 }
                 channel = session.createChannel("shell");
                 ConsoleInputStream in = new 
ConsoleInputStream(terminal.wrapInIfNeeded(System.in));
@@ -226,7 +245,7 @@ public class Main {
             if (channel instanceof PtyCapableChannelSession) {
                 registerSignalHandler(terminal, (PtyCapableChannelSession) 
channel);
             }
-            channel.waitFor(ClientChannel.CLOSED, 0);
+            channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), 0);
             if (channel.getExitStatus() != null) {
                 exitStatus = channel.getExitStatus();
             }
@@ -295,8 +314,8 @@ public class Main {
             is.close();
             agent.addIdentity(keyPair, user);
             if (keyFile != null) {
-                String[] keyFiles = new String[]{keyFile};
-                FileKeyPairProvider fileKeyPairProvider = new 
FileKeyPairProvider(keyFiles);
+                AbstractFileKeyPairProvider fileKeyPairProvider = 
SecurityUtils.createFileKeyPairProvider();
+                
fileKeyPairProvider.setPaths(Collections.singleton(Paths.get(keyFile)));
                 for (KeyPair key : fileKeyPairProvider.loadKeys()) {
                     agent.addIdentity(key, user);                
                 }

http://git-wip-us.apache.org/repos/asf/karaf/blob/23023e72/itests/src/test/java/org/apache/karaf/itests/SshCommandTestBase.java
----------------------------------------------------------------------
diff --git 
a/itests/src/test/java/org/apache/karaf/itests/SshCommandTestBase.java 
b/itests/src/test/java/org/apache/karaf/itests/SshCommandTestBase.java
index aaa0c04..f7a44f0 100644
--- a/itests/src/test/java/org/apache/karaf/itests/SshCommandTestBase.java
+++ b/itests/src/test/java/org/apache/karaf/itests/SshCommandTestBase.java
@@ -19,13 +19,17 @@ import java.io.OutputStream;
 import java.io.PipedInputStream;
 import java.io.PipedOutputStream;
 import java.util.Arrays;
+import java.util.EnumSet;
 import java.util.HashSet;
+import java.util.Set;
 
 import org.apache.karaf.features.Feature;
-import org.apache.sshd.ClientChannel;
-import org.apache.sshd.ClientSession;
-import org.apache.sshd.SshClient;
+import org.apache.sshd.client.SshClient;
+import org.apache.sshd.client.channel.ClientChannel;
+import org.apache.sshd.client.channel.ClientChannelEvent;
 import org.apache.sshd.client.future.ConnectFuture;
+import org.apache.sshd.client.session.ClientSession;
+import org.apache.sshd.client.session.ClientSession.ClientSessionEvent;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Assert;
@@ -118,16 +122,17 @@ public class SshCommandTestBase extends KarafTestSupport {
         client = SshClient.setUpDefaultClient();
         client.start();
         String sshPort = getSshPort();
-        ConnectFuture future = client.connect(username, "localhost", 
Integer.parseInt(sshPort)).await();
+        ConnectFuture future = client.connect(username, "localhost", 
Integer.parseInt(sshPort));
+        future.await();
         session = future.getSession();
 
-        int ret = ClientSession.WAIT_AUTH;
-        while ((ret & ClientSession.WAIT_AUTH) != 0) {
+        Set<ClientSessionEvent> ret = EnumSet.of(ClientSessionEvent.WAIT_AUTH);
+        while (ret.contains(ClientSessionEvent.WAIT_AUTH)) {
             session.addPasswordIdentity(password);
             session.auth().verify();
-            ret = session.waitFor(ClientSession.WAIT_AUTH | 
ClientSession.CLOSED | ClientSession.AUTHED, 0);
+            ret = session.waitFor(EnumSet.of(ClientSessionEvent.WAIT_AUTH, 
ClientSessionEvent.CLOSED, ClientSessionEvent.AUTHED), 0);
         }
-        if ((ret & ClientSession.CLOSED) != 0) {
+        if (ret.contains(ClientSessionEvent.CLOSED)) {
             throw new Exception("Could not open SSH channel");
         }
         channel = session.createChannel("shell");
@@ -158,7 +163,7 @@ public class SshCommandTestBase extends KarafTestSupport {
         pipe.write("logout\n".getBytes());
         pipe.flush();
 
-        channel.waitFor(ClientChannel.CLOSED, 0);
+        channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), 0);
         session.close(true);
         client.stop();
 

http://git-wip-us.apache.org/repos/asf/karaf/blob/23023e72/itests/src/test/java/org/apache/karaf/itests/SshKeyFormatTest.java
----------------------------------------------------------------------
diff --git a/itests/src/test/java/org/apache/karaf/itests/SshKeyFormatTest.java 
b/itests/src/test/java/org/apache/karaf/itests/SshKeyFormatTest.java
index 3db1544..7f9be85 100644
--- a/itests/src/test/java/org/apache/karaf/itests/SshKeyFormatTest.java
+++ b/itests/src/test/java/org/apache/karaf/itests/SshKeyFormatTest.java
@@ -23,16 +23,19 @@ package org.apache.karaf.itests;
 import com.google.common.io.ByteSource;
 import com.google.common.io.Resources;
 import org.apache.commons.ssl.PKCS8Key;
-import org.apache.sshd.ClientSession;
-import org.apache.sshd.SshClient;
+import org.apache.sshd.client.SshClient;
 import org.apache.sshd.client.future.ConnectFuture;
 import org.apache.sshd.client.keyverifier.RequiredServerKeyVerifier;
+import org.apache.sshd.client.session.ClientSession;
+import org.apache.sshd.client.session.ClientSession.ClientSessionEvent;
 import org.junit.Test;
 import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
 
 import java.io.File;
 import java.net.URL;
+import java.util.EnumSet;
+import java.util.Set;
 
 import static org.ops4j.pax.exam.CoreOptions.*;
 import static 
org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
@@ -64,16 +67,17 @@ public class SshKeyFormatTest extends SshCommandTestBase {
 
         client.setServerKeyVerifier(new 
RequiredServerKeyVerifier(pkcs8.getPublicKey()));
         client.start();
-        ConnectFuture future = client.connect("karaf", "localhost", 
Integer.parseInt(sshPort)).await();
+        ConnectFuture future = client.connect("karaf", "localhost", 
Integer.parseInt(sshPort));
+        future.await();
         ClientSession session = future.getSession();
-        int ret = ClientSession.WAIT_AUTH;
-        while ((ret & ClientSession.WAIT_AUTH) != 0) {
+
+        Set<ClientSessionEvent> ret = EnumSet.of(ClientSessionEvent.WAIT_AUTH);
+        while (ret.contains(ClientSessionEvent.WAIT_AUTH)) {
             session.addPasswordIdentity("karaf");
             session.auth().verify();
-            ret = session.waitFor(ClientSession.WAIT_AUTH | 
ClientSession.CLOSED | ClientSession.AUTHED, 0);
+            ret = session.waitFor(EnumSet.of(ClientSessionEvent.WAIT_AUTH, 
ClientSessionEvent.CLOSED, ClientSessionEvent.AUTHED), 0);
         }
-        if ((ret & ClientSession.CLOSED) != 0) {
-            System.err.format("ret %d%n", ret);
+        if (ret.contains(ClientSessionEvent.CLOSED)) {
             throw new Exception("Could not open SSH channel");
         }
         session.close(true);

http://git-wip-us.apache.org/repos/asf/karaf/blob/23023e72/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index c5783a9..7d34c6d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -280,7 +280,7 @@
         <spring42.version>4.2.4.RELEASE_1</spring42.version>
         <spring.security31.version>3.1.4.RELEASE</spring.security31.version>
 
-        <sshd.version>0.14.0</sshd.version>
+        <sshd.version>1.2.0</sshd.version>
         <derby-version>10.12.1.1</derby-version>
         <directory-version>2.0.0-M20</directory-version>
         <struts.bundle.version>1.3.10_1</struts.bundle.version>

http://git-wip-us.apache.org/repos/asf/karaf/blob/23023e72/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java
----------------------------------------------------------------------
diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java 
b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java
index 70a8899..2714398 100644
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java
@@ -20,6 +20,7 @@ package org.apache.karaf.shell.ssh;
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.file.Paths;
 import java.util.Arrays;
 
 import org.apache.karaf.shell.api.action.lifecycle.Manager;
@@ -31,13 +32,13 @@ import org.apache.karaf.util.tracker.BaseActivator;
 import org.apache.karaf.util.tracker.annotation.Managed;
 import org.apache.karaf.util.tracker.annotation.RequireService;
 import org.apache.karaf.util.tracker.annotation.Services;
-import org.apache.sshd.SshServer;
 import org.apache.sshd.common.NamedFactory;
-import org.apache.sshd.server.command.ScpCommandFactory;
+import org.apache.sshd.common.file.virtualfs.VirtualFileSystemFactory;
+import org.apache.sshd.server.SshServer;
 import org.apache.sshd.server.keyprovider.AbstractGeneratorHostKeyProvider;
-import org.apache.sshd.server.keyprovider.PEMGeneratorHostKeyProvider;
 import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
-import org.apache.sshd.server.sftp.SftpSubsystem;
+import org.apache.sshd.server.scp.ScpCommandFactory;
+import org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.cm.ManagedService;
 import org.osgi.util.tracker.ServiceTracker;
@@ -130,7 +131,7 @@ public class Activator extends BaseActivator implements 
ManagedService {
         if (server != null) {
             try {
                 server.stop(true);
-            } catch (InterruptedException e) {
+            } catch (IOException e) {
                 LOGGER.warn("Exception caught while stopping SSH server", e);
             }
             server = null;
@@ -162,7 +163,7 @@ public class Activator extends BaseActivator implements 
ManagedService {
             return null;
         }
 
-        keyPairProvider.setPath(hostKey);
+        keyPairProvider.setPath(Paths.get(hostKey));
         if (new File(hostKey).exists()) {
             // do not trash key file if there's something wrong with it.
             keyPairProvider.setOverwriteAllowed(false);
@@ -182,12 +183,12 @@ public class Activator extends BaseActivator implements 
ManagedService {
         server.setMacFactories(SshUtils.buildMacs(macs));
         server.setCipherFactories(SshUtils.buildCiphers(ciphers));
         server.setShellFactory(new ShellFactoryImpl(sessionFactory));
-        server.setCommandFactory(new ScpCommandFactory(new 
ShellCommandFactory(sessionFactory)));
-        
server.setSubsystemFactories(Arrays.<NamedFactory<org.apache.sshd.server.Command>>asList(new
 SftpSubsystem.Factory()));
+        server.setCommandFactory(new 
ScpCommandFactory.Builder().withDelegate(new 
ShellCommandFactory(sessionFactory)).build());
+        
server.setSubsystemFactories(Arrays.<NamedFactory<org.apache.sshd.server.Command>>asList(new
 SftpSubsystemFactory()));
         server.setKeyPairProvider(keyPairProvider);
         server.setPasswordAuthenticator(authenticator);
         server.setPublickeyAuthenticator(authenticator);
-        server.setFileSystemFactory(new KarafFileSystemFactory());
+        server.setFileSystemFactory(new 
VirtualFileSystemFactory(Paths.get(System.getProperty("karaf.base"))));
         server.setUserAuthFactories(authFactoriesFactory.getFactories());
         server.setAgentFactory(agentFactory);
         server.getProperties().put(SshServer.IDLE_TIMEOUT, 
Long.toString(sshIdleTimeout));

http://git-wip-us.apache.org/repos/asf/karaf/blob/23023e72/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafAgentFactory.java
----------------------------------------------------------------------
diff --git 
a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafAgentFactory.java 
b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafAgentFactory.java
index f54b9bf..cda3be1 100644
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafAgentFactory.java
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafAgentFactory.java
@@ -33,11 +33,12 @@ import org.apache.sshd.agent.common.AgentDelegate;
 import org.apache.sshd.agent.local.AgentImpl;
 import org.apache.sshd.agent.local.AgentServerProxy;
 import org.apache.sshd.agent.local.ChannelAgentForwarding;
-import org.apache.sshd.common.Channel;
+import org.apache.sshd.agent.local.ChannelAgentForwardingFactory;
 import org.apache.sshd.common.FactoryManager;
 import org.apache.sshd.common.NamedFactory;
-import org.apache.sshd.common.Session;
+import org.apache.sshd.common.channel.Channel;
 import org.apache.sshd.common.session.ConnectionService;
+import org.apache.sshd.common.session.Session;
 import org.apache.sshd.server.session.ServerSession;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -50,11 +51,11 @@ public class KarafAgentFactory implements SshAgentFactory {
     private final Map<String, SshAgent> locals = new ConcurrentHashMap<String, 
SshAgent>();
 
     public NamedFactory<Channel> getChannelForwardingFactory() {
-        return new ChannelAgentForwarding.Factory();
+        return new ChannelAgentForwardingFactory();
     }
 
     public SshAgent createClient(FactoryManager manager) throws IOException {
-        String proxyId = 
manager.getProperties().get(SshAgent.SSH_AUTHSOCKET_ENV_NAME);
+        String proxyId = (String) 
manager.getProperties().get(SshAgent.SSH_AUTHSOCKET_ENV_NAME);
         if (proxyId == null) {
             throw new IllegalStateException("No " + 
SshAgent.SSH_AUTHSOCKET_ENV_NAME + " environment variable set");
         }
@@ -81,7 +82,12 @@ public class KarafAgentFactory implements SshAgentFactory {
                 return proxy.getId();
             }
 
-            public void close() {
+            @Override
+            public boolean isOpen() {
+                return proxy.isOpen();
+            }
+
+            public void close() throws IOException {
                 proxies.remove(proxy.getId());
                 proxy.close();
             }

http://git-wip-us.apache.org/repos/asf/karaf/blob/23023e72/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafFileSystemFactory.java
----------------------------------------------------------------------
diff --git 
a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafFileSystemFactory.java
 
b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafFileSystemFactory.java
deleted file mode 100644
index 8d69af3..0000000
--- 
a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafFileSystemFactory.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.karaf.shell.ssh;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.sshd.common.Session;
-import org.apache.sshd.common.file.FileSystemFactory;
-import org.apache.sshd.common.file.FileSystemView;
-import org.apache.sshd.common.file.nativefs.NativeFileSystemView;
-
-/**
- * SSHd file system factory to reduce the visibility to the KARAF_BASE.
- */
-public class KarafFileSystemFactory implements FileSystemFactory {
-
-    public FileSystemView createFileSystemView(Session session) {
-        Map<String, String> roots = new HashMap<String, String>();
-        String dir = new 
File(System.getProperty("karaf.base")).getAbsolutePath();
-        roots.put("/", dir);
-        return new NativeFileSystemView(session.getUsername(), roots, "/");
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/karaf/blob/23023e72/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafJaasAuthenticator.java
----------------------------------------------------------------------
diff --git 
a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafJaasAuthenticator.java
 
b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafJaasAuthenticator.java
index 632cb98..8d75c41 100644
--- 
a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafJaasAuthenticator.java
+++ 
b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafJaasAuthenticator.java
@@ -30,9 +30,9 @@ import 
javax.security.auth.callback.UnsupportedCallbackException;
 import javax.security.auth.login.LoginContext;
 
 import org.apache.karaf.jaas.modules.publickey.PublickeyCallback;
-import org.apache.sshd.common.Session;
-import org.apache.sshd.server.PasswordAuthenticator;
-import org.apache.sshd.server.PublickeyAuthenticator;
+import org.apache.sshd.common.session.Session;
+import org.apache.sshd.server.auth.password.PasswordAuthenticator;
+import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
 import org.apache.sshd.server.session.ServerSession;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/karaf/blob/23023e72/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/OpenSSHGeneratorFileKeyProvider.java
----------------------------------------------------------------------
diff --git 
a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/OpenSSHGeneratorFileKeyProvider.java
 
b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/OpenSSHGeneratorFileKeyProvider.java
index 02baeff..0285053 100644
--- 
a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/OpenSSHGeneratorFileKeyProvider.java
+++ 
b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/OpenSSHGeneratorFileKeyProvider.java
@@ -23,8 +23,11 @@ import org.apache.commons.ssl.PEMUtil;
 import org.apache.commons.ssl.PKCS8Key;
 import org.apache.sshd.server.keyprovider.AbstractGeneratorHostKeyProvider;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.nio.file.Paths;
+import java.security.GeneralSecurityException;
 import java.security.KeyPair;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -39,15 +42,17 @@ public class OpenSSHGeneratorFileKeyProvider extends 
AbstractGeneratorHostKeyPro
     }
 
     public OpenSSHGeneratorFileKeyProvider(String path) {
-        super(path);
+        setPath(Paths.get(path));
     }
 
     public OpenSSHGeneratorFileKeyProvider(String path, String algorithm) {
-        super(path, algorithm);
+        this(path);
+        setAlgorithm(algorithm);
     }
 
     public OpenSSHGeneratorFileKeyProvider(String path, String algorithm, int 
keySize) {
-        super(path, algorithm, keySize);
+        this(path, algorithm);
+        setKeySize(keySize);
     }
 
     public String getPassword() {
@@ -59,17 +64,18 @@ public class OpenSSHGeneratorFileKeyProvider extends 
AbstractGeneratorHostKeyPro
     }
 
     @Override
-    protected KeyPair doReadKeyPair(InputStream is) throws Exception {
+    protected KeyPair doReadKeyPair(String resourceKey, InputStream is) throws 
IOException, GeneralSecurityException {
         PKCS8Key pkcs8 = new PKCS8Key(is, password == null ? null : 
password.toCharArray());
         return new KeyPair(pkcs8.getPublicKey(), pkcs8.getPrivateKey());
     }
 
     @Override
-    protected void doWriteKeyPair(KeyPair kp, OutputStream os) throws 
Exception {
+    protected void doWriteKeyPair(String resourceKey, KeyPair kp, OutputStream 
os) throws IOException, GeneralSecurityException {
         Collection<Object> items = new ArrayList<>();
         items.add(kp.getPrivate());
         items.add(kp.getPublic());
         byte[] bytes = PEMUtil.encode(items);
         os.write(bytes);
     }
+
 }

http://git-wip-us.apache.org/repos/asf/karaf/blob/23023e72/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ServerKeyVerifierImpl.java
----------------------------------------------------------------------
diff --git 
a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ServerKeyVerifierImpl.java 
b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ServerKeyVerifierImpl.java
index a60c494..6973ad6 100644
--- 
a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ServerKeyVerifierImpl.java
+++ 
b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ServerKeyVerifierImpl.java
@@ -23,8 +23,8 @@ import java.net.SocketAddress;
 import java.security.PublicKey;
 import java.security.spec.InvalidKeySpecException;
 
-import org.apache.sshd.ClientSession;
-import org.apache.sshd.client.ServerKeyVerifier;
+import org.apache.sshd.client.keyverifier.ServerKeyVerifier;
+import org.apache.sshd.client.session.ClientSession;
 
 public class ServerKeyVerifierImpl implements ServerKeyVerifier {
 

http://git-wip-us.apache.org/repos/asf/karaf/blob/23023e72/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshAction.java
----------------------------------------------------------------------
diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshAction.java 
b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshAction.java
index 444f09e..46cd1b4 100644
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshAction.java
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshAction.java
@@ -18,10 +18,18 @@
  */
 package org.apache.karaf.shell.ssh;
 
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
 import java.lang.reflect.Field;
 import java.net.URL;
+import java.nio.file.Paths;
 import java.security.KeyPair;
+import java.util.Collections;
+import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -38,23 +46,24 @@ import org.apache.karaf.shell.api.console.Session;
 import org.apache.karaf.shell.api.console.Signal;
 import org.apache.karaf.shell.api.console.SignalListener;
 import org.apache.karaf.shell.api.console.Terminal;
-import org.apache.sshd.ClientChannel;
-import org.apache.sshd.ClientSession;
-import org.apache.sshd.SshClient;
 import org.apache.sshd.agent.SshAgent;
 import org.apache.sshd.agent.local.AgentImpl;
 import org.apache.sshd.agent.local.LocalAgentFactory;
-import org.apache.sshd.client.ServerKeyVerifier;
-import org.apache.sshd.client.UserInteraction;
+import org.apache.sshd.client.channel.ClientChannelEvent;
+import org.apache.sshd.client.keyverifier.ServerKeyVerifier;
+import org.apache.sshd.client.SshClient;
+import org.apache.sshd.client.auth.keyboard.UserInteraction;
 import org.apache.sshd.client.channel.ChannelShell;
+import org.apache.sshd.client.channel.ClientChannel;
 import org.apache.sshd.client.future.ConnectFuture;
-import org.apache.sshd.common.PtyMode;
+import org.apache.sshd.client.session.ClientSession;
 import org.apache.sshd.common.SshConstants;
-import org.apache.sshd.common.channel.AbstractChannel;
-import org.apache.sshd.common.keyprovider.FileKeyPairProvider;
-import org.apache.sshd.common.util.Buffer;
-import org.apache.sshd.common.util.NoCloseInputStream;
-import org.apache.sshd.common.util.NoCloseOutputStream;
+import org.apache.sshd.common.channel.PtyMode;
+import org.apache.sshd.common.keyprovider.AbstractFileKeyPairProvider;
+import org.apache.sshd.common.util.SecurityUtils;
+import org.apache.sshd.common.util.buffer.Buffer;
+import org.apache.sshd.common.util.io.NoCloseInputStream;
+import org.apache.sshd.common.util.io.NoCloseOutputStream;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -91,7 +100,6 @@ public class SshAction implements Action {
     private Session session;
 
 
-
     @Override
     public Object execute() throws Exception {
 
@@ -123,11 +131,13 @@ public class SshAction implements Action {
         client.setServerKeyVerifier(serverKeyVerifier);
         log.debug("Created client: {}", client);
         client.setUserInteraction(new UserInteraction() {
-            public void welcome(String banner) {
+            @Override
+            public void welcome(ClientSession session, String banner, String 
lang) {
                 System.out.println(banner);
             }
 
-            public String[] interactive(String destination, String name, 
String instruction, String[] prompt, boolean[] echo) {
+            @Override
+            public String[] interactive(ClientSession s, String name, String 
instruction, String lang, String[] prompt, boolean[] echo) {
                 String[] answers = new String[prompt.length];
                 try {
                     for (int i = 0; i < prompt.length; i++) {
@@ -137,6 +147,18 @@ public class SshAction implements Action {
                 }
                 return answers;
             }
+            @Override
+            public boolean isInteractionAllowed(ClientSession session) {
+                return true;
+            }
+            @Override
+            public void serverVersionInfo(ClientSession session, List<String> 
lines) {
+
+            }
+            @Override
+            public String getUpdatedPassword(ClientSession session, String 
prompt, String lang) {
+                return null;
+            }
         });
         client.start();
 
@@ -169,7 +191,7 @@ public class SshAction implements Action {
                     channel.setOut(new NoCloseOutputStream(System.out));
                     channel.setErr(new NoCloseOutputStream(System.err));
                     channel.open().verify();
-                    channel.waitFor(ClientChannel.CLOSED, 0);
+                    channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), 0);
                 } else if (session.getTerminal() != null) {
                     final ChannelShell channel = 
sshSession.createShellChannel();
                     final jline.Terminal jlineTerminal = (jline.Terminal) 
session.get(".jline.terminal");
@@ -256,7 +278,7 @@ public class SshAction implements Action {
                                     // Ignore
                                 }
                                 // TODO: replace with 
PtyCapableChannelSession#sendWindowChange
-                                org.apache.sshd.common.Session sshSession = 
((AbstractChannel) channel).getSession();
+                                org.apache.sshd.common.session.Session 
sshSession = channel.getSession();
                                 Buffer buffer = 
sshSession.createBuffer(SshConstants.SSH_MSG_CHANNEL_REQUEST);
                                 buffer.putInt(channel.getRecipient());
                                 buffer.putString("window-change");
@@ -273,7 +295,7 @@ public class SshAction implements Action {
                     };
                     session.getTerminal().addSignalListener(signalListener, 
Signal.WINCH);
                     try {
-                        channel.waitFor(ClientChannel.CLOSED, 0);
+                        channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), 
0);
                     } finally {
                         
session.getTerminal().removeSignalListener(signalListener);
                     }
@@ -324,8 +346,8 @@ public class SshAction implements Action {
             is.close();
             agent.addIdentity(keyPair, user);
             if (keyFile != null) {
-                String[] keyFiles = new String[]{keyFile};
-                FileKeyPairProvider fileKeyPairProvider = new 
FileKeyPairProvider(keyFiles);
+                AbstractFileKeyPairProvider fileKeyPairProvider = 
SecurityUtils.createFileKeyPairProvider();
+                
fileKeyPairProvider.setPaths(Collections.singleton(Paths.get(keyFile)));
                 for (KeyPair key : fileKeyPairProvider.loadKeys()) {
                     agent.addIdentity(key, user);
                 }

http://git-wip-us.apache.org/repos/asf/karaf/blob/23023e72/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java
----------------------------------------------------------------------
diff --git 
a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java 
b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java
index 85528e7..db32c1a 100644
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java
@@ -23,7 +23,7 @@ import org.apache.karaf.shell.api.action.Command;
 import org.apache.karaf.shell.api.action.Option;
 import org.apache.karaf.shell.api.action.lifecycle.Reference;
 import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.apache.sshd.SshServer;
+import org.apache.sshd.server.SshServer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/karaf/blob/23023e72/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshTerminal.java
----------------------------------------------------------------------
diff --git 
a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshTerminal.java 
b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshTerminal.java
index 6c1213a..4b7aff6 100644
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshTerminal.java
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshTerminal.java
@@ -21,7 +21,7 @@ package org.apache.karaf.shell.ssh;
 import org.apache.karaf.shell.api.console.Signal;
 import org.apache.karaf.shell.api.console.Terminal;
 import org.apache.karaf.shell.support.terminal.SignalSupport;
-import org.apache.sshd.common.PtyMode;
+import org.apache.sshd.common.channel.PtyMode;
 import org.apache.sshd.server.Environment;
 
 public class SshTerminal extends SignalSupport implements Terminal {

http://git-wip-us.apache.org/repos/asf/karaf/blob/23023e72/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshUtils.java
----------------------------------------------------------------------
diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshUtils.java 
b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshUtils.java
index 7f29803..83f3112 100644
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshUtils.java
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshUtils.java
@@ -26,22 +26,11 @@ import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 
-import org.apache.sshd.common.Cipher;
-import org.apache.sshd.common.Mac;
 import org.apache.sshd.common.NamedFactory;
-import org.apache.sshd.common.cipher.AES128CBC;
-import org.apache.sshd.common.cipher.AES128CTR;
-import org.apache.sshd.common.cipher.AES192CBC;
-import org.apache.sshd.common.cipher.AES256CBC;
-import org.apache.sshd.common.cipher.AES256CTR;
-import org.apache.sshd.common.cipher.ARCFOUR128;
-import org.apache.sshd.common.cipher.ARCFOUR256;
-import org.apache.sshd.common.cipher.BlowfishCBC;
-import org.apache.sshd.common.cipher.TripleDESCBC;
-import org.apache.sshd.common.mac.HMACMD5;
-import org.apache.sshd.common.mac.HMACMD596;
-import org.apache.sshd.common.mac.HMACSHA1;
-import org.apache.sshd.common.mac.HMACSHA196;
+import org.apache.sshd.common.cipher.BuiltinCiphers;
+import org.apache.sshd.common.cipher.Cipher;
+import org.apache.sshd.common.mac.BuiltinMacs;
+import org.apache.sshd.common.mac.Mac;
 
 public class SshUtils {
 
@@ -59,24 +48,24 @@ public class SshUtils {
 
     public static List<NamedFactory<Mac>> buildMacs(String names) {
         return filter(Arrays.<NamedFactory<Mac>>asList(
-                        new HMACMD5.Factory(),
-                        new HMACSHA1.Factory(),
-                        new HMACMD596.Factory(),
-                        new HMACSHA196.Factory()),
+                        BuiltinMacs.hmacmd5,
+                        BuiltinMacs.hmacsha1,
+                        BuiltinMacs.hmacmd596,
+                        BuiltinMacs.hmacsha196),
                 names);
     }
 
     public static List<NamedFactory<Cipher>> buildCiphers(String names) {
         List<NamedFactory<Cipher>> avail = new 
LinkedList<NamedFactory<Cipher>>();
-        avail.add(new AES128CTR.Factory());
-        avail.add(new AES256CTR.Factory());
-        avail.add(new ARCFOUR128.Factory());
-        avail.add(new ARCFOUR256.Factory());
-        avail.add(new AES128CBC.Factory());
-        avail.add(new TripleDESCBC.Factory());
-        avail.add(new BlowfishCBC.Factory());
-        avail.add(new AES192CBC.Factory());
-        avail.add(new AES256CBC.Factory());
+        avail.add(BuiltinCiphers.aes128ctr);
+        avail.add(BuiltinCiphers.aes256ctr);
+        avail.add(BuiltinCiphers.arcfour128);
+        avail.add(BuiltinCiphers.arcfour256);
+        avail.add(BuiltinCiphers.aes128cbc);
+        avail.add(BuiltinCiphers.tripledescbc);
+        avail.add(BuiltinCiphers.blowfishcbc);
+        avail.add(BuiltinCiphers.aes192cbc);
+        avail.add(BuiltinCiphers.aes256cbc);
 
         avail = filter(avail, names);
 

http://git-wip-us.apache.org/repos/asf/karaf/blob/23023e72/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/UserAuthFactoriesFactory.java
----------------------------------------------------------------------
diff --git 
a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/UserAuthFactoriesFactory.java
 
b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/UserAuthFactoriesFactory.java
index b31ab93..76e61a1 100644
--- 
a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/UserAuthFactoriesFactory.java
+++ 
b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/UserAuthFactoriesFactory.java
@@ -18,21 +18,20 @@
  */
 package org.apache.karaf.shell.ssh;
 
-import org.apache.sshd.common.NamedFactory;
-import org.apache.sshd.server.UserAuth;
-import org.apache.sshd.server.auth.UserAuthKeyboardInteractive;
-import org.apache.sshd.server.auth.UserAuthPassword;
-import org.apache.sshd.server.auth.UserAuthPublicKey;
-
-import java.lang.reflect.ParameterizedType;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
+import org.apache.sshd.common.NamedFactory;
+import org.apache.sshd.server.auth.UserAuth;
+import org.apache.sshd.server.auth.keyboard.UserAuthKeyboardInteractiveFactory;
+import org.apache.sshd.server.auth.password.UserAuthPasswordFactory;
+import org.apache.sshd.server.auth.pubkey.UserAuthPublicKeyFactory;
+
 /**
  * <p>A factory for user authentication factories to set on
- * {@link org.apache.sshd.SshServer#setUserAuthFactories(java.util.List)} 
based on a
+ * {@link 
org.apache.sshd.server.SshServer#setUserAuthFactories(java.util.List)} based on 
a
  * comma-separated list of authentication methods.</p>
  *
  * <p>Currently, the following methods are supported:</p>
@@ -56,11 +55,11 @@ public class UserAuthFactoriesFactory {
         String[] ams = methods.split(",");
         for (String am : ams) {
             if (PASSWORD_METHOD.equals(am)) {
-                this.factories.add(new UserAuthPassword.Factory());
+                this.factories.add(new UserAuthPasswordFactory());
             } else if (KEYBOARD_INTERACTIVE_METHOD.equals(am)) {
-                this.factories.add(new UserAuthKeyboardInteractive.Factory());
+                this.factories.add(new UserAuthKeyboardInteractiveFactory());
             } else if (PUBLICKEY_METHOD.equals(am)) {
-                this.factories.add(new UserAuthPublicKey.Factory());
+                this.factories.add(new UserAuthPublicKeyFactory());
             } else {
                 throw new IllegalArgumentException("Invalid authentication 
method " + am + " specified");
             }

http://git-wip-us.apache.org/repos/asf/karaf/blob/23023e72/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/client/ClientMojo.java
----------------------------------------------------------------------
diff --git 
a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/client/ClientMojo.java
 
b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/client/ClientMojo.java
index 930be6c..3073ed0 100644
--- 
a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/client/ClientMojo.java
+++ 
b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/client/ClientMojo.java
@@ -23,17 +23,19 @@ import org.apache.maven.plugins.annotations.LifecyclePhase;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.plugins.annotations.ResolutionScope;
-import org.apache.sshd.ClientChannel;
-import org.apache.sshd.ClientSession;
-import org.apache.sshd.SshClient;
 import org.apache.sshd.agent.SshAgent;
 import org.apache.sshd.agent.local.AgentImpl;
 import org.apache.sshd.agent.local.LocalAgentFactory;
-import org.apache.sshd.client.UserInteraction;
+import org.apache.sshd.client.SshClient;
+import org.apache.sshd.client.auth.keyboard.UserInteraction;
+import org.apache.sshd.client.channel.ClientChannel;
+import org.apache.sshd.client.channel.ClientChannelEvent;
 import org.apache.sshd.client.future.ConnectFuture;
+import org.apache.sshd.client.session.ClientSession;
 import org.apache.sshd.common.RuntimeSshException;
-import org.apache.sshd.common.keyprovider.FileKeyPairProvider;
 
+import org.apache.sshd.common.keyprovider.AbstractFileKeyPairProvider;
+import org.apache.sshd.common.util.SecurityUtils;
 import org.fusesource.jansi.Ansi;
 import org.fusesource.jansi.Ansi.Color;
 import org.fusesource.jansi.AnsiConsole;
@@ -51,7 +53,12 @@ import java.io.ObjectInputStream;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.security.KeyPair;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.EnumSet;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
@@ -131,11 +138,12 @@ public class ClientMojo extends AbstractMojo {
             setupAgent(user, keyFile, client);
 
             client.setUserInteraction( new UserInteraction() {
-                public void welcome(String banner) {
+                @Override
+                public void welcome(ClientSession s, String banner, String 
lang) {
                     console.printf(banner);
                 }
-
-                public String[] interactive(String destination, String name, 
String instruction, String[] prompt, boolean[] echo)
+                @Override
+                public String[] interactive(ClientSession s, String name, 
String instruction, String lang, String[] prompt, boolean[] echo)
                 {
                     String[] answers = new String[prompt.length];
                     try {
@@ -154,6 +162,17 @@ public class ClientMojo extends AbstractMojo {
                     }
                     return answers;
                 }
+                @Override
+                public boolean isInteractionAllowed(ClientSession session) {
+                    return true;
+                }
+                @Override
+                public void serverVersionInfo(ClientSession session, 
List<String> lines) {
+                }
+                @Override
+                public String getUpdatedPassword(ClientSession session, String 
prompt, String lang) {
+                    return null;
+                }
             });
             client.start();
             if (console != null) {
@@ -172,7 +191,7 @@ public class ClientMojo extends AbstractMojo {
             channel.setOut( AnsiConsole.wrapOutputStream(sout));
             channel.setErr( AnsiConsole.wrapOutputStream(serr));
             channel.open();
-            channel.waitFor(ClientChannel.CLOSED, 0);
+            channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), 0);
 
             sout.writeTo(System.out);
             serr.writeTo(System.err);
@@ -218,8 +237,8 @@ public class ClientMojo extends AbstractMojo {
             is.close();
             agent.addIdentity(keyPair, user);
             if (keyFile != null) {
-                String[] keyFiles = new String[] { keyFile.getAbsolutePath() };
-                FileKeyPairProvider fileKeyPairProvider = new 
FileKeyPairProvider(keyFiles);
+                AbstractFileKeyPairProvider fileKeyPairProvider = 
SecurityUtils.createFileKeyPairProvider();
+                
fileKeyPairProvider.setPaths(Collections.singleton(keyFile.getAbsoluteFile().toPath()));
                 for (KeyPair key : fileKeyPairProvider.loadKeys()) {
                     agent.addIdentity(key, user);
                 }

http://git-wip-us.apache.org/repos/asf/karaf/blob/23023e72/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/client/DeployMojo.java
----------------------------------------------------------------------
diff --git 
a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/client/DeployMojo.java
 
b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/client/DeployMojo.java
index 308ec0e..21c6f89 100644
--- 
a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/client/DeployMojo.java
+++ 
b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/client/DeployMojo.java
@@ -25,17 +25,19 @@ import org.apache.maven.plugins.annotations.LifecyclePhase;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.plugins.annotations.ResolutionScope;
-import org.apache.sshd.ClientChannel;
-import org.apache.sshd.ClientSession;
-import org.apache.sshd.SshClient;
 import org.apache.sshd.agent.SshAgent;
 import org.apache.sshd.agent.local.AgentImpl;
 import org.apache.sshd.agent.local.LocalAgentFactory;
-import org.apache.sshd.client.UserInteraction;
+import org.apache.sshd.client.SshClient;
+import org.apache.sshd.client.auth.keyboard.UserInteraction;
+import org.apache.sshd.client.channel.ClientChannel;
+import org.apache.sshd.client.channel.ClientChannelEvent;
 import org.apache.sshd.client.future.ConnectFuture;
+import org.apache.sshd.client.session.ClientSession;
 import org.apache.sshd.common.RuntimeSshException;
-import org.apache.sshd.common.keyprovider.FileKeyPairProvider;
 
+import org.apache.sshd.common.keyprovider.AbstractFileKeyPairProvider;
+import org.apache.sshd.common.util.SecurityUtils;
 import org.fusesource.jansi.Ansi;
 import org.fusesource.jansi.Ansi.Color;
 import org.fusesource.jansi.AnsiConsole;
@@ -61,6 +63,8 @@ import java.io.StringWriter;
 import java.net.URL;
 import java.security.KeyPair;
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
@@ -150,11 +154,12 @@ public class DeployMojo extends MojoSupport {
             setupAgent(user, keyFile, client);
 
             client.setUserInteraction( new UserInteraction() {
-                public void welcome(String banner) {
+                @Override
+                public void welcome(ClientSession s, String banner, String 
lang) {
                     console.printf(banner);
                 }
-
-                public String[] interactive(String destination, String name, 
String instruction, String[] prompt, boolean[] echo)
+                @Override
+                public String[] interactive(ClientSession s, String name, 
String instruction, String lang, String[] prompt, boolean[] echo)
                 {
                     String[] answers = new String[prompt.length];
                     try {
@@ -173,6 +178,17 @@ public class DeployMojo extends MojoSupport {
                     }
                     return answers;
                 }
+                @Override
+                public boolean isInteractionAllowed(ClientSession session) {
+                    return true;
+                }
+                @Override
+                public void serverVersionInfo(ClientSession session, 
List<String> lines) {
+                }
+                @Override
+                public String getUpdatedPassword(ClientSession session, String 
prompt, String lang) {
+                    return null;
+                }
             });
             client.start();
             if (console != null) {
@@ -197,7 +213,7 @@ public class DeployMojo extends MojoSupport {
             channel.setOut( AnsiConsole.wrapOutputStream(sout));
             channel.setErr( AnsiConsole.wrapOutputStream(serr));
             channel.open();
-            channel.waitFor(ClientChannel.CLOSED, 0);
+            channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), 0);
 
             sout.writeTo(System.out);
             serr.writeTo(System.err);
@@ -243,8 +259,8 @@ public class DeployMojo extends MojoSupport {
             is.close();
             agent.addIdentity(keyPair, user);
             if (keyFile != null) {
-                String[] keyFiles = new String[] { keyFile.getAbsolutePath() };
-                FileKeyPairProvider fileKeyPairProvider = new 
FileKeyPairProvider(keyFiles);
+                AbstractFileKeyPairProvider fileKeyPairProvider = 
SecurityUtils.createFileKeyPairProvider();
+                
fileKeyPairProvider.setPaths(Collections.singleton(keyFile.getAbsoluteFile().toPath()));
                 for (KeyPair key : fileKeyPairProvider.loadKeys()) {
                     agent.addIdentity(key, user);
                 }

Reply via email to