Proxy Authentication Failed error

2019-02-28 10:49发布

I'm trying to access an FTP server through an FTP SITE Proxy to bypass a firewall using it.sauronsoftware.ftp4j.FTPClient I know my username/password is correct because I can connect using FileZilla. I tried using Authenticator, but it has no use. Code:

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

Gives me this error: java.io.IOException: Proxy authentication failed

Things I have tried:

  • Using the alternate constructor (String, int, String, String).
  • Removing Authenticator
  • Using just Authenticator, without the FTPProxyConnector
  • Authenticating before setting the connector, and vice versa.

However, when I am JUST using the Authenticator, I get a different error saying Connection timed out.

Both errors occur on line client.connect("ftpHost");

ANY help would be appreciated.

Note: The FTP Proxy Connector

EDIT: I found out that the proxy is used to bypass a Firewall-1 Checkpoint -- if this helps.

3条回答
祖国的老花朵
2楼-- · 2019-02-28 11:20

Check password property name. It's name is ftp.proxyPassword, and not ftp.proxyPass.

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

Try it and let us know your results!

查看更多
在下西门庆
3楼-- · 2019-02-28 11:23

Check password property name. It's name is ftp.proxyPassword, and not ftp.proxyPass.

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

Try it and let us know your results!

查看更多
聊天终结者
4楼-- · 2019-02-28 11:34

I found the solution...

I discovered that the FTP client was responding with a different response code:

200-User <username> authenticated by FireWall-1 authentication

In the source code of FTPProxyConnector, a response code of anything other than the regular

230-Connected to server. Logging in...

will throw an error.

I had to decompile the class file for FTPProxyConnector and then modify the source code, then recompile and save it back to the jar. Worked like a charm.

查看更多
登录 后发表回答