Search in sources :

Example 11 with PrivilegeBag

use of org.apache.hadoop.hive.metastore.api.PrivilegeBag in project hive by apache.

the class HiveV1Authorizer method grantPrivileges.

@Override
public void grantPrivileges(List<HivePrincipal> principals, List<HivePrivilege> privileges, HivePrivilegeObject privObject, HivePrincipal grantor, boolean grantOption) throws HiveAuthzPluginException, HiveAccessControlException {
    try {
        PrivilegeBag privBag = toPrivilegeBag(privileges, privObject, grantor, grantOption);
        grantOrRevokePrivs(principals, privBag, true, grantOption);
    } catch (Exception e) {
        throw new HiveAuthzPluginException(e);
    }
}
Also used : PrivilegeBag(org.apache.hadoop.hive.metastore.api.PrivilegeBag) SemanticException(org.apache.hadoop.hive.ql.parse.SemanticException) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException)

Example 12 with PrivilegeBag

use of org.apache.hadoop.hive.metastore.api.PrivilegeBag in project hive by apache.

the class SQLAuthorizationUtils method getThriftPrivilegesBag.

/**
   * Create thrift privileges bag
   *
   * @param hivePrincipals
   * @param hivePrivileges
   * @param hivePrivObject
   * @param grantorPrincipal
   * @param grantOption
   * @return
   * @throws HiveAuthzPluginException
   */
static PrivilegeBag getThriftPrivilegesBag(List<HivePrincipal> hivePrincipals, List<HivePrivilege> hivePrivileges, HivePrivilegeObject hivePrivObject, HivePrincipal grantorPrincipal, boolean grantOption) throws HiveAuthzPluginException {
    HiveObjectRef privObj = getThriftHiveObjectRef(hivePrivObject);
    PrivilegeBag privBag = new PrivilegeBag();
    for (HivePrivilege privilege : hivePrivileges) {
        if (privilege.getColumns() != null && privilege.getColumns().size() > 0) {
            throw new HiveAuthzPluginException("Privileges on columns not supported currently" + " in sql standard authorization mode");
        }
        if (!SUPPORTED_PRIVS_SET.contains(privilege.getName().toUpperCase(Locale.US))) {
            throw new HiveAuthzPluginException("Privilege: " + privilege.getName() + " is not supported in sql standard authorization mode");
        }
        PrivilegeGrantInfo grantInfo = getThriftPrivilegeGrantInfo(privilege, grantorPrincipal, grantOption, 0);
        for (HivePrincipal principal : hivePrincipals) {
            HiveObjectPrivilege objPriv = new HiveObjectPrivilege(privObj, principal.getName(), AuthorizationUtils.getThriftPrincipalType(principal.getType()), grantInfo);
            privBag.addToPrivileges(objPriv);
        }
    }
    return privBag;
}
Also used : PrivilegeBag(org.apache.hadoop.hive.metastore.api.PrivilegeBag) HiveObjectPrivilege(org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege) PrivilegeGrantInfo(org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo) HivePrincipal(org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrincipal) HivePrivilege(org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrivilege) HiveObjectRef(org.apache.hadoop.hive.metastore.api.HiveObjectRef) HiveAuthzPluginException(org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthzPluginException)

Example 13 with PrivilegeBag

use of org.apache.hadoop.hive.metastore.api.PrivilegeBag in project hive by apache.

the class AbstractTestAuthorizationApiAuthorizer method testGrantPriv.

@Test
public void testGrantPriv() throws Exception {
    FunctionInvoker invoker = new FunctionInvoker() {

        @Override
        public void invoke() throws Exception {
            msc.grant_privileges(new PrivilegeBag(new ArrayList<HiveObjectPrivilege>()));
        }
    };
    testFunction(invoker);
}
Also used : PrivilegeBag(org.apache.hadoop.hive.metastore.api.PrivilegeBag) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

PrivilegeBag (org.apache.hadoop.hive.metastore.api.PrivilegeBag)13 HiveObjectPrivilege (org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege)8 ArrayList (java.util.ArrayList)7 HiveObjectRef (org.apache.hadoop.hive.metastore.api.HiveObjectRef)7 PrivilegeGrantInfo (org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo)7 Test (org.junit.Test)6 Role (org.apache.hadoop.hive.metastore.api.Role)5 Database (org.apache.hadoop.hive.metastore.api.Database)4 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)3 HiveAuthzPluginException (org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthzPluginException)3 IMetaStoreClient (org.apache.hadoop.hive.metastore.IMetaStoreClient)2 FieldSchema (org.apache.hadoop.hive.metastore.api.FieldSchema)2 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)2 Partition (org.apache.hadoop.hive.metastore.api.Partition)2 StorageDescriptor (org.apache.hadoop.hive.metastore.api.StorageDescriptor)2 Table (org.apache.hadoop.hive.metastore.api.Table)2 SemanticException (org.apache.hadoop.hive.ql.parse.SemanticException)2 HiveAccessControlException (org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAccessControlException)2 TException (org.apache.thrift.TException)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1