public void revokeRole(List<HivePrincipal> hivePrincipals, List<String> roleNames,
boolean grantOption, HivePrincipal grantorPrinc) throws HiveAuthzPluginException,
HiveAccessControlException {
if (grantOption) {
// removing grant privileges only is not supported in metastore api
throw new HiveAuthzPluginException("Revoking only the admin privileges on "
+ "role is not currently supported");
}
if (!(isUserAdmin() || doesUserHasAdminOption(roleNames))) {
throw new HiveAccessControlException("Current user : " + currentUserName+ " is not"
+ " allowed to revoke role. " + ADMIN_ONLY_MSG + " Otherwise, " + HAS_ADMIN_PRIV_MSG);
}
for (HivePrincipal hivePrincipal : hivePrincipals) {
for (String roleName : roleNames) {
try {
IMetaStoreClient mClient = metastoreClientFactory.getHiveMetastoreClient();
mClient.revoke_role(roleName, hivePrincipal.getName(),
AuthorizationUtils.getThriftPrincipalType(hivePrincipal.getType()));
} catch (Exception e) {
String msg = "Error revoking roles for " + hivePrincipal.getName() + " to role "
+ roleName + ": " + e.getMessage();
throw new HiveAuthzPluginException(msg, e);
}
}
}
}