You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by on...@apache.org on 2018/08/14 20:45:41 UTC

[camel] branch master updated (cfa2bfe -> f4ae859)

This is an automated email from the ASF dual-hosted git repository.

onders pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from cfa2bfe  Added jpmorganchase/quorum
     new 590a1bb  Revert  changes regarding CAMEL-12723
     new f4ae859  CAMEL-12723 - support IPV6 in FTP components

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../camel/util/UnsafeUriCharactersEncoder.java     | 26 +++++++++++++++++++---
 .../camel/component/file/remote/FtpComponent.java  |  6 +----
 .../camel/component/file/remote/FtpsComponent.java |  6 +----
 .../camel/component/file/remote/SftpComponent.java | 12 +---------
 ... => FileToFtpsWithDefaultSettingsIPV6Test.java} |  4 ++--
 ...umeTest.java => SftpSimpleIPV6ConsumeTest.java} |  4 ++--
 6 files changed, 30 insertions(+), 28 deletions(-)
 copy components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/{FileToFtpsWithDefaultSettingsTest.java => FileToFtpsWithDefaultSettingsIPV6Test.java} (86%)
 copy components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/{SftpSimpleConsumeTest.java => SftpSimpleIPV6ConsumeTest.java} (90%)


[camel] 01/02: Revert changes regarding CAMEL-12723

Posted by on...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

onders pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 590a1bb2d15fbfa29068cbd2e3b2b51746bd3d47
Author: onders <on...@apache.org>
AuthorDate: Tue Aug 14 23:25:06 2018 +0300

    Revert  changes regarding CAMEL-12723
---
 .../camel/util/UnsafeUriCharactersEncoder.java     | 26 +++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/camel-core/src/main/java/org/apache/camel/util/UnsafeUriCharactersEncoder.java b/camel-core/src/main/java/org/apache/camel/util/UnsafeUriCharactersEncoder.java
index c32cfab..8273c53 100644
--- a/camel-core/src/main/java/org/apache/camel/util/UnsafeUriCharactersEncoder.java
+++ b/camel-core/src/main/java/org/apache/camel/util/UnsafeUriCharactersEncoder.java
@@ -28,10 +28,30 @@ import java.util.regex.Pattern;
  * A good source for details is <a href="http://en.wikipedia.org/wiki/Url_encode">wikipedia url encode</a> article.
  */
 public final class UnsafeUriCharactersEncoder {
+    private static BitSet unsafeCharactersRfc1738;
     private static BitSet unsafeCharactersHttp;
     private static final char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C',
                                               'D', 'E', 'F', 'a', 'b', 'c', 'd', 'e', 'f'};
     private static final Pattern RAW_PATTERN = Pattern.compile("RAW\\([^\\)]+\\)");
+
+    static {
+        unsafeCharactersRfc1738 = new BitSet(256);
+        unsafeCharactersRfc1738.set(' ');
+        unsafeCharactersRfc1738.set('"');
+        unsafeCharactersRfc1738.set('<');
+        unsafeCharactersRfc1738.set('>');
+        unsafeCharactersRfc1738.set('#');
+        unsafeCharactersRfc1738.set('%');
+        unsafeCharactersRfc1738.set('{');
+        unsafeCharactersRfc1738.set('}');
+        unsafeCharactersRfc1738.set('|');
+        unsafeCharactersRfc1738.set('\\');
+        unsafeCharactersRfc1738.set('^');
+        unsafeCharactersRfc1738.set('~');
+        unsafeCharactersRfc1738.set('[');
+        unsafeCharactersRfc1738.set(']');
+        unsafeCharactersRfc1738.set('`');
+    }
     
     static {
         unsafeCharactersHttp = new BitSet(256);
@@ -53,9 +73,9 @@ public final class UnsafeUriCharactersEncoder {
     private UnsafeUriCharactersEncoder() {
         // util class
     }
-    
+
     public static String encode(String s) {
-        return encodeHttpURI(s);
+        return encode(s, unsafeCharactersRfc1738);
     }
     
     public static String encodeHttpURI(String s) {
@@ -67,7 +87,7 @@ public final class UnsafeUriCharactersEncoder {
     }
     
     public static String encode(String s, boolean checkRaw) {
-        return encodeHttpURI(s, checkRaw);
+        return encode(s, unsafeCharactersRfc1738, checkRaw);
     }
     
     public static String encodeHttpURI(String s, boolean checkRaw) {


[camel] 02/02: CAMEL-12723 - support IPV6 in FTP components

Posted by on...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

onders pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit f4ae859e17552d26c053da1df30855ac1b2c4534
Author: onders <on...@apache.org>
AuthorDate: Tue Aug 14 23:27:35 2018 +0300

    CAMEL-12723 - support IPV6 in FTP components
---
 .../camel/component/file/remote/FtpComponent.java  |  6 +--
 .../camel/component/file/remote/FtpsComponent.java |  6 +--
 .../camel/component/file/remote/SftpComponent.java | 12 +----
 .../FileToFtpsWithDefaultSettingsIPV6Test.java     | 56 ++++++++++++++++++++
 .../remote/sftp/SftpSimpleIPV6ConsumeTest.java     | 61 ++++++++++++++++++++++
 5 files changed, 120 insertions(+), 21 deletions(-)

diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpComponent.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpComponent.java
index 326d534..35d5b54 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpComponent.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpComponent.java
@@ -40,11 +40,7 @@ public class FtpComponent extends RemoteFileComponent<FTPFile> {
 
     @Override
     protected GenericFileEndpoint<FTPFile> buildFileEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
-        String baseUri = getBaseUri(uri);
-
-        // lets make sure we create a new configuration as each endpoint can customize its own version
-        // must pass on baseUri to the configuration (see above)
-        FtpConfiguration config = new FtpConfiguration(new URI(baseUri));
+        FtpConfiguration config = new FtpConfiguration(new URI(uri.substring(0, uri.indexOf(":") + 1) + "//" + remaining));
 
         FtpUtils.ensureRelativeFtpDirectory(this, config);
 
diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsComponent.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsComponent.java
index 60c9125..70715d0 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsComponent.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsComponent.java
@@ -49,11 +49,7 @@ public class FtpsComponent extends FtpComponent implements SSLContextParametersA
 
     @Override
     protected GenericFileEndpoint<FTPFile> buildFileEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
-        String baseUri = getBaseUri(uri);
-
-        // lets make sure we create a new configuration as each endpoint can customize its own version
-        // must pass on baseUri to the configuration (see above)
-        FtpsConfiguration config = new FtpsConfiguration(new URI(baseUri));
+        FtpsConfiguration config = new FtpsConfiguration(new URI(uri.substring(0, uri.indexOf(":") + 1) + "//" + remaining));
 
         FtpUtils.ensureRelativeFtpDirectory(this, config);
 
diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpComponent.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpComponent.java
index a018b87..f7262c2 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpComponent.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpComponent.java
@@ -38,17 +38,7 @@ public class SftpComponent extends RemoteFileComponent<SftpRemoteFile> {
 
     @Override
     protected GenericFileEndpoint<SftpRemoteFile> buildFileEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
-        // get the base uri part before the options as they can be non URI valid such as the expression using $ chars
-        // and the URI constructor will regard $ as an illegal character and we dont want to enforce end users to
-        // to escape the $ for the expression (file language)
-        String baseUri = uri;
-        if (uri.contains("?")) {
-            baseUri = uri.substring(0, uri.indexOf("?"));
-        }
-
-        // lets make sure we create a new configuration as each endpoint can
-        // customize its own version
-        SftpConfiguration config = new SftpConfiguration(new URI(baseUri));
+        SftpConfiguration config = new SftpConfiguration(new URI(uri.substring(0, uri.indexOf(":") + 1) + "//" + remaining));
 
         FtpUtils.ensureRelativeFtpDirectory(this, config);
 
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsWithDefaultSettingsIPV6Test.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsWithDefaultSettingsIPV6Test.java
new file mode 100644
index 0000000..666dbca
--- /dev/null
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsWithDefaultSettingsIPV6Test.java
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.file.remote;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+/**
+ * Test the ftps component over TLS (explicit) and without client authentication
+ * 
+ * @version 
+ */
+public class FileToFtpsWithDefaultSettingsIPV6Test extends FtpsServerExplicitTLSWithoutClientAuthTestSupport {
+    
+    private String getFtpUrl() {
+        return "ftps://admin@[::1]:" + getPort() + "/tmp2/camel?password=admin&consumer.initialDelay=2000&disableSecureDataChannelDefaults=true&delete=true";
+    }
+    
+    @Test
+    public void testFromFileToFtp() throws Exception {
+        // some platforms cannot test SSL
+        if (!canTest) {
+            return;
+        }
+
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(2);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("file:src/main/data?noop=true").log("Got ${file:name}").to(getFtpUrl());
+
+                from(getFtpUrl()).to("mock:result");
+            }
+        };
+    }
+}
\ No newline at end of file
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleIPV6ConsumeTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleIPV6ConsumeTest.java
new file mode 100644
index 0000000..175f3a3
--- /dev/null
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleIPV6ConsumeTest.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.file.remote.sftp;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class SftpSimpleIPV6ConsumeTest extends SftpServerTestSupport {
+
+    @Test
+    public void testSftpSimpleConsume() throws Exception {
+        if (!canTest()) {
+            return;
+        }
+
+        String expected = "Hello World";
+
+        // create file using regular file
+        template.sendBodyAndHeader("file://" + FTP_ROOT_DIR, expected, Exchange.FILE_NAME, "hello.txt");
+
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.expectedHeaderReceived(Exchange.FILE_NAME, "hello.txt");
+        mock.expectedBodiesReceived(expected);
+        
+        context.startRoute("foo");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("sftp://[::1]:" + getPort() + "/" + FTP_ROOT_DIR + "?username=admin&password=admin&delay=10s&disconnect=true")
+                    .routeId("foo").noAutoStartup()
+                    .to("mock:result");
+            }
+        };
+    }
+}