FileDocCategorySizeDatePackage
JavaRunnerManager.javaAPI DocExample3894Sun Oct 25 18:13:36 GMT 1998None

JavaRunnerManager

public class JavaRunnerManager extends SecurityManager

Fields Summary
Constructors Summary
Methods Summary
public voidcheckConnect(java.lang.String host, int port)

		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);
	
public voidcheckExit(int status)

	
public voidcheckPackageAccess(java.lang.String pkg)

	
public voidcheckPackageDefinition(java.lang.String pkg)

		if (!pkg.startsWith("java."))
			return;
		try {
			super.checkPackageDefinition(pkg);
			return;
		} catch (AccessControlException ace) {
			// continue
		}
		if (inClassLoader())
			throw new SecurityException("Can't define sun/java classes");
	
private java.lang.ClassLoadergetNonSystemClassLoader()

		Class c[] = getClassContext();
		ClassLoader sys = ClassLoader.getSystemClassLoader();
		for (int i = 1; i < c.length; i++) {
			ClassLoader cl = c[i].getClassLoader();
			if (cl != null && !cl.equals(sys))
				return cl;
		}
		return null;