This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch sshd
in repository https://gitbox.apache.org/repos/asf/maven-wagon.git

commit 80094e556580d2f9e47275b07fa9e3ec9d015688
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Mon Oct 20 07:58:18 2025 +0200

    Update code to work with SSHD 2.13.2 API
    
    ---------
    Co-authored-by: copilot-swe-agent[bot] 
<[email protected]>
    Co-authored-by: slachiewicz <[email protected]>
---
 wagon-providers/wagon-ssh-common-test/pom.xml      |  18 +-
 .../maven/wagon/providers/ssh/ScpCommand.java      | 455 ---------------------
 .../wagon/providers/ssh/ScpCommandFactory.java     |  93 -----
 .../maven/wagon/providers/ssh/ShellCommand.java    |   7 +-
 .../wagon/providers/ssh/SshServerEmbedded.java     |  87 +---
 .../providers/ssh/TestPasswordAuthenticator.java   |   2 +-
 .../providers/ssh/TestPublickeyAuthenticator.java  |   6 +-
 7 files changed, 37 insertions(+), 631 deletions(-)

diff --git a/wagon-providers/wagon-ssh-common-test/pom.xml 
b/wagon-providers/wagon-ssh-common-test/pom.xml
index 23393a3f..106b5d1e 100644
--- a/wagon-providers/wagon-ssh-common-test/pom.xml
+++ b/wagon-providers/wagon-ssh-common-test/pom.xml
@@ -29,6 +29,9 @@ under the License.
   <artifactId>wagon-ssh-common-test</artifactId>
   <name>Apache Maven Wagon :: Providers :: SSH Common Tests</name>
 
+  <properties>
+    <sshdVersion>2.13.2</sshdVersion>
+  </properties>
   <dependencies>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
@@ -54,8 +57,19 @@ under the License.
     <dependency>
       <groupId>org.apache.sshd</groupId>
       <artifactId>sshd-core</artifactId>
-      <!-- lots of changes in later versions, we drop SSH provider in 4.x 
version -->
-      <version>0.8.0</version>
+      <version>${sshdVersion}</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.sshd</groupId>
+      <artifactId>sshd-scp</artifactId>
+      <version>${sshdVersion}</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.sshd</groupId>
+      <artifactId>sshd-sftp</artifactId>
+      <version>${sshdVersion}</version>
       <scope>compile</scope>
     </dependency>
     <dependency>
diff --git 
a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/ScpCommand.java
 
b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/ScpCommand.java
deleted file mode 100644
index 2348161d..00000000
--- 
a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/ScpCommand.java
+++ /dev/null
@@ -1,455 +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.maven.wagon.providers.ssh;
-
-import java.io.ByteArrayOutputStream;
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Arrays;
-
-import org.apache.sshd.common.util.DirectoryScanner;
-import org.apache.sshd.server.Command;
-import org.apache.sshd.server.Environment;
-import org.apache.sshd.server.ExitCallback;
-import org.apache.sshd.server.FileSystemAware;
-import org.apache.sshd.server.FileSystemView;
-import org.apache.sshd.server.SshFile;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This commands provide SCP support on both server and client side.
- * Permissions and preservation of access / modification times on files
- * are not supported.
- * olamy : copy of a class from mina for changing return codes in case of file 
not found 1 warning instead of 2
- *
- * @author <a href="mailto:[email protected]";>Apache MINA SSHD Project</a>
- */
-public class ScpCommand implements Command, Runnable, FileSystemAware {
-
-    protected static final Logger LOG = 
LoggerFactory.getLogger(ScpCommand.class);
-
-    protected static final int OK = 0;
-
-    protected static final int WARNING = 1;
-
-    protected static final int ERROR = 2;
-
-    protected String name;
-
-    protected boolean optR;
-
-    protected boolean optT;
-
-    protected boolean optF;
-
-    protected boolean optV;
-
-    protected boolean optD;
-
-    protected boolean optP;
-
-    protected FileSystemView root;
-
-    protected String path;
-
-    protected InputStream in;
-
-    protected OutputStream out;
-
-    protected OutputStream err;
-
-    protected ExitCallback callback;
-
-    protected IOException error;
-
-    public ScpCommand(String[] args) {
-        name = Arrays.asList(args).toString();
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Executing command {}", name);
-        }
-        path = ".";
-        for (int i = 1; i < args.length; i++) {
-            if (args[i].charAt(0) == '-') {
-                for (int j = 1; j < args[i].length(); j++) {
-                    switch (args[i].charAt(j)) {
-                        case 'f':
-                            optF = true;
-                            break;
-                        case 'p':
-                            optP = true;
-                            break;
-                        case 'r':
-                            optR = true;
-                            break;
-                        case 't':
-                            optT = true;
-                            break;
-                        case 'v':
-                            optV = true;
-                            break;
-                        case 'd':
-                            optD = true;
-                            break;
-                        default:
-                    }
-                }
-            } else if (i == args.length - 1) {
-                path = args[args.length - 1];
-            }
-        }
-        if (!optF && !optT) {
-            error = new IOException("Either -f or -t option should be set");
-        }
-    }
-
-    public void setInputStream(InputStream in) {
-        this.in = in;
-    }
-
-    public void setOutputStream(OutputStream out) {
-        this.out = out;
-    }
-
-    public void setErrorStream(OutputStream err) {
-        this.err = err;
-    }
-
-    public void setExitCallback(ExitCallback callback) {
-        this.callback = callback;
-    }
-
-    public void start(Environment env) throws IOException {
-        if (error != null) {
-            throw error;
-        }
-        new Thread(this, "ScpCommand: " + name).start();
-    }
-
-    public void destroy() {}
-
-    public void run() {
-        int exitValue = OK;
-        String exitMessage = null;
-
-        try {
-            if (optT) {
-                ack();
-                for (; ; ) {
-                    String line;
-                    boolean isDir = false;
-                    int c = readAck(true);
-                    switch (c) {
-                        case -1:
-                            return;
-                        case 'D':
-                            isDir = true;
-                        case 'C':
-                            line = ((char) c) + readLine();
-                            break;
-                        case 'E':
-                            readLine();
-                            return;
-                        default:
-                            // a real ack that has been acted upon already
-                            continue;
-                    }
-
-                    if (optR && isDir) {
-                        writeDir(line, root.getFile(path));
-                    } else {
-                        writeFile(line, root.getFile(path));
-                    }
-                }
-            } else if (optF) {
-                String pattern = path;
-                int idx = pattern.indexOf('*');
-                if (idx >= 0) {
-                    String basedir = "";
-                    int lastSep = pattern.substring(0, idx).lastIndexOf('/');
-                    if (lastSep >= 0) {
-                        basedir = pattern.substring(0, lastSep);
-                        pattern = pattern.substring(lastSep + 1);
-                    }
-                    String[] included = new DirectoryScanner(basedir, 
pattern).scan();
-                    for (String path : included) {
-                        SshFile file = root.getFile(basedir + "/" + path);
-                        if (file.isFile()) {
-                            readFile(file);
-                        } else if (file.isDirectory()) {
-                            if (!optR) {
-                                out.write(WARNING);
-                                out.write((path + " not a regular 
file\n").getBytes());
-                            } else {
-                                readDir(file);
-                            }
-                        } else {
-                            out.write(WARNING);
-                            out.write((path + " unknown file 
type\n").getBytes());
-                        }
-                    }
-                } else {
-                    String basedir = "";
-                    int lastSep = pattern.lastIndexOf('/');
-                    if (lastSep >= 0) {
-                        basedir = pattern.substring(0, lastSep);
-                        pattern = pattern.substring(lastSep + 1);
-                    }
-                    SshFile file = root.getFile(basedir + "/" + pattern);
-                    if (!file.doesExist()) {
-                        exitValue = WARNING;
-                        throw new IOException(file + ": no such file or 
directory");
-                    }
-                    if (file.isFile()) {
-                        readFile(file);
-                    } else if (file.isDirectory()) {
-                        if (!optR) {
-                            throw new IOException(file + " not a regular 
file");
-                        } else {
-                            readDir(file);
-                        }
-                    } else {
-                        throw new IOException(file + ": unknown file type");
-                    }
-                }
-            } else {
-                throw new IOException("Unsupported mode");
-            }
-        } catch (IOException e) {
-            try {
-                exitValue = (exitValue != OK ? exitValue : ERROR);
-                exitMessage = e.getMessage();
-                out.write(exitValue);
-                out.write(exitMessage.getBytes());
-                out.write('\n');
-                out.flush();
-            } catch (IOException e2) {
-                // Ignore
-            }
-            LOG.info("Error in scp command", e);
-        } finally {
-            if (callback != null) {
-                callback.onExit(exitValue, exitMessage);
-            }
-        }
-    }
-
-    protected void writeDir(String header, SshFile path) throws IOException {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Writing dir {}", path);
-        }
-        if (!header.startsWith("D")) {
-            throw new IOException("Expected a D message but got '" + header + 
"'");
-        }
-
-        int length = Integer.parseInt(header.substring(6, header.indexOf(' ', 
6)));
-        String name = header.substring(header.indexOf(' ', 6) + 1);
-
-        if (length != 0) {
-            throw new IOException("Expected 0 length for directory but got " + 
length);
-        }
-        SshFile file;
-        if (path.doesExist() && path.isDirectory()) {
-            file = root.getFile(path, name);
-        } else if (!path.doesExist()
-                && path.getParentFile().doesExist()
-                && path.getParentFile().isDirectory()) {
-            file = path;
-        } else {
-            throw new IOException("Can not write to " + path);
-        }
-        if (!(file.doesExist() && file.isDirectory()) && !file.mkdir()) {
-            throw new IOException("Could not create directory " + file);
-        }
-
-        ack();
-
-        for (; ; ) {
-            header = readLine();
-            if (header.startsWith("C")) {
-                writeFile(header, file);
-            } else if (header.startsWith("D")) {
-                writeDir(header, file);
-            } else if (header.equals("E")) {
-                ack();
-                break;
-            } else {
-                throw new IOException("Unexpected message: '" + header + "'");
-            }
-        }
-    }
-
-    protected void writeFile(String header, SshFile path) throws IOException {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Writing file {}", path);
-        }
-        if (!header.startsWith("C")) {
-            throw new IOException("Expected a C message but got '" + header + 
"'");
-        }
-
-        long length = Long.parseLong(header.substring(6, header.indexOf(' ', 
6)));
-        String name = header.substring(header.indexOf(' ', 6) + 1);
-
-        SshFile file;
-        if (path.doesExist() && path.isDirectory()) {
-            file = root.getFile(path, name);
-        } else if (path.doesExist() && path.isFile()) {
-            file = path;
-        } else if (!path.doesExist()
-                && path.getParentFile().doesExist()
-                && path.getParentFile().isDirectory()) {
-            file = path;
-        } else {
-            throw new IOException("Can not write to " + path);
-        }
-        if (file.doesExist() && file.isDirectory()) {
-            throw new IOException("File is a directory: " + file);
-        } else if (file.doesExist() && !file.isWritable()) {
-            throw new IOException("Can not write to file: " + file);
-        }
-        OutputStream os = file.createOutputStream(0);
-        try {
-            ack();
-
-            byte[] buffer = new byte[8 * 1024];
-            while (length > 0) {
-                int len = (int) Math.min(length, buffer.length);
-                len = in.read(buffer, 0, len);
-                if (len <= 0) {
-                    throw new IOException("End of stream reached");
-                }
-                os.write(buffer, 0, len);
-                length -= len;
-            }
-        } finally {
-            os.close();
-        }
-
-        ack();
-        readAck(false);
-    }
-
-    protected String readLine() throws IOException {
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        for (; ; ) {
-            int c = in.read();
-            if (c == '\n') {
-                return baos.toString();
-            } else if (c == -1) {
-                throw new IOException("End of stream");
-            } else {
-                baos.write(c);
-            }
-        }
-    }
-
-    protected void readFile(SshFile path) throws IOException {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Reading file {}", path);
-        }
-        StringBuilder buf = new StringBuilder();
-        buf.append("C");
-        buf.append("0644"); // what about perms
-        buf.append(" ");
-        buf.append(path.getSize()); // length
-        buf.append(" ");
-        buf.append(path.getName());
-        buf.append("\n");
-        out.write(buf.toString().getBytes());
-        out.flush();
-        readAck(false);
-
-        InputStream is = path.createInputStream(0);
-        try {
-            byte[] buffer = new byte[8 * 1024];
-            for (; ; ) {
-                int len = is.read(buffer, 0, buffer.length);
-                if (len == -1) {
-                    break;
-                }
-                out.write(buffer, 0, len);
-            }
-        } finally {
-            is.close();
-        }
-        ack();
-        readAck(false);
-    }
-
-    protected void readDir(SshFile path) throws IOException {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Reading directory {}", path);
-        }
-        StringBuilder buf = new StringBuilder();
-        buf.append("D");
-        buf.append("0755"); // what about perms
-        buf.append(" ");
-        buf.append("0"); // length
-        buf.append(" ");
-        buf.append(path.getName());
-        buf.append("\n");
-        out.write(buf.toString().getBytes());
-        out.flush();
-        readAck(false);
-
-        for (SshFile child : path.listSshFiles()) {
-            if (child.isFile()) {
-                readFile(child);
-            } else if (child.isDirectory()) {
-                readDir(child);
-            }
-        }
-
-        out.write("E\n".getBytes());
-        out.flush();
-        readAck(false);
-    }
-
-    protected void ack() throws IOException {
-        out.write(0);
-        out.flush();
-    }
-
-    protected int readAck(boolean canEof) throws IOException {
-        int c = in.read();
-        switch (c) {
-            case -1:
-                if (!canEof) {
-                    throw new EOFException();
-                }
-                break;
-            case OK:
-                break;
-            case WARNING:
-                LOG.warn("Received warning: " + readLine());
-                break;
-            case ERROR:
-                throw new IOException("Received nack: " + readLine());
-            default:
-                break;
-        }
-        return c;
-    }
-
-    public void setFileSystemView(FileSystemView view) {
-        this.root = view;
-    }
-}
diff --git 
a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/ScpCommandFactory.java
 
b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/ScpCommandFactory.java
deleted file mode 100644
index 02f022d9..00000000
--- 
a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/ScpCommandFactory.java
+++ /dev/null
@@ -1,93 +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.maven.wagon.providers.ssh;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.sshd.server.Command;
-import org.apache.sshd.server.CommandFactory;
-
-/**
- * This <code>CommandFactory</code> can be used as a standalone command factory
- * or can be used to augment another <code>CommandFactory</code> and provides
- * <code>SCP</code> support.
- *
- * @see ScpCommand
- *
- * @author <a href="mailto:[email protected]";>Apache MINA SSHD Project</a>
- */
-public class ScpCommandFactory implements CommandFactory {
-
-    private CommandFactory delegate;
-
-    public ScpCommandFactory() {}
-
-    public ScpCommandFactory(CommandFactory delegate) {
-        this.delegate = delegate;
-    }
-
-    /**
-     * Parses a command string and verifies that the basic syntax is
-     * correct. If parsing fails the responsibility is delegated to
-     * the configured {@link org.apache.sshd.server.CommandFactory} instance; 
if one exist.
-     *
-     * @param command command to parse
-     * @return configured {@link org.apache.sshd.server.Command} instance
-     * @throws IllegalArgumentException
-     */
-    public Command createCommand(String command) {
-        try {
-            return new ScpCommand(splitCommandString(command));
-        } catch (IllegalArgumentException iae) {
-            if (delegate != null) {
-                return delegate.createCommand(command);
-            }
-            throw iae;
-        }
-    }
-
-    private String[] splitCommandString(String command) {
-        if (!command.trim().startsWith("scp")) {
-            throw new IllegalArgumentException("Unknown command, does not 
begin with 'scp'");
-        }
-
-        String[] args = command.split(" ");
-        List<String> parts = new ArrayList<>();
-        parts.add(args[0]);
-        for (int i = 1; i < args.length; i++) {
-            if (!args[i].trim().startsWith("-")) {
-                parts.add(concatenateWithSpace(args, i));
-                break;
-            } else {
-                parts.add(args[i]);
-            }
-        }
-        return parts.toArray(new String[parts.size()]);
-    }
-
-    private String concatenateWithSpace(String[] args, int from) {
-        StringBuilder sb = new StringBuilder();
-
-        for (int i = from; i < args.length; i++) {
-            sb.append(args[i] + " ");
-        }
-        return sb.toString().trim();
-    }
-}
diff --git 
a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/ShellCommand.java
 
b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/ShellCommand.java
index 16becbda..17afa6cd 100644
--- 
a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/ShellCommand.java
+++ 
b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/ShellCommand.java
@@ -24,9 +24,10 @@
 import java.io.OutputStream;
 import java.nio.file.Files;
 
-import org.apache.sshd.server.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.codehaus.plexus.util.cli.CommandLineUtils;
 import org.codehaus.plexus.util.cli.Commandline;
 
@@ -72,7 +73,7 @@ public void setExitCallback(ExitCallback callback) {
         this.callback = callback;
     }
 
-    public void start(Environment env) throws IOException {
+    public void start(ChannelSession channel, Environment env) throws 
IOException {
         File tmpFile = File.createTempFile("wagon", "test-sh");
         tmpFile.deleteOnExit();
         int exitValue = 0;
@@ -109,7 +110,7 @@ public void start(Environment env) throws IOException {
         out.flush();
     }
 
-    public void destroy() {}
+    public void destroy(ChannelSession channel) throws Exception {}
 
     private void deleteQuietly(File f) {
 
diff --git 
a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/SshServerEmbedded.java
 
b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/SshServerEmbedded.java
index eefb64d6..a314869b 100644
--- 
a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/SshServerEmbedded.java
+++ 
b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/SshServerEmbedded.java
@@ -21,26 +21,14 @@
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 
-import org.apache.mina.core.session.IoSession;
-import org.apache.sshd.SshServer;
-import org.apache.sshd.common.Session;
-import org.apache.sshd.common.session.AbstractSession;
-import org.apache.sshd.server.Command;
-import org.apache.sshd.server.CommandFactory;
-import org.apache.sshd.server.FileSystemFactory;
-import org.apache.sshd.server.FileSystemView;
-import org.apache.sshd.server.PasswordAuthenticator;
-import org.apache.sshd.server.SshFile;
-import org.apache.sshd.server.auth.UserAuthPassword;
-import org.apache.sshd.server.auth.UserAuthPublicKey;
-import org.apache.sshd.server.filesystem.NativeSshFile;
-import org.apache.sshd.server.keyprovider.PEMGeneratorHostKeyProvider;
-import org.apache.sshd.server.session.SessionFactory;
+import org.apache.sshd.common.file.nativefs.NativeFileSystemFactory;
+import org.apache.sshd.scp.server.ScpCommandFactory;
+import org.apache.sshd.server.SshServer;
+import org.apache.sshd.server.auth.password.PasswordAuthenticator;
+import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
 import org.apache.sshd.server.shell.ProcessShellFactory;
-import org.codehaus.plexus.util.FileUtils;
 
 /**
  * @author Olivier Lamy
@@ -84,79 +72,39 @@ public SshServerEmbedded(String wagonProtocol, List<String> 
sshKeysResources, bo
     public int start() throws IOException {
         sshd.setPort(0);
 
-        sshd.setUserAuthFactories(Arrays.asList(new 
UserAuthPublicKey.Factory(), new UserAuthPassword.Factory()));
-
         sshd.setPublickeyAuthenticator(this.publickeyAuthenticator);
 
         sshd.setPasswordAuthenticator(this.passwordAuthenticator);
 
-        sshd.setUserAuthFactories(Arrays.asList(new 
UserAuthPublicKey.Factory(), new UserAuthPassword.Factory()));
-
         File path = new File("target/keys");
         path.mkdirs();
         path = new File(path, "simple.key");
         path.delete();
 
-        PEMGeneratorHostKeyProvider provider = new 
PEMGeneratorHostKeyProvider();
+        SimpleGeneratorHostKeyProvider provider = new 
SimpleGeneratorHostKeyProvider(path.toPath());
         provider.setAlgorithm("RSA");
         provider.setKeySize(1024);
-        provider.setPath(path.getPath());
 
         sshd.setKeyPairProvider(provider);
-        SessionFactory sessionFactory = new SessionFactory() {
-            @Override
-            protected AbstractSession doCreateSession(IoSession ioSession) 
throws Exception {
-                return super.doCreateSession(ioSession);
-            }
-        };
-        sshd.setSessionFactory(sessionFactory);
 
         // sshd.setFileSystemFactory(  );
 
-        final ProcessShellFactory processShellFactory = new 
ProcessShellFactory(new String[] {"/bin/sh", "-i", "-l"});
+        final ProcessShellFactory processShellFactory = new 
ProcessShellFactory("/bin/sh", "-i", "-l");
         sshd.setShellFactory(processShellFactory);
 
-        CommandFactory delegateCommandFactory = new CommandFactory() {
-            public Command createCommand(String command) {
-                return new ShellCommand(command);
-            }
-        };
-
-        ScpCommandFactory commandFactory = new 
ScpCommandFactory(delegateCommandFactory);
+        ScpCommandFactory commandFactory = new ScpCommandFactory.Builder()
+                .withDelegate((channel, command) -> new ShellCommand(command))
+                .build();
         sshd.setCommandFactory(commandFactory);
 
-        FileSystemFactory fileSystemFactory = new FileSystemFactory() {
-            public FileSystemView createFileSystemView(Session session) throws 
IOException {
-                return new FileSystemView() {
-                    public SshFile getFile(String file) {
-                        file = file.replace("\\", "");
-                        file = file.replace("\"", "");
-                        File f = new File(FileUtils.normalize(file));
-
-                        return new SshServerEmbedded.TestSshFile(
-                                f.getAbsolutePath(), f, 
System.getProperty("user.name"));
-                    }
-
-                    public SshFile getFile(SshFile baseDir, String file) {
-                        file = file.replace("\\", "");
-                        file = file.replace("\"", "");
-                        File f = new File(FileUtils.normalize(file));
-                        return new SshServerEmbedded.TestSshFile(
-                                f.getAbsolutePath(), f, 
System.getProperty("user.name"));
-                    }
-                };
-            }
-        };
-        sshd.setNioWorkers(0);
-        // sshd.setScheduledExecutorService(  );
-        sshd.setFileSystemFactory(fileSystemFactory);
+        sshd.setFileSystemFactory(new NativeFileSystemFactory());
         sshd.start();
         this.port = sshd.getPort();
         return this.port;
     }
 
-    public void stop() throws InterruptedException {
-        sshd.stop(Boolean.getBoolean("sshd.stopImmediatly"));
+    public void stop() throws IOException {
+        sshd.stop();
     }
 
     public int getPort() {
@@ -166,13 +114,4 @@ public int getPort() {
     public PasswordAuthenticator getPasswordAuthenticator() {
         return passwordAuthenticator;
     }
-    /**
-     *
-     */
-    public static class TestSshFile extends NativeSshFile {
-        public TestSshFile(String fileName, File file, String userName) {
-
-            super(FileUtils.normalize(fileName), file, userName);
-        }
-    }
 }
diff --git 
a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestPasswordAuthenticator.java
 
b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestPasswordAuthenticator.java
index b25f64f4..f987ef19 100644
--- 
a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestPasswordAuthenticator.java
+++ 
b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestPasswordAuthenticator.java
@@ -21,7 +21,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.sshd.server.PasswordAuthenticator;
+import org.apache.sshd.server.auth.password.PasswordAuthenticator;
 import org.apache.sshd.server.session.ServerSession;
 import org.codehaus.plexus.util.StringUtils;
 
diff --git 
a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestPublickeyAuthenticator.java
 
b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestPublickeyAuthenticator.java
index e77bef72..3f387527 100644
--- 
a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestPublickeyAuthenticator.java
+++ 
b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestPublickeyAuthenticator.java
@@ -29,10 +29,10 @@
 import java.security.spec.DSAPublicKeySpec;
 import java.security.spec.RSAPublicKeySpec;
 import java.util.ArrayList;
+import java.util.Base64;
 import java.util.List;
 
-import org.apache.mina.util.Base64;
-import org.apache.sshd.server.PublickeyAuthenticator;
+import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
 import org.apache.sshd.server.session.ServerSession;
 import org.codehaus.plexus.util.IOUtil;
 
@@ -111,7 +111,7 @@ public PublicKey decodePublicKey(String keyLine) throws 
Exception {
 
         for (String part : keyLine.split(" ")) {
             if (part.startsWith("AAAA")) {
-                bytes = Base64.decodeBase64(part.getBytes());
+                bytes = Base64.getDecoder().decode(part.getBytes());
                 break;
             }
         }

Reply via email to