【问题标题】:Apache FTPServer -- restricting commands like 'DELE'Apache FTPServer - 限制诸如“DELE”之类的命令
【发布时间】:2015-01-19 15:10:43
【问题描述】:

我正在使用 Apache Mina FTPServer。正如documentation 中提到的,我正在扩展DefaultFtplet 类。我将打印件 (SOP) 放入文档中提到的一些事件中,例如 onConnect 等,一切正常。

现在,我想限制DELE 命令,因此根据文档,我已经覆盖了onDeleteStart 方法,但是客户端挂起并断开连接我的任何消息。

由于我无法为这种情况找到任何更具体的文档,以下是我的代码:

@Override
public FtpletResult onDeleteStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
    System.out.println("\n\n\nonDeleteStart\n\n\n");

    FtpReply reply = new FtpReply() {

        @Override
        public String getMessage() {
            return "Deletion not supported";
        }

        @Override
        public int getCode() {
            return FtpReply.REPLY_450_REQUESTED_FILE_ACTION_NOT_TAKEN;
        }
    };
    session.write(reply); // Not sure if this is the right way!

    return FtpletResult.SKIP;
}

请让我知道我在这里缺少什么,或者这是正确的做法吗?

客户端(ftp 命令行和WinSCP)未从getMessage() 获取消息,并挂起并随后断开连接

【问题讨论】:

    标签: java ftp-server


    【解决方案1】:

    您可以使用DefaultFtpReply 而不是创建new FtpReply()

    FtpReply reply = new DefaultFtpReply(FtpReply.REPLY_450_REQUESTED_FILE_ACTION_NOT_TAKEN, 
    "Deletion not supported");
    session.write(reply );
    

    【讨论】:

      猜你喜欢
      • 2023-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多