Example usage for org.apache.commons.configuration ConfigurationException getMessage

List of usage examples for org.apache.commons.configuration ConfigurationException getMessage

Introduction

In this page you can find the example usage for org.apache.commons.configuration ConfigurationException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.zaproxy.zap.extension.ascan.PolicyManagerDialog.java

private JButton getExportButton() {
    if (this.exportButton == null) {
        this.exportButton = new JButton(Constant.messages.getString("ascan.policymgr.button.export"));
        this.exportButton.setEnabled(false);
        this.exportButton.addActionListener(new ActionListener() {
            @Override//from   w ww.j  a v a2  s .  co  m
            public void actionPerformed(ActionEvent e) {
                String name = (String) getParamsModel().getValueAt(getParamsTable().getSelectedRow(), 0);
                if (name != null) {
                    JFileChooser chooser = new JFileChooser(Constant.getPoliciesDir());
                    File file = new File(Constant.getZapHome(), name + PolicyManager.POLICY_EXTENSION);
                    chooser.setSelectedFile(file);

                    chooser.setFileFilter(new FileFilter() {
                        @Override
                        public boolean accept(File file) {
                            if (file.isDirectory()) {
                                return true;
                            } else if (file.isFile() && file.getName().endsWith(".policy")) {
                                return true;
                            }
                            return false;
                        }

                        @Override
                        public String getDescription() {
                            return Constant.messages.getString("file.format.zap.policy");
                        }
                    });
                    int rc = chooser.showSaveDialog(View.getSingleton().getMainFrame());
                    if (rc == JFileChooser.APPROVE_OPTION) {
                        file = chooser.getSelectedFile();
                        if (file == null) {
                            return;
                        }
                        try {
                            ScanPolicy policy = extension.getPolicyManager().getPolicy(name);
                            if (policy != null) {
                                extension.getPolicyManager().exportPolicy(policy, file);
                            }
                        } catch (ConfigurationException e1) {
                            logger.error(e1.getMessage(), e1);
                            View.getSingleton()
                                    .showWarningDialog(Constant.messages.getString("ascan.policy.load.error"));
                        }
                    }
                }
            }
        });
    }
    return this.exportButton;
}

From source file:org.zaproxy.zap.extension.ascan.PolicyManagerDialog.java

private JTable getParamsTable() {
    if (paramsTable == null) {
        paramsTable = new JTable();
        paramsTable.setModel(getParamsModel());
        paramsTable.addMouseListener(new MouseListener() {
            @Override/*from www  . j  a v  a 2s .c o  m*/
            public void mouseClicked(MouseEvent e) {
            }

            @Override
            public void mousePressed(MouseEvent e) {
                if (e.getClickCount() >= 2) {
                    int row = paramsTable.rowAtPoint(e.getPoint());
                    if (row >= 0) {
                        String name = (String) getParamsModel().getValueAt(row, 0);
                        if (name != null) {
                            try {
                                extension.showPolicyDialog(PolicyManagerDialog.this, name);
                            } catch (ConfigurationException e1) {
                                logger.error(e1.getMessage(), e1);
                            }
                        }
                    }
                }
            }

            @Override
            public void mouseReleased(MouseEvent e) {
            }

            @Override
            public void mouseEntered(MouseEvent e) {
            }

            @Override
            public void mouseExited(MouseEvent e) {
            }
        });
        paramsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                if (getParamsTable().getSelectedRowCount() == 0) {
                    getModifyButton().setEnabled(false);
                    getRemoveButton().setEnabled(false);
                    getExportButton().setEnabled(false);
                } else if (getParamsTable().getSelectedRowCount() == 1) {
                    getModifyButton().setEnabled(true);
                    // Dont let the last policy be removed
                    getRemoveButton().setEnabled(getParamsModel().getRowCount() > 1);
                    getExportButton().setEnabled(true);
                } else {
                    getModifyButton().setEnabled(false);
                    getRemoveButton().setEnabled(false);
                    getExportButton().setEnabled(false);
                }
            }
        });
    }
    return paramsTable;
}

From source file:org.zaproxy.zap.extension.autoupdate.ExtensionAutoUpdate.java

public void alertIfNewVersions() {
    // Kicks off a thread and pops up a window if there are new versions.
    // Depending on the options the user has chosen.
    // Only expect this to be called on startup and in desktop mode

    final OptionsParamCheckForUpdates options = getModel().getOptionsParam().getCheckForUpdatesParam();

    if (View.isInitialised()) {
        if (options.isCheckOnStartUnset()) {
            // First time in
            int result = getView().showConfirmDialog(Constant.messages.getString("cfu.confirm.startCheck"));
            if (result == JOptionPane.OK_OPTION) {
                options.setCheckOnStart(true);
                options.setCheckAddonUpdates(true);
                options.setDownloadNewRelease(true);
            } else {
                options.setCheckOnStart(false);
            }// w w  w .j av a 2 s. co m
            // Save
            try {
                this.getModel().getOptionsParam().getConfig().save();
            } catch (ConfigurationException ce) {
                logger.error(ce.getMessage(), ce);
                getView().showWarningDialog(Constant.messages.getString("cfu.confirm.error"));
                return;
            }
        }
        if (!options.isCheckOnStart()) {
            alertIfOutOfDate(false);
            return;
        }
    }

    if (!options.checkOnStart()) {
        // Top level option not set, dont do anything, unless already downloaded last release
        if (View.isInitialised() && this.getPreviousVersionInfo() != null) {
            ZapRelease rel = this.getPreviousVersionInfo().getZapRelease();
            if (rel != null && rel.isNewerThan(this.getCurrentVersion())) {
                File f = new File(Constant.FOLDER_LOCAL_PLUGIN, rel.getFileName());
                if (f.exists() && f.length() >= rel.getSize()) {
                    // Already downloaded, prompt to install and exit
                    this.promptToLaunchReleaseAndClose(rel.getVersion(), f);
                }
            }
        }
        return;
    }
    // Handle the response in a callback
    this.getLatestVersionInfo(this);
}

From source file:org.zaproxy.zap.extension.autoupdate.ExtensionAutoUpdate.java

private AddOnCollection getPreviousVersionInfo() {
    if (this.previousVersionInfo == null) {
        File f = new File(Constant.FOLDER_LOCAL_PLUGIN, VERSION_FILE_NAME);
        if (f.exists()) {
            try {
                this.previousVersionInfo = new AddOnCollection(new ZapXmlConfiguration(f), this.getPlatform());
            } catch (ConfigurationException e) {
                logger.error(e.getMessage(), e);
            }//from w w  w.  j  a va 2s.  c  o  m
        }
    }
    return this.previousVersionInfo;
}

From source file:org.zaproxy.zap.extension.autoupdate.OptionsParamCheckForUpdates.java

/**
 * Tells whether or not a "check for updates on start up" needs to be performed.
 * <p>/*  w w  w  .  ja v  a  2  s  .c o m*/
 * A check for updates needs to be performed if the method {@code isCheckOnStart()} returns {@code true} and if no check was
 * already done during the same day.
 * </p>
 * 
 * @return {@code true} if a check for updates on start up needs to be performed, {@code false} otherwise.
 * @see #isCheckOnStart()
 */
@ZapApiIgnore
public boolean checkOnStart() {
    if (!checkOnStart) {
        log.debug("isCheckForStart - false");
        return false;
    }
    String today = sdf.format(new Date());
    if (today.equals(dayLastChecked)) {
        log.debug("isCheckForStart - already checked today");
        return false;
    }
    getConfig().setProperty(DAY_LAST_CHECKED, today);
    try {
        getConfig().save();
    } catch (ConfigurationException e) {
        log.error(e.getMessage(), e);
    }

    return true;
}

From source file:org.zaproxy.zap.extension.autoupdate.OptionsParamCheckForUpdates.java

public void setDayLastInstallWarned() {
    getConfig().setProperty(DAY_LAST_INSTALL_WARNED, sdf.format(new Date()));
    try {//from   w  w w  .  j  av  a  2s  .  c  om
        getConfig().save();
    } catch (ConfigurationException e) {
        log.error(e.getMessage(), e);
    }
}

From source file:org.zaproxy.zap.extension.autoupdate.OptionsParamCheckForUpdates.java

public void setDayLastUpdateWarned() {
    getConfig().setProperty(DAY_LAST_UPDATE_WARNED, sdf.format(new Date()));
    try {//from  w  ww  . ja  va  2s .c o  m
        getConfig().save();
    } catch (ConfigurationException e) {
        log.error(e.getMessage(), e);
    }
}

From source file:org.zaproxy.zap.extension.customFire.CustomFireDialog.java

private void policySelected() {
    String policyName = getStringValue(FIELD_POLICY);
    try {/*from  w  ww .  j  a va2s. c  o  m*/
        scanPolicy = p.getPolicy(policyName);
        policyPanel.setScanPolicy(scanPolicy);
        scanPolicyName = policyName;
    } catch (ConfigurationException e) {
        logger.error(e.getMessage(), e);
    }
}

From source file:org.zaproxy.zap.extension.customFire.PolicyAllCategoryPanel.java

private JComboBox<String> getPolicySelector() {
    if (policySelector == null) {
        policySelector = new JComboBox<>();

        for (String policy : p.getAllPolicyNames()) {
            policySelector.addItem(policy);

        }/*  w  w  w  . jav  a2s  . c o m*/
        policySelector.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

                String policyName = (String) policySelector.getSelectedItem();
                if (policyName == null) {
                    return;
                }
                CustomScanPolicy policy;
                try {
                    policy = p.getPolicy(policyName);
                    if (policy != null) {
                        setScanPolicy(policy);
                        fireScanPolicyChanged(policy);
                    }
                } catch (ConfigurationException e1) {
                    logger.error(e1.getMessage(), e1);
                }
            }
        });
    }

    return policySelector;

}

From source file:org.zaproxy.zap.extension.customFire.PolicyManager.java

public CustomScanPolicy getDefaultScanPolicy() {
    try {// w  ww . j  a v  a  2  s  .c om
        String policyName = scannerParam.getDefaultPolicy(); //ia
        if (this.policyExists(policyName)) {
            logger.debug("getDefaultScanPolicy: " + policyName);
            return this.loadPolicy(policyName);
        }
        // No good, try the default name
        policyName = DEFAULT_POLICY_NAME;
        if (this.policyExists(policyName)) {
            logger.debug("getDefaultScanPolicy (default name): " + policyName);
            return this.loadPolicy(policyName);
        }
        if (this.allPolicyNames.size() > 0) {
            logger.debug("getDefaultScanPolicy (first one): " + policyName);
            return this.loadPolicy(this.allPolicyNames.get(0));
        }

    } catch (ConfigurationException e) {
        logger.error(e.getMessage(), e);
    }
    // Return a new 'blank' one
    logger.debug("getDefaultScanPolicy (new blank)");
    //returning default policy
    return new CustomScanPolicy();
}