Package org.apache.sentry.policy.common

Examples of org.apache.sentry.policy.common.PrivilegeValidatorContext


  public void testEmptyRole() throws Exception {
    CollectionRequiredInPrivilege collRequiredInRole = new CollectionRequiredInPrivilege();

    // check no db
    try {
      collRequiredInRole.validate(new PrivilegeValidatorContext("index=index1"));
      Assert.fail("Expected ConfigurationException");
    } catch (ConfigurationException e) {
      ;
    }

    // check with db
    try {
      collRequiredInRole.validate(new PrivilegeValidatorContext("db1","index=index2"));
      Assert.fail("Expected ConfigurationException");
    } catch (ConfigurationException e) {
      ;
    }
  }
View Full Code Here


  }

  @Test
  public void testCollectionWithoutAction() throws Exception {
    CollectionRequiredInPrivilege collRequiredInRole = new CollectionRequiredInPrivilege();
    collRequiredInRole.validate(new PrivilegeValidatorContext("collection=nodb"));
    collRequiredInRole.validate(new PrivilegeValidatorContext("db2","collection=db"));
  }
View Full Code Here

  }

  @Test
  public void testCollectionWithAction() throws Exception {
    CollectionRequiredInPrivilege collRequiredInRole = new CollectionRequiredInPrivilege();
    collRequiredInRole.validate(new PrivilegeValidatorContext(null,"collection=nodb->action=query"));
    collRequiredInRole.validate(new PrivilegeValidatorContext("db2","collection=db->action=update"));
  }
View Full Code Here

      Set<String> privileges = PrivilegeUtils.toPrivilegeStrings(roleValue);
      if (!invalidConfiguration && privileges != null) {
        Set<String> internedPrivileges = Sets.newHashSet();
        for(String privilege : privileges) {
          for(PrivilegeValidator validator : validators) {
            validator.validate(new PrivilegeValidatorContext(database, privilege.trim()));
          }
          internedPrivileges.add(stringInterner.intern(privilege));
        }
        roleNameToPrivilegeMap.putAll(roleName, internedPrivileges);
      }
View Full Code Here

  @Test
  public void testURIInPerDbPolicyFile() throws Exception {
    DatabaseRequiredInPrivilege dbRequiredInRole = new DatabaseRequiredInPrivilege();
    System.setProperty("sentry.allow.uri.db.policyfile", "true");
    dbRequiredInRole.validate(new PrivilegeValidatorContext("db1",
      "server=server1->URI=file:///user/db/warehouse/tab1"));
    System.setProperty("sentry.allow.uri.db.policyfile", "false");
  }
View Full Code Here

  @Test
  public void testURIWithDBInPerDbPolicyFile() throws Exception {
    DatabaseRequiredInPrivilege dbRequiredInRole = new DatabaseRequiredInPrivilege();
    try {
      dbRequiredInRole.validate(new PrivilegeValidatorContext("db1",
        "server=server1->db=db1->URI=file:///user/db/warehouse/tab1"));
      Assert.fail("Expected ConfigurationException");
    } catch (ConfigurationException e) {
      ;
    }
View Full Code Here

TOP

Related Classes of org.apache.sentry.policy.common.PrivilegeValidatorContext

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.