How to override getVirtualUserDir() in Apache Mina sshd-core version 0.14.0
Asked Answered
C

1

3

I used Apache Mina sshd-core version 0.10.0.Due to some issues with file uploading i had to change version into 0.14.0.In there i can not override getVirtualUserDir() method. Below is my sample code,

sshd.setFileSystemFactory(new NativeFileSystemFactory() {
        @Override
        public FileSystemView createFileSystemView(final Session session) {
            return new NativeFileSystemView(session.getUsername(), false) {
                @Override
                public String getVirtualUserDir() {

                    return "C:/root";
                }
            };
        };
    });

I would like to know that how can i overcome that problem in Apache Mina sshd-core version 0.14.0. Thanks.

Career answered 22/4, 2015 at 6:57 Comment(0)
S
7

The purpose of the getVirtualUserDir in Mina SSHD 0.10.0 was to set an initial directory of the file system.

In Mina SSHD 0.14.0 the same purpose is served by current parameter of NativeFileSystemView constructor:

public NativeFileSystemView(String userName, Map<String, String> roots, String current)

Note that the documentation claims not to call the constructor directly and use NativeFileSystemFactory instead. But the NativeFileSystemFactory never calls that overload of the constructor. Either the comment is obsolete or the factory is not finished yet.

Or it's a typo and it should have actually referred to VirtualFileSystemFactory. What is the factory you probably should use instead of overriding NativeFileSystemFactory.

sshd.setFileSystemFactory(new VirtualFileSystemFactory("C:/root"));
Seadon answered 22/4, 2015 at 7:18 Comment(1)
You save my time buddy.Career

© 2022 - 2024 — McMap. All rights reserved.