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 1ad47392295 CAMEL-22073: camel-http - NTLM authentication doesn't work
over http
1ad47392295 is described below
commit 1ad473922957bd6b3ae844b8eb4e3d0ffb4e0c7b
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri May 23 15:00:31 2025 +0200
CAMEL-22073: camel-http - NTLM authentication doesn't work over http
---
.../http/BasicAuthenticationHttpClientConfigurer.java | 15 +++++++++++++++
1 file changed, 15 insertions(+)
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 8ca73426032..7c356dce35e 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,10 +16,17 @@
*/
package org.apache.camel.component.http;
+import org.apache.hc.client5.http.auth.AuthSchemeFactory;
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.impl.auth.BasicSchemeFactory;
+import org.apache.hc.client5.http.impl.auth.BearerSchemeFactory;
+import org.apache.hc.client5.http.impl.auth.DigestSchemeFactory;
+import org.apache.hc.client5.http.impl.auth.NTLMSchemeFactory;
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
+import org.apache.hc.core5.http.config.RegistryBuilder;
public class BasicAuthenticationHttpClientConfigurer implements
HttpClientConfigurer {
private final String username;
@@ -42,6 +49,14 @@ public class BasicAuthenticationHttpClientConfigurer
implements HttpClientConfig
Credentials defaultcreds;
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()
+ .register(StandardAuthScheme.BASIC,
BasicSchemeFactory.INSTANCE)
+ .register(StandardAuthScheme.DIGEST,
DigestSchemeFactory.INSTANCE)
+ .register(StandardAuthScheme.BEARER,
BearerSchemeFactory.INSTANCE)
+ .register(StandardAuthScheme.NTLM,
NTLMSchemeFactory.INSTANCE)
+ .build();
+ clientBuilder.setDefaultAuthSchemeRegistry(copy);
} else {
defaultcreds = new UsernamePasswordCredentials(username, password);
}