use of org.apache.neethi.PolicyContainingAssertion in project cxf by apache.
the class AssertionInfoMap method supportsAlternative.
public boolean supportsAlternative(PolicyComponent assertion, List<QName> errors) {
boolean pass = true;
if (assertion instanceof PolicyAssertion) {
PolicyAssertion a = (PolicyAssertion) assertion;
if (!a.isAsserted(this) && !a.isOptional()) {
errors.add(a.getName());
pass = false;
}
} else if (assertion instanceof Assertion) {
Assertion ass = (Assertion) assertion;
Collection<AssertionInfo> ail = getAssertionInfo(ass.getName());
boolean found = false;
for (AssertionInfo ai : ail) {
if (ai.getAssertion().equal(ass) || ai.getAssertion().equals(ass)) {
found = true;
if (!ai.isAsserted() && !ass.isOptional()) {
errors.add(ass.getName());
pass = false;
}
}
}
if (!found) {
errors.add(ass.getName());
return false;
}
}
if (assertion instanceof PolicyContainingAssertion) {
Policy p = ((PolicyContainingAssertion) assertion).getPolicy();
if (p != null) {
Iterator<List<Assertion>> alternatives = p.getAlternatives();
while (alternatives.hasNext()) {
List<Assertion> pc = alternatives.next();
for (Assertion p2 : pc) {
pass &= supportsAlternative(p2, errors);
}
}
}
}
return pass;
}
use of org.apache.neethi.PolicyContainingAssertion in project cxf by apache.
the class AssertionInfoMap method putAssertionInfo.
private void putAssertionInfo(Assertion a) {
if (a instanceof PolicyContainingAssertion) {
Policy p = ((PolicyContainingAssertion) a).getPolicy();
if (p != null) {
List<Assertion> pcs = new ArrayList<>();
getAssertions(p, pcs);
for (Assertion na : pcs) {
putAssertionInfo(na);
}
}
}
AssertionInfo ai = new AssertionInfo(a);
Collection<AssertionInfo> ail = get(a.getName());
if (ail == null) {
ail = new ArrayList<>();
put(a.getName(), ail);
}
for (AssertionInfo ai2 : ail) {
if (ai2.getAssertion() == a) {
return;
}
}
ail.add(ai);
}
use of org.apache.neethi.PolicyContainingAssertion in project cxf by apache.
the class EffectivePolicyImpl method initialiseInterceptors.
void initialiseInterceptors(PolicyInterceptorProviderRegistry reg, PolicyEngine engine, Set<Interceptor<? extends org.apache.cxf.message.Message>> out, Assertion a, boolean useIn, boolean fault, Message m) {
QName qn = a.getName();
List<Interceptor<? extends org.apache.cxf.message.Message>> i = null;
if (useIn && !fault) {
i = reg.getInInterceptorsForAssertion(qn);
} else if (!useIn && !fault) {
i = reg.getOutInterceptorsForAssertion(qn);
} else if (useIn && fault) {
i = reg.getInFaultInterceptorsForAssertion(qn);
} else if (!useIn && fault) {
i = reg.getOutFaultInterceptorsForAssertion(qn);
}
out.addAll(i);
if (a instanceof PolicyContainingAssertion) {
Policy p = ((PolicyContainingAssertion) a).getPolicy();
if (p != null) {
for (Assertion a2 : getSupportedAlternatives(engine, p, m)) {
initialiseInterceptors(reg, engine, out, a2, useIn, fault, m);
}
}
}
}
use of org.apache.neethi.PolicyContainingAssertion in project cxf by apache.
the class PolicyUtils method printPolicyComponent.
public static void printPolicyComponent(PolicyComponent pc, StringBuilder buf, int level) {
indent(buf, level);
buf.append("type: ");
buf.append(typeToString(pc.getType()));
if (Constants.TYPE_ASSERTION == pc.getType()) {
buf.append(" ");
buf.append(((Assertion) pc).getName());
if (((Assertion) pc).isOptional()) {
buf.append(" (optional)");
}
buf.append(" (");
buf.append(pc);
buf.append(")");
nl(buf);
if (pc instanceof PolicyContainingAssertion) {
PolicyComponent nested = ((PolicyContainingAssertion) pc).getPolicy();
level++;
printPolicyComponent(nested, buf, level);
level--;
}
} else {
level++;
List<PolicyComponent> children = CastUtils.cast(((PolicyOperator) pc).getPolicyComponents(), PolicyComponent.class);
nl(buf);
for (PolicyComponent child : children) {
printPolicyComponent(child, buf, level);
}
level--;
}
}
use of org.apache.neethi.PolicyContainingAssertion in project cxf by apache.
the class EndpointPolicyImpl method initializeInterceptors.
void initializeInterceptors(PolicyInterceptorProviderRegistry reg, Set<Interceptor<? extends Message>> out, Assertion a, boolean fault, Message msg) {
QName qn = a.getName();
List<Interceptor<? extends org.apache.cxf.message.Message>> i = fault ? reg.getInFaultInterceptorsForAssertion(qn) : reg.getInInterceptorsForAssertion(qn);
out.addAll(i);
if (a instanceof PolicyContainingAssertion) {
Policy p = ((PolicyContainingAssertion) a).getPolicy();
if (p != null) {
for (Assertion a2 : getSupportedAlternatives(p, msg)) {
initializeInterceptors(reg, out, a2, fault, msg);
}
}
}
}
Aggregations