This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 079389915b4 camel-http - NTLM authentication doesn't work over http
(#18170)
079389915b4 is described below
commit 079389915b4fff73bbf1ec431d37a9597ab3c400
Author: Bruno Gonçalves <[email protected]>
AuthorDate: Sat May 24 07:29:00 2025 +0100
camel-http - NTLM authentication doesn't work over http (#18170)
Set NTLM as preferred scheme
---
.../http/BasicAuthenticationHttpClientConfigurer.java | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git
a/components/camel-http/src/main/java/org/apache/camel/component/http/BasicAuthenticationHttpClientConfigurer.java
b/components/camel-http/src/main/java/org/apache/camel/component/http/BasicAuthenticationHttpClientConfigurer.java
index 6798dbb88e0..6a719327ea8 100644
---
a/components/camel-http/src/main/java/org/apache/camel/component/http/BasicAuthenticationHttpClientConfigurer.java
+++
b/components/camel-http/src/main/java/org/apache/camel/component/http/BasicAuthenticationHttpClientConfigurer.java
@@ -16,12 +16,15 @@
*/
package org.apache.camel.component.http;
+import java.util.List;
+
import org.apache.hc.client5.http.auth.AuthSchemeFactory;
import org.apache.hc.client5.http.auth.BearerToken;
import org.apache.hc.client5.http.auth.Credentials;
import org.apache.hc.client5.http.auth.NTCredentials;
import org.apache.hc.client5.http.auth.StandardAuthScheme;
import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
+import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.auth.BasicSchemeFactory;
import org.apache.hc.client5.http.impl.auth.BearerSchemeFactory;
import org.apache.hc.client5.http.impl.auth.DigestSchemeFactory;
@@ -53,13 +56,23 @@ public class BasicAuthenticationHttpClientConfigurer
implements HttpClientConfig
if (domain != null) {
defaultcreds = new NTCredentials(username, password, host, domain);
// NTLM is not included by default so we need to rebuild the
registry to include NTLM
- var copy = RegistryBuilder.<AuthSchemeFactory> create()
+ var autoSchemes = RegistryBuilder.<AuthSchemeFactory> create()
.register(StandardAuthScheme.BASIC,
BasicSchemeFactory.INSTANCE)
.register(StandardAuthScheme.DIGEST,
DigestSchemeFactory.INSTANCE)
.register(StandardAuthScheme.BEARER,
BearerSchemeFactory.INSTANCE)
.register(StandardAuthScheme.NTLM,
NTLMSchemeFactory.INSTANCE)
.build();
- clientBuilder.setDefaultAuthSchemeRegistry(copy);
+
+ // Set NTLM as preferred scheme
+ RequestConfig requestConfig = RequestConfig.custom()
+
.setTargetPreferredAuthSchemes(List.of(StandardAuthScheme.NTLM))
+ .build();
+
+ clientBuilder
+ .setDefaultAuthSchemeRegistry(autoSchemes)
+ .setDefaultRequestConfig(requestConfig);
+
+ clientBuilder.setDefaultAuthSchemeRegistry(autoSchemes);
} else if (bearerToken != null) {
defaultcreds = new BearerToken(bearerToken);
} else {