Search in sources :

Example 6 with StructuralNodeModifier

use of org.zaproxy.zap.model.StructuralNodeModifier 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

StructuralNodeModifier (org.zaproxy.zap.model.StructuralNodeModifier)6 ParameterParser (org.zaproxy.zap.model.ParameterParser)4 StandardParameterParser (org.zaproxy.zap.model.StandardParameterParser)4 Context (org.zaproxy.zap.model.Context)3 ZapXmlConfiguration (org.zaproxy.zap.utils.ZapXmlConfiguration)3 ConfigurationException (org.apache.commons.configuration.ConfigurationException)2 RecordContext (org.parosproxy.paros.db.RecordContext)2 Tech (org.zaproxy.zap.model.Tech)2 File (java.io.File)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 InvalidParameterException (java.security.InvalidParameterException)1 ArrayList (java.util.ArrayList)1 Pattern (java.util.regex.Pattern)1 URIException (org.apache.commons.httpclient.URIException)1 DatabaseException (org.parosproxy.paros.db.DatabaseException)1 Session (org.parosproxy.paros.model.Session)1 SiteNode (org.parosproxy.paros.model.SiteNode)1 HttpMessage (org.parosproxy.paros.network.HttpMessage)1 SessionDialog (org.parosproxy.paros.view.SessionDialog)1