예제 #1
0
파일: AclRequest.java 프로젝트: Rima-B/opal
  public void delete(final Subject subject) {
    ResourceRequestBuilderFactory.<Acl>newBuilder()
        .forResource(
            "/authz"
                + resource
                + "?subject="
                + subject.getPrincipal()
                + "&type="
                + subject.getType()
                + "&perm="
                + action.getName())
        .delete() //
        .withCallback(
            new ResourceCallback<Acl>() {

              @Override
              public void onResource(Response response, Acl resource) {
                if (response.getStatusCode() == Response.SC_OK) {
                  aclDeleteCallback.onDelete(subject);
                } else {
                  aclDeleteCallback.onDeleteFailed(response, subject);
                }
              }
            })
        .send();
  }
  @Override
  public void selectSubject(final Subject subject) {
    String uri =
        ResourcePermissionRequestPaths.UriBuilders.PROJECT_PERMISSIONS_SUBJECT
            .create()
            .query(ResourcePermissionRequestPaths.TYPE_QUERY_PARAM, subject.getType().getName())
            .build(project.getName(), subject.getPrincipal());

    ResourceAuthorizationRequestBuilderFactory.newBuilder() //
        .forResource(uri) //
        .authorize(getView().getDeleteAllAuthorizer()) //
        .delete()
        .send();

    ResourceRequestBuilderFactory.<JsArray<Acl>>newBuilder()
        .forResource(uri)
        .get()
        .withCallback(
            new ResourceCallback<JsArray<Acl>>() {
              @Override
              public void onResource(Response response, JsArray<Acl> acls) {
                List<Acl> subjectAcls = JsArrays.toList(acls);
                if (!subjectAcls.isEmpty()) {
                  getView().setSubjectData(subject, subjectAcls);
                } else {
                  // refresh and select another subject if any
                  retrievePermissions();
                }
              }
            })
        .send();
  }
  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();
  }
예제 #4
0
 @Override
 public void onResource(Response response, Subject subject) {
   if (response.getStatusCode() == Response.SC_OK) {
     requestCredentials.setUsername(subject.getPrincipal());
     revealCurrentPlace();
   } else {
     eventBus.fireEvent(new SessionEndedEvent());
   }
 }
 @Override
 public void deleteAllSubjectPermissions(final Subject subject) {
   String uri =
       ResourcePermissionRequestPaths.UriBuilders.PROJECT_PERMISSIONS_SUBJECT
           .create()
           .query(ResourcePermissionRequestPaths.TYPE_QUERY_PARAM, subject.getType().getName())
           .build(project.getName(), subject.getPrincipal());
   ResourceRequestBuilderFactory.<JsArray<Acl>>newBuilder()
       .forResource(uri)
       .delete()
       .withCallback(
           Response.SC_OK,
           new ResponseCodeCallback() {
             @Override
             public void onResponseCode(Request request, Response response) {
               selectSubject(subject);
             }
           })
       .send();
 }