Example #1
0
 public boolean hasPermission(Acls acls) {
   String decodedResource = URL.decodePathSegment(resource);
   for (Acl acl : JsArrays.toIterable(acls.getAclsArray())) {
     if (acl.getResource().equals(decodedResource) && hasAction(acl)) return true;
   }
   return false;
 }
  public void deletePermission(Acl acl) {
    final Subject subject = acl.getSubject();
    String nodeUri =
        getNodeUri(
            ResourcePermissionType.getTypeByPermission(acl.getActions(0)),
            acl.getResource(),
            subject.getPrincipal(),
            subject.getType().getName());

    ResourceRequestBuilderFactory.<JsArray<Acl>>newBuilder()
        .forResource(nodeUri)
        .delete()
        .withCallback(
            Response.SC_OK,
            new ResponseCodeCallback() {
              @Override
              public void onResponseCode(Request request, Response response) {
                selectSubject(subject);
              }
            }) //
        .withCallback(
            Response.SC_FORBIDDEN,
            new ResponseCodeCallback() {
              @Override
              public void onResponseCode(Request request, Response response) {
                // ignore
              }
            }) //
        .send();
  }
Example #3
0
 private boolean hasAction(Acl acl) {
   for (int i = 0; i < acl.getActionsArray().length(); i++) {
     if (acl.getActionsArray().get(i).equals(action.getName())) {
       return true;
     }
   }
   return false;
 }
    @Override
    public int compare(Acl o1, Acl o2) {
      ResourcePermissionType t1 = ResourcePermissionType.getTypeByPermission(o1.getActions(0));
      ResourcePermissionType t2 = ResourcePermissionType.getTypeByPermission(o2.getActions(0));

      if (t1.ordinal() < t2.ordinal()) {
        return 1;
      }

      if (t1.ordinal() > t2.ordinal()) {
        return -1;
      }

      return 0;
    }
 @Override
 public String map(Acl acl) {
   ResourcePermissionType type = ResourcePermissionType.getTypeByPermission(acl.getActions(0));
   return TranslationsUtils.replaceArguments(
       translations.permissionResourceNodeTypeMap().get(type.name()));
 }
 @Override
 public String format(Acl acl) {
   return getName(
       ResourcePermissionType.getTypeByPermission(acl.getActions(0)),
       new AclResourceTokenizer(acl.getResource()));
 }
 @Override
 public PlaceRequest map(Acl acl) {
   return getPlaceRequest(
       ResourcePermissionType.getTypeByPermission(acl.getActions(0)),
       new AclResourceTokenizer(acl.getResource()));
 }