Search in sources :

Example 1 with StandardParameterParser

use of org.zaproxy.zap.model.StandardParameterParser in project zaproxy by zaproxy.

the class ContextStructurePanel method initContextData.

@Override
public void initContextData(Session session, Context context) {
    ParameterParser urlParamParser = context.getUrlParamParser();
    ParameterParser formParamParser = context.getPostParamParser();
    this.ddnTableModel.setStructuralNodeModifiers(context.getDataDrivenNodes());
    if (urlParamParser instanceof StandardParameterParser) {
        StandardParameterParser urlStdParamParser = (StandardParameterParser) urlParamParser;
        this.getUrlKvPairSeparators().setText(urlStdParamParser.getKeyValuePairSeparators());
        this.getUrlKeyValueSeparators().setText(urlStdParamParser.getKeyValueSeparators());
        for (String structParam : urlStdParamParser.getStructuralParameters()) {
            this.ddnTableModel.addStructuralNodeModifier(new StructuralNodeModifier(StructuralNodeModifier.Type.StructuralParameter, null, structParam));
        }
    }
    if (formParamParser instanceof StandardParameterParser) {
        StandardParameterParser formStdParamParser = (StandardParameterParser) formParamParser;
        this.getPostKvPairSeparators().setText(formStdParamParser.getKeyValuePairSeparators());
        this.getPostKeyValueSeparators().setText(formStdParamParser.getKeyValueSeparators());
    }
}
Also used : StandardParameterParser(org.zaproxy.zap.model.StandardParameterParser) ParameterParser(org.zaproxy.zap.model.ParameterParser) StructuralNodeModifier(org.zaproxy.zap.model.StructuralNodeModifier) StandardParameterParser(org.zaproxy.zap.model.StandardParameterParser)

Example 2 with StandardParameterParser

use of org.zaproxy.zap.model.StandardParameterParser in project zaproxy by zaproxy.

the class ContextStructurePanel method saveToContext.

/**
	 * Save the data from this panel to the provided context.
	 *
	 * @param context the context
	 * @param updateSiteStructure {@code true} if the nodes of the context should be restructured, {@code false} otherwise
	 * @see Context#restructureSiteTree()
	 */
private void saveToContext(Context context, boolean updateSiteStructure) {
    ParameterParser urlParamParser = context.getUrlParamParser();
    ParameterParser formParamParser = context.getPostParamParser();
    List<String> structParams = new ArrayList<String>();
    List<StructuralNodeModifier> ddns = new ArrayList<StructuralNodeModifier>();
    for (StructuralNodeModifier snm : this.ddnTableModel.getElements()) {
        if (snm.getType().equals(StructuralNodeModifier.Type.StructuralParameter)) {
            structParams.add(snm.getName());
        } else {
            ddns.add(snm);
        }
    }
    if (urlParamParser instanceof StandardParameterParser) {
        StandardParameterParser urlStdParamParser = (StandardParameterParser) urlParamParser;
        urlStdParamParser.setKeyValuePairSeparators(this.getUrlKvPairSeparators().getText());
        urlStdParamParser.setKeyValueSeparators(this.getUrlKeyValueSeparators().getText());
        urlStdParamParser.setStructuralParameters(structParams);
        context.setUrlParamParser(urlStdParamParser);
        urlStdParamParser.setContext(context);
    }
    if (formParamParser instanceof StandardParameterParser) {
        StandardParameterParser formStdParamParser = (StandardParameterParser) formParamParser;
        formStdParamParser.setKeyValuePairSeparators(this.getPostKvPairSeparators().getText());
        formStdParamParser.setKeyValueSeparators(this.getPostKeyValueSeparators().getText());
        context.setPostParamParser(formStdParamParser);
        formStdParamParser.setContext(context);
    }
    context.setDataDrivenNodes(ddns);
    if (updateSiteStructure) {
        context.restructureSiteTree();
    }
}
Also used : StandardParameterParser(org.zaproxy.zap.model.StandardParameterParser) ParameterParser(org.zaproxy.zap.model.ParameterParser) StructuralNodeModifier(org.zaproxy.zap.model.StructuralNodeModifier) StandardParameterParser(org.zaproxy.zap.model.StandardParameterParser) ArrayList(java.util.ArrayList)

Aggregations

ParameterParser (org.zaproxy.zap.model.ParameterParser)2 StandardParameterParser (org.zaproxy.zap.model.StandardParameterParser)2 StructuralNodeModifier (org.zaproxy.zap.model.StructuralNodeModifier)2 ArrayList (java.util.ArrayList)1