X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Fplat%2FJava12.java;h=003640551ae738468e96cb1abd592e97793e02d3;hb=36c7cba0672b0b0ac61f484a918a34969100ca92;hp=a159eae7b53412fc2d1b275239c8fba020b3d249;hpb=bcc8b1b4cf4e4801d218151e6a7f9961972d91c1;p=org.ibex.core.git diff --git a/src/org/xwt/plat/Java12.java b/src/org/xwt/plat/Java12.java index a159eae..0036405 100644 --- a/src/org/xwt/plat/Java12.java +++ b/src/org/xwt/plat/Java12.java @@ -10,12 +10,54 @@ import java.io.*; import java.util.*; import org.xwt.util.*; import org.xwt.*; +import java.lang.reflect.*; -// FEATURE: Java 1.4 allows undecorated frames and can maximize windows /** Platform class for most reasonable Java1.2+ JVMs */ public class Java12 extends AWT { + /** this is done with reflection in case a new version of the plugin comes out that doesn't let us pull the sun.plugin.* trick */ + protected synchronized HTTP.ProxyInfo _detectProxy() { + return (HTTP.ProxyInfo)java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() { + public Object run() { + try { + HTTP.ProxyInfo pi = new HTTP.ProxyInfo(); + + Class PluginProxyHandler = Class.forName("sun.plugin.protocol.PluginProxyHandler"); + Method getDefaultProxyHandler = PluginProxyHandler.getMethod("getDefaultProxyHandler", new Class[] { }); + Object proxyHandler = getDefaultProxyHandler.invoke(null, new Object[] { }); + + Class ProxyHandler = Class.forName("sun.plugin.protocol.ProxyHandler"); + Method getProxyInfo = ProxyHandler.getMethod("getProxyInfo", new Class[] { URL.class }); + Object proxyInfo = getProxyInfo.invoke(proxyHandler, new Object[] { new URL("http://www.xwt.org") }); + + Class ProxyInfo = Class.forName("sun.plugin.protocol.ProxyInfo"); + + if (((Boolean)ProxyInfo.getMethod("isSocksUsed", new Class[] { }).invoke(proxyInfo, new Object[] { })).booleanValue()) { + pi.socksProxyHost = + (String)ProxyInfo.getMethod("getSocksProxy", new Class[] { }).invoke(proxyInfo, new Object[] { }); + pi.socksProxyPort = + ((Integer)ProxyInfo.getMethod("getSocksPort", new Class[] { }).invoke(proxyInfo, new Object[] { })).intValue(); + } + + if (((Boolean)ProxyInfo.getMethod("isProxyUsed", new Class[] { }).invoke(proxyInfo, new Object[] { })).booleanValue()) { + pi.httpProxyHost = + (String)ProxyInfo.getMethod("getProxy", new Class[] { }).invoke(proxyInfo, new Object[] { }); + pi.httpProxyPort = + ((Integer)ProxyInfo.getMethod("getPort", new Class[] { }).invoke(proxyInfo, new Object[] { })).intValue(); + } + + if (pi.httpProxyHost != null || pi.socksProxyHost != null) return pi; + else return null; + + } catch (Throwable e) { + if (Log.on) Log.log(this, "exception while querying sun.plugin.protocol.PluginProxyHandler:"); + if (Log.on) Log.log(this, e); + return null; + } + }}); + } + protected Socket __getSocket(String host, int port, boolean ssl) throws IOException { return super._getSocket(host, port, ssl); } protected Socket _getSocket(final String host, final int port, final boolean ssl) throws IOException { return (Socket)java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {