You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2013/12/11 13:19:11 UTC
git commit: CAMEL-7057 Fixed the issue with password having double &&
Updated Branches:
refs/heads/master 9cfd30962 -> c584871f5
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/c584871f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c584871f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c584871f
Branch: refs/heads/master
Commit: c584871f53e344f167854d11506a2e3043e40679
Parents: 9cfd309
Author: Willem Jiang <wi...@gmail.com>
Authored: Wed Dec 11 20:12:40 2013 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Wed Dec 11 20:13:12 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/c584871f/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 3403227..584c9f0 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;
@@ -208,10 +210,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/c584871f/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());
+ }
+
+}