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());
}
}
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();
}
}
Aggregations