Answer the question
In order to leave comments, you need to log in
How to call a SOAP method with NTLMv2 authentication from Java?
The problem is this.
There is a generated jax-ws client code for accessing SharePoint. SharePoint is raised on Windows 2008 R2 (with NTLMv2 authorization). The third day I struggle with jax-ws client access to the above service. The standard Authenticator is no good. However, it turns out to be very cool to authorize using HttpClient (apache.org.httpcomponents:httpclient:4.1), but it was not possible to find a method to slip it as a transport for jax-ws. I tried to shove jax-ws headers from it to the client (the Authorization: NTLM header is needed) - unsuccessfully (more precisely, HttpGet.getAllHeaders() after authorization gives me empty headers from the request, HttpResponse.getAllHeaders is not empty, but there is no token there). Help, whoever can :-) otherwise, I feel that the next night will again be sleepless :-(
Answer the question
In order to leave comments, you need to log in
The key point in the task: only jax-ws (the client is used inside a separate lib, without any dependencies such as servlets and web services), no Spring and similar tools. Did you manage to implement similar authorization for standard jax-ws ? (and yes, googling made it clear that the standard Authenticator works for NTLM, but not for NTLMv2)
UPD After much experimentation and searching, we managed to implement this miracle through the standard jax-ws.
Solution from here and from here
Required packages:
jcifs-1.3.17.jar
commons-httpclient-3.1.jar
What's wrong with the standard Authenticator? I did a similar task (collecting information from the SharePoint portal) on Spring-WS. There, in the service, I simply set the Authenticator
/** */
@PostConstruct
public void postCreate() {
Authenticator authenticator = new CustomAuthenticator("domain\\login", "password".toCharArray());
Authenticator.setDefault(authenticator);
}
package com.custom.sharepoint.util;
import java.net.*;
public class CustomAuthenticator extends Authenticator {
private final String username;
private final char[] password;
public CustomAuthenticator(String username, char[] password) {
this.username = username;
this.password = password;
}
@Override
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question