FileDocCategorySizeDatePackage
XYZPolicy.javaAPI DocExample3294Sun Oct 25 18:13:36 GMT 1998None

XYZPolicy

public class XYZPolicy extends Policy

Fields Summary
private KeyStore
ks
Vector
permissions
Constructors Summary
public XYZPolicy()

		permissions = new Vector();

		AccessController.doPrivileged(new PrivilegedAction() {
			public Object run() {
				initKeyStore();
				initPolicy();
				return null;
			}
		});
	
Methods Summary
public java.security.PermissionCollectiongetPermissions(java.security.CodeSource codesource)

		Permissions perms = new Permissions();
		for (Enumeration e = permissions.elements(); e.hasMoreElements(); ) {
			XYZPolicyEntry pe = (XYZPolicyEntry) e.nextElement();
			if (pe.cs == null)
				perms.add(pe.p);
			else if (pe.cs.equals(codesource))
				perms.add(pe.p);
		}
		return perms;
	
private voidinitKeyStore()

		try {
			// In 1.2 beta 4, we must supply an argument to the getInstance
			// method
			ks = KeyStore.getInstance(KeyStore.getDefaultType());
			ks.load(new FileInputStream(System.getProperty("user.home") +
						File.separator + ".keystore"), null);
		} catch (Exception e) {
			ks = null;
		}
	
private voidinitPolicy()

		CodeSource cs = null;
		permissions.add(new XYZPolicyEntry(
						new PropertyPermission("java.version", "read"), cs));
		
		// http://piccolo/ sdo
		try {
			if (ks != null) {
				URL u = new URL("http://piccolo/");
				// In 1.2 beta 4, we need the certificates to initialize
				// the code source (instead of the public keys, which is
				// what we used earlier
				java.security.cert.Certificate c[] = ks.getCertificateChain("sdo");
	
				cs = new CodeSource(u, c);
				permissions.add(new XYZPolicyEntry(
						new PropertyPermission("os.arch", "read"), cs));
			}
		} catch (Exception e) {}
	
public voidrefresh()

		initPolicy();