Exemplo n.º 1
0
  public static Filter create(final PrincipalKeys principalsKeys) {
    if (isSuperUser()) {
      return null;
    }

    if (principalsKeys.isEmpty()) {
      return createNoPrincipalsFilter();
    }

    final ValueFilter.Builder valueFilterBuilder =
        ValueFilter.create().fieldName(NodeIndexPath.PERMISSIONS_READ.toString());

    for (final PrincipalKey principalKey : principalsKeys) {
      valueFilterBuilder.addValue(ValueFactory.newString(principalKey.toString()));
    }

    return valueFilterBuilder.build();
  }
Exemplo n.º 2
0
 private static Filter createNoPrincipalsFilter() {
   return ValueFilter.create()
       .fieldName(NodeIndexPath.PERMISSIONS_READ.toString())
       .addValue(ValueFactory.newString(PrincipalKey.ofAnonymous().toString()))
       .build();
 }