Hi Dave, Thanks for your reply but i can't use the cron job in my present environment . I was looking for some workaround (if any) using httpClient itself. Moreover this is a pretty generalized code for all AuthSchemes and so i don't want to break the uniformity. Thanks for your help .
Regards, Anirban On Thu, Oct 11, 2012 at 4:33 PM, Godbey, David J. (HQ-LM020)[DIGITAL MANAGEMENT INC.] <[email protected]> wrote: > 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:[email protected]] > Sent: Thursday, October 11, 2012 1:20 AM > To: [email protected] > 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: [email protected] > For additional commands, e-mail: [email protected] > >
