Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2006

Tip: Looking for answers? Try searching our database.

problem with URLConnection behind a firewall

Thread view: 
vj - 15 Nov 2006 06:44 GMT
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



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.