Bug 54883

Summary: FTP task should support proxies
Product: Ant Reporter: Arno Unkrig <arno>
Component: Optional TasksAssignee: Ant Notifications List <notifications>
Status: NEW ---    
Severity: enhancement CC: arno
Priority: P1 Keywords: PatchAvailable
Version: 1.9.1   
Target Milestone: 1.9.2   
Hardware: PC   
OS: All   
Attachments: Patch for '/ANT_183/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java'.

Description Arno Unkrig 2013-04-24 10:23:26 UTC
The FTP task

    http://svn.apache.org/repos/asf/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTask.java

does not support proxies (which is documented). Alas, I need that feature urgently, and

    http://commons.apache.org/proper/commons-net/examples/ftp/FTPClientExample.java

indicates that it should be very easy to add it. Basically, you merely have to replace

    ftp = new FTPClient();

with

    ftp = new FTPHTTPClient(proxyHost, proxyPort, proxyUser, proxyPassword);

if communication through a proxy is requested.
Comment 1 Arno Unkrig 2013-05-31 08:59:44 UTC
I found out that FTPHTTPClient implements only ONE variety of FTP proxy support ("FTP over HTTP"), while there seem to exist at least SIX ways to do it, see

http://www.codeproject.com/Articles/9547/How-Proxy-Server-serves-FTP-clients

The proxy that I use supports at least these:

(1) USER u1, PASS p1, SITE x, USER u2,   PASS p2
(2) USER u1, PASS p1, OPEN x, USER u2,   PASS p2
(3) USER u1, PASS p1,         USER u2@x, PASS p2

, where "x" is the target FTP server, "u1/p1" are the credentials for the FTP proxy, and "u2/p2" are the credentials for the target FTP server.

I will dig deeper into this to develop a plan as to how FTP proxying should be implemented.
Comment 2 Arno Unkrig 2013-05-31 15:01:31 UTC
Created attachment 30349 [details]
Patch for '/ANT_183/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java'.

Patch that adds the missing 'FTP proxy' functionality to the 'FTP' task.
Comment 3 Arno Unkrig 2013-05-31 15:11:06 UTC
Added a patch for the 'FTP' task which adds four new task attributes

    private String proxyServer; // null: No FTP proxy
    private int proxyPort = DEFAULT_FTP_PORT;
    private String proxyUserid; // null: No FTP proxy authentication
    private String proxyPassword;

and implements communication via the FTP proxy server iff required:

  <connect to proxy server on proxy port>
  user <proxy-userid>
  pass <proxy-password>
  user <userid>@<server>:<port>
  pass <password>

Notice: 'FTP.java' did not change between 1.8.3 and 1.9.1.

Please re-test, document and put into the next release of ANT.
Comment 4 Arno Unkrig 2013-06-02 15:06:13 UTC
I created a small project

https://svn.code.sf.net/p/loggifier/code/trunk/ant_issue_54883

which implements a single TASK 'ftp2', which has the attributes and functionality as the standard task 'ftp', and adds the four attributes.

This is regarded as a temporary solution until the feature is adopted by APACHE ANT.