如何在Apache Mina sshd-core版本0.14.0中覆盖getVirtualUserDir() [英] How to override getVirtualUserDir() in Apache Mina sshd-core version 0.14.0

查看:408
本文介绍了如何在Apache Mina sshd-core版本0.14.0中覆盖getVirtualUserDir()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Apache Mina sshd-core版本0.10.0。由于文件上传的一些问题我不得不将版本更改为0.14.0。在那里我无法覆盖getVirtualUserDir()方法。下面是我的示例代码,

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

我想知道如何在Apache Mina sshd-core版本0.14中克服这个问题。 0。谢谢。

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

推荐答案

Mina SSHD 0.10中 getVirtualUserDir 的目的。 0是设置文件系统的初始目录。

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

在Mina SSHD 0.14.0中,相同的目的是由当前参数 NativeFileSystemView 构造函数:

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)

请注意,文档声称不会调用构造函数直接使用 NativeFileSystemFactory 。但 NativeFileSystemFactory 从不调用构造函数的重载。评论已过时或工厂尚未完成。

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.

或者这是一个错字,它应该实际上是指 VirtualFileSystemFactory 。您应该使用的工厂是什么,而不是覆盖 NativeFileSystemFactory

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

这篇关于如何在Apache Mina sshd-core版本0.14.0中覆盖getVirtualUserDir()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆