hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "anir ........." <anir1...@gmail.com>
Subject Issue with NTLM proxy authentication over Https
Date Thu, 11 Oct 2012 05:19:54 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message