private static void checkRequiredPrivileges(
      RequiredPrivileges reqPrivileges, HivePrivilegeObject hivePrivObject,
      IMetaStoreClient metastoreClient, String userName, List<String> curRoles, boolean isAdmin,
      HiveOperationType opType)
          throws HiveAuthzPluginException, HiveAccessControlException {

    // keep track of the principals on which privileges have been checked for
    // this object

    // get privileges for this user and its roles on this object
    RequiredPrivileges availPrivs = SQLAuthorizationUtils.getPrivilegesFromMetaStore(
        metastoreClient, userName, hivePrivObject, curRoles, isAdmin, false);

    // check if required privileges is subset of available privileges
    List<String> deniedMessages = new ArrayList<String>();
    Collection<SQLPrivTypeGrant> missingPrivs = reqPrivileges.findMissingPrivs(availPrivs);
    SQLAuthorizationUtils.addMissingPrivMsg(missingPrivs, hivePrivObject, deniedMessages);
    SQLAuthorizationUtils.assertNoDeniedPermissions(new HivePrincipal(userName,
        HivePrincipalType.USER), opType, deniedMessages);
  }
Utility class to authorize grant/revoke privileges
ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/sqlstd/GrantPrivAuthUtils.java