private void extractMutations( TestStep testStep, SecurityTestRunContext context ) throws XmlException, Exception
{
strategy = getExecutionStrategy().getStrategy();
XmlObjectTreeModel model = null;// getXmlObjectTreeModel( testStep );
List<SecurityCheckedParameter> scpList = getParameterHolder().getParameterList();
StringToStringMap stsmap = new StringToStringMap();
for( SecurityCheckedParameter scp : scpList )
{
if( scp.isChecked() && scp.getXpath().trim().length() > 0 )
{
XmlTreeNode[] treeNodes = null;
if( strategy.equals( StrategyTypeConfig.ONE_BY_ONE ) )
{
stsmap = new StringToStringMap();
model = SecurityScanUtil.getXmlObjectTreeModel( testStep, scp );
}
else
{
if( model == null )
{
model = SecurityScanUtil.getXmlObjectTreeModel( testStep, scp );
}
}
treeNodes = model.selectTreeNodes( context.expand( scp.getXpath() ) );
if( treeNodes.length > 0 )
{
XmlTreeNode mynode = treeNodes[0];
if( mynode.isLeaf() )
{
if( mynode.getSchemaType() != null && mynode.getSchemaType().getEnumerationValues() != null
&& mynode.getSchemaType().getEnumerationValues().length > 0 )
{
EnumerationValues nodeInfo = new EnumerationValues( mynode.getSchemaType().getBaseType()
.getShortJavaName() );
for( XmlAnySimpleType s : mynode.getSchemaType().getEnumerationValues() )
{
nodeInfo.addValue( s.getStringValue() );
}
updateEnumNodeValue( mynode, nodeInfo );
stsmap.put( scp.getLabel(), mynode.getNodeText() );
// addToUpdated( context, scp.getLabel(),
// mynode.getNodeText() );
if( strategy.equals( StrategyTypeConfig.ONE_BY_ONE ) )
{
PropertyMutation pm = new PropertyMutation();
pm.setPropertyName( scp.getName() );
pm.setPropertyValue( model.getXmlObject().toString() );
stsmap = new StringToStringMap();
stsmap.put( scp.getLabel(), mynode.getNodeText() );
pm.setMutatedParameters( stsmap );
addMutation( context, pm );
}
}
else
{
SchemaTypeImpl simpleType = ( SchemaTypeImpl )mynode.getSchemaType();
XmlObjectTreeModel model2 = new XmlObjectTreeModel( simpleType.getTypeSystem(),
simpleType.getParseObject() );
extractRestrictions( model2, context, mynode, model, scp, stsmap );
}
}
}