XMLDocumentStreamReader doc = new XMLDocumentStreamReader(reader);
StAXOMBuilder builder = new StAXOMBuilder(doc);
OMElement element = builder.getDocumentElement();
neethiPolicy = PolicyEngine.getPolicy(element);
WSPolicy wsPolicy = new WSPolicy();
wsPolicy.setNeethiPolicy(neethiPolicy);
// normalize the neethi tree so we can easily identify
// the policy alternatives
/* Messes up the hierarchy if rampart config policies included
try {
neethiPolicy.normalize(true);
} catch (UnsupportedOperationException ex){
// RampartConfig policies don't support this yet
}
*/
// top-level children of ExactlyOne are policy alternatives so
// for each child create a policy model list and pull the
// policies out
for(Object alternative : neethiPolicy.getPolicyComponents()) {
List<Object> assertions = new ArrayList<Object>();
readPolicyAssertions(assertions, (PolicyComponent)alternative, context);
wsPolicy.getPolicyAssertions().add(assertions);
}
return wsPolicy;
}