Example usage for org.apache.commons.configuration HierarchicalConfiguration getInt

List of usage examples for org.apache.commons.configuration HierarchicalConfiguration getInt

Introduction

In this page you can find the example usage for org.apache.commons.configuration HierarchicalConfiguration getInt.

Prototype

public int getInt(String key, int defaultValue) 

Source Link

Usage

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 . jav  a 2s  . co  m*/
}

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

@Override
protected void parse() {
    removeOldOptions();// ww  w.j a  v 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) {
    }

    try {
        this.scanHeadersAllRequests = getConfig().getBoolean(SCAN_HEADERS_ALL_REQUESTS, false);
    } 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.zaproxy.zap.extension.keyboard.KeyboardParam.java

@Override
protected void parse() {
    try {//from  w w  w .ja v a2  s. c  om
        List<HierarchicalConfiguration> fields = ((HierarchicalConfiguration) getConfig())
                .configurationsAt(ALL_SHORTCUTS_KEY);
        map = new HashMap<String, KeyStroke>(fields.size());
        for (HierarchicalConfiguration sub : fields) {
            String name = sub.getString(MENU_ITEM_KEY, "");
            if (name.length() > 0) {
                map.put(name, KeyStroke.getKeyStroke(sub.getInt(KEYCODE_KEY, 0), sub.getInt(MODIFIERS_KEY, 0),
                        false));
            }
        }
    } catch (ConversionException e) {
        logger.error("Error while loading keyboard shortcuts " + e.getMessage(), e);
    }
}

From source file:playground.michalm.jtrrouter.matsim.MATSimJTRRouter.java

@Override
protected void initFlow(HierarchicalConfiguration flowCfg) {
    // int node = flowCfg.getInt("[@node]");

    int inLink = flowCfg.getInt("[@inLink]", -1);
    int outLink = flowCfg.getInt("[@outLink]", -1);

    // int next = flowCfg.getInt("[@next]");
    int no = flowCfg.getInt("[@no]", 0);

    Node node;//  w w  w  .  ja  v a  2  s . com
    Node next;

    if (inLink != -1) {
        Link link = idToLinkMap.get(Id.create(inLink, Link.class));

        node = link.getFromNode();
        next = link.getToNode();
    } else {
        Link link = idToLinkMap.get(Id.create(outLink, Link.class));

        node = link.getToNode();
        next = link.getFromNode();
    }

    int nodeId = Integer.parseInt(node.getId().toString());
    int nextId = Integer.parseInt(next.getId().toString());

    flows[nodeId] = new MATSimFlow(nodeId, inLink, outLink, nextId, no);
}