Package com.sun.jini.start

Examples of com.sun.jini.start.AggregatePolicyProvider


public class NullCasesTest extends QATest {
    public void run() throws Exception {
  if (System.getSecurityManager() == null) {
      System.setSecurityManager(new SecurityManager());
  }
  AggregatePolicyProvider policy = new AggregatePolicyProvider();

  try {
      policy.setPolicy(null, null);
      throw new TestException("Successfully set null policy.");
  } catch (NullPointerException e) {
  }
  policy.setPolicy(null, new DynamicPolicyProvider());
  policy.setPolicy(NullCasesTest.class.getClassLoader(), null);

  policy.grant(null, null, null);
  try {
      policy.grant(null, new Principal[]{ null }, null);
      throw new TestException("Successfully granted: "
                    + "null, new Principal[]{ null }, null");
  } catch (NullPointerException e) {
  }
  try {
      policy.grant(null, null, new Permission[]{ null });
      throw new TestException("Successfully granted: "
                    + "null, null, new Permission[]{ null }");
  } catch (NullPointerException e) {
  }
  policy.getGrants(null, null);
  try {
      policy.getGrants(null, new Principal[]{ null });
      throw new TestException("Successfully called "
                    + "getGrants(null, new Principal[]{ null })");
  } catch (NullPointerException e) {
  }
  PermissionCollection pc =
      policy.getPermissions((ProtectionDomain) null);
  if (pc.elements().hasMoreElements()) {
      throw new TestException(
                    "permissions returned for null protection domain");
  }
  if (policy.implies(null, new RuntimePermission("foo"))) {
      throw new TestException(
                    "policy implies(null, new RuntimePermission(\"foo\"))");
  }
    }
View Full Code Here


    public void run() throws Exception {
  if (System.getSecurityManager() == null) {
      System.setSecurityManager(new SecurityManager());
  }
  Policy.setPolicy(new AggregatePolicyProvider());

  ClassLoader ldr1 = new URLClassLoader(new URL[]{
      new URL("file", "", getContextJarFile) });
  Runnable getContext = (Runnable) Class.forName(
                "com.sun.jini.test.impl.start.aggregatepolicyprovider"
View Full Code Here

           new URL[]{ new URL("file:/foo") });
  ClassLoader ldr2 = new URLClassLoader(
           new URL[]{ new URL("file:/bar") }, ldr1);
  Thread thr = Thread.currentThread();

  AggregatePolicyProvider policy = new AggregatePolicyProvider();
  checkPolicy0Permissions(policy);
  thr.setContextClassLoader(ldr1);
  checkPolicy0Permissions(policy);
  System.setProperty("java.security.policy", policy1File);
  policy.refresh();
  checkPolicy1Permissions(policy);

  thr.setContextClassLoader(null);
  policy.setPolicy(null, new PolicyFileProvider(policy0File));
  policy.setPolicy(ldr1,
      new DynamicPolicyProvider(new PolicyFileProvider(policy1File)));

  checkPolicy0Permissions(policy);
  if (policy.grantSupported()) {
      throw new TestException("1-st grant is supported.");
  }
  try {
      policy.grant(null, null,
       new Permission[]{ new RuntimePermission("foo") });
      throw new TestException("1-st grant does not throw exception.");
  } catch (UnsupportedOperationException e) {
  }

  thr.setContextClassLoader(ldr1);
  checkPolicy1Permissions(policy);
  if (!policy.grantSupported()) {
      throw new TestException("2-nd grant is not supported.");
  }
  policy.grant(null, null,
         new Permission[]{ new RuntimePermission("foo") });

  thr.setContextClassLoader(ldr2);
  checkPolicy1Permissions(policy);
  if (!policy.grantSupported()) {
      throw new TestException("3-rd grant is not supported.");
  }
  policy.grant(null, null,
         new Permission[]{ new RuntimePermission("foo") });

  policy.setPolicy(ldr2, new PolicyFileProvider(policy0File));
  checkPolicy0Permissions(policy);
  if (policy.grantSupported()) {
      throw new TestException("4-th grant is supported.");
  }
  try {
      policy.grant(null, null,
       new Permission[]{ new RuntimePermission("foo") });
      throw new TestException("2-nd grant does not throw exception.");
  } catch (UnsupportedOperationException e) {
  }

  thr.setContextClassLoader(ldr1);
  checkPolicy1Permissions(policy);
  if (!policy.grantSupported()) {
      throw new TestException("5-th grant is not supported.");
  }
  policy.grant(null, null,
         new Permission[]{ new RuntimePermission("foo") });

  policy.setPolicy(ldr2, null);
  thr.setContextClassLoader(ldr2);
  checkPolicy1Permissions(policy);
  if (!policy.grantSupported()) {
      throw new TestException("6-th grant is not supported.");
  }
  policy.grant(null, null,
         new Permission[]{ new RuntimePermission("foo") });
    }
View Full Code Here

    public void run() throws Exception {
  if (System.getSecurityManager() == null) {
      System.setSecurityManager(new SecurityManager());
  }
  policy = new AggregatePolicyProvider();
  ClassLoader ldr = UntrustedGetContextClassLoader.class.getClassLoader();
  policy.setPolicy(ldr, new PolicyFileProvider());
  Thread.currentThread().setContextClassLoader(ldr);
  Test test = new Test();
  test.start();
View Full Code Here

  }
  Security.setProperty(
      "com.sun.jini.start.AggregatePolicyProvider."
      + "mainPolicyClass", "foo");
  try {
      new AggregatePolicyProvider();
      throw new TestException(
                    "Successfully created AggregatePolicyProvider, while "
                    + "PolicyInitializationException was expected to "
                    + "be thrown.");
  } catch (PolicyInitializationException e) {
View Full Code Here

TOP

Related Classes of com.sun.jini.start.AggregatePolicyProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.