camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] camel git commit: CAMEL-10603: Fixed ahc component real uri configuration. Thanks to Thomas Günter for the patch.
Date Thu, 15 Dec 2016 16:14:10 GMT
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 <davsclaus@apache.org>
Authored: Thu Dec 15 17:10:43 2016 +0100
Committer: Claus Ibsen <davsclaus@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);
     }
 


Mime
View raw message