Search in sources :

Example 11 with HiveAccessControlException

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

the class MetadataOperation method authorizeMetaGets.

protected void authorizeMetaGets(HiveOperationType opType, List<HivePrivilegeObject> inpObjs, String cmdString) throws HiveSQLException {
    SessionState ss = SessionState.get();
    HiveAuthzContext.Builder ctxBuilder = new HiveAuthzContext.Builder();
    ctxBuilder.setUserIpAddress(ss.getUserIpAddress());
    ctxBuilder.setForwardedAddresses(ss.getForwardedAddresses());
    ctxBuilder.setCommandString(cmdString);
    try {
        ss.getAuthorizerV2().checkPrivileges(opType, inpObjs, null, ctxBuilder.build());
    } catch (HiveAuthzPluginException | HiveAccessControlException e) {
        throw new HiveSQLException(e.getMessage(), e);
    }
}
Also used : SessionState(org.apache.hadoop.hive.ql.session.SessionState) HiveAccessControlException(org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) HiveAuthzContext(org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthzContext) HiveAuthzPluginException(org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthzPluginException)

Example 12 with HiveAccessControlException

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

the class HiveAuthorizationHelper method authorize.

/* Helper method to check privileges */
private void authorize(final HiveOperationType hiveOpType, final List<HivePrivilegeObject> toRead, final List<HivePrivilegeObject> toWrite, final String cmd) throws HiveAccessControlException {
    try {
        HiveAuthzContext.Builder authzContextBuilder = new HiveAuthzContext.Builder();
        authzContextBuilder.setUserIpAddress("Not available");
        authzContextBuilder.setCommandString(cmd);
        authorizerV2.checkPrivileges(hiveOpType, toRead, toWrite, authzContextBuilder.build());
    } catch (final HiveAccessControlException e) {
        throw e;
    } catch (final Exception e) {
        throw new DrillRuntimeException("Failed to use the Hive authorization components: " + e.getMessage(), e);
    }
}
Also used : HiveAccessControlException(org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException) HiveAuthzContext(org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthzContext) DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException) UserException(org.apache.drill.common.exceptions.UserException) DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException) HiveAccessControlException(org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException) HiveAuthzPluginException(org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthzPluginException) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException)

Aggregations

HiveAccessControlException (org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException)12 HiveAuthzPluginException (org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthzPluginException)11 TException (org.apache.thrift.TException)8 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)7 IMetaStoreClient (org.apache.hadoop.hive.metastore.IMetaStoreClient)5 HivePrincipal (org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrincipal)4 ArrayList (java.util.ArrayList)3 HiveObjectPrivilege (org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege)3 PrivilegeBag (org.apache.hadoop.hive.metastore.api.PrivilegeBag)2 PrivilegeGrantInfo (org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo)2 HiveAuthzContext (org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthzContext)2 HivePrivilege (org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrivilege)2 HiveRoleGrant (org.apache.hadoop.hive.ql.security.authorization.plugin.HiveRoleGrant)2 Connection (java.sql.Connection)1 DatabaseMetaData (java.sql.DatabaseMetaData)1 SQLException (java.sql.SQLException)1 HashMap (java.util.HashMap)1 DrillRuntimeException (org.apache.drill.common.exceptions.DrillRuntimeException)1 UserException (org.apache.drill.common.exceptions.UserException)1 HiveObjectRef (org.apache.hadoop.hive.metastore.api.HiveObjectRef)1