static RequiredPrivileges getPrivilegesFromMetaStore(IMetaStoreClient metastoreClient,
      String userName, HivePrivilegeObject hivePrivObject, List<String> curRoles, boolean isAdmin, boolean ignoreUnknown)
          throws HiveAuthzPluginException {

    // get privileges for this user and its role on this object
    PrincipalPrivilegeSet thrifPrivs = null;
    try {
      HiveObjectRef objectRef = AuthorizationUtils.getThriftHiveObjectRef(hivePrivObject);
      if (objectRef.getObjectType() == null) {
        objectRef.setObjectType(HiveObjectType.GLOBAL);
      }
      thrifPrivs = metastoreClient.get_privilege_set(
          objectRef, userName, null);
    } catch (MetaException e) {
      throwGetPrivErr(e, hivePrivObject, userName);
    } catch (TException e) {
      throwGetPrivErr(e, hivePrivObject, userName);
    } catch (HiveException e) {
      throwGetPrivErr(e, hivePrivObject, userName);
    }

    filterPrivsByCurrentRoles(thrifPrivs, curRoles);

    // convert to RequiredPrivileges
    RequiredPrivileges privs = getRequiredPrivsFromThrift(thrifPrivs);

    // add owner privilege if user is owner of the object
    try {
      if (isOwner(metastoreClient, userName, curRoles, hivePrivObject)) {
        privs.addPrivilege(SQLPrivTypeGrant.OWNER_PRIV);
      }
    } catch (HiveAuthzPluginException ex) {
      if (ex.getCause() instanceof NoSuchObjectException && ignoreUnknown) {
        privs.addPrivilege(SQLPrivTypeGrant.OWNER_PRIV);
      } else {
        throw ex;
      }
    }
    if (isAdmin) {
      privs.addPrivilege(SQLPrivTypeGrant.ADMIN_PRIV);
    }

    return privs;
  }
Get the privileges this user(userName argument) has on the object
(hivePrivObject argument) If isAdmin is true, adds an admin privilege as
well.

@param metastoreClient
@param userName
@param hivePrivObject
@param curRoles
         current active roles for user
@param isAdmin
         if user can run as admin user
@param ignoreUnknown
         boolean flag to ignore unknown table
@return
@throws HiveAuthzPluginException
ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/sqlstd/SQLAuthorizationUtils.java