hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: ntlm authentication
Date Sat, 04 Oct 2008 14:16:26 GMT
On 04/10/2008, Leo Wraith <haboreh@yahoo.com> wrote:
>
>
>  I have a Web application online running on a Linux server. I need to access files located
on a private network running Windows server. The client has given me a public IP which uses
port 8080 that I can use to access the reources that I need.
>
>  If I type the IP plus the port in IE like so: http://[my ip addres]:8080 I get the prompt
to enter the appropriate user and password. When I enter the user and password that were given
to me by the client, I'm able to access the directories that I need.
>
>  Now, I want to this from my application without user intervention. In other words, I
want to be able to pass the IP, port, userid and password from within my routine and then
access the necessary resources.
>
>  I've been working with several samples but the result is always the same. When I run
the JSP page, I get prompted for the userid and password.
>
>  Could you please take a look at the code snippet and give me a heads-up.
>
>      HttpClient client = new HttpClient();
>      // Set credentials on the client
>      Credentials credentials = new NTCredentials("userid", "password",
>                                                                           "http://0.0.0.0:8080",
null);
>      //HttpState state = client.getState();
>      //state().setCredentials(null, null, credentials);
>      client.getState().setCredentials(null, null, credentials);
>      String url = "http://0.0.0.0/PathToFiles";
>      HttpMethod method = new GetMethod(url);
>      client.executeMethod(method);
>
>      // String responseStr = method.getResponseBodyAsString();
>      // System.out.println(responseStr);
>      // method.releaseConnection();
>
>      String redirectURL = "http://0.0.0.0:8080/PathToFiles" ;
>      response.sendRedirect(response.encodeRedirectURL(redirectURL));

I assume that 0.0.0.0 is not the real IP address...

>  Thanks so much for the help

Which version of HTTPClient are you using?

BTW, HTTPClient 3.x only ever supported NTLMv1, it does not support NTLMv2.

See also:

http://hc.apache.org/httpclient-3.x/authentication.html#NTLM

http://hc.apache.org/httpcomponents-client/ntlm.html

>
>
>
>
>

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


Mime
View raw message