Hello, The document at the mentioned location states that " NTLM is a proprietary authentication scheme developed by Microsoft and optimized for Windows operating system"
But I am getting the same message even when the code is run on Linux. Should I then understand that the proxy I am trying to connect is Windows? Thanks Mallika -----Original Message----- From: Oleg Kalnichevski [mailto:[email protected]] Sent: 26 October 2009 12:57 To: HttpClient User Discussion Subject: Re: using HttpClient4.0 to retrieve files from a website. [email protected] wrote: > Hello, > > After some more search and reading, here is the sample code that I am trying > out: > > HttpClient httpclient = new DefaultHttpClient(); > HttpContext localContext = new BasicHttpContext(); > HttpGet httpget = new HttpGet("targetURL"); > > AuthScope proxyScope = new AuthScope(proxyHost, proxyPort); > AuthScope targetScope = new AuthScope(targetHost, targetPort); > > AuthState proxyAuthState = new AuthState(); > proxyAuthState.setAuthScope(proxyScope); > proxyAuthState.setCredentials(new UsernamePasswordCredentials(proxyUser, > proxyPassword) ); > localContext.setAttribute(ClientContext.PROXY_AUTH_STATE, proxyAuthState); > > AuthState targetAuthState = new AuthState(); > targetAuthState.setAuthScope(targetScope); > targetAuthState.setCredentials(new UsernamePasswordCredentials(webSiteUser, > webSitePassword) ); > localContext.setAttribute(ClientContext.TARGET_AUTH_STATE, targetAuthState); > > HttpHost proxy = new HttpHost(proxyHost, proxyPort); > httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); > > HttpResponse response = null; > HttpHost targetHost = new HttpHost(targetHost, targetPort, "https"); > try { > response = httpclient.execute(targetHost, httpget); > System.out.println("----------------------------------------"); > System.out.println(response.getStatusLine()); > } > catch(Exception e) { > System.out.println("Exception " + e.toString()); > > } > > And I get the following output: > Oct 26, 2009 12:02:01 PM > org.apache.http.impl.client.AbstractAuthenticationHandler selectScheme > WARNING: Authentication scheme ntlm not supported > Oct 26, 2009 12:02:01 PM org.apache.http.impl.client.DefaultRequestDirector > createTunnelToTarget > WARNING: Authentication error: Unable to respond to any of these challenges: > {kerberos=Proxy-Authenticate: Kerberos, ntlm=Proxy-Authenticate: NTLM, > negotiate=Proxy-Authenticate: Negotiate} > ---------------------------------------- > HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires > authorization to fulfill the request. Access to the Web Proxy filter is > denied. ) > > > Can anyone please tell me whats wrong in this? > http://hc.apache.org/httpcomponents-client/ntlm.html Oleg > Regards > Mallika > > > From: GUNTURU NAGAMALLIKA (BCS/ITP) > Sent: 26 October 2009 09:38 > To: '[email protected]' > Subject: using HttpClient4.0 to retrieve files from a website. > > Hello, > > We are trying to use HttpClient 4.0 API to connect to an internet website > that requires user authentication to retrieve files. And we connect to the > internet through a proxy that also needs a different user credentials. > > All the samples that I have seen so far, do either proxy authentication or > web-site authentication but not both: > > > a) Is the scenario I explained above, achievable using HttpClient? I guess > it should be possible, but I am not sure how? Can someone help me with this > > And for info, the production environment will be on Linux and the development > environment is Windows.. > > Thanks and Regards > Mallika Gunturu > > **** DISCLAIMER**** > http://www.belgacom-ics.com/maildisclaimer > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] **** DISCLAIMER**** http://www.belgacom-ics.com/maildisclaimer --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
