Search in sources :

Example 1 with ShowRoleGrantDesc

use of org.apache.hadoop.hive.ql.ddl.privilege.show.rolegrant.ShowRoleGrantDesc in project hive by apache.

the class HiveAuthorizationTaskFactoryImpl method createShowRoleGrantTask.

@Override
public Task<?> createShowRoleGrantTask(ASTNode ast, Path resultFile, Set<ReadEntity> inputs, Set<WriteEntity> outputs) {
    ASTNode child = (ASTNode) ast.getChild(0);
    PrincipalType principalType = PrincipalType.USER;
    switch(child.getType()) {
        case HiveParser.TOK_USER:
            principalType = PrincipalType.USER;
            break;
        case HiveParser.TOK_GROUP:
            principalType = PrincipalType.GROUP;
            break;
        case HiveParser.TOK_ROLE:
            principalType = PrincipalType.ROLE;
            break;
    }
    String principalName = BaseSemanticAnalyzer.unescapeIdentifier(child.getChild(0).getText());
    ShowRoleGrantDesc showRoleGrantDesc = new ShowRoleGrantDesc(principalName, principalType, resultFile.toString());
    return TaskFactory.get(new DDLWork(inputs, outputs, showRoleGrantDesc));
}
Also used : ShowRoleGrantDesc(org.apache.hadoop.hive.ql.ddl.privilege.show.rolegrant.ShowRoleGrantDesc) DDLWork(org.apache.hadoop.hive.ql.ddl.DDLWork) ASTNode(org.apache.hadoop.hive.ql.parse.ASTNode) PrincipalType(org.apache.hadoop.hive.metastore.api.PrincipalType)

Example 2 with ShowRoleGrantDesc

use of org.apache.hadoop.hive.ql.ddl.privilege.show.rolegrant.ShowRoleGrantDesc in project hive by apache.

the class TestHiveAuthorizationTaskFactory method testShowRoleGrantUser.

/**
 * SHOW ROLE GRANT USER ...
 */
@Test
public void testShowRoleGrantUser() throws Exception {
    DDLWork work = analyze("SHOW ROLE GRANT USER " + USER);
    ShowRoleGrantDesc roleDesc = (ShowRoleGrantDesc) work.getDDLDesc();
    Assert.assertNotNull("Role should not be null", roleDesc);
    Assert.assertEquals(PrincipalType.USER, roleDesc.getPrincipalType());
    Assert.assertEquals(USER, roleDesc.getName());
}
Also used : ShowRoleGrantDesc(org.apache.hadoop.hive.ql.ddl.privilege.show.rolegrant.ShowRoleGrantDesc) DDLWork(org.apache.hadoop.hive.ql.ddl.DDLWork) Test(org.junit.Test)

Example 3 with ShowRoleGrantDesc

use of org.apache.hadoop.hive.ql.ddl.privilege.show.rolegrant.ShowRoleGrantDesc in project hive by apache.

the class TestHiveAuthorizationTaskFactory method testShowRoleGrantRole.

/**
 * SHOW ROLE GRANT ROLE ...
 */
@Test
public void testShowRoleGrantRole() throws Exception {
    DDLWork work = analyze("SHOW ROLE GRANT ROLE " + ROLE);
    ShowRoleGrantDesc roleDesc = (ShowRoleGrantDesc) work.getDDLDesc();
    Assert.assertNotNull("Role should not be null", roleDesc);
    Assert.assertEquals(PrincipalType.ROLE, roleDesc.getPrincipalType());
    Assert.assertEquals(ROLE, roleDesc.getName());
}
Also used : ShowRoleGrantDesc(org.apache.hadoop.hive.ql.ddl.privilege.show.rolegrant.ShowRoleGrantDesc) DDLWork(org.apache.hadoop.hive.ql.ddl.DDLWork) Test(org.junit.Test)

Example 4 with ShowRoleGrantDesc

use of org.apache.hadoop.hive.ql.ddl.privilege.show.rolegrant.ShowRoleGrantDesc in project hive by apache.

the class TestHiveAuthorizationTaskFactory method testShowRoleGrantGroup.

/**
 * SHOW ROLE GRANT GROUP ...
 */
@Test
public void testShowRoleGrantGroup() throws Exception {
    DDLWork work = analyze("SHOW ROLE GRANT GROUP " + GROUP);
    ShowRoleGrantDesc roleDesc = (ShowRoleGrantDesc) work.getDDLDesc();
    Assert.assertNotNull("Role should not be null", roleDesc);
    Assert.assertEquals(PrincipalType.GROUP, roleDesc.getPrincipalType());
    Assert.assertEquals(GROUP, roleDesc.getName());
}
Also used : ShowRoleGrantDesc(org.apache.hadoop.hive.ql.ddl.privilege.show.rolegrant.ShowRoleGrantDesc) DDLWork(org.apache.hadoop.hive.ql.ddl.DDLWork) Test(org.junit.Test)

Aggregations

DDLWork (org.apache.hadoop.hive.ql.ddl.DDLWork)4 ShowRoleGrantDesc (org.apache.hadoop.hive.ql.ddl.privilege.show.rolegrant.ShowRoleGrantDesc)4 Test (org.junit.Test)3 PrincipalType (org.apache.hadoop.hive.metastore.api.PrincipalType)1 ASTNode (org.apache.hadoop.hive.ql.parse.ASTNode)1