Esempio n. 1
0
  /**
   * Callback for creation of add dialogs. Will be invoked once the presenter has loaded the
   * resource description.
   *
   * @param address
   * @param isSingleton
   * @param securityContext
   * @param description
   */
  public void showAddDialog(
      final ModelNode address,
      boolean isSingleton,
      SecurityContext securityContext,
      ModelNode description) {

    String resourceAddress = AddressUtils.asKey(address, isSingleton);

    if (securityContext.getOperationPriviledge(resourceAddress, "add").isGranted()) {
      _showAddDialog(address, isSingleton, securityContext, description);
    } else {
      Feedback.alert(Console.CONSTANTS.unauthorized(), Console.CONSTANTS.unauthorizedAdd());
    }
  }
Esempio n. 2
0
 public void onStreamLogFile(final String logFile, final int fileSize) {
   if (logStore.isOpen(logFile)) {
     this.circuit.dispatch(new SelectLogFile(logFile));
   } else {
     if (fileSize > LOG_FILE_SIZE_THRESHOLD) {
       Feedback.confirm(
           "Download Log File",
           "Downloading this log file may take some time. Do you want to proceed?",
           new Feedback.ConfirmationHandler() {
             @Override
             public void onConfirmation(boolean isConfirmed) {
               if (isConfirmed) {
                 streamingProgress.monitor(logFile);
               }
             }
           });
     } else {
       streamingProgress.monitor(logFile);
     }
   }
 }
 public void verifyEnableDisableAssignment(final Assignment assignment) {
   String question;
   String operation;
   String successMessage;
   if (assignment.isEnabled()) {
     operation = "undeploy";
     question = "Disable " + assignment.getName();
     successMessage = assignment.getName() + " successfully disabled.";
   } else {
     operation = "deploy";
     question = "Enable " + assignment.getName();
     successMessage = assignment.getName() + " successfully enabled.";
   }
   Feedback.confirm(
       Console.CONSTANTS.common_label_areYouSure(),
       question,
       isConfirmed -> {
         if (isConfirmed) {
           modifyAssignment(assignment, operation, successMessage);
         }
       });
 }
Esempio n. 4
0
  @SuppressWarnings("unchecked")
  Widget asWidget() {
    secTable = new DefaultCellTable<>(8, item -> item.getPattern() + "_" + item.getRole());
    secProvider = new ListDataProvider<>();
    secProvider.addDataDisplay(secTable);

    Column<ActivemqSecurityPattern, String> roleColumn =
        new Column<ActivemqSecurityPattern, String>(new TextCell()) {
          @Override
          public String getValue(ActivemqSecurityPattern object) {
            return object.getRole();
          }
        };

    Column<ActivemqSecurityPattern, String> patternColumn =
        new Column<ActivemqSecurityPattern, String>(new TextCell()) {
          @Override
          public String getValue(ActivemqSecurityPattern object) {
            return object.getPattern();
          }
        };

    secTable.addColumn(patternColumn, "Pattern");
    secTable.addColumn(roleColumn, "Role");

    form = new Form<>(ActivemqSecurityPattern.class);
    form.setNumColumns(2);
    form.bind(secTable);

    CheckBoxItem send = new CheckBoxItem("send", "Send?");
    CheckBoxItem consume = new CheckBoxItem("consume", "Consume?");
    CheckBoxItem manage = new CheckBoxItem("manage", "Manage?");

    CheckBoxItem createDQ = new CheckBoxItem("createDurableQueue", "CreateDurable?");
    CheckBoxItem deleteDQ = new CheckBoxItem("deleteDurableQueue", "DeleteDurable?");

    CheckBoxItem createNDQ = new CheckBoxItem("createNonDurableQueue", "CreateNonDurable?");
    CheckBoxItem deleteNDQ = new CheckBoxItem("deleteNonDurableQueue", "DeleteNonDurable?");

    form.setFields(send, consume, manage);
    form.setFieldsInGroup(
        Console.CONSTANTS.common_label_advanced(),
        new DisclosureGroupRenderer(),
        createDQ,
        deleteDQ,
        createNDQ,
        deleteNDQ);

    FormHelpPanel helpPanel =
        new FormHelpPanel(
            () -> {
              ModelNode address = Baseadress.get();
              address.add("subsystem", "messaging-activemq");
              address.add("server", "*");
              address.add("security-setting", "*");
              address.add("role", "*");
              return address;
            },
            form);

    FormToolStrip<ActivemqSecurityPattern> formTools =
        new FormToolStrip<>(
            form,
            new FormToolStrip.FormCallback<ActivemqSecurityPattern>() {
              @Override
              public void onSave(Map<String, Object> changeset) {
                presenter.onSaveSecDetails(form.getEditedEntity(), changeset);
              }

              @Override
              public void onDelete(ActivemqSecurityPattern entity) {}
            });

    ToolStrip tableTools = new ToolStrip();

    ToolButton addBtn =
        new ToolButton(
            Console.CONSTANTS.common_label_add(), event -> presenter.launchNewSecDialogue());
    addBtn.ensureDebugId(Console.DEBUG_CONSTANTS.debug_label_add_securityDetails());
    tableTools.addToolButtonRight(addBtn);

    ToolButton removeBtn =
        new ToolButton(
            Console.CONSTANTS.common_label_delete(),
            event ->
                Feedback.confirm(
                    Console.MESSAGES.deleteTitle("Security Config"),
                    Console.MESSAGES.deleteConfirm("Security Config"),
                    isConfirmed -> {
                      if (isConfirmed) {
                        presenter.onDeleteSecDetails(form.getEditedEntity());
                      }
                    }));

    tableTools.addToolButtonRight(removeBtn);

    VerticalPanel formPanel = new VerticalPanel();
    formPanel.addStyleName("fill-layout-width");

    formPanel.add(helpPanel.asWidget());
    formPanel.add(formTools.asWidget());
    formPanel.add(form.asWidget());

    serverName = new ContentHeaderLabel();

    MultipleToOneLayout layout =
        new MultipleToOneLayout()
            .setPlain(true)
            .setHeadlineWidget(serverName)
            .setDescription(
                "A security setting allows sets of permissions to be defined against queues based on their address.")
            .setMaster("Available security settings", secTable)
            .setMasterTools(tableTools.asWidget())
            .setDetail("Details", formPanel);

    return layout.build();
  }
  private ToolStrip setupTableButtons() {
    ToolStrip tools = new ToolStrip();
    ToolButton addButton =
        new ToolButton(
            Console.CONSTANTS.common_label_add(),
            event -> {
              ModelNodeFormBuilder.FormAssets addFormAssets =
                  new ModelNodeFormBuilder()
                      .setResourceDescription(resourceDescription)
                      .setCreateMode(true)
                      .unsorted()
                      .exclude("permissions")
                      .setCreateNameAttribute(false)
                      .setSecurityContext(securityContext)
                      .build();
              addFormAssets.getForm().setEnabled(true);

              DefaultWindow dialog = new DefaultWindow(Console.MESSAGES.newTitle("Permission"));
              AddResourceDialog.Callback callback =
                  new AddResourceDialog.Callback() {
                    @Override
                    public void onAdd(ModelNode payload) {
                      circuit.dispatch(
                          new AddListAttribute(
                              ElytronStore.CONSTANT_PERMISSION_MAPPER_ADDRESS,
                              "permissions",
                              permissionMapping,
                              payload));
                      dialog.hide();
                    }

                    @Override
                    public void onCancel() {
                      dialog.hide();
                    }
                  };
              AddResourceDialog addDialog =
                  new AddResourceDialog(addFormAssets, resourceDescription, callback);
              dialog.setWidth(480);
              dialog.setHeight(360);
              dialog.setWidget(addDialog);
              dialog.setGlassEnabled(true);
              dialog.center();
            });
    ToolButton removeButton =
        new ToolButton(
            Console.CONSTANTS.common_label_delete(),
            event -> {
              final ModelNode selection = selectionModel.getSelectedObject();
              if (selection != null) {
                Feedback.confirm(
                    "Filter",
                    Console.MESSAGES.deleteConfirm(
                        "Permission " + selection.get("class-name").asString()),
                    isConfirmed -> {
                      if (isConfirmed) {
                        circuit.dispatch(
                            new RemoveListAttribute(
                                ElytronStore.CONSTANT_PERMISSION_MAPPER_ADDRESS,
                                permissionMapping,
                                "permissions",
                                selection));
                      }
                    });
              }
            });
    tools.addToolButtonRight(addButton);
    tools.addToolButtonRight(removeButton);
    return tools;
  }
Esempio n. 6
0
  private void _showAddDialog(
      final ModelNode address,
      boolean isSingleton,
      SecurityContext securityContext,
      ModelNode description) {
    List<Property> tuples = address.asPropertyList();
    String type = "";
    if (tuples.size() > 0) {
      type = tuples.get(tuples.size() - 1).getName();
    }

    ModelNodeFormBuilder builder =
        new ModelNodeFormBuilder()
            .setCreateMode(true)
            .setSingleton(isSingleton)
            .setResourceDescription(description)
            .setSecurityContext(securityContext);

    ModelNodeFormBuilder.FormAssets assets = builder.build();

    final ModelNodeForm form = assets.getForm();
    form.setEnabled(true);

    if (form.hasWritableAttributes()) {
      final DefaultWindow window = new DefaultWindow(Console.MESSAGES.createResource(type));
      window.addStyleName("browser-view");

      DialogueOptions options =
          new DialogueOptions(
              new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                  // save
                  FormValidation validation = form.validate();
                  if (!validation.hasErrors()) {
                    presenter.onAddChildResource(address, form.getUpdatedEntity());
                    window.hide();
                  }
                }
              },
              new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                  // cancel
                  window.hide();
                }
              });

      VerticalPanel layout = new VerticalPanel();
      layout.setStyleName("fill-layout-width");
      ModelNode opDescription = description.get("operations").get("add").get("description");
      ContentDescription text = new ContentDescription(opDescription.asString());
      layout.add(text);
      layout.add(assets.asWidget());

      WindowContentBuilder content = new WindowContentBuilder(layout, options);
      window.trapWidget(content.build());
      window.setGlassEnabled(true);
      window.setWidth(480);
      window.setHeight(360);
      window.center();
    } else {
      // no writable attributes
      Feedback.alert(
          Console.CONSTANTS.cannotCreateChildResource(),
          Console.MESSAGES.noConfigurableAttributes(address.toString()));
    }
  }
Esempio n. 7
0
  @SuppressWarnings("unchecked")
  Widget asWidget() {
    serverName = new ContentHeaderLabel();

    table = new DefaultCellTable<>(10, ActivemqDivert::getRoutingName);
    provider = new ListDataProvider<>();
    provider.addDataDisplay(table);

    Column<ActivemqDivert, String> name =
        new Column<ActivemqDivert, String>(new TextCell()) {
          @Override
          public String getValue(ActivemqDivert object) {
            return object.getRoutingName();
          }
        };

    Column<ActivemqDivert, String> from =
        new Column<ActivemqDivert, String>(new TextCell()) {
          @Override
          public String getValue(ActivemqDivert object) {
            return object.getDivertAddress();
          }
        };

    Column<ActivemqDivert, String> to =
        new Column<ActivemqDivert, String>(new TextCell()) {
          @Override
          public String getValue(ActivemqDivert object) {
            return object.getForwardingAddress();
          }
        };

    table.addColumn(name, "Name");
    table.addColumn(from, "From");
    table.addColumn(to, "To");

    ToolStrip tools = new ToolStrip();
    tools.addToolButtonRight(
        new ToolButton(
            Console.CONSTANTS.common_label_add(), clickEvent -> presenter.launchNewDivertWizard()));

    tools.addToolButtonRight(
        new ToolButton(
            Console.CONSTANTS.common_label_remove(),
            clickEvent ->
                Feedback.confirm(
                    Console.MESSAGES.deleteTitle("Divert"),
                    Console.MESSAGES.deleteConfirm(
                        "Divert " + getSelectedEntity().getRoutingName()),
                    isConfirmed -> {
                      if (isConfirmed) {
                        presenter.onDeleteDivert(getSelectedEntity().getRoutingName());
                      }
                    })));

    divertForm =
        new DivertForm(
            presenter,
            new FormToolStrip.FormCallback<ActivemqDivert>() {
              @Override
              public void onSave(Map<String, Object> changeset) {
                presenter.onSaveDivert(getSelectedEntity().getRoutingName(), changeset);
              }

              @Override
              public void onDelete(ActivemqDivert entity) {}
            });

    MultipleToOneLayout layout =
        new MultipleToOneLayout()
            .setPlain(true)
            .setHeadlineWidget(serverName)
            .setDescription(Console.CONSTANTS.divertDescription())
            .setMaster("Diverts", table)
            .setMasterTools(tools)
            .setDetail("Details", divertForm.asWidget());

    divertForm.getForm().bind(table);
    return layout.build();
  }
  private ToolStrip mainTableTools() {
    ToolStrip tools = new ToolStrip();
    ToolButton addButton =
        new ToolButton(
            Console.CONSTANTS.common_label_add(),
            event -> {
              ModelNodeFormBuilder.FormAssets addFormAssets =
                  new ModelNodeFormBuilder()
                      .setResourceDescription(resourceDescription)
                      .setCreateMode(true)
                      .unsorted()
                      .setCreateNameAttribute(false)
                      .setSecurityContext(securityContext)
                      .build();
              addFormAssets.getForm().setEnabled(true);
              addFormAssets
                  .getForm()
                  .addFormValidator(
                      (formItems, formValidation) -> {

                        // at least one field is necessary to fill
                        boolean allEmpty = true;
                        for (FormItem formItem : formItems) {
                          if (!formItem.isUndefined()) {
                            allEmpty = false;
                            break;
                          }
                        }
                        if (allEmpty) {
                          formValidation.addError("match-abstract-type");
                          FormItem mechanismNameFormItem =
                              formItem(formItems, "match-abstract-type");
                          mechanismNameFormItem.setErrMessage(
                              "At least one field must contain valid values.");
                          mechanismNameFormItem.setErroneous(true);
                        }
                      });

              DefaultWindow dialog = new DefaultWindow(Console.MESSAGES.newTitle("Match Rule"));
              AddResourceDialog.Callback callback =
                  new AddResourceDialog.Callback() {
                    @Override
                    public void onAdd(ModelNode payload) {
                      for (Property node : payload.asPropertyList()) {
                        // remove undefined attributes
                        if (!node.getValue().isDefined()) {
                          payload.remove(node.getName());
                        }
                      }
                      circuit.dispatch(
                          new AddListAttribute(
                              ElytronStore.AUTHENTICATION_CONTEXT_ADDRESS,
                              MATCH_RULES,
                              authContextName,
                              payload));
                      dialog.hide();
                    }

                    @Override
                    public void onCancel() {
                      dialog.hide();
                    }
                  };
              AddResourceDialog addDialog =
                  new AddResourceDialog(addFormAssets, resourceDescription, callback);
              dialog.setWidth(480);
              dialog.setHeight(510);
              dialog.setWidget(addDialog);
              dialog.setGlassEnabled(true);
              dialog.center();
            });
    ToolButton removeButton =
        new ToolButton(
            Console.CONSTANTS.common_label_delete(),
            event -> {
              final ModelNode selection = selectionModel.getSelectedObject();
              if (selection != null) {
                Feedback.confirm(
                    "Match Rule",
                    Console.MESSAGES.deleteConfirm("Match Rule " + selection.asString()),
                    isConfirmed -> {
                      if (isConfirmed) {
                        circuit.dispatch(
                            new RemoveListAttribute(
                                ElytronStore.AUTHENTICATION_CONTEXT_ADDRESS,
                                authContextName,
                                MATCH_RULES,
                                selection));
                      }
                    });
              }
            });
    tools.addToolButtonRight(addButton);
    tools.addToolButtonRight(removeButton);
    return tools;
  }