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() {