private boolean matchPrivs(Privilege[] inputPriv,
      PrincipalPrivilegeSet privileges, boolean[] check) {

    if (inputPriv == null) {
      return true;
    }

    if (privileges == null) {
      return false;
    }

    /*
     * user grants
     */
    Set<String> privSet = new HashSet<String>();
    if (privileges.getUserPrivileges() != null
        && privileges.getUserPrivileges().size() > 0) {
      Collection<List<PrivilegeGrantInfo>> privCollection = privileges.getUserPrivileges().values();

      List<String> userPrivs = getPrivilegeStringList(privCollection);
      if (userPrivs != null && userPrivs.size() > 0) {
        for (String priv : userPrivs) {
          if (priv == null || priv.trim().equals("")) {
            continue;
          }
            if (priv.equalsIgnoreCase(Privilege.ALL.toString())) {
              setBooleanArray(check, true);
              return true;
            }
            privSet.add(priv.toLowerCase());
        }
      }
    }

    /*
     * group grants
     */
    if (privileges.getGroupPrivileges() != null
        && privileges.getGroupPrivileges().size() > 0) {
      Collection<List<PrivilegeGrantInfo>> groupPrivCollection = privileges
          .getGroupPrivileges().values();
      List<String> groupPrivs = getPrivilegeStringList(groupPrivCollection);
      if (groupPrivs != null && groupPrivs.size() > 0) {
        for (String priv : groupPrivs) {
          if (priv == null || priv.trim().equals("")) {
            continue;
          }
          if (priv.equalsIgnoreCase(Privilege.ALL.toString())) {
            setBooleanArray(check, true);
            return true;
          }
          privSet.add(priv.toLowerCase());
        }
      }
    }

    /*
     * roles grants
     */
    if (privileges.getRolePrivileges() != null
        && privileges.getRolePrivileges().size() > 0) {
      Collection<List<PrivilegeGrantInfo>> rolePrivsCollection = privileges
          .getRolePrivileges().values();
      ;
      List<String> rolePrivs = getPrivilegeStringList(rolePrivsCollection);
      if (rolePrivs != null && rolePrivs.size() > 0) {
        for (String priv : rolePrivs) {
          if (priv == null || priv.trim().equals("")) {
            continue;
          }
          if (priv.equalsIgnoreCase(Privilege.ALL.toString())) {
            setBooleanArray(check, true);
            return true;
          }
          privSet.add(priv.toLowerCase());
        }
      }
    }

    for (int i = 0; i < inputPriv.length; i++) {
      String toMatch = inputPriv[i].toString();
      if (!check[i]) {
        check[i] = privSet.contains(toMatch.toLowerCase());
      }
    }

    return firstFalseIndex(check) <0;
  }
try to match an array of privileges from user/groups/roles grants.
ql/src/java/org/apache/hadoop/hive/ql/security/authorization/BitSetCheckedAuthorizationProvider.java