You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Claus Ibsen <cl...@gmail.com> on 2010/09/29 08:27:55 UTC

Re: svn commit: r1002290 - in /camel/trunk/components/camel-ftp/src: main/java/org/apache/camel/component/file/remote/ test/java/org/apache/camel/component/file/remote/

Ah yeah, well spotted. Its like the the big or little endian problem
http://en.wikipedia.org/wiki/Endianness

Thanks for fixing.

On Tue, Sep 28, 2010 at 7:41 PM,  <ja...@apache.org> wrote:
> Author: janstey
> Date: Tue Sep 28 17:41:32 2010
> New Revision: 1002290
>
> URL: http://svn.apache.org/viewvc?rev=1002290&view=rev
> Log:
> fix related to FTP password shorthand username:password@server
>
> Modified:
>    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java
>    camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileScottTigerTest.java
>    camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/UriConfigurationTest.java
>
> Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java
> URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java?rev=1002290&r1=1002289&r2=1002290&view=diff
> ==============================================================================
> --- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java (original)
> +++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java Tue Sep 28 17:41:32 2010
> @@ -56,13 +56,13 @@ public abstract class RemoteFileConfigur
>         setProtocol(uri.getScheme());
>         setDefaultPort();
>
> -        // UserInfo can contain both username and password as: pwd:user@ftpserver
> +        // UserInfo can contain both username and password as: user:pwd@ftpserver
>         // see: http://en.wikipedia.org/wiki/URI_scheme
>         String username = uri.getUserInfo();
>         String pw = null;
>         if (username != null && username.contains(":")) {
> -            pw = ObjectHelper.before(username, ":");
> -            username = ObjectHelper.after(username, ":");
> +            pw = ObjectHelper.after(username, ":");
> +            username = ObjectHelper.before(username, ":");
>         }
>         if (username != null) {
>             setUsername(username);
>
> Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileScottTigerTest.java
> URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileScottTigerTest.java?rev=1002290&r1=1002289&r2=1002290&view=diff
> ==============================================================================
> --- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileScottTigerTest.java (original)
> +++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileScottTigerTest.java Tue Sep 28 17:41:32 2010
> @@ -23,7 +23,7 @@ public class FromFtpDeleteFileScottTiger
>
>     @Override
>     protected String getFtpUrl() {
> -        return "ftp://tiger:scott@localhost:" + getPort() + "/deletefile?binary=false&delete=true";
> +        return "ftp://scott:tiger@localhost:" + getPort() + "/deletefile?binary=false&delete=true";
>     }
>
>  }
> \ No newline at end of file
>
> Modified: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/UriConfigurationTest.java
> URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/UriConfigurationTest.java?rev=1002290&r1=1002289&r2=1002290&view=diff
> ==============================================================================
> --- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/UriConfigurationTest.java (original)
> +++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/UriConfigurationTest.java Tue Sep 28 17:41:32 2010
> @@ -198,6 +198,20 @@ public class UriConfigurationTest extend
>     }
>
>     @Test
> +    public void testPasswordInContextPathConfiguration() {
> +        Endpoint endpoint = context.getEndpoint("ftp://user:secret@hostname:1021/some/file");
> +        assertIsInstanceOf(FtpEndpoint.class, endpoint);
> +        FtpEndpoint ftpEndpoint = (FtpEndpoint) endpoint;
> +        RemoteFileConfiguration config = (RemoteFileConfiguration) ftpEndpoint.getConfiguration();
> +
> +        assertEquals("ftp", config.getProtocol());
> +        assertEquals("hostname", config.getHost());
> +        assertEquals(1021, config.getPort());
> +        assertEquals("user", config.getUsername());
> +        assertEquals("secret", config.getPassword());
> +    }
> +
> +    @Test
>     public void testStartingDirectoryWithDot() throws Exception {
>         Endpoint endpoint = context.getEndpoint("ftp://user@hostname?password=secret");
>         FtpEndpoint ftpEndpoint = assertIsInstanceOf(FtpEndpoint.class, endpoint);
>
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: svn commit: r1002290 - in /camel/trunk/components/camel-ftp/src: main/java/org/apache/camel/component/file/remote/ test/java/org/apache/camel/component/file/remote/

Posted by Jon Anstey <ja...@gmail.com>.
np. I had a good test for this elsewhere that noticed the problem :)

On Wed, Sep 29, 2010 at 3:57 AM, Claus Ibsen <cl...@gmail.com> wrote:

> Ah yeah, well spotted. Its like the the big or little endian problem
> http://en.wikipedia.org/wiki/Endianness
>
> Thanks for fixing.
>
> On Tue, Sep 28, 2010 at 7:41 PM,  <ja...@apache.org> wrote:
> > Author: janstey
> > Date: Tue Sep 28 17:41:32 2010
> > New Revision: 1002290
> >
> > URL: http://svn.apache.org/viewvc?rev=1002290&view=rev
> > Log:
> > fix related to FTP password shorthand username:password@server
> >
> > Modified:
> >
>  camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java
> >
>  camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileScottTigerTest.java
> >
>  camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/UriConfigurationTest.java
> >
> > Modified:
> camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java
> > URL:
> http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java?rev=1002290&r1=1002289&r2=1002290&view=diff
> >
> ==============================================================================
> > ---
> camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java
> (original)
> > +++
> camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java
> Tue Sep 28 17:41:32 2010
> > @@ -56,13 +56,13 @@ public abstract class RemoteFileConfigur
> >         setProtocol(uri.getScheme());
> >         setDefaultPort();
> >
> > -        // UserInfo can contain both username and password as:
> pwd:user@ftpserver
> > +        // UserInfo can contain both username and password as:
> user:pwd@ftpserver
> >         // see: http://en.wikipedia.org/wiki/URI_scheme
> >         String username = uri.getUserInfo();
> >         String pw = null;
> >         if (username != null && username.contains(":")) {
> > -            pw = ObjectHelper.before(username, ":");
> > -            username = ObjectHelper.after(username, ":");
> > +            pw = ObjectHelper.after(username, ":");
> > +            username = ObjectHelper.before(username, ":");
> >         }
> >         if (username != null) {
> >             setUsername(username);
> >
> > Modified:
> camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileScottTigerTest.java
> > URL:
> http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileScottTigerTest.java?rev=1002290&r1=1002289&r2=1002290&view=diff
> >
> ==============================================================================
> > ---
> camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileScottTigerTest.java
> (original)
> > +++
> camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileScottTigerTest.java
> Tue Sep 28 17:41:32 2010
> > @@ -23,7 +23,7 @@ public class FromFtpDeleteFileScottTiger
> >
> >     @Override
> >     protected String getFtpUrl() {
> > -        return "ftp://tiger:scott@localhost:" + getPort() +
> "/deletefile?binary=false&delete=true";
> > +        return "ftp://scott:tiger@localhost:" + getPort() +
> "/deletefile?binary=false&delete=true";
> >     }
> >
> >  }
> > \ No newline at end of file
> >
> > Modified:
> camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/UriConfigurationTest.java
> > URL:
> http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/UriConfigurationTest.java?rev=1002290&r1=1002289&r2=1002290&view=diff
> >
> ==============================================================================
> > ---
> camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/UriConfigurationTest.java
> (original)
> > +++
> camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/UriConfigurationTest.java
> Tue Sep 28 17:41:32 2010
> > @@ -198,6 +198,20 @@ public class UriConfigurationTest extend
> >     }
> >
> >     @Test
> > +    public void testPasswordInContextPathConfiguration() {
> > +        Endpoint endpoint =
> context.getEndpoint("ftp://user:secret@hostname:1021/some/file");
> > +        assertIsInstanceOf(FtpEndpoint.class, endpoint);
> > +        FtpEndpoint ftpEndpoint = (FtpEndpoint) endpoint;
> > +        RemoteFileConfiguration config = (RemoteFileConfiguration)
> ftpEndpoint.getConfiguration();
> > +
> > +        assertEquals("ftp", config.getProtocol());
> > +        assertEquals("hostname", config.getHost());
> > +        assertEquals(1021, config.getPort());
> > +        assertEquals("user", config.getUsername());
> > +        assertEquals("secret", config.getPassword());
> > +    }
> > +
> > +    @Test
> >     public void testStartingDirectoryWithDot() throws Exception {
> >         Endpoint endpoint = context.getEndpoint("ftp://user
> @hostname?password=secret");
> >         FtpEndpoint ftpEndpoint = assertIsInstanceOf(FtpEndpoint.class,
> endpoint);
> >
> >
> >
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>



-- 
Cheers,
Jon

Camel in Action: http://manning.com/ibsen
Open Source Integration: http://fusesource.com
Blog: http://janstey.blogspot.com