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

限于喜欢 提交于 2019-11-30 08:50:46

问题


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.


回答1:


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"));


来源:https://stackoverflow.com/questions/29789995/how-to-override-getvirtualuserdir-in-apache-mina-sshd-core-version-0-14-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!