Search in sources :

Example 1 with HiveOperationType

use of org.apache.hadoop.hive.ql.security.authorization.plugin.HiveOperationType in project hive by apache.

the class TestOperation2Privilege method checkHiveOperationTypeMatch.

/**
   * test that all enums in {@link HiveOperationType} match one map entry in
   * Operation2Privilege
   */
@Test
public void checkHiveOperationTypeMatch() {
    Set<HiveOperationType> operationMapKeys = Operation2Privilege.getOperationTypes();
    for (HiveOperationType operationType : HiveOperationType.values()) {
        if (!operationMapKeys.contains(operationType)) {
            fail("Unable to find corresponding entry in Operation2Privilege map for HiveOperationType " + operationType);
        }
    }
    assertEquals("Check if Operation2Privilege, HiveOperationType have same number of instances", operationMapKeys.size(), HiveOperationType.values().length);
}
Also used : HiveOperationType(org.apache.hadoop.hive.ql.security.authorization.plugin.HiveOperationType) Test(org.junit.Test)

Example 2 with HiveOperationType

use of org.apache.hadoop.hive.ql.security.authorization.plugin.HiveOperationType in project hive by apache.

the class Driver method doAuthorizationV2.

private static void doAuthorizationV2(SessionState ss, HiveOperation op, Set<ReadEntity> inputs, Set<WriteEntity> outputs, String command, Map<String, List<String>> tab2cols, Map<String, List<String>> updateTab2Cols) throws HiveException {
    /* comment for reviewers -> updateTab2Cols needed to be separate from tab2cols because if I
    pass tab2cols to getHivePrivObjects for the output case it will trip up insert/selects,
    since the insert will get passed the columns from the select.
     */
    HiveAuthzContext.Builder authzContextBuilder = new HiveAuthzContext.Builder();
    authzContextBuilder.setUserIpAddress(ss.getUserIpAddress());
    authzContextBuilder.setForwardedAddresses(ss.getForwardedAddresses());
    authzContextBuilder.setCommandString(command);
    HiveOperationType hiveOpType = getHiveOperationType(op);
    List<HivePrivilegeObject> inputsHObjs = getHivePrivObjects(inputs, tab2cols);
    List<HivePrivilegeObject> outputHObjs = getHivePrivObjects(outputs, updateTab2Cols);
    ss.getAuthorizerV2().checkPrivileges(hiveOpType, inputsHObjs, outputHObjs, authzContextBuilder.build());
}
Also used : HiveAuthzContext(org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthzContext) HiveOperationType(org.apache.hadoop.hive.ql.security.authorization.plugin.HiveOperationType) HivePrivilegeObject(org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrivilegeObject)

Aggregations

HiveOperationType (org.apache.hadoop.hive.ql.security.authorization.plugin.HiveOperationType)2 HiveAuthzContext (org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthzContext)1 HivePrivilegeObject (org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrivilegeObject)1 Test (org.junit.Test)1