FTP over Proxy

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

FTP over Proxy

Michael Prieß
Hi,

im using the camel ftp component. 2.5 and have tried to open a connection to
a remote ftp
server via the proxy, but this doesn't work.I need to configure a
user@server proxy connection and im
not sure if i can resolve my problem with the apache commons ftp server.

I tried to start my java application with the following properties:

        System.setProperty("ftp.proxyHost", "xxx.xxx.xxx.xxx");
        System.setProperty("ftp.proxyPort", "8080");

After searching in the mailingliste, i found the following:

*Does FTPClient support FTP connections through an FTP proxy server?*

http://wiki.apache.org/commons/Net/FrequentlyAskedQuestions

Does the commons ftp only support a socks4 or socks5 proxy ?

A idea how i can get a user@server proxy connection ?

Regards,

Michael

*

*
Reply | Threaded
Open this post in threaded view
|

Re: FTP over Proxy

alexey-s
This post has NOT been accepted by the mailing list yet.
Hi.

I use Camel 2.7.0 in the new project.
It is necessary to take away files with FTP servers. The component camel-ftp works well.
The component isn't able to pass through Squid proxy server.
It is used FTP over HTTP proxy.
Library FTP4J copes with this problem.
I have developed component FTP of the client constructed on library FTP4J.
FTP4J Version 1.6 - 2011/01/07.

I have added in FTP4J transfer socket timeout and storage of answer FTPReply in FTPClient.

In camel the component has added parameter "proxy".
It is a line url authorizations for proxy server.
If the scheme http is specified, we put HTTPTunnelConnector.
If the scheme ftp is specified, we put FTPProxyConnector.
If the scheme socks5 is specified, we put SOCKS5Connector.
If the scheme socks or socks4 is specified, we put SOCKS4Connector.

If the parameter "proxy" isn't specified, there is a direct connection to FTP server.

Example of adjustment of a route


<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
  xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  default-activation="lazy">

  <cm:property-placeholder persistent-id="com.mycompany.route.bundle">
    <cm:default-properties>
      <cm:property name="ftp.url" value="ftp4j://ftp.mycompany.com/"/>
      <cm:property name="ftp.delay" value="100000"/>
      <cm:property name="ftp.proxy" value="&proxy=http://user:pwd@cache.mycompany.lan:3128/"/>
    </cm:default-properties>
  </cm:property-placeholder>
   
 
  <camelContext xmlns="http://camel.apache.org/schema/blueprint">     
    <route>
      <from uri="{{ftp.url}}?delay={{ftp.delay}}&amp;noop=true&amp;binary=true{{ftp.proxy}}"/>
      <to uri="file://data/dict/inbox"/>
      <to uri="mock:log"/>
    </route>
  </camelContext>

</blueprint>

If it is interesting, I will create the task in JIRA. I will put there a code.
Reply | Threaded
Open this post in threaded view
|

Re: FTP over Proxy

Charles Moulliard
Hi,

For sure that we are interested. Here is the page describing the process to create a ticket + patch

http://camel.apache.org/contributing.html

Regards,

Charles Moulliard
Apache Committer
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
Reply | Threaded
Open this post in threaded view
|

Re: FTP over Proxy

alexey-s
This post has NOT been accepted by the mailing list yet.
Hi.
I have add https://issues.apache.org/jira/browse/CAMEL-3845


Regards,

Aleksey Sushko
Reply | Threaded
Open this post in threaded view
|

Re: FTP over Proxy

Charles Moulliard
Thx. I will try to have a look next week.

On Thu, Apr 7, 2011 at 11:25 PM, alexey-s [via Camel]
<[hidden email]> wrote:

> Hi.
> I have add https://issues.apache.org/jira/browse/CAMEL-3845
>
>
> Regards,
>
> Aleksey Sushko
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://camel.465427.n5.nabble.com/FTP-over-Proxy-tp3314841p4289492.html
> To unsubscribe from FTP over Proxy, click here.
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
Reply | Threaded
Open this post in threaded view
|

Re: FTP over Proxy

alexey-s
This post has NOT been accepted by the mailing list yet.
In reply to this post by alexey-s
Hello.

Ftp4j license does not allow embedding it in Camel.
I found a nasty bug. No checking disconnection.

I took the system of authorization on the proxy server. Created a new component for creating socket and several components of the authorization.
Created FTPClient heir of the project commons-net. Creating a socket replaced by a system of authorization.
I got a working authentication for FTP over HTTP proxy server.
If we will modify FTPClient component of the project commons-net, then a component camel-ftp will not change.

Can I release this code under a license Apache License?

Regards,

Aleksey Sushko
Reply | Threaded
Open this post in threaded view
|

Re: FTP over Proxy

davsclaus
Administrator
If you found a bug in Apache commons Net, then I suggest to report to them and provide the patch.

There has been a Commons Net 2.2 release. And Camel will by default use 2.0. So we are considering upgrading.
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Reply | Threaded
Open this post in threaded view
|

Re: FTP over Proxy

alexey-s
Good afternoon.

Let's go back to the history of the issue. The discussion was offered functionality https://issues.apache.org/jira/browse/CAMEL-3845

Check the description FTPS component in http://camel.apache.org/ftp2.html
SFTP component uses this functionality.

What prevents the FTP component to pass through a proxy?
FtpEndpoint creates commons-net FTPClient.

GenericFileComponent create endpoint
endpoint = buildFileEndpoint (uri, remaining, parameters);

After creating the endpoint initialization of parameters
        setProperties(endpoint, parameters);

The main component, commons-net FTPClient, not configurable.
We need to manually set SocketFactory.

It would be logical to make the identification of parameters for ftpClient
   ftpClient.socketFactory=#soketFactory
   ftpClient.proxy=#proxy

I posted on GitHub implementation of the system passing proxy.
   https://github.com/alexey-su/camel-ftpext

This component recognizes the parameter ftpClient.proxyUrl
When you create an endpoint sets the desired soketFactory.

Examples
  ftpext://publicftpserver.com/download?ftpClient.proxyUrl=<a href="http://user:password@proxy.domain.lan:port/">http://user:password@proxy.domain.lan:port/
Reply | Threaded
Open this post in threaded view
|

Re: FTP over Proxy

Claus Ibsen-2
Hi

Sounds like a good idea to support this out of  the box in camel-ftp.
You are welcome to submit a patch with your enhancement in the
camel-ftp component.


On Mon, Oct 21, 2013 at 2:00 PM, alexey-s <[hidden email]> wrote:

> Good afternoon.
>
> Let's go back to the history of the issue. The discussion was offered
> functionality https://issues.apache.org/jira/browse/CAMEL-3845
>
> Check the description FTPS component in http://camel.apache.org/ftp2.html
> SFTP component uses this functionality.
>
> What prevents the FTP component to pass through a proxy?
> FtpEndpoint creates commons-net FTPClient.
>
> GenericFileComponent create endpoint
> endpoint = buildFileEndpoint (uri, remaining, parameters);
>
> After creating the endpoint initialization of parameters
>         setProperties(endpoint, parameters);
>
> The main component, commons-net FTPClient, not configurable.
> We need to manually set SocketFactory.
>
> It would be logical to make the identification of parameters for ftpClient
>    ftpClient.socketFactory=#soketFactory
>    ftpClient.proxy=#proxy
>
> I posted on GitHub implementation of the system passing proxy.
>    https://github.com/alexey-su/camel-ftpext
>
> This component recognizes the parameter ftpClient.proxyUrl
> When you create an endpoint sets the desired soketFactory.
>
> Examples
>
> ftpext://publicftpserver.com/download?ftpClient.proxyUrl=<a href="http://user:password@proxy.domain.lan:port/">http://user:password@...:port/
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/FTP-over-Proxy-tp3314841p5741973.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: [hidden email]
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Reply | Threaded
Open this post in threaded view
|

Re: FTP over Proxy

alexey-s
Hi

The change is very small

DefaultComponent object has a method
     protected void setProperties (Object bean, Map <String, Object> parameters) throws Exception
It is necessary to repeat this method in DefaultEndpoint.

Why is that? Used factory EndpointHelper owes its name to the tune DefaultEndpoint.

FtpEndpoint is created by setting the parameter component.

replace the line
103:   IntrospectionSupport.setProperties (client, ftpClientParameters);
111:   IntrospectionSupport.setProperties (ftpClientConfig, ftpClientConfigParameters);
the challenge of the new method
103:   setProperties (client, ftpClientParameters);
111:   setProperties (ftpClientConfig, ftpClientConfigParameters);
Reply | Threaded
Open this post in threaded view
|

Re: FTP over Proxy

Claus Ibsen-2
Hi

Good idea about that setProperties in default endpoint.

I logged a couple of tickets
https://issues.apache.org/jira/browse/CAMEL-6907
https://issues.apache.org/jira/browse/CAMEL-6908

On Fri, Oct 25, 2013 at 5:30 AM, alexey-s <[hidden email]> wrote:

> Hi
>
> The change is very small
>
> DefaultComponent object has a method
>      protected void setProperties (Object bean, Map <String, Object>
> parameters) throws Exception
> It is necessary to repeat this method in DefaultEndpoint.
>
> Why is that? Used factory EndpointHelper owes its name to the tune
> DefaultEndpoint.
>
> FtpEndpoint is created by setting the parameter component.
>
> replace the line
> 103:   IntrospectionSupport.setProperties (client, ftpClientParameters);
> 111:   IntrospectionSupport.setProperties (ftpClientConfig,
> ftpClientConfigParameters);
> the challenge of the new method
> 103:   setProperties (client, ftpClientParameters);
> 111:   setProperties (ftpClientConfig, ftpClientConfigParameters);
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/FTP-over-Proxy-tp3314841p5742147.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: [hidden email]
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen