Mombu the Programming Forum sponsored links

Go Back   Mombu the Programming Forum > Programming > Getting IE automated proxy settings from Java or JScript?
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 22nd April 11:30
chris frederick
External User
 
Posts: 1
Default Getting IE automated proxy settings from Java or JScript?



I've been researching this on and off for weeks, and haven't come up with
anything useful yet. If anyone knows how to do this, please let me know.
From a Java applet running in IE 6.0 using the Sun J2SE 1.4.2_03 plug-in, I
need to retrieve the proxy host and port that will be used to access a
specific URL. The site with the client machines is using automated proxy
settings (i.e., a ".pac" file) to retrieve the proxy server address and port
number.

So basically, I need to do one of two things:

1. From either Java or Javascript/Jscript, find the URL to the PAC file
that is stored in the browser configuration. Open that URL, and execute the
FindProxyForURL() Javascript function therein.
2. Even better, find a way to access the copy of FindProxyForURL() that
Sun's do***entation claims the Java Plug-in preloads when it starts. See
the following URL:
http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/proxie_config.html#automatic

The restrictions on my environment are:

1. I cannot use any native Windows code, whether called via JNI or exec(),
to read the registry value that contains the URL of the .pac file.
2. I cannot hard code the auto configuration URL, because remote
administration software can change it.
3. I cannot modify the Java code to use the URLConnection class and let the
JRE transparently handle the proxying.

The security permissions in the JRE's java.policy file may be relaxed,
within reason, to allow the applet to read (but not write) certain system
properties that are not readable by default. This is how I get the IE proxy
settings when it is NOT configured to use a .pac file, but as far as I can
tell, there is no Java property that provides the automated proxy URL if the
browser is configured to use one.

Thanks in advance for any advice that you can provide.

- Chris
  Reply With Quote


  sponsored links


2 1st May 21:36
chris
External User
 
Posts: 1
Default Getting IE automated proxy settings from Java or JScript?



In case anyone else needs to do this, here's what I came up with. There
still doesn't appear to be a good way to get the desired information using
J2SE 1.4.2. However, it's trivial with the upcoming J2SE 1.5.0 (which is
currently available in beta), using the new ProxySelector class and
associated APIs.

ProxySelector ps = ProxySelector.getDefault();
URI uri = null;
try {
uri = new URI("https://the_site_i_need_to.access.com");
}
catch (URISyntaxException e) {
// Handle exception
}
List proxyList = ps.select(uri);
int len = proxyList.size();
for (int i = 0; i < len; i++) {
Proxy p = (Proxy) proxyList.get(i);
InetSocketAddress addr = (InetSocketAddress) p.address();
if (addr == null) {
// Use a direct connection - no proxy
}
else {
InetAddress ip_addr = addr.getAddress();
int tcp_port = addr.getPort();
// Use the specified IP and port number as the proxy
}
}
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666