Search in sources :

Example 1 with ProductIdentifier

use of com.mercedesbenz.sechub.domain.scan.product.ProductIdentifier in project sechub by mercedes-benz.

the class ExecutorConfigDialogUI method createMainPanel.

private void createMainPanel() {
    ActionSupport actionSupport = ActionSupport.getInstance();
    mainPanel = new JPanel(new GridBagLayout());
    int row = 0;
    /* name */
    nameTextField = new JTextField(config.name);
    mainPanel.add(new JLabel("Name"), createLabelConstraint(row));
    mainPanel.add(nameTextField, createComponentConstraint(row++));
    nameTextField.setBorder(BorderFactory.createLineBorder(Color.ORANGE, 2));
    nameTextField.setToolTipText("mandatory field");
    /* enabled */
    enabledCheckBox = new JCheckBox("", config.enabled);
    mainPanel.add(new JLabel("Enabled"), createLabelConstraint(row));
    mainPanel.add(enabledCheckBox, createComponentConstraint(row++));
    /* UUID readonly */
    uuidTextField = new JTextField(config.uuid != null ? "" + config.uuid : null);
    uuidTextField.setEditable(false);
    mainPanel.add(new JLabel("UUID"), createLabelConstraint(row));
    mainPanel.add(uuidTextField, createComponentConstraint(row++));
    /* product */
    ComboBoxModel<ProductIdentifier> comboBoxModel = new DefaultComboBoxModel<>(ProductIdentifier.values());
    productIdentifierCombobox = new JComboBox<>(comboBoxModel);
    productIdentifierCombobox.setSelectedItem(ProductIdentifier.valueOf(config.productIdentifier));
    mainPanel.add(new JLabel("Product identifier"), createLabelConstraint(row));
    mainPanel.add(productIdentifierCombobox, createComponentConstraint(row++));
    SpinnerNumberModel versionSpinnerModel = new SpinnerNumberModel(1, 0, 9999, 1);
    executorVersionTextField = new JSpinner(versionSpinnerModel);
    executorVersionTextField.setValue(config.executorVersion);
    mainPanel.add(new JLabel("Executor version"), createLabelConstraint(row));
    mainPanel.add(executorVersionTextField, createComponentConstraint(row++));
    /* base url */
    baseURLTextField = new JTextField(config.setup.baseURL);
    mainPanel.add(new JLabel("Product base url"), createLabelConstraint(row));
    mainPanel.add(baseURLTextField, createComponentConstraint(row++));
    actionSupport.provideUndoRedo(baseURLTextField);
    /* credentials */
    userTextField = new JTextField(config.setup.credentials.user);
    mainPanel.add(new JLabel("Product user:"), createLabelConstraint(row));
    mainPanel.add(userTextField, createComponentConstraint(row++));
    pwdTextField = new JTextField(config.setup.credentials.password);
    mainPanel.add(new JLabel("Product password/apitoken:"), createLabelConstraint(row));
    mainPanel.add(pwdTextField, createComponentConstraint(row++));
    /* template button */
    JButton button = new JButton("Edit parameters");
    mainPanel.add(button, createComponentConstraint(row++));
    /* job parameters */
    jobParametersTextArea = new JTextArea(resolveInitialJobParamsAsString());
    actionSupport.installAllTextActionsAsPopupTo(jobParametersTextArea);
    mainPanel.add(new JLabel("Parameters:"), createLabelConstraint(row));
    jobParameterScrollPane = new JScrollPane(jobParametersTextArea);
    GridBagConstraints jobParameterScrollPaneGridDataConstraints = createComponentConstraint(row++);
    jobParameterScrollPaneGridDataConstraints.gridheight = 140;
    jobParameterScrollPaneGridDataConstraints.weighty = 0.0;
    jobParameterScrollPaneGridDataConstraints.fill = GridBagConstraints.BOTH;
    jobParameterScrollPane.setPreferredSize(new Dimension(400, 300));
    jobParameterScrollPane.setMinimumSize(new Dimension(400, 300));
    mainPanel.add(jobParameterScrollPane, jobParameterScrollPaneGridDataConstraints);
    button.addActionListener(e -> {
        ProductIdentifier procutIdentifier = (ProductIdentifier) comboBoxModel.getSelectedItem();
        int version = (int) versionSpinnerModel.getNumber();
        ShowProductExecutorTemplatesDialogAction action = context.getCommandUI().resolveShowProductExecutorMappingDialogActionOrNull(procutIdentifier, version);
        if (action == null) {
            JOptionPane.showMessageDialog(context.getFrame(), "No special parameter editor dialog available for " + procutIdentifier + " v" + version);
            return;
        }
        TemplatesDialogConfig config = new TemplatesDialogConfig();
        config.inputContent = jobParametersTextArea.getText();
        config.provideExportAllButton = true;
        config.provideExportAllButtonText = "Apply";
        /* open template dialog, auto import clipboard content and add apply button */
        TemplatesDialogResult result = action.openDialog(config);
        if (result.provideExportAllButtonPressed) {
            jobParametersTextArea.setText(result.outputContent);
            scrollToLeftTopOfJobParameters();
        }
    });
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) JTextArea(javax.swing.JTextArea) GridBagLayout(java.awt.GridBagLayout) JButton(javax.swing.JButton) ActionSupport(com.mercedesbenz.sechub.developertools.admin.ui.action.ActionSupport) JLabel(javax.swing.JLabel) ShowProductExecutorTemplatesDialogAction(com.mercedesbenz.sechub.developertools.admin.ui.action.adapter.ShowProductExecutorTemplatesDialogAction) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) JCheckBox(javax.swing.JCheckBox) SpinnerNumberModel(javax.swing.SpinnerNumberModel) ProductIdentifier(com.mercedesbenz.sechub.domain.scan.product.ProductIdentifier) TemplatesDialogResult(com.mercedesbenz.sechub.developertools.admin.ui.action.adapter.ProductExecutorTemplatesDialogUI.TemplatesDialogResult) JSpinner(javax.swing.JSpinner) TemplatesDialogConfig(com.mercedesbenz.sechub.developertools.admin.ui.action.adapter.ProductExecutorTemplatesDialogUI.TemplatesDialogConfig)

Example 2 with ProductIdentifier

use of com.mercedesbenz.sechub.domain.scan.product.ProductIdentifier in project sechub by mercedes-benz.

the class DeleteProductExecutorConfigService method deleteProductExecutorConfig.

/* @formatter:off */
@UseCaseAdminDeletesExecutorConfiguration(@Step(number = 2, name = "Service call", description = "Service deletes an existing product executor configuration by its UUID"))
public void deleteProductExecutorConfig(UUID uuid) {
    auditLogService.log("Wants to removed product execution {}", uuid);
    Optional<ProductExecutorConfig> opt = repository.findById(uuid);
    if (!opt.isPresent()) {
        LOG.info("Delete canceled, because executor config with uuid {} did not exist", uuid);
        ;
        return;
    }
    ProductExecutorConfig found = opt.get();
    String name = found.getName();
    ProductIdentifier productIdentifier = found.getProductIdentifier();
    Integer executorVersion = found.getExecutorVersion();
    repository.deleteById(uuid);
    LOG.info("Removed product execution config uuid:{}, name:{} which was for product:{} V{}", uuid, name, productIdentifier, executorVersion);
}
Also used : ProductIdentifier(com.mercedesbenz.sechub.domain.scan.product.ProductIdentifier) UseCaseAdminDeletesExecutorConfiguration(com.mercedesbenz.sechub.sharedkernel.usecases.admin.config.UseCaseAdminDeletesExecutorConfiguration)

Example 3 with ProductIdentifier

use of com.mercedesbenz.sechub.domain.scan.product.ProductIdentifier in project sechub by mercedes-benz.

the class SerecoProductResultSpdxJsonResolver method resolveSpdxJson.

/**
 * Fetches SPDX-Json from Sereco ProductResult
 *
 * @param serecoProductResult from Sereco
 * @return SpdxJson as String or <code>null</code>
 */
@Override
public String resolveSpdxJson(ProductResult serecoProductResult) {
    ProductIdentifier productIdentifier = serecoProductResult.getProductIdentifier();
    if (!productIdentifier.equals(ProductIdentifier.SERECO)) {
        throw new IllegalArgumentException("Must be of type Sereco, but was: " + productIdentifier);
    }
    String origin = serecoProductResult.getResult();
    SerecoMetaData data = JSONConverter.get().fromJSON(SerecoMetaData.class, origin);
    List<SerecoLicenseDocument> licenseDocuments = data.getLicenseDocuments();
    for (SerecoLicenseDocument licenseDocument : licenseDocuments) {
        SerecoLicenseSpdx spdx = licenseDocument.getSpdx();
        if (spdx == null) {
            continue;
        }
        String spdxJson = spdx.getJson();
        if (spdxJson != null) {
            return spdxJson;
        }
    }
    LOG.info("No SPDX report found in the product results.");
    return null;
}
Also used : ProductIdentifier(com.mercedesbenz.sechub.domain.scan.product.ProductIdentifier) SerecoLicenseSpdx(com.mercedesbenz.sechub.sereco.metadata.SerecoLicenseSpdx) SerecoMetaData(com.mercedesbenz.sechub.sereco.metadata.SerecoMetaData) SerecoLicenseDocument(com.mercedesbenz.sechub.sereco.metadata.SerecoLicenseDocument)

Example 4 with ProductIdentifier

use of com.mercedesbenz.sechub.domain.scan.product.ProductIdentifier in project sechub by mercedes-benz.

the class SerecoReportProductExecutor method createReport.

private ProductResult createReport(SecHubExecutionContext context, ProductExecutorContext executorContext) {
    if (context == null) {
        throw new IllegalArgumentException("context may not be null!");
    }
    String projectId = context.getConfiguration().getProjectId();
    UUID secHubJobUUID = context.getSechubJobUUID();
    UUIDTraceLogID traceLogId = UUIDTraceLogID.traceLogID(secHubJobUUID);
    LOG.debug("{} start sereco execution", traceLogId);
    /* load the results by job uuid */
    ProductIdentifier[] supportedProducts = getSupportedProducts();
    List<ProductResult> foundProductResults = productResultRepository.findAllProductResults(secHubJobUUID, supportedProducts);
    if (foundProductResults.isEmpty()) {
        LOG.warn("{} no product results for {} found, will return an empty sereco JSON as result! ", traceLogId, getSupportedProducts());
        return new ProductResult(secHubJobUUID, projectId, executorContext.getExecutorConfig(), "{}");
    }
    return createReport(projectId, secHubJobUUID, traceLogId, executorContext, foundProductResults);
}
Also used : UUIDTraceLogID(com.mercedesbenz.sechub.sharedkernel.UUIDTraceLogID) ProductResult(com.mercedesbenz.sechub.domain.scan.product.ProductResult) ProductIdentifier(com.mercedesbenz.sechub.domain.scan.product.ProductIdentifier) UUID(java.util.UUID)

Aggregations

ProductIdentifier (com.mercedesbenz.sechub.domain.scan.product.ProductIdentifier)4 ActionSupport (com.mercedesbenz.sechub.developertools.admin.ui.action.ActionSupport)1 TemplatesDialogConfig (com.mercedesbenz.sechub.developertools.admin.ui.action.adapter.ProductExecutorTemplatesDialogUI.TemplatesDialogConfig)1 TemplatesDialogResult (com.mercedesbenz.sechub.developertools.admin.ui.action.adapter.ProductExecutorTemplatesDialogUI.TemplatesDialogResult)1 ShowProductExecutorTemplatesDialogAction (com.mercedesbenz.sechub.developertools.admin.ui.action.adapter.ShowProductExecutorTemplatesDialogAction)1 ProductResult (com.mercedesbenz.sechub.domain.scan.product.ProductResult)1 SerecoLicenseDocument (com.mercedesbenz.sechub.sereco.metadata.SerecoLicenseDocument)1 SerecoLicenseSpdx (com.mercedesbenz.sechub.sereco.metadata.SerecoLicenseSpdx)1 SerecoMetaData (com.mercedesbenz.sechub.sereco.metadata.SerecoMetaData)1 UUIDTraceLogID (com.mercedesbenz.sechub.sharedkernel.UUIDTraceLogID)1 UseCaseAdminDeletesExecutorConfiguration (com.mercedesbenz.sechub.sharedkernel.usecases.admin.config.UseCaseAdminDeletesExecutorConfiguration)1 Dimension (java.awt.Dimension)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 UUID (java.util.UUID)1 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)1 JButton (javax.swing.JButton)1 JCheckBox (javax.swing.JCheckBox)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1