Examples of PolicyFile


Examples of com.getperka.flatpack.policy.pst.PolicyFile

      return false;
    }

    @Override
    public boolean visit(PolicyFile x) {
      PolicyFile n = new PolicyFile();
      n.setAllows(clone(x.getAllows()));
      n.setPackagePolicies(clone(x.getPackagePolicies()));
      n.setTypePolicies(clone(x.getTypePolicies()));
      n.setVerbs(clone(x.getVerbs()));
      stack.push(n);
      return false;
    }
View Full Code Here

Examples of com.getperka.flatpack.policy.pst.PolicyFile

  /**
   * The top-level parse rule.
   */
  public Rule PolicyFile() {
    Var<PolicyFile> x = new Var<PolicyFile>(new PolicyFile());
    return Sequence(
        PolicyBlock(x),
        EOI);
  }
View Full Code Here

Examples of com.getperka.flatpack.policy.pst.PolicyFile

   * Parse the test file, and shuffle the elements to ensure that there aren't any test dependencies
   * on the particulars of how the contents of the file are ordered.
   */
  @Test
  public void testShuffle() {
    PolicyFile policyFile = loadTestPolicy();

    final Random r = new Random(0);
    for (int i = 0; i < 10; i++) {
      policyFile.accept(new PolicyVisitor() {

        /**
         * Shuffle nested lists.
         */
        @Override
        public void traverse(List<? extends PolicyNode> list) {
          if (list != null) {
            Collections.shuffle(list, r);
          }
          super.traverse(list);
        }

        /**
         * Don't re-order the internal state of an Ident.
         */
        @Override
        public boolean visit(Ident<?> x) {
          return false;
        }
      });

      try {
        doTest(policyFile.toSource());
      } catch (IllegalArgumentException e) {
        System.err.println(i + " Failing source:\n" + policyFile.toSource());
        throw e;
      }
    }
  }
View Full Code Here

Examples of com.getperka.flatpack.policy.pst.PolicyFile

  }

  @Test
  public void test() throws IOException {
    String contents = FileUtils.readAllText(getClass().getResourceAsStream("test.policy"));
    PolicyFile p = (PolicyFile) testRule(parser.PolicyFile(), contents);

    // Test print-parse-print to make sure nothing is getting lost
    String string = p.toSource();
    PolicyFile p2 = (PolicyFile) testRule(parser.PolicyFile(), string);
    assertEquals(string, p2.toSource());
  }
View Full Code Here

Examples of com.getperka.flatpack.policy.pst.PolicyFile

  }

  @Test
  public void testCloner() throws IOException {
    String contents = FileUtils.readAllText(getClass().getResourceAsStream("test.policy"));
    PolicyFile p = (PolicyFile) testRule(parser.PolicyFile(), contents);
    PolicyFile p2 = new PolicyCloner().clone(p);

    assertEquals(p.toSource(), p2.toSource());
  }
View Full Code Here

Examples of gnu.java.security.PolicyFile

    /**
     * Initialize this instance.
     */
    public JNodePolicy(ExtensionPoint permissionsEp) {
        this.policyFile = new PolicyFile(ClassLoader
            .getSystemResource("/org/jnode/security/jnode.policy"));
        this.codeSource2Permissions = new HashMap<CodeSource, PermissionCollection>();
        this.permissionsEp = permissionsEp;
        loadExtensions();
    }
View Full Code Here

Examples of org.apache.sentry.provider.file.PolicyFile

  /**
   * Tests that users in two groups work correctly
   **/
  @Test
  public void testAdmin5() throws Exception {
    policyFile = new PolicyFile();
    policyFile
        .addRolesToGroup("admin_group1", ADMINGROUP)
        .addRolesToGroup("admin_group2", ADMINGROUP)
        .addPermissionsToRole(ADMINGROUP, "server=server1")
        .addGroupsToUser("admin1", "admin_group1", "admin_group2")
View Full Code Here

Examples of org.apache.sentry.provider.file.PolicyFile

  /**
   * Tests that user with two roles the most powerful role takes effect
   **/
  @Test
  public void testGroup2() throws Exception {
    policyFile = new PolicyFile();
    policyFile
        .addRolesToGroup("group1", ADMINGROUP, "analytics")
        .addPermissionsToRole(ADMINGROUP, "server=server1")
        .addPermissionsToRole("analytics", "server=server1->db=" + dbName)
        .addGroupsToUser("user1", "group1")
View Full Code Here

Examples of org.apache.sentry.provider.file.PolicyFile

  /**
   * Tests that user names with special characters are handled correctly
   **/
  @Test
  public void testGroup7() throws Exception {
    policyFile = new PolicyFile();
    policyFile
        .addRolesToGroup("group1", ADMINGROUP)
        .addPermissionsToRole(ADMINGROUP, "server=server1")
        .addGroupsToUser("user1~!@#$%^&*()+-", "group1")
        .addGroupsToUser("user2", "group1")
View Full Code Here

Examples of org.apache.sentry.provider.file.PolicyFile

  }
  @Test
  public void testPerDbFileCannotContainUsersOrDatabases() throws Exception {
    PolicyEngine policy;
    ImmutableSet<String> permissions;
    PolicyFile policyFile;
    // test sanity
    policyFile = PolicyFile.setAdminOnServer1("admin");
    policyFile.addGroupsToUser("admin1", "admin");
    policyFile.write(globalPolicyFile);
    policyFile.write(otherPolicyFile);
    policy = new DBPolicyFileBackend(globalPolicyFile.getPath(), "server1");
    permissions = policy.getPermissions(
        Arrays.asList(new Authorizable[] {
            new Server("server1")
    }), Lists.newArrayList("admin")).get("admin");
    Assert.assertEquals(permissions.toString(), "[server=server1]");
    // test to ensure [users] fails parsing of per-db file
    policyFile.addDatabase("other", otherPolicyFile.getPath());
    policyFile.write(globalPolicyFile);
    policyFile.write(otherPolicyFile);
    policy = new DBPolicyFileBackend(globalPolicyFile.getPath(), "server1");
    permissions = policy.getPermissions(
        Arrays.asList(new Authorizable[] {
            new Server("server1")
    }), Lists.newArrayList("admin")).get("admin");
    Assert.assertEquals(permissions.toString(), "[server=server1]");
    // test to ensure [databases] fails parsing of per-db file
    // by removing the user mapping from the per-db policy file
    policyFile.removeGroupsFromUser("admin1", "admin")
      .write(otherPolicyFile);
    policy = new DBPolicyFileBackend(globalPolicyFile.getPath(), "server1");
    permissions = policy.getPermissions(
        Arrays.asList(new Authorizable[] {
            new Server("server1")
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.