URLconnection from an agent using a proxy

Hi

I need to connect to a website from an agent thu a proxy.

I set the proxy by:

Properties properties = System.getProperties();

properties.put(“http.proxyHost”, “123.123.123.123”);

properties.put(“http.proxyPort”, “1234”);

I use URLconnection and get a security exception

when doing this because i’m not allowed to modify the system properties thru the code.

I need to change the java.security og java.policy file to be allowed access.

But i’m not shure what exactly to put into the files.

Any help?

regards

Jesper Kiaer

http://www.jezzper.com

Subject: URLconnection from an agent using a proxy

Hi,

if you take a look at the java.policy file, you see that its structure is pretty straight-forward. All you need to do is allow

read,write access to the properties

http.proxyHost

http.proxyPort

Best regards
Mario Varchmin
http://www.e-llennium.com/e-llennium/index_en.htm

Subject: RE: URLconnection from an agent using a proxy

Hi Mario

Thanks for the answer. Had tried it but did not help me. Johan send me in the right direction (se my other posting)

regard

Jesper Kiaer

http://www.jezzper.com

Subject: URLconnection from an agent using a proxy

Use System.putProperty(key, value)instead. The use of System.getProperties().put(key, value) is restricted.

  • Johan

johan@kanngard.net

http://dev.kanngard.net

Subject: RE: URLconnection from an agent using a proxy

Hi

Tack så mycket! :slight_smile:

It almost got me going…System.setProperty(key,value) did the trick :-).

Best Regards

Jesper Kiaer

http://www.jezzper.com

Subject: RE: URLconnection from an agent using a proxy

Varsågod! :slight_smile:

  • Johan

johan@kanngard.net

http://dev.kanngard.net