I am not by far an expert in different protocols over http, but I can do this with curl to one of the APIs at my workplace:
curl --http1.1 --ntlm -u 'user:pass' 'MY_URL'
This works just fine. But notice that I can specify --ntlm
.
I am trying to replicate the same thing with http-jdk-client
, so something like this:
var client = HttpClient.newBuilder()
.authenticator(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(<user>, <pass>.toCharArray());
}
})
.sslContext(sslContext()) // an SSL Context that trusts everyone
.version(HttpClient.Version.HTTP_1_1)
.build();
var request = HttpRequest.newBuilder()
.uri(URI.create(url))
.build();
client.sendAsync(request, HttpResponse.BodyHandlers.ofString())
.thenApply(HttpResponse::body)
.thenAccept(System.out::println)
.join();
This fails with a 401
.
On the other hand if I use the same curl
, but drop the --ntlm
, I get the same 401
. So it really seems to me I need to somehow replicate that flag in the jdk client.
Someone knows some hints or ideas? Thank you.