This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch camel-4.10.x in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.10.x by this push: new 5d47664389c CAMEL-22073: camel-http - NTLM authentication doesn't work over http 5d47664389c is described below commit 5d47664389c934ecd57c278f93f52c65aea4b1fd Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Thu May 22 10:47:33 2025 +0200 CAMEL-22073: camel-http - NTLM authentication doesn't work over http --- .../apache/camel/component/http/HttpCredentialsHelper.java | 5 +++-- .../camel/component/http/PreemptiveAuthExecChainHandler.java | 12 ++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCredentialsHelper.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCredentialsHelper.java index 0e23bf2e690..8361ba747e6 100644 --- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCredentialsHelper.java +++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCredentialsHelper.java @@ -50,9 +50,10 @@ public final class HttpCredentialsHelper { return "Basic " + new String(encodedAuth); } - public static Credentials getCredentials(String method, String username, String password, String host, String domain) { + public static Credentials getCredentials( + String method, String username, String password, String host, String domain) { if (username != null && password != null) { - if (domain != null && host != null) { + if ("NTLM".equalsIgnoreCase(method)) { return new NTCredentials(username, password.toCharArray(), host, domain); } else { return new UsernamePasswordCredentials(username, password.toCharArray()); diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/PreemptiveAuthExecChainHandler.java b/components/camel-http/src/main/java/org/apache/camel/component/http/PreemptiveAuthExecChainHandler.java index 40c96676619..4c5feadbe9a 100644 --- a/components/camel-http/src/main/java/org/apache/camel/component/http/PreemptiveAuthExecChainHandler.java +++ b/components/camel-http/src/main/java/org/apache/camel/component/http/PreemptiveAuthExecChainHandler.java @@ -19,6 +19,7 @@ package org.apache.camel.component.http; import java.io.IOException; import org.apache.hc.client5.http.auth.AuthCache; +import org.apache.hc.client5.http.auth.AuthScheme; import org.apache.hc.client5.http.auth.AuthScope; import org.apache.hc.client5.http.auth.Credentials; import org.apache.hc.client5.http.auth.CredentialsProvider; @@ -26,6 +27,7 @@ import org.apache.hc.client5.http.classic.ExecChain; import org.apache.hc.client5.http.classic.ExecChainHandler; import org.apache.hc.client5.http.impl.auth.BasicAuthCache; import org.apache.hc.client5.http.impl.auth.BasicScheme; +import org.apache.hc.client5.http.impl.auth.NTLMScheme; import org.apache.hc.client5.http.protocol.HttpClientContext; import org.apache.hc.core5.http.ClassicHttpRequest; import org.apache.hc.core5.http.ClassicHttpResponse; @@ -61,8 +63,14 @@ public class PreemptiveAuthExecChainHandler implements ExecChainHandler { if (credentials == null) { throw new HttpException("No credentials for preemptive authentication"); } - BasicScheme authScheme = new BasicScheme(); - authScheme.initPreemptive(credentials); + AuthScheme authScheme; + if ("NTLM".equalsIgnoreCase(endpoint.getAuthMethod())) { + authScheme = new NTLMScheme(); + } else { + BasicScheme bs = new BasicScheme(); + bs.initPreemptive(credentials); + authScheme = bs; + } authCache = new BasicAuthCache(); authCache.put(httpHost, authScheme); context.setAuthCache(authCache);