use of org.apache.neethi.builders.PolicyContainingPrimitiveAssertion in project cxf by apache.
the class AddressingAssertionBuilder method build.
public Assertion build(Element elem, AssertionBuilderFactory factory) {
String localName = elem.getLocalName();
QName qn = new QName(elem.getNamespaceURI(), localName);
boolean optional = false;
Attr attribute = PolicyConstants.findOptionalAttribute(elem);
if (attribute != null) {
optional = Boolean.valueOf(attribute.getValue());
}
if (MetadataConstants.ADDRESSING_ASSERTION_QNAME.equals(qn) || MetadataConstants.ADDRESSING_ASSERTION_QNAME_0705.equals(qn)) {
Assertion nap = new XMLPrimitiveAssertionBuilder() {
public Assertion newPrimitiveAssertion(Element element, Map<QName, String> mp) {
return new PrimitiveAssertion(MetadataConstants.ADDRESSING_ASSERTION_QNAME, isOptional(element), isIgnorable(element), mp);
}
public Assertion newPolicyContainingAssertion(Element element, Map<QName, String> mp, Policy policy) {
return new PolicyContainingPrimitiveAssertion(MetadataConstants.ADDRESSING_ASSERTION_QNAME, isOptional(element), isIgnorable(element), mp, policy);
}
}.build(elem, factory);
if (!(nap instanceof PolicyContainingPrimitiveAssertion || nap instanceof org.apache.neethi.builders.PrimitiveAssertion)) {
// this happens when neethi fails to recognize the specified addressing policy element
LOG.warning("Unable to recognize the addressing policy");
}
return nap;
} else if (MetadataConstants.ANON_RESPONSES_ASSERTION_QNAME.equals(qn) || MetadataConstants.ANON_RESPONSES_ASSERTION_QNAME_0705.equals(qn)) {
return new PrimitiveAssertion(MetadataConstants.ANON_RESPONSES_ASSERTION_QNAME, optional);
} else if (MetadataConstants.NON_ANON_RESPONSES_ASSERTION_QNAME.getLocalPart().equals(localName) || MetadataConstants.NON_ANON_RESPONSES_ASSERTION_QNAME_0705.getLocalPart().equals(localName)) {
return new PrimitiveAssertion(MetadataConstants.NON_ANON_RESPONSES_ASSERTION_QNAME, optional);
}
return null;
}
use of org.apache.neethi.builders.PolicyContainingPrimitiveAssertion in project cxf by apache.
the class AssertionInfoMapTest method testAllAssertionsIn.
@Test
public void testAllAssertionsIn() {
Policy nested = new Policy();
Assertion nb = new PrimitiveAssertion(new QName("http://x.y.z", "b"));
nested.addAssertion(nb);
Policy p = new Policy();
Assertion a1 = new PrimitiveAssertion(new QName("http://x.y.z", "a"));
Assertion a2 = new PrimitiveAssertion(new QName("http://x.y.z", "a"));
Assertion b = new PrimitiveAssertion(new QName("http://x.y.z", "b"));
Assertion c = new PolicyContainingPrimitiveAssertion(new QName("http://x.y.z", "c"), false, false, nested);
All alt1 = new All();
alt1.addAssertion(a1);
alt1.addAssertion(b);
All alt2 = new All();
alt1.addAssertion(a2);
alt2.addAssertion(c);
ExactlyOne ea = new ExactlyOne();
ea.addPolicyComponent(alt1);
ea.addPolicyComponent(alt2);
p.addPolicyComponent(ea);
AssertionInfoMap aim = new AssertionInfoMap(p);
Collection<AssertionInfo> listA = aim.getAssertionInfo(new QName("http://x.y.z", "a"));
assertEquals("2 A assertions should've been added", 2, listA.size());
AssertionInfo[] ais = listA.toArray(new AssertionInfo[] {});
assertTrue("Two different A instances should be added", ais[0].getAssertion() == a1 && ais[1].getAssertion() == a2 || ais[0].getAssertion() == a2 && ais[1].getAssertion() == a1);
Collection<AssertionInfo> listB = aim.getAssertionInfo(new QName("http://x.y.z", "b"));
assertEquals("2 B assertions should've been added", 2, listB.size());
ais = listB.toArray(new AssertionInfo[] {});
assertTrue("Two different B instances should be added", ais[0].getAssertion() == nb && ais[1].getAssertion() == b || ais[0].getAssertion() == b && ais[1].getAssertion() == nb);
Collection<AssertionInfo> listC = aim.getAssertionInfo(new QName("http://x.y.z", "c"));
assertEquals("1 C assertion should've been added", 1, listC.size());
ais = listC.toArray(new AssertionInfo[] {});
assertSame("One C instances should be added", ais[0].getAssertion(), c);
}
use of org.apache.neethi.builders.PolicyContainingPrimitiveAssertion in project cxf by apache.
the class RM12AssertionBuilder method build.
/**
* @see org.apache.neethi.builders.AssertionBuilder#build(org.w3c.dom.Element,
* org.apache.neethi.AssertionBuilderFactory)
*/
public Assertion build(Element elem, AssertionBuilderFactory factory) throws IllegalArgumentException {
Assertion assertion = null;
if (RM11Constants.WSRMP_NAMESPACE_URI.equals(elem.getNamespaceURI())) {
boolean optional = XMLPrimitiveAssertionBuilder.isOptional(elem);
String lname = elem.getLocalName();
if (RMConstants.RMASSERTION_NAME.equals(lname)) {
// top-level RMAssertion, with nested policy
XMLPrimitiveAssertionBuilder nesting = new XMLPrimitiveAssertionBuilder() {
public Assertion newPrimitiveAssertion(Element element, Map<QName, String> mp) {
return new PrimitiveAssertion(RM11Constants.WSRMP_RMASSERTION_QNAME, isOptional(element), isIgnorable(element), mp);
}
public Assertion newPolicyContainingAssertion(Element element, Map<QName, String> mp, Policy policy) {
return new PolicyContainingPrimitiveAssertion(RM11Constants.WSRMP_RMASSERTION_QNAME, isOptional(element), isIgnorable(element), mp, policy);
}
};
assertion = nesting.build(elem, factory);
} else if (SEQUENCESTR_NAME.equals(lname)) {
assertion = new PrimitiveAssertion(SEQSTR_QNAME, optional);
} else if (SEQUENCETRANSEC_NAME.equals(lname)) {
assertion = new PrimitiveAssertion(SEQTRANSSEC_QNAME, optional);
} else if (DELIVERYASSURANCE_NAME.equals(lname)) {
// DeliveryAssurance, with nested policy
XMLPrimitiveAssertionBuilder nesting = new XMLPrimitiveAssertionBuilder() {
public Assertion newPrimitiveAssertion(Element element, Map<QName, String> mp) {
return new PrimitiveAssertion(DELIVERYASSURANCE_QNAME, isOptional(element), isIgnorable(element), mp);
}
public Assertion newPolicyContainingAssertion(Element element, Map<QName, String> mp, Policy policy) {
return new PolicyContainingPrimitiveAssertion(DELIVERYASSURANCE_QNAME, isOptional(element), isIgnorable(element), mp, policy);
}
};
assertion = nesting.build(elem, factory);
} else if (EXACTLYONCE_NAME.equals(lname)) {
assertion = new PrimitiveAssertion(EXACTLYONCE_QNAME, optional);
} else if (ATLEASTONCE_NAME.equals(lname)) {
assertion = new PrimitiveAssertion(ATLEASTONCE_QNAME, optional);
} else if (ATMOSTONCE_NAME.equals(lname)) {
assertion = new PrimitiveAssertion(ATMOSTONCE_QNAME, optional);
} else if (INORDER_NAME.equals(lname)) {
assertion = new PrimitiveAssertion(INORDER_QNAME, optional);
}
}
return assertion;
}
Aggregations