Search in sources :

Example 11 with HivePrincipal

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

the class SQLStdHiveAuthorizationValidator method checkPrivileges.

@Override
public void checkPrivileges(HiveOperationType hiveOpType, List<HivePrivilegeObject> inputHObjs, List<HivePrivilegeObject> outputHObjs, HiveAuthzContext context) throws HiveAuthzPluginException, HiveAccessControlException {
    if (LOG.isDebugEnabled()) {
        String msg = "Checking privileges for operation " + hiveOpType + " by user " + authenticator.getUserName() + " on " + " input objects " + inputHObjs + " and output objects " + outputHObjs + ". Context Info: " + context;
        LOG.debug(msg);
    }
    String userName = authenticator.getUserName();
    IMetaStoreClient metastoreClient = metastoreClientFactory.getHiveMetastoreClient();
    // check privileges on input and output objects
    List<String> deniedMessages = new ArrayList<String>();
    checkPrivileges(hiveOpType, inputHObjs, metastoreClient, userName, IOType.INPUT, deniedMessages);
    checkPrivileges(hiveOpType, outputHObjs, metastoreClient, userName, IOType.OUTPUT, deniedMessages);
    SQLAuthorizationUtils.assertNoDeniedPermissions(new HivePrincipal(userName, HivePrincipalType.USER), hiveOpType, deniedMessages);
}
Also used : HivePrincipal(org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrincipal) ArrayList(java.util.ArrayList) IMetaStoreClient(org.apache.hadoop.hive.metastore.IMetaStoreClient)

Aggregations

HivePrincipal (org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrincipal)11 ArrayList (java.util.ArrayList)5 HiveAuthzPluginException (org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthzPluginException)5 HivePrivilege (org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrivilege)5 IMetaStoreClient (org.apache.hadoop.hive.metastore.IMetaStoreClient)4 HiveObjectPrivilege (org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege)4 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)4 PrivilegeGrantInfo (org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo)4 HiveAccessControlException (org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException)4 HivePrivilegeObject (org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrivilegeObject)4 TException (org.apache.thrift.TException)4 HiveObjectRef (org.apache.hadoop.hive.metastore.api.HiveObjectRef)3 HivePrivilegeInfo (org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrivilegeInfo)3 HiveAuthorizer (org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthorizer)2 HashMap (java.util.HashMap)1 PrincipalType (org.apache.hadoop.hive.metastore.api.PrincipalType)1 PrivilegeBag (org.apache.hadoop.hive.metastore.api.PrivilegeBag)1