Ah - that works. I was getting confused by references in the docs like ...
DefaultHttpClient httpclient = new DefaultHttpClient();
NTCredentials creds = new NTCredentials("user", "pwd", "myworkstation",
"microsoft.com");
httpclient.getCredentialsProvider().setCredentials(AuthScope.ANY, creds);
Thanks a lot
Derek
-----Original Message-----
From: David Motes [mailto:[email protected]]
Sent: Tuesday, October 11, 2011 12:35 PM
To: HttpClient User Discussion
Subject: Re: Very basic questions on authentication in 4.1.2
You need to specify the target host on the httpclient.execute.
Something like httpclient.execute(targetHost,httpget);
There is an example somewhere in the distribution or the online docs that shows
how to do proxying with auth.
If you cant find it I'll see if I can strip some code out and show you.
On Tue, Oct 11, 2011 at 1:13 PM, <[email protected]> wrote:
> I am. For clarity here's the code I have so far (Scala - yeah I'm
> strange :-))
>
> var httpclient : HttpClient = new DefaultHttpClient()
> var proxy : HttpHost = new HttpHost("host_name",80)
> httpclient.getParams().setParameter( ConnRoutePNames.DEFAULT_PROXY,
> proxy )
>
> val creds : NTCredentials = new NTCredentials("uname", "passwd",
> "workstation", "domain")
>
> var credsProvider : CredentialsProvider = new
> BasicCredentialsProvider()
> credsProvider.setCredentials(
> new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT,
> AuthScope.ANY_REALM, "ntlm"),
> creds
> )
> <here's the troublesome bit ..... getting httpclient to *use* the
> credentials>
>
> var httpget: HttpGet = new HttpGet(uri)
>
> var response: HttpResponse = httpclient.execute(httpget)
>
>
>
> -----Original Message-----
> From: David Motes [mailto:[email protected]]
> Sent: Tuesday, October 11, 2011 12:08 PM
> To: HttpClient User Discussion
> Subject: Re: Very basic questions on authentication in 4.1.2
>
> Make sure you are using DefaultHttpClient not HttpClient
>
> On Tue, Oct 11, 2011 at 12:39 PM, <[email protected]> wrote:
>> I'm missing something very basic here - so apologies for the idiot questions.
>>
>> I'm trying to set up httpclient to use a (windows) proxy. With 4.1.2 . I've
>> read the thread from Sept 8th and the docs - but there seems to be a
>> mismatch between them and the jar file I have.
>>
>> httpClient.getCredentialsProvider() doesn't exist - all I have is
>> getConnectionManager() and getParams().
>>
>> So I assume that I've missed something fundamental - but for the life of me
>> I can't see what.
>>
>> Thanks
>> Derek
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]