This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes Http Request through Proxy Server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Http Request through Proxy Server" Watch "Http Request through Proxy Server" New topic
Author

Http Request through Proxy Server

Steven Phillips
Greenhorn

Joined: Aug 19, 2005
Posts: 1
I am trying to make a HTTP request through our corporate firewall which uses Kerberos authentication. The proxy consistently rejects my request with a 407 (unauthorised error). From what I have read the settings to gain authentication from proxy servers are dependant on the proxy we are using and are not documented. I have tried many combinations of settings in my code and the result is always the 407....

Can anyone suggest any additional ways to gain authentication ? Should I be using httpclients or a third party package ? Alternatively is it possible to make the request through IE and thus using the IE proxy settings ?

Any help much appreicated !!

One example of code tried......

System.setProperty("http.proxySet", "true");
System.setProperty("http.proxyHost", "Proxy.server");
System.setProperty("http.proxyPort", "8080");
System.setProperty("http.proxyType", "4");
String proxyUser = "username";
String proxyPassword = "password";
String login = "http://www.google.com";

URL loginURL = new URL(login);
URLConnection connection = loginURL.openConnection();
jason white
Ranch Hand

Joined: Aug 08, 2005
Posts: 60
Steven,

Just taking a shot in the dark here but I have run into this problem when the firewall restrict traffic outbound (from my company). I typically had to get with the firewall team in order to remedy this because the port I was going out of wasn't authorized... Also, I don't know much about Kerberos but it might actually restrict down to the ip or dns name of your machine as well. In the end I usually work with the firewall/network team to remedy stuff like this a bit. Typically ports 80 and 8080 are locked down pretty tight too since everyone tries to tunnel in and out of enterprise networks via that port.

This sounds more like a network configuration issue than a program level issue.

Again, a stab in the dark!
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

System.setProperty("http.proxySet", "true");
System.setProperty("http.proxyHost", "Proxy.server");
System.setProperty("http.proxyPort", "8080");
System.setProperty("http.proxyType", "4");

String proxyUser = "username";
String proxyPassword = "password";

String login = "http://www.google.com";

URL loginURL = new URL(login);
URLConnection connection = loginURL.openConnection();

What are you doing with the username and password? Just declaring two variables ofcourse has no effect.

Have a look at this:
How to use Java to connect with HTTP servers outside your corporate firewall


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
Consider Paul's rocket mass heater.
 
subject: Http Request through Proxy Server
 
Similar Threads
Unable to tunnel through proxy. Proxy returns "HTTP/1.0 407 Proxy Authentication Requ
Proxy authentication (Kerberos?!)
java.net.ConnectException: Connection refused: connect
Unable to tunnel through proxy. Proxy returns "HTTP/1.0 407 Proxy Authentication Requ
Weblogic Eclipse Proxy