Anirban,
I have a cron job working that successfully connects to an Exchange Web Service 
via JAXWS protected by NTLMv2. I can post my code if you think it will help.
Dave

-----Original Message-----
From: anir ......... [mailto:anir1...@gmail.com] 
Sent: Thursday, October 11, 2012 1:20 AM
To: httpclient-users@hc.apache.org
Subject: Issue with NTLM proxy authentication over Https

Hi,

I am trying to return a secure socket connection from my code if the 
authentication through a proxy is successful.
My code is something like this :-

.....
*        if (tcp.getProxyUser() != null && tcp.getProxyPassword() != null) {
*
*            // add basic authentication header for the proxy*
*            authstring = "Basic "*
*                    + XMLUtils.base64encode((tcp.getProxyUser() + ":" + tcp
*
*                    .getProxyPassword()).getBytes());*
*        }*
*
*
* //try 3 times*
*       for (int i = 0; i <= 2; i++) {*
*
*
*            repondChallange(out, connect, authstring);*
*
*
*            if (processProxyResponse(is)) {*
*                return socket;*
*            }*
*            Header[] headers = extractHeaders(is);*
*            authstring = getAuthString(tcp, port, host, headers);*
*            while (is.available() > 0 && is.read() > 0) {*
*                // read all*
*            }*
*            if (closeConnection(headers)) {*
*                socket.close();*
*                socket = new Socket(tcp.getProxyHost(), proxyPort, null,
0);*
*                socket.setTcpNoDelay(true);*
*                socket.setSoTimeout(0);*
*                is = new BufferedInputStream(socket.getInputStream(),
2048);*
*                out = new BufferedOutputStream(socket.getOutputStream(),
2048);*
*            }*
.....

The RespondChallange Method writes to the output stream with headers like 
User-Agent: , Proxy-Authorization: .
The method* processProxyResponse(is) *checks for the reply from the proxy 
server and returns true only if status code of 200 is encountered.
The getAuthString method basically is a generic method which returns the string 
based on the authentication Scheme selected  and serves as the value for
*Proxy-Authorization: *header :-

.....
*            ConnectMethod method = new ConnectMethod();*
*            authstring = authscheme.authenticate(credentials, method);*
.....

My code works fine for Basic,Digest  Authentication but fails for NTLM scheme 
with Error code :- 407.

Using the JCIFS library it works though.
Just wanted to know if this is a known problem with apache commons httclient ??
Is there a workaround for this ,since i am not too keen on using JCIFS library 
??

Thanks,
Anirban

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org

Reply via email to