How to Build Request Header - TLM Authentication - Using Spring RestTemplate

622 views Asked by At

We have a web service client that is making requests against restful web services that require NTLM-based authentication. We are using:

org.springframework.web.client.RestTemplate

To execute a GET request, we call:

RestTemplate.execute(java.lang.String,
org.springframework.http.HttpMethod,
org.springframework.web.client.RequestCallback,
org.springframework.web.client.ResponseExtractor<T>)

In the RequestCallback, we provide the header parameters (Map < String, String >) that, among other things, provide the authentication mechanism as one of params.

I need to be able to build a authorization parameter of type "NTLM", but I do not know how to create the string properly to accommodate NTLM-based authentication. I have found information for creating an NTLM-based service, but I believe my needs as a client calling NTLM service are simpler. For example, we had been using basic authentication client (before service switched to NTLM) like this:

..
String str = username:password
headerParams.put("Authorization", "Basic " + DatatypeConverter.printBase64Binary(str.getBytes("UTF-8")));
..

How would I do the same as above, only with NTLM rather than basic?

0

There are 0 answers