コード例 #1
0
  public boolean matchPermission(
      User user, byte[] table, byte[] family, byte[] qualifier, TablePermission.Action action) {
    PermissionCache<TablePermission> tablePerms = tableCache.get(table);
    if (tablePerms != null) {
      List<TablePermission> userPerms = tablePerms.getUser(user.getShortName());
      if (userPerms != null) {
        for (TablePermission p : userPerms) {
          if (p.matchesFamilyQualifier(table, family, qualifier, action)) {
            return true;
          }
        }
      }

      String[] groups = user.getGroupNames();
      if (groups != null) {
        for (String group : groups) {
          List<TablePermission> groupPerms = tablePerms.getGroup(group);
          if (groupPerms != null) {
            for (TablePermission p : groupPerms) {
              if (p.matchesFamilyQualifier(table, family, qualifier, action)) {
                return true;
              }
            }
          }
        }
      }
    }

    return false;
  }
コード例 #2
0
  private boolean authorize(
      List<TablePermission> perms, byte[] table, KeyValue kv, TablePermission.Action action) {
    if (perms != null) {
      for (TablePermission p : perms) {
        if (p.implies(table, kv, action)) {
          return true;
        }
      }
    } else if (LOG.isDebugEnabled()) {
      LOG.debug("No permissions for authorize() check, table=" + Bytes.toStringBinary(table));
    }

    return false;
  }
コード例 #3
0
 private boolean authorize(
     List<TablePermission> perms,
     byte[] table,
     byte[] family,
     byte[] qualifier,
     Permission.Action action) {
   if (perms != null) {
     for (TablePermission p : perms) {
       if (p.implies(table, family, qualifier, action)) {
         return true;
       }
     }
   } else if (LOG.isDebugEnabled()) {
     LOG.debug("No permissions found for table=" + Bytes.toStringBinary(table));
   }
   return false;
 }