You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2016/12/15 16:14:10 UTC

[1/2] camel git commit: CAMEL-10603: Fixed ahc component real uri configuration. Thanks to Thomas Günter for the patch.

Repository: camel
Updated Branches:
  refs/heads/camel-2.18.x 8c862aa11 -> 414df4ddd
  refs/heads/master 7d38be747 -> d18325656


CAMEL-10603: Fixed ahc component real uri configuration. Thanks to Thomas G�nter for the patch.


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

Branch: refs/heads/master
Commit: d183256567a5ac4cb520092e4d2631263ab05a85
Parents: 7d38be7
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Dec 15 17:10:43 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Dec 15 17:10:43 2016 +0100

----------------------------------------------------------------------
 .../apache/camel/component/ahc/AhcComponent.java    | 16 ++++++++++++++--
 .../component/ahc/AhcClientConfigRealmUriTest.java  |  4 ++--
 2 files changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d1832565/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcComponent.java b/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcComponent.java
index 6577c60..7a22dc0 100644
--- a/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcComponent.java
+++ b/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcComponent.java
@@ -22,6 +22,7 @@ import java.util.Map;
 import org.apache.camel.Endpoint;
 import org.apache.camel.impl.HeaderFilterStrategyComponent;
 import org.apache.camel.util.IntrospectionSupport;
+import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.URISupport;
 import org.apache.camel.util.UnsafeUriCharactersEncoder;
 import org.apache.camel.util.jsse.SSLContextParameters;
@@ -41,7 +42,7 @@ public class AhcComponent extends HeaderFilterStrategyComponent {
     private static final Logger LOG = LoggerFactory.getLogger(AhcComponent.class);
     
     private static final String CLIENT_CONFIG_PREFIX = "clientConfig.";
-    private static final String CLIENT_REALM_CONFIG_PREFIX = "realm.";
+    private static final String CLIENT_REALM_CONFIG_PREFIX = "clientConfig.realm.";
 
     private AsyncHttpClient client;
     private AsyncHttpClientConfig clientConfig;
@@ -92,7 +93,18 @@ public class AhcComponent extends HeaderFilterStrategyComponent {
 
                 // set and validate additional parameters on client config
                 Map<String, Object> realmParams = IntrospectionSupport.extractProperties(parameters, CLIENT_REALM_CONFIG_PREFIX);
-                realmBuilder = new Realm.Builder(realmParams.get("realm.principal").toString(), realmParams.get("realm.password").toString());
+
+                Object principal = realmParams.remove("principal");
+                Object password = realmParams.remove("password");
+
+                if (ObjectHelper.isEmpty(principal)) {
+                    throw new IllegalArgumentException(CLIENT_REALM_CONFIG_PREFIX + ".principal must be configured");
+                }
+                if (password == null) {
+                    password = "";
+                }
+
+                realmBuilder = new Realm.Builder(principal.toString(), password.toString());
                 setProperties(realmBuilder, realmParams);
                 validateParameters(uri, realmParams, null);
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/d1832565/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcClientConfigRealmUriTest.java
----------------------------------------------------------------------
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcClientConfigRealmUriTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcClientConfigRealmUriTest.java
index 22a515a..ff070b2 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcClientConfigRealmUriTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcClientConfigRealmUriTest.java
@@ -24,8 +24,8 @@ public class AhcClientConfigRealmUriTest extends BaseAhcTest {
     @Test
     public void testAhcProduce() throws Exception {
         Object out = template.requestBody(getAhcEndpointUri()
-                + "?realm.scheme=DIGEST&realm.principal=someUser"
-                + "&realm.password=somePass&realm.usePreemptiveAuth=true", null, String.class);
+                + "?clientConfig.realm.scheme=DIGEST&clientConfig.realm.principal=someUser"
+                + "&clientConfig.realm.password=somePass&clientConfig.realm.usePreemptiveAuth=true", null, String.class);
         assertEquals("Bye World", out);
     }
 


[2/2] camel git commit: CAMEL-10603: Fixed ahc component real uri configuration. Thanks to Thomas Günter for the patch.

Posted by da...@apache.org.
CAMEL-10603: Fixed ahc component real uri configuration. Thanks to Thomas G�nter for the patch.


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

Branch: refs/heads/camel-2.18.x
Commit: 414df4ddd7293039bb89567433270496101ff13a
Parents: 8c862aa
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Dec 15 17:10:43 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Dec 15 17:11:27 2016 +0100

----------------------------------------------------------------------
 .../apache/camel/component/ahc/AhcComponent.java    | 16 ++++++++++++++--
 .../component/ahc/AhcClientConfigRealmUriTest.java  |  4 ++--
 2 files changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/414df4dd/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcComponent.java b/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcComponent.java
index 6577c60..7a22dc0 100644
--- a/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcComponent.java
+++ b/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcComponent.java
@@ -22,6 +22,7 @@ import java.util.Map;
 import org.apache.camel.Endpoint;
 import org.apache.camel.impl.HeaderFilterStrategyComponent;
 import org.apache.camel.util.IntrospectionSupport;
+import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.URISupport;
 import org.apache.camel.util.UnsafeUriCharactersEncoder;
 import org.apache.camel.util.jsse.SSLContextParameters;
@@ -41,7 +42,7 @@ public class AhcComponent extends HeaderFilterStrategyComponent {
     private static final Logger LOG = LoggerFactory.getLogger(AhcComponent.class);
     
     private static final String CLIENT_CONFIG_PREFIX = "clientConfig.";
-    private static final String CLIENT_REALM_CONFIG_PREFIX = "realm.";
+    private static final String CLIENT_REALM_CONFIG_PREFIX = "clientConfig.realm.";
 
     private AsyncHttpClient client;
     private AsyncHttpClientConfig clientConfig;
@@ -92,7 +93,18 @@ public class AhcComponent extends HeaderFilterStrategyComponent {
 
                 // set and validate additional parameters on client config
                 Map<String, Object> realmParams = IntrospectionSupport.extractProperties(parameters, CLIENT_REALM_CONFIG_PREFIX);
-                realmBuilder = new Realm.Builder(realmParams.get("realm.principal").toString(), realmParams.get("realm.password").toString());
+
+                Object principal = realmParams.remove("principal");
+                Object password = realmParams.remove("password");
+
+                if (ObjectHelper.isEmpty(principal)) {
+                    throw new IllegalArgumentException(CLIENT_REALM_CONFIG_PREFIX + ".principal must be configured");
+                }
+                if (password == null) {
+                    password = "";
+                }
+
+                realmBuilder = new Realm.Builder(principal.toString(), password.toString());
                 setProperties(realmBuilder, realmParams);
                 validateParameters(uri, realmParams, null);
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/414df4dd/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcClientConfigRealmUriTest.java
----------------------------------------------------------------------
diff --git a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcClientConfigRealmUriTest.java b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcClientConfigRealmUriTest.java
index 22a515a..ff070b2 100644
--- a/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcClientConfigRealmUriTest.java
+++ b/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcClientConfigRealmUriTest.java
@@ -24,8 +24,8 @@ public class AhcClientConfigRealmUriTest extends BaseAhcTest {
     @Test
     public void testAhcProduce() throws Exception {
         Object out = template.requestBody(getAhcEndpointUri()
-                + "?realm.scheme=DIGEST&realm.principal=someUser"
-                + "&realm.password=somePass&realm.usePreemptiveAuth=true", null, String.class);
+                + "?clientConfig.realm.scheme=DIGEST&clientConfig.realm.principal=someUser"
+                + "&clientConfig.realm.password=somePass&clientConfig.realm.usePreemptiveAuth=true", null, String.class);
         assertEquals("Bye World", out);
     }