gpt4 book ai didi

java - 代理身份验证失败错误

转载 作者:行者123 更新时间:2023-11-29 05:46:54 26 4
gpt4 key购买 nike

我正在尝试通过 FTP SITE 代理访问 FTP 服务器,以使用 it.sauronsoftware.ftp4j.FTPClient 绕过防火墙 我知道我的用户名/密码是正确的,因为我可以使用 FileZilla 进行连接.我尝试使用 Authenticator,但没有用。代码:

import java.net.Authenticator;
import it.sauronsoftware.ftp4j.FTPClient;
import it.sauronsoftware.ftp4j.connectors.FTPProxyConnector;
...
FTPClient client = new FTPClient();
FTPProxyConnector connector = new FTPProxyConnector(String "proxyHost", int proxyPort);
client.setConnector(connector);

Authenticator.setDefault(new Authenticator() {
@Override
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("proxyUser", "proxyPass".toCharArray());
}});

System.setProperty("ftp.proxyHost", "proxyHost");
System.setProperty("ftp.proxyPort", "proxyPort");
System.setProperty("ftp.proxyUser", "proxyUser");
System.setProperty("ftp.proxyPass", "proxyPass");

System.out.println("Proxy Accessed");

client.connect("ftpHost");
client.login("ftpUser", "ftpPass");

给我这个错误:java.io.IOException: Proxy authentication failed

我尝试过的事情:

  • 使用备用构造函数(String, int, String, String)
  • 删除Authenticator
  • 仅使用 Authenticator,不使用 FTPProxyConnector
  • 在设置连接器之前进行身份验证,反之亦然。

但是,当我只是使用 Authenticator 时,我收到一个不同的错误,提示 Connection timed out

这两个错误都发生在 client.connect("ftpHost"); 行上

任何帮助将不胜感激。

备注:The FTP Proxy Connector

编辑:我发现代理用于绕过 Firewall-1 检查点——如果这有帮助的话。

最佳答案

检查密码属性名称。它的名称是 ftp.proxyPassword,而不是 ftp.proxyPass。

System.setProperty("ftp.proxyUser", "proxyUser");
System.setProperty("ftp.proxyPassword", "proxyPass");

尝试一下,让我们知道您的结果!

关于java - 代理身份验证失败错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15534701/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com