camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [2/2] git commit: CAMEL-7057 Fixed the issue with password having double &&
Date Wed, 11 Dec 2013 12:22:04 GMT
CAMEL-7057 Fixed the issue with password having double &&


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/1fabe99d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1fabe99d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1fabe99d

Branch: refs/heads/camel-2.11.x
Commit: 1fabe99de77d5d324b64535b3e5158deba725f28
Parents: 759b3ce
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Wed Dec 11 20:12:40 2013 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Wed Dec 11 20:20:58 2013 +0800

----------------------------------------------------------------------
 .../org/apache/camel/impl/DefaultComponent.java | 13 ++++--
 .../component/http/HttpEndpointURLTest.java     | 43 ++++++++++++++++++++
 2 files changed, 53 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/1fabe99d/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
index 90ee408..617f917 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
@@ -20,6 +20,8 @@ import java.net.URI;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Component;
@@ -202,10 +204,15 @@ public abstract class DefaultComponent extends ServiceSupport implements
Compone
                 + "has & parameter separators. Check the uri if its missing a ? marker.");
         }
 
-        // check for uri containing double && markers
+        // check for uri containing double && markers without include by RAW
         if (uri.contains("&&")) {
-            throw new ResolveEndpointFailedException(uri, "Invalid uri syntax: Double &&
marker found. "
-                + "Check the uri and remove the duplicate & marker.");
+            Pattern pattern = Pattern.compile("RAW(.*&&.*)");
+            Matcher m = pattern.matcher(uri);
+            // we should skip the RAW part
+            if (!m.find()) {
+                throw new ResolveEndpointFailedException(uri, "Invalid uri syntax: Double
&& marker found. "
+                    + "Check the uri and remove the duplicate & marker.");
+            }
         }
 
         // if we have a trailing & then that is invalid as well

http://git-wip-us.apache.org/repos/asf/camel/blob/1fabe99d/components/camel-http/src/test/java/org/apache/camel/component/http/HttpEndpointURLTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpEndpointURLTest.java
b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpEndpointURLTest.java
new file mode 100644
index 0000000..2f44225
--- /dev/null
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpEndpointURLTest.java
@@ -0,0 +1,43 @@
+/**
+ * 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.http;
+
+import java.util.List;
+
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class HttpEndpointURLTest extends CamelTestSupport {
+    
+    @Test
+    public void testHttpEndpointURLWithAuthPassWord() {
+        HttpEndpoint endpoint = (HttpEndpoint)context.getEndpoint("http://localhost/test?authMethod=Basic&authPassword=RAW(pa&&word)&authUsername=usr");
+        HttpClientConfigurer configurer = endpoint.getHttpClientConfigurer();
+        assertTrue("Expect the CompositeHttpConfigurer", configurer instanceof CompositeHttpConfigurer);
+        List<HttpClientConfigurer> configurers =  ((CompositeHttpConfigurer)configurer).getConfigurers();
+        BasicAuthenticationHttpClientConfigurer basicAuthenticationConfigurer = null;
+        for (HttpClientConfigurer config : configurers) {
+            if (config instanceof BasicAuthenticationHttpClientConfigurer) {
+                basicAuthenticationConfigurer = (BasicAuthenticationHttpClientConfigurer)config;
+                break;
+            }
+        }
+        assertNotNull("We should find the basicAuthenticationConfigurer", basicAuthenticationConfigurer);
+        assertEquals("pa&&word", basicAuthenticationConfigurer.getPassword());
+    }
+
+}


Mime
View raw message