List of usage examples for org.apache.commons.configuration HierarchicalConfiguration getString
public String getString(String key, String defaultValue)
From source file:org.parosproxy.paros.core.scanner.ScannerParam.java
@Override protected void parse() { removeOldOptions();//w w w . j av a 2 s . c o m try { this.threadPerHost = getConfig().getInt(THREAD_PER_HOST, 1); } catch (Exception e) { } try { this.hostPerScan = getConfig().getInt(HOST_PER_SCAN, 2); } catch (Exception e) { } try { this.delayInMs = getConfig().getInt(DELAY_IN_MS, 0); } catch (Exception e) { } try { this.maxResultsToList = getConfig().getInt(MAX_RESULTS_LIST, 1000); } catch (Exception e) { } try { this.maxScansInUI = getConfig().getInt(MAX_SCANS_IN_UI, 5); } catch (Exception e) { } try { this.injectPluginIdInHeader = getConfig().getBoolean(INJECT_PLUGIN_ID_IN_HEADER, false); } catch (Exception e) { } try { this.handleAntiCSRFTokens = getConfig().getBoolean(HANDLE_ANTI_CSRF_TOKENS, false); } catch (Exception e) { } try { this.promptInAttackMode = getConfig().getBoolean(PROMPT_IN_ATTACK_MODE, true); } catch (Exception e) { } try { this.rescanInAttackMode = getConfig().getBoolean(RESCAN_IN_ATTACK_MODE, true); } catch (Exception e) { } try { this.promptToClearFinishedScans = getConfig().getBoolean(PROMPT_TO_CLEAR_FINISHED, true); } catch (Exception e) { } try { this.showAdvancedDialog = getConfig().getBoolean(SHOW_ADV_DIALOG, false); } catch (Exception e) { } try { this.defaultPolicy = getConfig().getString(DEFAULT_POLICY, null); } catch (Exception e) { } try { this.attackPolicy = getConfig().getString(ATTACK_POLICY, null); } catch (Exception e) { } try { this.targetParamsInjectable = getConfig().getInt(TARGET_INJECTABLE, TARGET_INJECTABLE_DEFAULT); } catch (Exception e) { } try { this.targetParamsEnabledRPC = getConfig().getInt(TARGET_ENABLED_RPC, TARGET_ENABLED_RPC_DEFAULT); } catch (Exception e) { } try { this.allowAttackOnStart = getConfig().getBoolean(ALLOW_ATTACK_ON_START, false); } catch (Exception e) { } try { this.maxChartTimeInMins = getConfig().getInt(MAX_CHART_TIME_IN_MINS, DEFAULT_MAX_CHART_TIME_IN_MINS); } catch (Exception e) { } // Parse the parameters that need to be excluded // ------------------------------------------------ try { List<HierarchicalConfiguration> fields = ((HierarchicalConfiguration) getConfig()) .configurationsAt(EXCLUDED_PARAMS_KEY); this.excludedParams.clear(); this.excludedParamsMap.clear(); List<String> tempParamNames = new ArrayList<>(fields.size()); for (HierarchicalConfiguration sub : fields) { String name = sub.getString(EXCLUDED_PARAM_NAME, ""); if (!name.isEmpty() && !tempParamNames.contains(name)) { tempParamNames.add(name); addScannerParamFilter(name, sub.getInt(EXCLUDED_PARAM_TYPE, NameValuePair.TYPE_UNDEFINED), sub.getString(EXCLUDED_PARAM_URL)); } } } catch (ConversionException e) { logger.error("Error while loading the exluded parameter list: " + e.getMessage(), e); } // If the list is null probably we've to use defaults!!! if (this.excludedParams.isEmpty()) { // OK let's set the Default parameter exclusion list // Evaluate the possibility to load it from an external file... addScannerParamFilter("(?i)ASP.NET_SessionId", NameValuePair.TYPE_UNDEFINED, "*"); addScannerParamFilter("(?i)ASPSESSIONID.*", NameValuePair.TYPE_UNDEFINED, "*"); addScannerParamFilter("(?i)PHPSESSID", NameValuePair.TYPE_UNDEFINED, "*"); addScannerParamFilter("(?i)SITESERVER", NameValuePair.TYPE_UNDEFINED, "*"); addScannerParamFilter("(?i)sessid", NameValuePair.TYPE_UNDEFINED, "*"); addScannerParamFilter("__VIEWSTATE", NameValuePair.TYPE_POST_DATA, "*"); addScannerParamFilter("__EVENTVALIDATION", NameValuePair.TYPE_POST_DATA, "*"); addScannerParamFilter("__EVENTTARGET", NameValuePair.TYPE_POST_DATA, "*"); addScannerParamFilter("__EVENTARGUMENT", NameValuePair.TYPE_POST_DATA, "*"); addScannerParamFilter("(?i)jsessionid", NameValuePair.TYPE_UNDEFINED, "*"); addScannerParamFilter("cfid", NameValuePair.TYPE_COOKIE, "*"); addScannerParamFilter("cftoken", NameValuePair.TYPE_COOKIE, "*"); } }
From source file:org.parosproxy.paros.network.ConnectionParam.java
private void loadProxyExcludedDomains() { List<HierarchicalConfiguration> fields = ((HierarchicalConfiguration) getConfig()) .configurationsAt(ALL_PROXY_EXCLUDED_DOMAINS_KEY); this.proxyExcludedDomains = new ArrayList<>(fields.size()); ArrayList<ProxyExcludedDomainMatcher> excludedDomainsEnabled = new ArrayList<>(fields.size()); for (HierarchicalConfiguration sub : fields) { String value = sub.getString(PROXY_EXCLUDED_DOMAIN_VALUE_KEY, ""); if (value.isEmpty()) { log.warn("Failed to read an outgoing proxy excluded domain entry, required value is empty."); continue; }/* w ww . j a v a 2 s . c om*/ ProxyExcludedDomainMatcher excludedDomain = null; boolean regex = sub.getBoolean(PROXY_EXCLUDED_DOMAIN_REGEX_KEY, false); if (regex) { try { Pattern pattern = ProxyExcludedDomainMatcher.createPattern(value); excludedDomain = new ProxyExcludedDomainMatcher(pattern); } catch (IllegalArgumentException e) { log.error("Failed to read an outgoing proxy excluded domain entry with regex: " + value, e); } } else { excludedDomain = new ProxyExcludedDomainMatcher(value); } if (excludedDomain != null) { excludedDomain.setEnabled(sub.getBoolean(PROXY_EXCLUDED_DOMAIN_ENABLED_KEY, true)); proxyExcludedDomains.add(excludedDomain); if (excludedDomain.isEnabled()) { excludedDomainsEnabled.add(excludedDomain); } } } excludedDomainsEnabled.trimToSize(); this.proxyExcludedDomainsEnabled = excludedDomainsEnabled; }
From source file:org.pivot4j.ui.AbstractPivotRenderer.java
/** * @see org.pivot4j.state.Configurable#restoreSettings(org.apache.commons.configuration.HierarchicalConfiguration) *//*w w w . j ava 2 s . c om*/ @Override public void restoreSettings(HierarchicalConfiguration configuration) { if (configuration == null) { throw new NullArgumentException("configuration"); } this.drillDownMode = configuration.getString("drillDown[@mode]", DrillDownCommand.MODE_POSITION); this.enableDrillDown = configuration.getBoolean("drillDown[@enabled]", true); this.enableSort = configuration.getBoolean("sort[@enabled]", true); // TODO Need to support a custom implementation. String sortModeName = configuration.getString("sort[@mode]", SortMode.BASIC.getName()); this.sortMode = SortMode.fromName(sortModeName); if (sortMode == null) { Logger logger = LoggerFactory.getLogger(getClass()); if (logger.isWarnEnabled()) { logger.warn("Ignoring unknown sort mode name : {}", sortModeName); } this.sortMode = SortMode.BASIC; } this.enableDrillThrough = configuration.getBoolean("drillThrough[@enabled]", false); List<HierarchicalConfiguration> aggregationSettings = configuration .configurationsAt("aggregations.aggregation"); this.aggregatorNames.clear(); for (HierarchicalConfiguration aggConfig : aggregationSettings) { String name = aggConfig.getString("[@name]"); if (name != null) { Axis axis = Axis.Standard.valueOf(aggConfig.getString("[@axis]")); AggregatorPosition position = AggregatorPosition.valueOf(aggConfig.getString("[@position]")); AggregatorKey key = new AggregatorKey(axis, position); List<String> names = aggregatorNames.get(key); if (names == null) { names = new LinkedList<String>(); aggregatorNames.put(key, names); } if (!names.contains(name)) { names.add(name); } } } initializeRenderProperties(); for (String category : getRenderPropertyCategories()) { RenderPropertyList properties = renderProperties.get(category); if (properties != null) { try { properties.restoreSettings(configuration.configurationAt("properties." + category)); } catch (IllegalArgumentException e) { } } } this.renderSlicer = configuration.getBoolean("filter[@visible]", false); String collectorType = configuration.getString("propertyCollector[@type]"); // TODO At this time, we're not sure how to make property collector // configurable. So, let's just treat it as a read-only property. if ("non-internal".equalsIgnoreCase(collectorType)) { this.propertyCollector = new NonInternalPropertyCollector(); } else { this.propertyCollector = null; } }
From source file:org.pivot4j.ui.chart.ChartRenderer.java
/** * @see org.pivot4j.ui.AbstractPivotRenderer#restoreSettings(org.apache.commons * .configuration.HierarchicalConfiguration) *///from w w w . j av a2 s .c o m @Override public void restoreSettings(HierarchicalConfiguration configuration) { super.restoreSettings(configuration); this.pageAxis = readAxisMapping("page", configuration, Axis.COLUMNS); this.chartAxis = readAxisMapping("chart", configuration, Axis.COLUMNS); this.seriesAxis = readAxisMapping("series", configuration, Axis.ROWS); this.plotAxis = readAxisMapping("plot", configuration, Axis.ROWS); this.memberSeparator = configuration.getString("member-separator", DEFAULT_MEMBER_SEPARATOR); }
From source file:org.topology.bgp_ls.config.nodes.impl.RoutingFilterConfigurationParser.java
RoutingFilterConfiguration parseConfiguration(HierarchicalConfiguration config) throws ConfigurationException { List<HierarchicalConfiguration> prefixList = config.configurationsAt("Prefixes"); RoutingFilterConfigurationImpl rfc = null; if (prefixList.size() > 1) throw new ConfigurationException("more then one subnode specified"); if (prefixList.size() == 1) rfc = parsePrefixFilter(prefixList.get(0)); if (rfc == null) throw new ConfigurationException("no filter type specified"); rfc.setName(config.getString("[@name]", "")); return rfc;/*from w w w . j av a 2s .co m*/ }
From source file:org.zaproxy.zap.control.AddOnLoader.java
private static Map<AddOn, List<String>> loadAddOnsRunState(AddOnCollection addOnCollection) { List<HierarchicalConfiguration> savedAddOns = ((HierarchicalConfiguration) Model.getSingleton() .getOptionsParam().getConfig()).configurationsAt(ADDONS_RUNNABLE_KEY); Map<AddOn, List<String>> runnableAddOns = new HashMap<>(); for (HierarchicalConfiguration savedAddOn : savedAddOns) { AddOn addOn = addOnCollection.getAddOn(savedAddOn.getString(ADDON_RUNNABLE_ID_KEY, "")); if (addOn == null) { // No longer exists, skip it. continue; }/*from w w w.j a va 2 s . c o m*/ int version = savedAddOn.getInt(ADDON_RUNNABLE_VERSION_KEY, -1); if (version == -1 || addOn.getFileVersion() != version) { // No version or not the same version, skip it. continue; } List<String> runnableExtensions = new ArrayList<>(); List<String> currentExtensions = addOn.getExtensionsWithDeps(); for (String savedExtension : savedAddOn.getStringArray(ADDON_RUNNABLE_ALL_EXTENSIONS_KEY)) { if (currentExtensions.contains(savedExtension)) { runnableExtensions.add(savedExtension); } } runnableAddOns.put(addOn, runnableExtensions); } return runnableAddOns; }
From source file:org.zaproxy.zap.control.BaseZapAddOnXmlData.java
private void readDataImpl(HierarchicalConfiguration zapAddOnXml) { name = zapAddOnXml.getString(NAME_ELEMENT, ""); packageVersion = zapAddOnXml.getInt(VERSION_ELEMENT, 0); version = createVersion(zapAddOnXml.getString(SEM_VER_ELEMENT, "")); description = zapAddOnXml.getString(DESCRIPTION_ELEMENT, ""); author = zapAddOnXml.getString(AUTHOR_ELEMENT, ""); url = zapAddOnXml.getString(URL_ELEMENT, ""); changes = zapAddOnXml.getString(CHANGES_ELEMENT, ""); dependencies = readDependencies(zapAddOnXml, "zapaddon"); notBeforeVersion = zapAddOnXml.getString(NOT_BEFORE_VERSION_ELEMENT, ""); notFromVersion = zapAddOnXml.getString(NOT_FROM_VERSION_ELEMENT, ""); extensions = getStrings(zapAddOnXml, EXTENSIONS_ALL_ELEMENTS, EXTENSION_ELEMENT); extensionsWithDeps = readExtensionsWithDeps(zapAddOnXml); addOnClassnames = readAddOnClassnames(zapAddOnXml); readAdditionalData(zapAddOnXml);//w w w . j a va2 s . c o m }
From source file:org.zaproxy.zap.control.BaseZapAddOnXmlData.java
private Dependencies readDependencies(HierarchicalConfiguration currentNode, String element) { List<HierarchicalConfiguration> dependencies = currentNode.configurationsAt(DEPENDENCIES_ELEMENT); if (dependencies.isEmpty()) { return null; }// w ww . j a va2 s . co m if (dependencies.size() > 1) { malformedFile("expected at most one \"dependencies\" element for \"" + element + "\" element, found " + dependencies.size() + "."); } HierarchicalConfiguration node = dependencies.get(0); String javaVersion = node.getString(DEPENDENCIES_JAVA_VERSION_ELEMENT, ""); List<HierarchicalConfiguration> fields = node.configurationsAt(DEPENDENCIES_ADDONS_ALL_ELEMENTS); if (fields.isEmpty()) { return new Dependencies(javaVersion, Collections.<AddOnDep>emptyList()); } List<AddOnDep> addOns = readAddOnDependencies(fields); return new Dependencies(javaVersion, addOns); }
From source file:org.zaproxy.zap.control.BaseZapAddOnXmlData.java
private List<AddOnDep> readAddOnDependencies(List<HierarchicalConfiguration> fields) { List<AddOnDep> addOns = new ArrayList<>(fields.size()); for (HierarchicalConfiguration sub : fields) { String id = sub.getString(ZAPADDON_ID_ELEMENT, ""); if (id.isEmpty()) { malformedFile("an add-on dependency has empty \"" + ZAPADDON_ID_ELEMENT + "\"."); }/*from w w w. ja v a 2s . c o m*/ AddOnDep addOnDep = new AddOnDep(id, sub.getString(ZAPADDON_NOT_BEFORE_VERSION_ELEMENT, ""), sub.getString(ZAPADDON_NOT_FROM_VERSION_ELEMENT, ""), sub.getString(ZAPADDON_SEMVER_ELEMENT, "")); addOns.add(addOnDep); } return addOns; }
From source file:org.zaproxy.zap.control.BaseZapAddOnXmlData.java
private List<ExtensionWithDeps> readExtensionsWithDeps(HierarchicalConfiguration currentNode) { List<HierarchicalConfiguration> extensions = currentNode.configurationsAt(EXTENSIONS_V1_ALL_ELEMENTS); if (extensions.isEmpty()) { return Collections.emptyList(); }//w ww.j a v a2 s . co m List<ExtensionWithDeps> extensionsWithDeps = new ArrayList<>(extensions.size()); for (HierarchicalConfiguration extensionNode : extensions) { String classname = extensionNode.getString(EXTENSION_CLASS_NAME, ""); if (classname.isEmpty()) { malformedFile("a v1 extension has empty \"" + EXTENSION_CLASS_NAME + "\"."); } List<HierarchicalConfiguration> fields = extensionNode.configurationsAt(EXTENSION_DEPENDENCIES); if (fields.isEmpty()) { // Extension v1 without dependencies, handle as normal extension. if (this.extensions.isEmpty()) { // Empty thus Collections.emptyList(), create and use a mutable list. this.extensions = new ArrayList<>(5); } this.extensions.add(classname); continue; } List<AddOnDep> addOnDeps = readAddOnDependencies(fields); AddOnClassnames classnames = readAddOnClassnames(extensionNode); extensionsWithDeps.add(new ExtensionWithDeps(classname, addOnDeps, classnames)); } return extensionsWithDeps; }