Example #1
0
  /**
   * Attempts to add user to blacklist of Security Team, it first tests the values and then submits
   * them.
   *
   * @param userId ID of User to be added to blacklist
   * @param description Why is user blacklisted
   */
  public void addUserToBlacklist(final int userId, String description) {

    this.userId = userId;
    this.description = description;

    // test arguments
    if (!this.testDeleting()) {
      return;
    }

    // new events
    JsonCallbackEvents newEvents =
        new JsonCallbackEvents() {
          public void onError(PerunError error) {
            session
                .getUiElements()
                .setLogErrorText("Adding user " + userId + " to blacklist failed.");
            events.onError(error);
          };

          public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("User " + userId + " added to blacklist.");
            events.onFinished(jso);
          };

          public void onLoadingStart() {
            events.onLoadingStart();
          };
        };

    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(JSON_URL, prepareJSONObject());
  }
Example #2
0
  /**
   * Verify application
   *
   * @param appId
   */
  public void verifyApplication(int appId) {

    this.appId = appId;

    // test arguments
    if (!this.testApplication()) {
      return;
    }

    // new events
    JsonCallbackEvents newEvents =
        new JsonCallbackEvents() {
          @Override
          public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Verifying application failed.");
            events.onError(error);
          };

          @Override
          public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Application verified.");
            events.onFinished(jso);
          };

          @Override
          public void onLoadingStart() {
            events.onLoadingStart();
          };
        };

    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(JSON_URL_VERIFY, prepareJSONObject());
  }
Example #3
0
  /**
   * Reject application
   *
   * @param appId
   * @param reason
   */
  public void rejectApplication(int appId, String reason) {

    this.appId = appId;
    this.reason = reason;

    // test arguments
    if (!this.testApplication()) {
      return;
    }

    // new events
    JsonCallbackEvents newEvents =
        new JsonCallbackEvents() {
          public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Rejecting application failed.");
            events.onError(error);
          };

          public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Application rejected.");
            events.onFinished(jso);
          };

          public void onLoadingStart() {
            events.onLoadingStart();
          };
        };

    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(JSON_URL_REJECT, prepareJSONObject());
  }
Example #4
0
  /**
   * Attempts to create a new Service, it first tests the values and then submits them.
   *
   * @param name service Name
   * @param ownerId ID of owner
   */
  public void createService(final String name, int ownerId) {
    this.serviceName = name;
    this.ownerId = ownerId;

    // test arguments
    if (!this.testCreating()) {
      return;
    }

    // new events
    JsonCallbackEvents newEvents =
        new JsonCallbackEvents() {
          public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Creating service " + serviceName + " failed.");
            events.onError(error); // custom events
          };

          public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Service " + serviceName + " created.");
            events.onFinished(jso);
          };

          public void onLoadingStart() {
            events.onLoadingStart();
          };
        };

    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(JSON_URL, prepareJSONObject());
  }
  /**
   * Attempts to free denial of selected exec service on facility
   *
   * @param execServiceId
   */
  public void freeDenialOfExecService(final int execServiceId) {

    this.execServiceId = execServiceId;

    // test arguments
    if (!this.testCreating()) {
      return;
    }

    // new events
    JsonCallbackEvents newEvents =
        new JsonCallbackEvents() {
          public void onError(PerunError error) {
            session
                .getUiElements()
                .setLogErrorText("Allowing of exec service " + execServiceId + " failed.");
            events.onError(error);
          };

          public void onFinished(JavaScriptObject jso) {
            session
                .getUiElements()
                .setLogSuccessText("Exec service " + execServiceId + " allowed on facility.");
            events.onFinished(jso);
          };

          public void onLoadingStart() {
            events.onLoadingStart();
          };
        };

    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(JSON_URL, prepareJSONObject());
  };
Example #6
0
  /**
   * Attempts to create service member in VO
   *
   * @param voId vo where member should be created
   * @param name name of service member
   * @param email email of service member
   * @param users list of real users
   * @param namespace namespace to create login in
   * @param login users login in namespace
   * @param certDN users cert DN
   * @param caCertDN users CA cert DN
   */
  public void createMember(
      final int voId,
      final String name,
      final String email,
      ArrayList<User> users,
      String namespace,
      String login,
      String certDN,
      String caCertDN,
      String specificUserType) {

    this.voId = voId;
    this.name = name;
    this.email = email;
    this.users = users;
    this.login = login;
    this.namespace = namespace;
    this.certDN = certDN;
    this.caCertDN = caCertDN;
    this.specificUserType = specificUserType;

    // test arguments
    if (!this.testAdding()) {
      return;
    }

    // new events
    JsonCallbackEvents newEvents =
        new JsonCallbackEvents() {
          public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Creating member: " + name + " failed.");
            events.onError(error);
          };

          public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Member " + name + " created !");

            // call validation asynchronously
            Member mem = jso.cast();
            ValidateMemberAsync request = new ValidateMemberAsync();
            request.validateMemberAsync(mem);

            events.onFinished(jso);
          };

          public void onLoadingStart() {
            events.onLoadingStart();
          };
        };

    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(JSON_URL, prepareJSONObject());
  }
Example #7
0
  /**
   * Attempts to update a Publication, it first tests the values and then submits them.
   *
   * @param publication Publication
   */
  public void updatePublication(final Publication publication) {

    this.publication = publication;

    // test arguments
    if (!this.testCreating()) {
      return;
    }

    // json object
    JSONObject jsonQuery = prepareJSONObject();

    // local events
    JsonCallbackEvents newEvents =
        new JsonCallbackEvents() {

          public void onError(PerunError error) {
            session
                .getUiElements()
                .setLogErrorText("Updating publication: " + publication.getId() + " failed.");
            events.onError(error);
          };

          public void onFinished(JavaScriptObject jso) {
            Publication pub = jso.cast();
            session
                .getUiElements()
                .setLogSuccessText("Publication with ID: " + pub.getId() + " updated.");
            events.onFinished(jso);
          };

          public void onLoadingStart() {
            events.onLoadingStart();
          };
        };

    // create request
    JsonPostClient request = new JsonPostClient(newEvents);
    request.sendData(JSON_URL, jsonQuery);
  }
Example #8
0
  /**
   * Attempts to update a Category, it first tests the values and then submits them.
   *
   * @param category category to update
   */
  public void updateCategory(Category category) {

    this.id = category.getId();
    this.name = category.getName();
    this.rank = category.getRank();

    // test arguments
    if (!this.testCreating()) {
      return;
    }

    // json object
    JSONObject jsonQuery = prepareJSONObject();

    // local events
    JsonCallbackEvents newEvents =
        new JsonCallbackEvents() {

          public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Updating category " + name + " failed.");
            events.onError(error);
          };

          public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Category " + name + " updated.");
            events.onFinished(jso);
          };

          public void onLoadingStart() {
            events.onLoadingStart();
          };
        };

    // create request
    JsonPostClient request = new JsonPostClient(newEvents);
    request.sendData(JSON_URL, jsonQuery);
  }
Example #9
0
  /**
   * Approve application
   *
   * @param app
   */
  public void approveApplication(final Application app) {

    this.appId = app.getId();

    // test arguments
    if (!this.testApplication()) {
      return;
    }

    // new events
    final JsonCallbackEvents newEvents =
        new JsonCallbackEvents() {
          @Override
          public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Approving application failed.");
            events.onError(error);
          }

          @Override
          public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Application approved.");
            events.onFinished(jso);
          }

          @Override
          public void onLoadingStart() {
            events.onLoadingStart();
          }
        };

    // check for similar users before approving

    JSONObject jso = new JSONObject();
    jso.put("appId", new JSONNumber(appId));

    if (app.getUser() != null) {

      // ok approve sending data
      JsonPostClient jspc = new JsonPostClient(newEvents);
      jspc.sendData(JSON_URL_APPROVE, prepareJSONObject());

    } else {

      JsonPostClient checkJspc =
          new JsonPostClient(
              new JsonCallbackEvents() {
                @Override
                public void onError(PerunError error) {
                  session.getUiElements().setLogErrorText("Approving application failed.");
                  events.onError(error);
                }

                @Override
                public void onFinished(JavaScriptObject jso) {

                  ArrayList<Identity> users = JsonUtils.jsoAsList(jso);
                  if (users != null && !users.isEmpty()) {

                    FlexTable ft = new FlexTable();
                    ft.setWidth("600px");
                    ft.setHTML(0, 0, "<p><strong>Following similar user(s) were found in system:");
                    ft.getFlexCellFormatter().setColSpan(0, 0, 3);

                    ft.setHTML(
                        1, 0, "<strong>" + ApplicationMessages.INSTANCE.name() + "</strong>");
                    ft.setHTML(
                        1, 1, "<strong>" + ApplicationMessages.INSTANCE.email() + "</strong>");
                    ft.setHTML(
                        1,
                        2,
                        "<strong>" + ApplicationMessages.INSTANCE.organization() + "</strong>");

                    int i = 2;

                    for (Identity user : users) {

                      ft.setHTML(i, 0, user.getName());

                      if (user.getEmail() != null && !user.getEmail().isEmpty()) {
                        ft.setHTML(i, 1, user.getEmail());
                      } else {
                        ft.setHTML(i, 1, "N/A");
                      }

                      if (user.getOrganization() != null && !user.getOrganization().isEmpty()) {
                        ft.setHTML(i, 2, user.getOrganization());
                      } else {
                        ft.setHTML(i, 2, "N/A");
                      }

                      i++;
                    }

                    String type = "";
                    if (app.getExtSourceType()
                        .equals("cz.metacentrum.perun.core.impl.ExtSourceX509")) {
                      type = "cert";
                    } else if (app.getExtSourceType()
                        .equals("cz.metacentrum.perun.core.impl.ExtSourceIdp")) {
                      type = "fed";
                    }

                    ft.setHTML(
                        i,
                        0,
                        "<p>Please contact new applicant with question, if he/she isn't already member of any other VO."
                            + "<ul><li>If YES, ask him/her to join identities at <a href=\""
                            + Utils.getIdentityConsolidatorLink(type, false)
                            + "\" target=\"_blank\">identity consolidator</a> before approving this application."
                            + "</li><li>If NO, you can approve this application anyway. "
                            + "</li><li>If UNSURE, contact <a href=\"mailto:"
                            + Utils.perunReportEmailAddress()
                            + "\">support</a> to help you.</li></ul>");

                    ft.getFlexCellFormatter().setColSpan(i, 0, 3);

                    i++;

                    ft.setHTML(
                        i, 0, "<strong>Do you wish to approve this application anyway ?</strong>");
                    ft.getFlexCellFormatter().setColSpan(i, 0, 3);

                    Confirm c =
                        new Confirm(
                            "Similar users found!",
                            ft,
                            new ClickHandler() {
                              @Override
                              public void onClick(ClickEvent clickEvent) {

                                // ok approve sending data
                                JsonPostClient jspc = new JsonPostClient(newEvents);
                                jspc.sendData(JSON_URL_APPROVE, prepareJSONObject());
                              }
                            },
                            new ClickHandler() {
                              @Override
                              public void onClick(ClickEvent clickEvent) {
                                events.onFinished(null);
                              }
                            },
                            true);

                    c.setOkButtonText("Approve");

                    c.setNonScrollable(true);
                    c.show();

                  } else {

                    // ok approve sending data
                    JsonPostClient jspc = new JsonPostClient(newEvents);
                    jspc.sendData(JSON_URL_APPROVE, prepareJSONObject());
                  }
                }

                @Override
                public void onLoadingStart() {
                  events.onLoadingStart();
                }
              });
      checkJspc.sendData("registrarManager/checkForSimilarUsers", jso);
    }
  }