Package org.apache.sentry.core.model.db

Examples of org.apache.sentry.core.model.db.AccessURI


  }
  @Test
  public void testNonAbolutePath() throws Exception {
    Subject user1 = new Subject("user1");
    Server server1 = new Server("server1");
    AccessURI uri = new AccessURI("file:///path/to/");
    Set<? extends Action> actions = EnumSet.of(DBModelAction.ALL, DBModelAction.SELECT, DBModelAction.INSERT);
    policyFile.addGroupsToUser(user1.getName(), "group1")
      .addRolesToGroup("group1", "role1")
      .addPermissionsToRole("role1", "server=" + server1.getName() + "->uri=" + uri.getName());
    policyFile.write(iniFile);
    DBPolicyFileBackend policy = new DBPolicyFileBackend(server1.getName(), initResource);
    authzProvider = new LocalGroupResourceAuthorizationProvider(initResource, policy);
    // positive test
    List<? extends Authorizable> authorizableHierarchy = ImmutableList.of(server1, uri);
    Assert.assertTrue(authorizableHierarchy.toString(),
        authzProvider.hasAccess(user1, authorizableHierarchy, actions, ActiveRoleSet.ALL));
    // negative tests
    // TODO we should support the case of /path/to/./ but let's to that later
    uri = new AccessURI("file:///path/to/./");
    authorizableHierarchy = ImmutableList.of(server1, uri);
    Assert.assertFalse(authorizableHierarchy.toString(),
        authzProvider.hasAccess(user1, authorizableHierarchy, actions, ActiveRoleSet.ALL));
    uri = new AccessURI("file:///path/to/../");
    authorizableHierarchy = ImmutableList.of(server1, uri);
    Assert.assertFalse(authorizableHierarchy.toString(),
        authzProvider.hasAccess(user1, authorizableHierarchy, actions, ActiveRoleSet.ALL));
    uri = new AccessURI("file:///path/to/../../");
    authorizableHierarchy = ImmutableList.of(server1, uri);
    Assert.assertFalse(authorizableHierarchy.toString(),
        authzProvider.hasAccess(user1, authorizableHierarchy, actions, ActiveRoleSet.ALL));
    uri = new AccessURI("file:///path/to/dir/../../");
    authorizableHierarchy = ImmutableList.of(server1, uri);
    Assert.assertFalse(authorizableHierarchy.toString(),
        authzProvider.hasAccess(user1, authorizableHierarchy, actions, ActiveRoleSet.ALL));
  }
View Full Code Here


    Assert.assertFalse(authorizableHierarchy.toString(),
        authzProvider.hasAccess(user1, authorizableHierarchy, actions, ActiveRoleSet.ALL));
  }
  @Test(expected=IllegalArgumentException.class)
  public void testInvalidPath() throws Exception {
    new AccessURI(":invaliduri");
  }
View Full Code Here

    } else if (privSubjectDesc.getUri()) {
      String uriPath = privSubjectDesc.getObject();
      String warehouseDir = conf.getVar(HiveConf.ConfVars.METASTOREWAREHOUSE);
      try {
      authorizableHeirarchy.add(new AccessURI(PathUtils.parseDFSURI(warehouseDir, uriPath)));
      } catch(URISyntaxException e) {
        throw new HiveException(e.getMessage());
      }
    } else {
      dbName = privSubjectDesc.getObject();
View Full Code Here

public class TestURI {

  @Test(expected=IllegalArgumentException.class)
  public void testBadUriEmpty() {
    new AccessURI("");
  }
View Full Code Here

  public void testBadUriEmpty() {
    new AccessURI("");
  }
  @Test(expected=IllegalArgumentException.class)
  public void testBadUriNull() {
    new AccessURI(null);
  }
View Full Code Here

  public void testBadUriNull() {
    new AccessURI(null);
  }
  @Test(expected=IllegalArgumentException.class)
  public void testBadUriNoFilePrefix() {
    new AccessURI("/");
  }
View Full Code Here

  public void testBadUriNoFilePrefix() {
    new AccessURI("/");
  }
  @Test(expected=IllegalArgumentException.class)
  public void testBadUriIncorrectFilePrefix() {
    new AccessURI("file:/some/path");
  }
View Full Code Here

  public void testBadUriIncorrectFilePrefix() {
    new AccessURI("file:/some/path");
  }
  @Test(expected=IllegalArgumentException.class)
  public void testBadUriIncorrectHdfsPrefix() {
    new AccessURI("hdfs:/some/path");
  }
View Full Code Here

    case Table:
      return new Table(name);
    case View:
      return new View(name);
    case URI:
      return new AccessURI(name);
    default:
      return null;
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.sentry.core.model.db.AccessURI

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.