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

lgoldstein pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git

commit d7b5d39999c550580c35477441f56a1fd9661df3
Author: Lyor Goldstein <lgoldst...@apache.org>
AuthorDate: Tue Aug 6 18:28:53 2019 +0300

    [SSHD-937] Provide ChannelSession instance when creating a subsystem 
instance
---
 CHANGES.md                                         |  5 +++
 .../sshd/cli/server/SshServerCliSupport.java       |  8 ++---
 .../org/apache/sshd/cli/server/SshServerMain.java  |  5 ++-
 .../apache/sshd/server/ServerFactoryManager.java   |  9 +++--
 .../java/org/apache/sshd/server/SshServer.java     |  8 ++---
 .../apache/sshd/server/channel/ChannelSession.java | 12 ++++---
 .../apache/sshd/server/command/CommandFactory.java |  4 +--
 .../sshd/server/subsystem/SubsystemFactory.java    | 42 +++++++++++++++++++---
 .../java/org/apache/sshd/KeyReExchangeTest.java    |  2 +-
 .../subsystem/sftp/SftpSubsystemFactory.java       |  4 ++-
 .../sshd/client/subsystem/sftp/SftpTest.java       | 23 ++++++------
 .../client/subsystem/sftp/SftpVersionsTest.java    | 11 +++---
 .../helpers/SpaceAvailableExtensionImplTest.java   |  7 ++--
 .../openssh/helpers/OpenSSHExtensionsTest.java     |  3 +-
 14 files changed, 92 insertions(+), 51 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index f1b25ee..68722a2 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -18,6 +18,10 @@ session is initiated and protect their instance from 
shutdown when session is de
     server.setSubsystemFactories(Collections.singletonList(factory));
 ```
 
+* `SubsystemFactory` is  a proper interface and it has been refactored to 
contain a
+`createSubsystem` method that accepts the `ChannelSession` through which the 
request
+has been made
+
 ## Minor code helpers
 
 * `SessionListener` supports `sessionPeerIdentificationReceived` that is 
invoked once successful
@@ -32,3 +36,4 @@ for the server's identification before sending its own.
 
 * [SSHD-934](https://issues.apache.org/jira/browse/SSHD-934) - Fixed ECDSA 
public key encoding into OpenSSH format.
 
+* [SSHD-937](https://issues.apache.org/jira/browse/SSHD-937) - Provide 
ChannelSession instance when creating a subsystem instance.
\ No newline at end of file
diff --git 
a/sshd-cli/src/main/java/org/apache/sshd/cli/server/SshServerCliSupport.java 
b/sshd-cli/src/main/java/org/apache/sshd/cli/server/SshServerCliSupport.java
index 3336b52..eee5daa 100644
--- a/sshd-cli/src/main/java/org/apache/sshd/cli/server/SshServerCliSupport.java
+++ b/sshd-cli/src/main/java/org/apache/sshd/cli/server/SshServerCliSupport.java
@@ -40,7 +40,6 @@ import java.util.stream.Stream;
 import org.apache.sshd.cli.CliSupport;
 import org.apache.sshd.cli.server.helper.ServerPortForwardingEventListener;
 import org.apache.sshd.cli.server.helper.SftpServerSubSystemEventListener;
-import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.common.PropertyResolver;
 import org.apache.sshd.common.PropertyResolverUtils;
 import org.apache.sshd.common.config.ConfigFileReaderSupport;
@@ -56,7 +55,6 @@ import org.apache.sshd.common.util.threads.ThreadUtils;
 import org.apache.sshd.server.ServerAuthenticationManager;
 import org.apache.sshd.server.ServerFactoryManager;
 import org.apache.sshd.server.SshServer;
-import org.apache.sshd.server.command.Command;
 import org.apache.sshd.server.config.SshServerConfigFileReader;
 import org.apache.sshd.server.forward.ForwardingFilter;
 import org.apache.sshd.server.keyprovider.AbstractGeneratorHostKeyProvider;
@@ -165,14 +163,14 @@ public abstract class SshServerCliSupport extends 
CliSupport {
         return banner;
     }
 
-    public static List<NamedFactory<Command>> resolveServerSubsystems(
+    public static List<SubsystemFactory> resolveServerSubsystems(
             ServerFactoryManager server, Level level, PrintStream stdout, 
PrintStream stderr, PropertyResolver options)
                 throws Exception {
         ClassLoader cl = 
ThreadUtils.resolveDefaultClassLoader(SubsystemFactory.class);
         String classList = 
System.getProperty(SubsystemFactory.class.getName());
         if (GenericUtils.isNotEmpty(classList)) {
             String[] classes = GenericUtils.split(classList, ',');
-            List<NamedFactory<Command>> subsystems = new 
ArrayList<>(classes.length);
+            List<SubsystemFactory> subsystems = new 
ArrayList<>(classes.length);
             for (String fqcn : classes) {
                 try {
                     Class<?> clazz = cl.loadClass(fqcn);
@@ -204,7 +202,7 @@ public abstract class SshServerCliSupport extends 
CliSupport {
             : Stream.of(GenericUtils.split(nameList, ','))
                 .collect(Collectors.toCollection(() -> new 
TreeSet<>(String.CASE_INSENSITIVE_ORDER)));
         ServiceLoader<SubsystemFactory> loader = 
ServiceLoader.load(SubsystemFactory.class, cl);
-        List<NamedFactory<Command>> subsystems = new ArrayList<>();
+        List<SubsystemFactory> subsystems = new ArrayList<>();
         for (SubsystemFactory factory : loader) {
             String name = factory.getName();
             if (havePreferences && (!preferredNames.contains(name))) {
diff --git 
a/sshd-cli/src/main/java/org/apache/sshd/cli/server/SshServerMain.java 
b/sshd-cli/src/main/java/org/apache/sshd/cli/server/SshServerMain.java
index 10f5955..99c4901 100644
--- a/sshd-cli/src/main/java/org/apache/sshd/cli/server/SshServerMain.java
+++ b/sshd-cli/src/main/java/org/apache/sshd/cli/server/SshServerMain.java
@@ -27,7 +27,6 @@ import java.util.Objects;
 import java.util.TreeMap;
 import java.util.logging.Level;
 
-import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.common.NamedResource;
 import org.apache.sshd.common.PropertyResolver;
 import org.apache.sshd.common.PropertyResolverUtils;
@@ -37,13 +36,13 @@ import org.apache.sshd.common.keyprovider.KeyPairProvider;
 import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.server.SshServer;
 import org.apache.sshd.server.auth.pubkey.AcceptAllPublickeyAuthenticator;
-import org.apache.sshd.server.command.Command;
 import org.apache.sshd.server.config.SshServerConfigFileReader;
 import org.apache.sshd.server.config.keys.ServerIdentity;
 import org.apache.sshd.server.keyprovider.AbstractGeneratorHostKeyProvider;
 import org.apache.sshd.server.scp.ScpCommandFactory;
 import org.apache.sshd.server.shell.ProcessShellCommandFactory;
 import org.apache.sshd.server.shell.ShellFactory;
+import org.apache.sshd.server.subsystem.SubsystemFactory;
 
 /**
  * TODO Add javadoc
@@ -191,7 +190,7 @@ public class SshServerMain extends SshServerCliSupport {
             .withDelegate(ProcessShellCommandFactory.INSTANCE)
             .build());
 
-        List<NamedFactory<Command>> subsystems =
+        List<SubsystemFactory> subsystems =
             resolveServerSubsystems(sshd, level, System.out, System.err, 
resolver);
         if (GenericUtils.isNotEmpty(subsystems)) {
             System.out.append("Setup 
subsystems=").println(NamedResource.getNames(subsystems));
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/server/ServerFactoryManager.java 
b/sshd-core/src/main/java/org/apache/sshd/server/ServerFactoryManager.java
index 6ea4586..10e23b0 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/ServerFactoryManager.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/ServerFactoryManager.java
@@ -22,11 +22,10 @@ import java.util.List;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.sshd.common.FactoryManager;
-import org.apache.sshd.common.NamedFactory;
-import org.apache.sshd.server.command.Command;
 import org.apache.sshd.server.command.CommandFactory;
 import org.apache.sshd.server.session.ServerProxyAcceptorHolder;
 import org.apache.sshd.server.shell.ShellFactory;
+import org.apache.sshd.server.subsystem.SubsystemFactory;
 
 /**
  * The <code>ServerFactoryManager</code> enable the retrieval of additional
@@ -107,8 +106,8 @@ public interface ServerFactoryManager
      * Retrieve the list of named factories for 
<code>CommandFactory.Command</code> to
      * be used to create subsystems.
      *
-     * @return a list of named <code>CommandFactory.Command</code> factories
-     * or {@code null} if subsystems are not supported on this server
+     * @return a list of named {@link SubsystemFactory}-ies
+     * or {@code null}/empty if subsystems are not supported on this server
      */
-    List<NamedFactory<Command>> getSubsystemFactories();
+    List<SubsystemFactory> getSubsystemFactories();
 }
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java 
b/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java
index 05da391..b617cae 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java
@@ -50,13 +50,13 @@ import 
org.apache.sshd.server.auth.hostbased.HostBasedAuthenticator;
 import org.apache.sshd.server.auth.keyboard.KeyboardInteractiveAuthenticator;
 import org.apache.sshd.server.auth.password.PasswordAuthenticator;
 import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
-import org.apache.sshd.server.command.Command;
 import org.apache.sshd.server.command.CommandFactory;
 import org.apache.sshd.server.session.ServerConnectionServiceFactory;
 import org.apache.sshd.server.session.ServerProxyAcceptor;
 import org.apache.sshd.server.session.ServerUserAuthServiceFactory;
 import org.apache.sshd.server.session.SessionFactory;
 import org.apache.sshd.server.shell.ShellFactory;
+import org.apache.sshd.server.subsystem.SubsystemFactory;
 
 /**
  * <p>
@@ -103,7 +103,7 @@ public class SshServer extends AbstractFactoryManager 
implements ServerFactoryMa
     private ShellFactory shellFactory;
     private SessionFactory sessionFactory;
     private CommandFactory commandFactory;
-    private List<NamedFactory<Command>> subsystemFactories;
+    private List<SubsystemFactory> subsystemFactories;
     private List<NamedFactory<UserAuth>> userAuthFactories;
     private KeyPairProvider keyPairProvider;
     private PasswordAuthenticator passwordAuthenticator;
@@ -193,11 +193,11 @@ public class SshServer extends AbstractFactoryManager 
implements ServerFactoryMa
     }
 
     @Override
-    public List<NamedFactory<Command>> getSubsystemFactories() {
+    public List<SubsystemFactory> getSubsystemFactories() {
         return subsystemFactories;
     }
 
-    public void setSubsystemFactories(List<NamedFactory<Command>> 
subsystemFactories) {
+    public void setSubsystemFactories(List<SubsystemFactory> 
subsystemFactories) {
         this.subsystemFactories = subsystemFactories;
     }
 
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java 
b/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
index cf04394..00c2ca3 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
@@ -35,7 +35,6 @@ import org.apache.sshd.agent.SshAgentFactory;
 import org.apache.sshd.agent.common.AgentForwardSupport;
 import org.apache.sshd.common.Closeable;
 import org.apache.sshd.common.FactoryManager;
-import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.common.PropertyResolverUtils;
 import org.apache.sshd.common.RuntimeSshException;
 import org.apache.sshd.common.SshConstants;
@@ -74,6 +73,7 @@ import org.apache.sshd.server.forward.AgentForwardingFilter;
 import org.apache.sshd.server.forward.X11ForwardingFilter;
 import org.apache.sshd.server.session.ServerSession;
 import org.apache.sshd.server.shell.ShellFactory;
+import org.apache.sshd.server.subsystem.SubsystemFactory;
 import org.apache.sshd.server.x11.X11ForwardSupport;
 
 /**
@@ -591,16 +591,18 @@ public class ChannelSession extends AbstractServerChannel 
{
             log.debug("handleSubsystem({})[want-reply={}] subsystem={}", this, 
wantReply, subsystem);
         }
 
-        ServerFactoryManager manager = 
Objects.requireNonNull(getServerSession(), "No server 
session").getFactoryManager();
-        List<NamedFactory<Command>> factories = 
Objects.requireNonNull(manager, "No server factory 
manager").getSubsystemFactories();
+        ServerFactoryManager manager =
+            Objects.requireNonNull(getServerSession(), "No server 
session").getFactoryManager();
+        Collection<SubsystemFactory> factories =
+            Objects.requireNonNull(manager, "No server factory 
manager").getSubsystemFactories();
         if (GenericUtils.isEmpty(factories)) {
             log.warn("handleSubsystem({}) No factories for subsystem: {}", 
this, subsystem);
             return RequestHandler.Result.ReplyFailure;
         }
 
         try {
-            commandInstance = NamedFactory.create(factories, subsystem);
-        } catch (RuntimeException | Error e) {
+            commandInstance = SubsystemFactory.createSubsystem(this,  
factories, subsystem);
+        } catch (IOException | RuntimeException | Error e) {
             log.warn("handleSubsystem({}) Failed ({}) to create command for 
subsystem={}: {}",
                   this, e.getClass().getSimpleName(), subsystem, 
e.getMessage());
             if (log.isDebugEnabled()) {
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/server/command/CommandFactory.java 
b/sshd-core/src/main/java/org/apache/sshd/server/command/CommandFactory.java
index f86d46c..dbd4f0c 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/command/CommandFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/command/CommandFactory.java
@@ -36,8 +36,8 @@ public interface CommandFactory {
      * If the command is not known, a dummy command should be returned to allow
      * the display output to be sent back to the client.
      *
-     * @param channel The {@link ChannelSession} through which the command has 
been
-     * received
+     * @param channel The {@link ChannelSession} through which the command
+     * has been received
      * @param command The command that will be run
      * @return a non {@code null} {@link Command} instance
      * @throws IOException if failed to create the instance
diff --git 
a/sshd-core/src/main/java/org/apache/sshd/server/subsystem/SubsystemFactory.java
 
b/sshd-core/src/main/java/org/apache/sshd/server/subsystem/SubsystemFactory.java
index 8b0cc3f..28b5de7 100644
--- 
a/sshd-core/src/main/java/org/apache/sshd/server/subsystem/SubsystemFactory.java
+++ 
b/sshd-core/src/main/java/org/apache/sshd/server/subsystem/SubsystemFactory.java
@@ -19,14 +19,46 @@
 
 package org.apache.sshd.server.subsystem;
 
-import org.apache.sshd.common.NamedFactory;
+import java.io.IOException;
+import java.util.Collection;
+
+import org.apache.sshd.common.NamedResource;
+import org.apache.sshd.server.channel.ChannelSession;
 import org.apache.sshd.server.command.Command;
 
 /**
  * @author <a href="mailto:d...@mina.apache.org";>Apache MINA SSHD Project</a>
  */
-// CHECKSTYLE:OFF
-public interface SubsystemFactory extends NamedFactory<Command> {
-    // nothing extra
+public interface SubsystemFactory extends NamedResource {
+    /**
+     * @param channel The {@link ChannelSession} through which the command
+     * has been received
+     * @return a non {@code null} {@link Command} instance representing
+     * the subsystem to be run
+     * @throws IOException if failed to create the instance
+     */
+    Command createSubsystem(ChannelSession channel) throws IOException;
+
+    /**
+     * @param channel The {@link ChannelSession} through which the command
+     * has been received
+     * @param factories The available {@link SubsystemFactory}-ies - ignored
+     * if {@code null}/empty
+     * @param name Requested subsystem name
+     * @return The created {@link Command} instance representing
+     * the subsystem to be run - {@code null} if no match found
+     * @throws IOException If found a matching factory but failed to create
+     * the command instance
+     */
+    static Command createSubsystem(
+            ChannelSession channel, Collection<? extends SubsystemFactory> 
factories, String name)
+                throws IOException {
+        SubsystemFactory factory =
+            NamedResource.findByName(name, String.CASE_INSENSITIVE_ORDER, 
factories);
+        if (factory != null) {
+            return factory.createSubsystem(channel);
+        } else {
+            return null;
+        }
+    }
 }
-//CHECKSTYLE:ON
diff --git a/sshd-core/src/test/java/org/apache/sshd/KeyReExchangeTest.java 
b/sshd-core/src/test/java/org/apache/sshd/KeyReExchangeTest.java
index 1d6a3e7..9390383 100644
--- a/sshd-core/src/test/java/org/apache/sshd/KeyReExchangeTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/KeyReExchangeTest.java
@@ -674,7 +674,7 @@ public class KeyReExchangeTest extends BaseTestSupport {
         }
 
         @Override
-        public Command create() {
+        public Command createSubsystem(ChannelSession channel) throws 
IOException {
             return new Command() {
                 private ExitCallback callback;
 
diff --git 
a/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpSubsystemFactory.java
 
b/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpSubsystemFactory.java
index 0dfae8d..4158abc 100644
--- 
a/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpSubsystemFactory.java
+++ 
b/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpSubsystemFactory.java
@@ -19,6 +19,7 @@
 
 package org.apache.sshd.server.subsystem.sftp;
 
+import java.io.IOException;
 import java.util.Objects;
 import java.util.function.Supplier;
 
@@ -26,6 +27,7 @@ import org.apache.sshd.common.subsystem.sftp.SftpConstants;
 import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.ObjectBuilder;
 import org.apache.sshd.common.util.threads.CloseableExecutorService;
+import org.apache.sshd.server.channel.ChannelSession;
 import org.apache.sshd.server.command.Command;
 import org.apache.sshd.server.subsystem.SubsystemFactory;
 
@@ -144,7 +146,7 @@ public class SftpSubsystemFactory
     }
 
     @Override
-    public Command create() {
+    public Command createSubsystem(ChannelSession channel) throws IOException {
         SftpSubsystem subsystem =
             new SftpSubsystem(resolveExecutorService(),
                 getUnsupportedAttributePolicy(), getFileSystemAccessor(),
diff --git 
a/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpTest.java 
b/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpTest.java
index 4ea1003..17b11cf 100644
--- 
a/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpTest.java
+++ 
b/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpTest.java
@@ -70,7 +70,6 @@ import 
org.apache.sshd.client.subsystem.sftp.impl.AbstractSftpClient;
 import org.apache.sshd.client.subsystem.sftp.impl.DefaultCloseableHandle;
 import org.apache.sshd.common.Factory;
 import org.apache.sshd.common.FactoryManager;
-import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.common.OptionalFeature;
 import org.apache.sshd.common.PropertyResolverUtils;
 import org.apache.sshd.common.SshConstants;
@@ -94,8 +93,8 @@ import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.common.util.buffer.BufferUtils;
 import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
 import org.apache.sshd.common.util.io.IoUtils;
-import org.apache.sshd.server.command.Command;
 import org.apache.sshd.server.session.ServerSession;
+import org.apache.sshd.server.subsystem.SubsystemFactory;
 import org.apache.sshd.server.subsystem.sftp.AbstractSftpEventListenerAdapter;
 import org.apache.sshd.server.subsystem.sftp.AbstractSftpSubsystemHelper;
 import org.apache.sshd.server.subsystem.sftp.DirectoryHandle;
@@ -627,10 +626,10 @@ public class SftpTest extends 
AbstractSftpClientTestSupport {
 
     @Test
     public void testSftpFileSystemAccessor() throws Exception {
-        List<NamedFactory<Command>> factories = sshd.getSubsystemFactories();
+        List<SubsystemFactory> factories = sshd.getSubsystemFactories();
         assertEquals("Mismatched subsystem factories count", 1, 
GenericUtils.size(factories));
 
-        NamedFactory<Command> f = factories.get(0);
+        SubsystemFactory f = factories.get(0);
         assertObjectInstanceOf("Not an SFTP subsystem factory", 
SftpSubsystemFactory.class, f);
 
         SftpSubsystemFactory factory = (SftpSubsystemFactory) f;
@@ -721,10 +720,10 @@ public class SftpTest extends 
AbstractSftpClientTestSupport {
     @Test
     @SuppressWarnings({"checkstyle:anoninnerlength", 
"checkstyle:methodlength"})
     public void testClient() throws Exception {
-        List<NamedFactory<Command>> factories = sshd.getSubsystemFactories();
+        List<SubsystemFactory> factories = sshd.getSubsystemFactories();
         assertEquals("Mismatched subsystem factories count", 1, 
GenericUtils.size(factories));
 
-        NamedFactory<Command> f = factories.get(0);
+        SubsystemFactory f = factories.get(0);
         assertObjectInstanceOf("Not an SFTP subsystem factory", 
SftpSubsystemFactory.class, f);
 
         SftpSubsystemFactory factory = (SftpSubsystemFactory) f;
@@ -1333,7 +1332,7 @@ public class SftpTest extends 
AbstractSftpClientTestSupport {
 
     @Test   // see SSHD-621
     public void testServerDoesNotSupportSftp() throws Exception {
-        List<NamedFactory<Command>> factories = sshd.getSubsystemFactories();
+        List<SubsystemFactory> factories = sshd.getSubsystemFactories();
         assertEquals("Mismatched subsystem factories count", 1, 
GenericUtils.size(factories));
 
         sshd.setSubsystemFactories(null);
@@ -1452,10 +1451,10 @@ public class SftpTest extends 
AbstractSftpClientTestSupport {
     public void testCreateSymbolicLink() throws Exception {
         // Do not execute on windows as the file system does not support 
symlinks
         Assume.assumeTrue("Skip non-Unix O/S", OsUtils.isUNIX());
-        List<NamedFactory<Command>> factories = sshd.getSubsystemFactories();
+        List<SubsystemFactory> factories = sshd.getSubsystemFactories();
         assertEquals("Mismatched subsystem factories count", 1, 
GenericUtils.size(factories));
 
-        NamedFactory<Command> f = factories.get(0);
+        SubsystemFactory f = factories.get(0);
         assertObjectInstanceOf("Not an SFTP subsystem factory", 
SftpSubsystemFactory.class, f);
 
         SftpSubsystemFactory factory = (SftpSubsystemFactory) f;
@@ -1478,7 +1477,8 @@ public class SftpTest extends 
AbstractSftpClientTestSupport {
         };
 
         Path targetPath = detectTargetFolder();
-        Path lclSftp = CommonTestSupportUtils.resolve(targetPath, 
SftpConstants.SFTP_SUBSYSTEM_NAME, getClass().getSimpleName(), 
getCurrentTestName());
+        Path lclSftp = CommonTestSupportUtils.resolve(
+            targetPath, SftpConstants.SFTP_SUBSYSTEM_NAME, 
getClass().getSimpleName(), getCurrentTestName());
         CommonTestSupportUtils.deleteRecursive(lclSftp);
 
         /*
@@ -1555,7 +1555,8 @@ public class SftpTest extends 
AbstractSftpClientTestSupport {
                 Path parentPath = targetPath.getParent();
                 String remFilePath = 
CommonTestSupportUtils.resolveRelativeRemotePath(parentPath, lclFile);
 
-                try (FileChannel fc = sftp.openRemotePathChannel(remFilePath, 
EnumSet.of(StandardOpenOption.CREATE, StandardOpenOption.READ, 
StandardOpenOption.WRITE))) {
+                try (FileChannel fc = sftp.openRemotePathChannel(
+                        remFilePath, EnumSet.of(StandardOpenOption.CREATE, 
StandardOpenOption.READ, StandardOpenOption.WRITE))) {
                     int writeLen = fc.write(ByteBuffer.wrap(expected));
                     assertEquals("Mismatched written length", expected.length, 
writeLen);
 
diff --git 
a/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpVersionsTest.java
 
b/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpVersionsTest.java
index af3514a..ea28b5b 100644
--- 
a/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpVersionsTest.java
+++ 
b/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpVersionsTest.java
@@ -49,13 +49,14 @@ import 
org.apache.sshd.client.subsystem.sftp.SftpClient.Attributes;
 import org.apache.sshd.client.subsystem.sftp.SftpClient.CloseableHandle;
 import org.apache.sshd.client.subsystem.sftp.SftpClient.DirEntry;
 import org.apache.sshd.client.subsystem.sftp.SftpClient.OpenMode;
-import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.common.subsystem.sftp.SftpConstants;
 import org.apache.sshd.common.subsystem.sftp.SftpHelper;
 import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.MapEntryUtils.NavigableMapBuilder;
+import org.apache.sshd.server.channel.ChannelSession;
 import org.apache.sshd.server.command.Command;
 import org.apache.sshd.server.session.ServerSession;
+import org.apache.sshd.server.subsystem.SubsystemFactory;
 import org.apache.sshd.server.subsystem.sftp.AbstractSftpEventListenerAdapter;
 import org.apache.sshd.server.subsystem.sftp.DefaultGroupPrincipal;
 import org.apache.sshd.server.subsystem.sftp.SftpEventListener;
@@ -244,7 +245,7 @@ public class SftpVersionsTest extends 
AbstractSftpClientTestSupport {
         AtomicInteger numInvocations = new AtomicInteger(0);
         SftpSubsystemFactory factory = new SftpSubsystemFactory() {
             @Override
-            public Command create() {
+            public Command createSubsystem(ChannelSession channel) throws 
IOException {
                 SftpSubsystem subsystem = new 
SftpSubsystem(resolveExecutorService(),
                         getUnsupportedAttributePolicy(), 
getFileSystemAccessor(), getErrorStatusDataHandler()) {
                     @Override
@@ -317,7 +318,7 @@ public class SftpVersionsTest extends 
AbstractSftpClientTestSupport {
         String remotePath = 
CommonTestSupportUtils.resolveRelativeRemotePath(parentPath, lclSftp);
         int numInvoked = 0;
 
-        List<NamedFactory<Command>> factories = sshd.getSubsystemFactories();
+        List<SubsystemFactory> factories = sshd.getSubsystemFactories();
         sshd.setSubsystemFactories(Collections.singletonList(factory));
         try (ClientSession session = client.connect(getCurrentTestName(), 
TEST_LOCALHOST, port)
                     .verify(CONNECT_TIMEOUT, TimeUnit.SECONDS)
@@ -368,7 +369,7 @@ public class SftpVersionsTest extends 
AbstractSftpClientTestSupport {
         final AtomicInteger numInvocations = new AtomicInteger(0);
         SftpSubsystemFactory factory = new SftpSubsystemFactory() {
             @Override
-            public Command create() {
+            public Command createSubsystem(ChannelSession channel) throws 
IOException {
                 SftpSubsystem subsystem = new 
SftpSubsystem(resolveExecutorService(),
                         getUnsupportedAttributePolicy(), 
getFileSystemAccessor(), getErrorStatusDataHandler()) {
                     @Override
@@ -439,7 +440,7 @@ public class SftpVersionsTest extends 
AbstractSftpClientTestSupport {
         String remotePath = 
CommonTestSupportUtils.resolveRelativeRemotePath(parentPath, lclSftp);
         int numInvoked = 0;
 
-        List<NamedFactory<Command>> factories = sshd.getSubsystemFactories();
+        List<SubsystemFactory> factories = sshd.getSubsystemFactories();
         sshd.setSubsystemFactories(Collections.singletonList(factory));
         try (ClientSession session = client.connect(getCurrentTestName(), 
TEST_LOCALHOST, port)
                     .verify(CONNECT_TIMEOUT, TimeUnit.SECONDS)
diff --git 
a/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/SpaceAvailableExtensionImplTest.java
 
b/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/SpaceAvailableExtensionImplTest.java
index a2a73e1..d7fba62 100644
--- 
a/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/SpaceAvailableExtensionImplTest.java
+++ 
b/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/SpaceAvailableExtensionImplTest.java
@@ -32,10 +32,11 @@ import org.apache.sshd.client.session.ClientSession;
 import org.apache.sshd.client.subsystem.sftp.AbstractSftpClientTestSupport;
 import org.apache.sshd.client.subsystem.sftp.SftpClient;
 import 
org.apache.sshd.client.subsystem.sftp.extensions.SpaceAvailableExtension;
-import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.common.subsystem.sftp.SftpConstants;
 import 
org.apache.sshd.common.subsystem.sftp.extensions.SpaceAvailableExtensionInfo;
+import org.apache.sshd.server.channel.ChannelSession;
 import org.apache.sshd.server.command.Command;
+import org.apache.sshd.server.subsystem.SubsystemFactory;
 import org.apache.sshd.server.subsystem.sftp.SftpSubsystem;
 import org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory;
 import org.apache.sshd.util.test.CommonTestSupportUtils;
@@ -67,10 +68,10 @@ public class SpaceAvailableExtensionImplTest extends 
AbstractSftpClientTestSuppo
         final String queryPath = 
CommonTestSupportUtils.resolveRelativeRemotePath(parentPath, lclSftp);
         final SpaceAvailableExtensionInfo expected = new 
SpaceAvailableExtensionInfo(store);
 
-        List<NamedFactory<Command>> factories = sshd.getSubsystemFactories();
+        List<SubsystemFactory> factories = sshd.getSubsystemFactories();
         sshd.setSubsystemFactories(Collections.singletonList(new 
SftpSubsystemFactory() {
             @Override
-            public Command create() {
+            public Command createSubsystem(ChannelSession channel) throws 
IOException {
                 return new SftpSubsystem(resolveExecutorService(),
                         getUnsupportedAttributePolicy(), 
getFileSystemAccessor(), getErrorStatusDataHandler()) {
                     @Override
diff --git 
a/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/helpers/OpenSSHExtensionsTest.java
 
b/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/helpers/OpenSSHExtensionsTest.java
index 4cc7a46..1a98bbb 100644
--- 
a/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/helpers/OpenSSHExtensionsTest.java
+++ 
b/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/helpers/OpenSSHExtensionsTest.java
@@ -48,6 +48,7 @@ import 
org.apache.sshd.common.subsystem.sftp.extensions.openssh.StatVfsExtension
 import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.common.util.io.IoUtils;
+import org.apache.sshd.server.channel.ChannelSession;
 import org.apache.sshd.server.command.Command;
 import org.apache.sshd.server.session.ServerSession;
 import org.apache.sshd.server.subsystem.sftp.SftpSubsystem;
@@ -125,7 +126,7 @@ public class OpenSSHExtensionsTest extends 
AbstractSftpClientTestSupport {
 
         sshd.setSubsystemFactories(Collections.singletonList(new 
SftpSubsystemFactory() {
             @Override
-            public Command create() {
+            public Command createSubsystem(ChannelSession channel) throws 
IOException {
                 return new SftpSubsystem(resolveExecutorService(),
                         getUnsupportedAttributePolicy(), 
getFileSystemAccessor(), getErrorStatusDataHandler()) {
                     @Override

Reply via email to