Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > problem with URLConnection behind a firewall

Reply
Thread Tools

problem with URLConnection behind a firewall

 
 
vj
Guest
Posts: n/a
 
      11-15-2006
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("usernameassword").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

 
Reply With Quote
 
 
 
 
Graham
Guest
Posts: n/a
 
      11-15-2006
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/...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


vj wrote:

> 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("usernameassword").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


 
Reply With Quote
 
 
 
 
Real Gagnon
Guest
Posts: n/a
 
      11-16-2006
"vj" <(E-Mail Removed)> 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.mydomai n.local") ;
systemSettings.put("http.proxyPort", "80") ;

see http://www.rgagnon.com/javadetails/java-0085.html

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

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
OutputStream from a URLConnection produces an OutOfMemory OutputStream from a URLConnection produces an OutOfMemory WinstonSmith_101@hotmail.com Java 2 10-25-2006 04:45 PM
URLConnection problem Marcelo Java 2 11-30-2005 12:52 PM
Urlconnection Problem / more local IP's Testbm Java 1 10-11-2004 05:10 PM
RMI client behind a firewall, server behind a firewall too Robert Dodier Java 6 09-14-2004 09:23 PM
Web Service invocation from behind proxy behind firewall Kumarforg ASP .Net Web Services 0 08-03-2004 07:15 AM



Advertisments