List of usage examples for org.apache.commons.configuration ConfigurationException getMessage
public String getMessage()
From source file:org.zaproxy.zap.extension.customFire.PolicyManager.java
public CustomScanPolicy getAttackScanPolicy() { try {/* www . j ava 2 s . c om*/ String policyName = extension.getScannerParam().getAttackPolicy(); if (this.policyExists(policyName)) { return this.loadPolicy(policyName); } // No good, try the default name policyName = DEFAULT_POLICY_NAME; if (this.policyExists(policyName)) { return this.loadPolicy(policyName); } if (this.allPolicyNames.size() > 0) { return this.loadPolicy(this.allPolicyNames.get(0)); } } catch (ConfigurationException e) { logger.error(e.getMessage(), e); } // Return a new 'blank' one return new CustomScanPolicy(); }
From source file:org.zaproxy.zap.extension.customFire.PolicyManagerDialog.java
private JButton getAddButton() { if (this.addButton == null) { this.addButton = new JButton(Constant.messages.getString("customFire.custom.policymgr.button.add")); this.addButton.addActionListener(new ActionListener() { @Override//from w ww . j a v a2 s .c om public void actionPerformed(ActionEvent e) { try { extension.showPolicyDialog(PolicyManagerDialog.this); } catch (ConfigurationException e1) { logger.error(e1.getMessage(), e1); } } }); } return this.addButton; }
From source file:org.zaproxy.zap.extension.customFire.PolicyManagerDialog.java
private JButton getModifyButton() { if (this.modifyButton == null) { this.modifyButton = new JButton( Constant.messages.getString("customFire.custom.policymgr.button.modify")); this.modifyButton.setEnabled(false); this.modifyButton.addActionListener(new ActionListener() { @Override/*from ww w .ja va2 s.co m*/ public void actionPerformed(ActionEvent e) { String name = (String) getParamsModel().getValueAt(getParamsTable().getSelectedRow(), 0); if (name != null) { try { extension.showPolicyDialog(PolicyManagerDialog.this, name); } catch (ConfigurationException e1) { logger.error(e1.getMessage(), e1); } } } }); } return this.modifyButton; }
From source file:org.zaproxy.zap.extension.customFire.PolicyManagerDialog.java
private JButton getExportButton() { if (this.exportButton == null) { this.exportButton = new JButton( Constant.messages.getString("customFire.custom.policymgr.button.export")); this.exportButton.setEnabled(false); this.exportButton.addActionListener(new ActionListener() { @Override/* ww w. j a va 2 s.com*/ 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 { CustomScanPolicy 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("customFire.custom.policy.load.error")); } } } } }); } return this.exportButton; }
From source file:org.zaproxy.zap.extension.option.OptionsParamCheckForUpdates.java
public boolean isCheckOnStart() { if (checkOnStart == 0) { log.debug("isCheckForStart - false"); return false; }/*from w w w .j av a 2s. co m*/ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 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.reveal.ExtensionReveal.java
void setReveal(boolean reveal) { if (this.reveal == reveal) { return;/* ww w .j a v a 2s . c om*/ } this.reveal = reveal; revealParam.setReveal(reveal); try { revealParam.getConfig().save(); } catch (ConfigurationException e) { logger.error(e.getMessage(), e); } if (revealButton != null) { revealButton.setSelected(reveal); } }
From source file:org.zaproxy.zap.model.Vulnerabilities.java
private static synchronized void init() { if (vulns == null) { // Read them in from the file XMLConfiguration config;/*from w ww .j av a2 s .co m*/ try { File f = new File(Constant.getInstance().VULNS_CONFIG); config = new XMLConfiguration(); config.setDelimiterParsingDisabled(true); config.load(f); } catch (ConfigurationException e) { logger.error(e.getMessage(), e); initEmpty(); return; } String[] test; try { test = config.getStringArray("vuln_items"); } catch (ConversionException e) { logger.error(e.getMessage(), e); initEmpty(); return; } final int numberOfVulns = test.length; List<Vulnerability> tempVulns = new ArrayList<>(numberOfVulns); idToVuln = new HashMap<>(Math.max((int) (numberOfVulns / 0.75) + 1, 16)); String name; List<String> references; for (String item : test) { name = "vuln_item_" + item; try { references = new ArrayList<>(Arrays.asList(config.getStringArray(name + ".reference"))); } catch (ConversionException e) { logger.error(e.getMessage(), e); references = new ArrayList<>(0); } Vulnerability v = new Vulnerability(item, config.getString(name + ".alert"), config.getString(name + ".desc"), config.getString(name + ".solution"), references); tempVulns.add(v); idToVuln.put(item, v); } vulns = Collections.unmodifiableList(tempVulns); } }
From source file:org.zaproxy.zap.view.ComponentMaximiserMouseListener.java
/** * Confirms, by asking the user, if the maximisation should be done. * <p>// www . j av a2s . co m * After positive confirmation this method returns always {@code true}. * * @return {@code true} if the maximisation should be done, {@code false} otherwise. * @see #triggerMaximisation(Component) * @see OptionsParamView#getWarnOnTabDoubleClick() */ private boolean confirmMaximisation() { if (!viewOptions.getWarnOnTabDoubleClick()) { return true; } if (View.getSingleton().showConfirmDialog(DOUBLE_CLICK_WARN_MESSAGE) != JOptionPane.OK_OPTION) { return false; } viewOptions.setWarnOnTabDoubleClick(false); try { viewOptions.getConfig().save(); } catch (ConfigurationException e) { LOGGER.error(e.getMessage(), e); } return true; }
From source file:org.zaproxy.zap.view.ContextExportDialog.java
@Override public void save() { try {/* www . j ava 2s . c om*/ Model.getSingleton().getSession().exportContext(getContextValue(CONTEXT_FIELD), getSelectedFile()); } catch (ConfigurationException e) { View.getSingleton().showWarningDialog(this, MessageFormat.format(Constant.messages.getString("context.import.error"), e.getMessage())); } }
From source file:org.zaproxy.zap.view.MainToolbarPanel.java
private JToggleButton getShowTabIconNames() { if (btnShowTabIconNames == null) { btnShowTabIconNames = new ZapToggleButton(); btnShowTabIconNames/*from w w w. j a v a 2 s . c om*/ .setIcon(new ImageIcon(MainToolbarPanel.class.getResource("/resource/icon/ui_tab_icon.png"))); btnShowTabIconNames.setToolTipText(Constant.messages.getString("view.toolbar.showNames")); btnShowTabIconNames.setSelectedIcon( new ImageIcon(MainToolbarPanel.class.getResource("/resource/icon/ui_tab_text.png"))); btnShowTabIconNames.setSelectedToolTipText(Constant.messages.getString("view.toolbar.showIcons")); setShowTabIconNames(Model.getSingleton().getOptionsParam().getViewParam().getShowTabNames()); DisplayUtils.scaleIcon(btnShowTabIconNames); btnShowTabIconNames.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent e) { setShowTabIconNames(getShowTabIconNames().isSelected()); Model.getSingleton().getOptionsParam().getViewParam().setShowTabNames(showtabiconnames); try { Model.getSingleton().getOptionsParam().getViewParam().getConfig().save(); } catch (ConfigurationException e1) { logger.error(e1.getMessage(), e1); } } }); } return btnShowTabIconNames; }