Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Http Request through Proxy Server

 
Steven Phillips
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15490
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic