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);
}
}
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;
}
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);
}
Aggregations