For Programmers: Free Programming Magazines  


Home > Archive > Java Help > February 2006 > Automate authentication of a web-site through HTTPUrlConnection









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Automate authentication of a web-site through HTTPUrlConnection
rajivranjan09@gmail.com

2006-02-27, 4:06 am

Hi Guys,

I have a website which uses SSL communication. When someone tries to
access this site, it pops up a HTTP authentication box and only on
successfull authentication can a client access the site.

I am trying to write a utility whcih can try to access this site once a
day. I am using HTTPUrlConnection for this but I have no idea how would
the utility provide credentials information to the application. I
tried doing this -

URL mySite = new URL(mySiteURL);
HttpURLConnection mySiteConn =
(HttpURLConnection)mySite.openConnection();
mySiteConn.setRequestProperty("Authentication", "rajiv:welcome");
mySiteConn.setRequestMethod("GET");
int httpStatusCode = mySiteConn.getResponseCode();

but "mySiteConn.getResponseCode()" is throwing IOException.

Can someone please tell me how can I possibly do this?

_Rajiv

William Brogden

2006-02-27, 7:09 pm

On 27 Feb 2006 00:10:33 -0800, <rajivranjan09@gmail.com> wrote:

> Hi Guys,
>
> I have a website which uses SSL communication. When someone tries to
> access this site, it pops up a HTTP authentication box and only on
> successfull authentication can a client access the site.
>
> I am trying to write a utility whcih can try to access this site once a
> day. I am using HTTPUrlConnection for this but I have no idea how would
> the utility provide credentials information to the application. I
> tried doing this -
>
> URL mySite = new URL(mySiteURL);
> HttpURLConnection mySiteConn =
> (HttpURLConnection)mySite.openConnection();
> mySiteConn.setRequestProperty("Authentication", "rajiv:welcome");
> mySiteConn.setRequestMethod("GET");
> int httpStatusCode = mySiteConn.getResponseCode();
>
> but "mySiteConn.getResponseCode()" is throwing IOException.
>
> Can someone please tell me how can I possibly do this?
>
> _Rajiv
>


You might want to look into the HttpClient toolkit

http://jakarta.apache.org/commons/h...t/sslguide.html


--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com