Finally have a solution to this.
The problem
Apache Axis uses Apache HTTPClient
which provides its own NTLM implementation.
However this implementation is incomplete; it only supports the primitive LM authentication.
The system I need to connect to insists upon the more recent NTLM authentication.
Therefore my Webservice was failing to authenticate when using the Apache HTTP Client with NTLM.
This actually then enters an infinite loop as the HTTPClient
will never stop trying and failing to authenticate.
The solution
jcifs fully supports all 3 versions of the NTLM handshake.
I have copy-and-pasted org.apache.commons.httpclient.auth.NTLM
into my own class (it is declared as 'final' in order to defeat inheritance)
I have then overwritten the method
public String getType3Message(
String user, String password, String host, String domain,
byte[] nonce) throws AuthenticationException
to construct an instance of jcifs.ntlmssp.Type3Message
and use this object to return a Type3Message
that has the NTML authentication correctly generated.
I then needed to create my own instance of org.apache.commons.httpclient.auth.AuthScheme
to make use of this new NTLM implementation. call
org.apache.commons.httpclient.auth.AuthPolicy.registerAuthScheme(AuthPolicy.NTLM, MyNewAuthScheme.class)
start up my WS endpoint stub.
And it works !!!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…