Author Topic: Configuring Java clients to use HTTP Proxy  (Read 1942 times)

pooms

  • Jr. Member
  • **
  • Posts: 75
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • Email
Configuring Java clients to use HTTP Proxy
« on: April 25, 2002, 06:25:55 PM »
If you are developing your own Java clients that talk to HTTP
servers, or if you are using someone else's Java program
that does this, you can set Java properties to cause it to
use an HTTP Proxy. Simply add the following command line
parameters:

-DproxySet=true -DproxyHost=localhost -DproxyPort=8080

and your Java client will use Proxomitron.

 
 

sidki3003

  • Sr. Member
  • ****
  • Posts: 476
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://
    • Email
Configuring Java clients to use HTTP Proxy
« Reply #1 on: April 26, 2002, 05:27:12 AM »
hmm... it doesn't seem to work with sun java 1.4 running jar files

 
 

pooms

  • Jr. Member
  • **
  • Posts: 75
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • Email
Configuring Java clients to use HTTP Proxy
« Reply #2 on: April 26, 2002, 07:45:04 AM »
Really? I haven't been able to move to JDK 1.4 yet as I have
dependencies on a whole bunch of other things. But I was able
to set it up with JDK 1.3.1. I'm developing and testing some
java web services using SOAP & XML over HTTP and I was
passing the traffic through Proxomitron. HTTP only, though,
I didn't try HTTPS.

Try using -Dhttp.proxyHost=localhost -Dhttp.proxyPort=8080 as described here:
http://java.sun.com/j2se/1.4/docs/guide/net/properties.html

 
 

sidki3003

  • Sr. Member
  • ****
  • Posts: 476
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://
    • Email
Configuring Java clients to use HTTP Proxy
« Reply #3 on: April 26, 2002, 07:29:21 PM »
No soup for me this time. I'm using ready-made class files, and maybe you have to explicitly allow such params in your source.
I was attracted by this idea since i think of java*.exe as a security risc.
Once you allow it to pass your firewall, any java app can connect to whereever it wants.
With an intermediate local proxy it's more easy to control such things.


 
 

pooms

  • Jr. Member
  • **
  • Posts: 75
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • Email
Configuring Java clients to use HTTP Proxy
« Reply #4 on: April 26, 2002, 07:57:26 PM »
That's odd, I can't think of any reason that you shouldn't be able
to do this, unless it is a JDK 1.4 issue. Or unless the program
has done something explicit to unset those properties, or to
set them from somewhere else, overriding what you set.

I'm building software that will be used in business-to-business
applications and I wanted to make sure that if our software is
running behind a firewall, and that company's policy is to
require internet access go through an HTTP proxy, that we are able
to set up the proxy information for our software. So I was testing
with the jar files that our customers would be using.

Maybe this software you were trying with doesn't actually use
HTTP, or maybe they didn't use Java's built-in HTTP support
and wrote their own socket-based communication? Hard
to guess without knowing what it is.

 
 

sidki3003

  • Sr. Member
  • ****
  • Posts: 476
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://
    • Email
Configuring Java clients to use HTTP Proxy
« Reply #5 on: April 26, 2002, 10:03:25 PM »
From time to time i come across java http downloaders i'd like to control.
The java app i had at hand and i ran the tests on is a website downloader called "loader"
http://home.tiscali.cz:8080/~cz210552/loader.html

So switches like
java -DproxySet=true -DproxyHost=localhost -DproxyPort=8080 -jar loader.jar http://www.microsoft.com
and above mentioned variations thereof didn't work.

However, this app allows for setting a proxy in it's config file.
So using those params here is 1. of course redundant and 2. the config switch "direct" may override anything else passed to java.exe.

The rest is off-topic, but i found a solution for me at Sun's webpage. Thanks for pointing me there
Socksifying like
java -DsocksProxyHost=localhost -jar loader.jar http://www.fbi.gov/
actually works and i can control everything via my local socks proxy.

BTW as a developer, can't you have several JDK's installed?
I saw the option in the PluginCPL to choose between several runtime versions.

Regards
sidki


 
 

pooms

  • Jr. Member
  • **
  • Posts: 75
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • Email
Configuring Java clients to use HTTP Proxy
« Reply #6 on: May 28, 2002, 01:16:16 AM »
Just to follow up on this further, with java 1.4 installed I am able to
cause my Java client to send HTTP and HTTPS traffic through Proxomitron
by setting the following properties on the command line:

-Dhttp.proxyHost=localhost
-Dhttp.proxyPort=8080
-Dhttps.proxyHost=localhost
-Dhttps.proxyPort=8080