简体   繁体   中英

Proxy Authentication Failed error

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.

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!

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM