List of usage examples for org.apache.commons.configuration ConfigurationException getMessage
public String getMessage()
From source file:org.wso2.carbon.registry.uddi.servlet.JUDDIRegistryServlet.java
/** * Create the shared instance of jUDDI's Registry class and call it's * "init()" method to initialize all core components. *//*from ww w . j av a2 s .c om*/ @Override public void init(ServletConfig config) throws ServletException { super.init(config); try { Registry.start(); } catch (ConfigurationException e) { log.error("jUDDI registry could not be started." + e.getMessage(), e); } }
From source file:org.wso2.carbon.registry.uddi.servlet.JUDDIRegistryServlet.java
@Override public void destroy() { try {//from w w w.j a v a2s . c o m Registry.stop(); } catch (ConfigurationException e) { log.error("jUDDI registry could not be stopped." + e.getMessage(), e); } super.destroy(); }
From source file:org.zaproxy.zap.extension.ascan.ActiveScanAPI.java
@Override public ApiResponse handleApiAction(String name, JSONObject params) throws ApiException { log.debug("handleApiAction " + name + " " + params.toString()); ScanPolicy policy;/* w w w .j a v a2 s . co m*/ int policyId; User user = null; try { switch (name) { case ACTION_SCAN_AS_USER: int userID = ApiUtils.getIntParam(params, PARAM_USER_ID); ExtensionUserManagement usersExtension = Control.getSingleton().getExtensionLoader() .getExtension(ExtensionUserManagement.class); if (usersExtension == null) { throw new ApiException(Type.NO_IMPLEMENTOR, ExtensionUserManagement.NAME); } Context context = ApiUtils.getContextByParamId(params, PARAM_CONTEXT_ID); if (!context.isIncluded(params.getString(PARAM_URL))) { throw new ApiException(Type.URL_NOT_IN_CONTEXT, PARAM_CONTEXT_ID); } user = usersExtension.getContextUserAuthManager(context.getIndex()).getUserById(userID); if (user == null) { throw new ApiException(Type.USER_NOT_FOUND, PARAM_USER_ID); } // Same behaviour but with addition of the user to scan // $FALL-THROUGH$ case ACTION_SCAN: URI url = getTargetUrl(params.getString(PARAM_URL)); boolean scanJustInScope = user == null ? this.getParam(params, PARAM_JUST_IN_SCOPE, false) : false; String policyName = null; policy = null; try { policyName = params.getString(PARAM_SCAN_POLICY_NAME); } catch (Exception e1) { // Ignore } try { if (policyName != null && policyName.length() > 0) { // Not specified, use the default one log.debug("handleApiAction scan policy =" + policyName); policy = controller.getPolicyManager().getPolicy(policyName); } } catch (ConfigurationException e) { throw new ApiException(ApiException.Type.DOES_NOT_EXIST, PARAM_SCAN_POLICY_NAME); } String method = this.getParam(params, PARAM_METHOD, HttpRequestHeader.GET); if (method.trim().length() == 0) { method = HttpRequestHeader.GET; } if (!Arrays.asList(HttpRequestHeader.METHODS).contains(method)) { throw new ApiException(ApiException.Type.ILLEGAL_PARAMETER, PARAM_METHOD); } int scanId = scanURL(url, user, this.getParam(params, PARAM_RECURSE, true), scanJustInScope, method, this.getParam(params, PARAM_POST_DATA, ""), policy); return new ApiResponseElement(name, Integer.toString(scanId)); case ACTION_PAUSE_SCAN: getActiveScan(params).pauseScan(); break; case ACTION_RESUME_SCAN: getActiveScan(params).resumeScan(); break; case ACTION_STOP_SCAN: getActiveScan(params).stopScan(); break; case ACTION_REMOVE_SCAN: GenericScanner2 activeScan = controller.removeScan(Integer.valueOf(params.getInt(PARAM_SCAN_ID))); if (activeScan == null) { throw new ApiException(ApiException.Type.DOES_NOT_EXIST, PARAM_SCAN_ID); } break; case ACTION_PAUSE_ALL_SCANS: controller.pauseAllScans(); break; case ACTION_RESUME_ALL_SCANS: controller.resumeAllScans(); break; case ACTION_STOP_ALL_SCANS: controller.stopAllScans(); break; case ACTION_REMOVE_ALL_SCANS: controller.removeAllScans(); break; case ACTION_CLEAR_EXCLUDED_FROM_SCAN: try { Session session = Model.getSingleton().getSession(); session.setExcludeFromScanRegexs(new ArrayList<String>()); } catch (DatabaseException e) { log.error(e.getMessage(), e); throw new ApiException(ApiException.Type.INTERNAL_ERROR, e.getMessage()); } break; case ACTION_EXCLUDE_FROM_SCAN: String regex = params.getString(PARAM_REGEX); try { Session session = Model.getSingleton().getSession(); session.addExcludeFromScanRegexs(regex); } catch (DatabaseException e) { log.error(e.getMessage(), e); throw new ApiException(ApiException.Type.INTERNAL_ERROR, e.getMessage()); } catch (PatternSyntaxException e) { throw new ApiException(ApiException.Type.ILLEGAL_PARAMETER, PARAM_REGEX); } break; case ACTION_ENABLE_ALL_SCANNERS: policy = getScanPolicyFromParams(params); policy.getPluginFactory().setAllPluginEnabled(true); policy.save(); break; case ACTION_DISABLE_ALL_SCANNERS: policy = getScanPolicyFromParams(params); policy.getPluginFactory().setAllPluginEnabled(false); policy.save(); break; case ACTION_ENABLE_SCANNERS: policy = getScanPolicyFromParams(params); setScannersEnabled(policy, getParam(params, PARAM_IDS, "").split(","), true); policy.save(); break; case ACTION_DISABLE_SCANNERS: policy = getScanPolicyFromParams(params); setScannersEnabled(policy, getParam(params, PARAM_IDS, "").split(","), false); policy.save(); break; case ACTION_SET_ENABLED_POLICIES: policy = getScanPolicyFromParams(params); setEnabledPolicies(policy, getParam(params, PARAM_IDS, "").split(",")); policy.save(); break; case ACTION_SET_POLICY_ATTACK_STRENGTH: policyId = getPolicyIdFromParamId(params); policy = getScanPolicyFromParams(params); Plugin.AttackStrength attackStrength = getAttackStrengthFromParamAttack(params); for (Plugin scanner : policy.getPluginFactory().getAllPlugin()) { if (scanner.getCategory() == policyId) { scanner.setAttackStrength(attackStrength); } } policy.save(); break; case ACTION_SET_POLICY_ALERT_THRESHOLD: policyId = getPolicyIdFromParamId(params); policy = getScanPolicyFromParams(params); Plugin.AlertThreshold alertThreshold1 = getAlertThresholdFromParamAlertThreshold(params); for (Plugin scanner : policy.getPluginFactory().getAllPlugin()) { if (scanner.getCategory() == policyId) { scanner.setAlertThreshold(alertThreshold1); } } policy.save(); break; case ACTION_SET_SCANNER_ATTACK_STRENGTH: policy = getScanPolicyFromParams(params); Plugin scanner = getScannerFromParamId(policy, params); scanner.setAttackStrength(getAttackStrengthFromParamAttack(params)); policy.save(); break; case ACTION_SET_SCANNER_ALERT_THRESHOLD: policy = getScanPolicyFromParams(params); AlertThreshold alertThreshold2 = getAlertThresholdFromParamAlertThreshold(params); getScannerFromParamId(policy, params).setAlertThreshold(alertThreshold2); policy.save(); break; case ACTION_ADD_SCAN_POLICY: String newPolicyName = params.getString(PARAM_SCAN_POLICY_NAME); if (controller.getPolicyManager().getAllPolicyNames().contains(newPolicyName)) { throw new ApiException(ApiException.Type.ALREADY_EXISTS, PARAM_SCAN_POLICY_NAME); } if (!controller.getPolicyManager().isLegalPolicyName(newPolicyName)) { throw new ApiException(ApiException.Type.ILLEGAL_PARAMETER, PARAM_SCAN_POLICY_NAME); } policy = controller.getPolicyManager().getTemplatePolicy(); policy.setName(newPolicyName); controller.getPolicyManager().savePolicy(policy); break; case ACTION_REMOVE_SCAN_POLICY: // Check it exists policy = getScanPolicyFromParams(params); if (controller.getPolicyManager().getAllPolicyNames().size() == 1) { // Dont remove the last one throw new ApiException(ApiException.Type.ILLEGAL_PARAMETER, "You are not allowed to remove the last scan policy"); } controller.getPolicyManager().deletePolicy(policy.getName()); break; default: throw new ApiException(ApiException.Type.BAD_ACTION); } } catch (ConfigurationException e) { throw new ApiException(ApiException.Type.INTERNAL_ERROR, e.getMessage()); } return ApiResponseElement.OK; }
From source file:org.zaproxy.zap.extension.ascan.CustomScanDialog.java
private void policySelected() { String policyName = getStringValue(FIELD_POLICY); try {/*from www . ja va 2 s . co m*/ scanPolicy = extension.getPolicyManager().getPolicy(policyName); getPolicyAllCategoryPanel(false).setScanPolicy(scanPolicy); for (PolicyCategoryPanel panel : this.categoryPanels) { panel.setPluginFactory(scanPolicy.getPluginFactory(), scanPolicy.getDefaultThreshold()); } scanPolicyName = policyName; } catch (ConfigurationException e) { logger.error(e.getMessage(), e); } }
From source file:org.zaproxy.zap.extension.ascan.ExtensionActiveScan.java
protected void showPolicyDialog(PolicyManagerDialog parent, String name) throws ConfigurationException { ScanPolicy policy;/* w w w.j ava 2 s . c om*/ if (name != null) { policy = this.getPolicyManager().getPolicy(name); } else { policy = this.getPolicyManager().getTemplatePolicy(); } PolicyDialog dialog = new PolicyDialog(this, parent, policy); dialog.initParam(getModel().getOptionsParam()); for (AbstractParamPanel panel : policyPanels) { dialog.addPolicyPanel(panel); } int result = dialog.showDialog(true); if (result == JOptionPane.OK_OPTION) { try { getModel().getOptionsParam().getConfig().save(); } catch (ConfigurationException ce) { logger.error(ce.getMessage(), ce); getView().showWarningDialog(Constant.messages.getString("scanner.save.warning")); } } }
From source file:org.zaproxy.zap.extension.ascan.PolicyAllCategoryPanel.java
private JComboBox<String> getPolicySelector() { if (policySelector == null) { policySelector = new JComboBox<>(); for (String policy : extension.getPolicyManager().getAllPolicyNames()) { policySelector.addItem(policy); }/* w w w . java2 s . com*/ policySelector.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String policyName = (String) policySelector.getSelectedItem(); if (policyName == null) { return; } ScanPolicy policy; try { policy = extension.getPolicyManager().getPolicy(policyName); if (policy != null) { setScanPolicy(policy); } } catch (ConfigurationException e1) { logger.error(e1.getMessage(), e1); } } }); } return policySelector; }
From source file:org.zaproxy.zap.extension.ascan.PolicyManager.java
public ScanPolicy getDefaultScanPolicy() { try {// ww w.j a v a 2 s. c o m String policyName = extension.getScannerParam().getDefaultPolicy(); 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) { // Still no joy, try the first 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)"); return new ScanPolicy(); }
From source file:org.zaproxy.zap.extension.ascan.PolicyManager.java
public ScanPolicy getAttackScanPolicy() { try {/*www .ja va 2 s .co m*/ 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) { // Still no joy, try the first return this.loadPolicy(this.allPolicyNames.get(0)); } } catch (ConfigurationException e) { logger.error(e.getMessage(), e); } // Return a new 'blank' one return new ScanPolicy(); }
From source file:org.zaproxy.zap.extension.ascan.PolicyManagerDialog.java
private JButton getAddButton() { if (this.addButton == null) { this.addButton = new JButton(Constant.messages.getString("ascan.policymgr.button.add")); this.addButton.addActionListener(new ActionListener() { @Override//from w w w. j a v a2 s . c o m 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.ascan.PolicyManagerDialog.java
private JButton getModifyButton() { if (this.modifyButton == null) { this.modifyButton = new JButton(Constant.messages.getString("ascan.policymgr.button.modify")); this.modifyButton.setEnabled(false); this.modifyButton.addActionListener(new ActionListener() { @Override/*from ww w . j a va 2 s . c om*/ 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; }