Package net.jini.security.policy

Examples of net.jini.security.policy.PolicyFileProvider


public class Test {
    public static void main(String[] args) throws Exception {
  if (System.getSecurityManager() == null) {
      System.setSecurityManager(new SecurityManager());
  }
  Policy policy = new PolicyFileProvider();
  PermissionCollection pc =
      policy.getPermissions((ProtectionDomain) null);
  if (pc.elements().hasMoreElements()) {
      throw new Error("permissions returned for null protection domain");
  }
  if (policy.implies(null, new RuntimePermission("foo"))) {
      throw new Error();
  }
    }
View Full Code Here


  String policy0File =
      System.getProperty("test.src", ".") + File.separator + "policy.0";
  String policy1File =
      System.getProperty("test.src", ".") + File.separator + "policy.1";

  Policy policy = new PolicyFileProvider();
  checkPolicy0Permissions(policy);
  System.setProperty("java.security.policy", policy1File);
  policy.refresh();
  checkPolicy1Permissions(policy);

  System.setProperty("java.security.policy", policy0File);
  policy = new PolicyFileProvider(policy1File);
  checkPolicy1Permissions(policy);
  policy.refresh();
  checkPolicy1Permissions(policy);
    }
View Full Code Here

              logger.log(Level.FINEST,
            "Global policy set: {0}", globalPolicy);
          }
    Policy service_policy =
        getServicePolicyProvider(
            new PolicyFileProvider(desc.policy));
    Policy backstop_policy =
        getServicePolicyProvider(initialGlobalPolicy);
                LoaderSplitPolicyProvider split_service_policy =
                    new LoaderSplitPolicyProvider(
                        cl, service_policy, backstop_policy);
View Full Code Here

        "Global policy set: {0}", globalPolicy);
      }
     
      Policy service_policy =
    ActivateWrapper.getServicePolicyProvider(
         new PolicyFileProvider(getPolicy()));
      Policy backstop_policy =
    ActivateWrapper.getServicePolicyProvider(initialGlobalPolicy);
      LoaderSplitPolicyProvider split_service_policy =
    new LoaderSplitPolicyProvider(
        newClassLoader, service_policy, backstop_policy);
View Full Code Here

  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 {
View Full Code Here

     * @throws TestException if failed
     *
     */
    protected void createPolicyFileProvider() throws TestException {
        try {
            policy = new PolicyFileProvider();
        } catch (Exception e) {
            msg = "new PolicyFileProvider()";
            throw new TestException(Util.fail(msg, e, msg));
        }
    }
View Full Code Here

      throw new TestException("No policy found for name " + policyFile);
        }
        msg = "new PolicyFileProvider(" + newPolicy + ")";

        try {
            policy = new PolicyFileProvider(newPolicy);
        } catch (Exception e) {
            throw new TestException(Util.fail(msg, e, msg));
        }
        logger.log(Level.FINE, msg + " created");
    }
View Full Code Here

     *
     */
    protected void createPolicyFileProviderSE(String msg)
            throws TestException {
        try {
            PolicyFileProvider policy = new PolicyFileProvider();
            throw new TestException(Util.fail(msg, msg, SE));
        } catch (SecurityException se) {
            logger.log(Level.FINE, Util.pass(msg, se));
        } catch (TestException qae) {
            throw qae;
View Full Code Here

     *
     */
    protected void createPolicyFileProviderSE(String policyFile, String msg)
            throws TestException {
        try {
            PolicyFileProvider policy = new PolicyFileProvider(policyFile);
            throw new TestException(Util.fail(msg, msg, SE));
        } catch (SecurityException se) {
            logger.log(Level.FINE, Util.pass(msg, se));
        } catch (TestException qae) {
            throw qae;
View Full Code Here

     *
     */
    protected void createPolicyFileProviderPIE(String msg)
            throws TestException {
        try {
            PolicyFileProvider policy = new PolicyFileProvider();
            throw new TestException(Util.fail(msg, msg, PIE));
        } catch (PolicyInitializationException pie) {
            logger.log(Level.FINE, Util.pass(msg, pie));
        } catch (TestException qae) {
            throw qae;
View Full Code Here

TOP

Related Classes of net.jini.security.policy.PolicyFileProvider

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.