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;
  }
  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;
  }
 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;
 }
Beispiel #4
0
  @Override
  @edu.umd.cs.findbugs.annotations.SuppressWarnings(
      value = "NP_NULL_ON_SOME_PATH",
      justification = "Passed on construction except on constructor not to be used")
  public boolean equals(Object obj) {
    if (!(obj instanceof TablePermission)) {
      return false;
    }
    TablePermission other = (TablePermission) obj;

    if (!(table.equals(other.getTableName())
        && ((family == null && other.getFamily() == null)
            || Bytes.equals(family, other.getFamily()))
        && ((qualifier == null && other.getQualifier() == null)
            || Bytes.equals(qualifier, other.getQualifier()))
        && ((namespace == null && other.getNamespace() == null)
            || (namespace != null && namespace.equals(other.getNamespace()))))) {
      return false;
    }

    // check actions
    return super.equals(other);
  }