try {
super.checkConnect(host, port);
return;
} catch (AccessControlException ace) {
// continue
}
// Starting in 1.2 beta 4, we can't depend upon the currentClassLoader
// method anymore. In fact, this code is better taken care of in
// the class loader itself, using the getPermissions() method that
// was introduced in 1.2 beta 4
ClassLoader loader = getNonSystemClassLoader();
String remoteHost;
if (loader == null)
return;
if (!(loader instanceof JarLoader)) {
System.err.println("Class loader out of sync");
return;
}
JarLoader cl = (JarLoader) loader;
remoteHost = cl.getHost();
if (host.equals(remoteHost))
return;
// Note that this entire block has been re-written for 1.2 beta 4
// to use the new doPrivileged interface
try {
class testHost implements PrivilegedExceptionAction {
String local, remote;
testHost(String local, String remote) {
this.local = local;
this.remote = remote;
}
public Object run() throws UnknownHostException {
InetAddress hostAddr = InetAddress.getByName(local);
InetAddress remoteAddr = InetAddress.getByName(remote);
if (hostAddr.equals(remoteAddr))
return new Boolean("true");
return new Boolean("false");
}
}
testHost th = new testHost(host, remoteHost);
Boolean b = (Boolean) AccessController.doPrivileged(th);
if (b.booleanValue())
return;
} catch (PrivilegedActionException pae) {
// Must be an UnknownHostException; continue and throw exception
}
throw new SecurityException(
"Can't connect from " + remoteHost + " to " + host);