Hi,
I am creating a URLConnection object behind a firewall and facing some
serious problems.
The thing goes on smooth untill firewall does not enforces security. As
soon as user authorization is enforced the thing stops working. The
firewall is HTTP working on port 8080 of localhost. Here is the code
that i am using
/*************************CODE************************/
Properties systemSettings = System.getProperties();
System.setProperties(systemSettings);
URL url=new URL("http://someserver/somepage");
URLConnection uc = url.openConnection ();
String encoded = new String
(Base64.base64Encode(new
String("username:password").getBytes()));
uc.setRequestProperty("Proxy-Authorization", "Basic " + encoded);
System.out.println("Connecting...");
uc.connect();
InputStream is= uc.getInputStream();
System.out.println("Connected and retriving data...");
/***********************************************************/
the main problem is that as soon as authorization is enforced the
programs freezes after giving the output "Connecting..." !!!
Any ideas what really is the problem. I have tried googling and tried
all sorts of methods that were suggested on the web.
Thanks,
VJ
Graham - 15 Nov 2006 10:47 GMT
Hi vj,
Are you using a firewall
(http://en.wikipedia.org/wiki/Firewall_%28networking%29) or a proxy
(http://en.wikipedia.org/wiki/Proxy_server)? There are some
differences, so it is worth checking what you are actually working
with.
If you are actually using a proxy then you need to look at:
http://java.sun.com/j2se/1.5.0/docs/api/java/net/Proxy.html
You can pass the proxy object when you call url.openConnection ()
Regards,
Graham
Lead Senior Developer
Modern Security Solutions
http://www.modernsecuritysolutions.com
> Hi,
>
[quoted text clipped - 30 lines]
> Thanks,
> VJ
Real Gagnon - 16 Nov 2006 02:49 GMT
"vj" <mr.vaibhavjain@gmail.com> wrote in news:1163573095.757240.204140
@f16g2000cwb.googlegroups.com:
> uc.setRequestProperty("Proxy-Authorization", "Basic " + encoded);
You need to set some System properties since a proxy is used :
Properties systemSettings = System.getProperties();
systemSettings.put("http.proxyHost","proxy.mydomain.local") ;
systemSettings.put("http.proxyPort", "80") ;
see http://www.rgagnon.com/javadetails/java-0085.html
Bye.

Signature
Real Gagnon from Quebec, Canada
* Looking for Java or PB code examples ? Visit Real's How-to
* http://www.rgagnon.com/howto.html