use of org.apache.neethi.Assertion 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.Assertion 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.Assertion 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.Assertion in project cxf by apache.
the class EffectivePolicyImpl method initialiseInterceptors.
void initialiseInterceptors(PolicyEngine engine, boolean useIn, boolean fault, Message m) {
if (((PolicyEngineImpl) engine).getBus() != null) {
PolicyInterceptorProviderRegistry reg = ((PolicyEngineImpl) engine).getBus().getExtension(PolicyInterceptorProviderRegistry.class);
Set<Interceptor<? extends org.apache.cxf.message.Message>> out = new LinkedHashSet<>();
for (Assertion a : getChosenAlternative()) {
initialiseInterceptors(reg, engine, out, a, useIn, fault, m);
}
setInterceptors(new ArrayList<Interceptor<? extends org.apache.cxf.message.Message>>(out));
}
}
use of org.apache.neethi.Assertion in project cxf by apache.
the class EndpointPolicyImpl method initializeInterceptors.
synchronized void initializeInterceptors(Message m) {
if (interceptors != null) {
return;
}
if (engine == null || engine.getBus() == null || engine.getBus().getExtension(PolicyInterceptorProviderRegistry.class) == null) {
return;
}
PolicyInterceptorProviderRegistry reg = engine.getBus().getExtension(PolicyInterceptorProviderRegistry.class);
Set<Interceptor<? extends Message>> out = new LinkedHashSet<>();
if (getChosenAlternative() != null) {
for (Assertion a : getChosenAlternative()) {
initializeInterceptors(reg, out, a, false, m);
}
}
final List<Interceptor<? extends Message>> tmp;
if (requestor) {
tmp = new ArrayList<>(out);
out.clear();
for (Assertion a : getChosenAlternative()) {
initializeInterceptors(reg, out, a, true, m);
}
faultInterceptors = new ArrayList<>(out);
} else if (ei != null && ei.getBinding() != null) {
for (BindingOperationInfo boi : ei.getBinding().getOperations()) {
EffectivePolicy p = engine.getEffectiveServerRequestPolicy(ei, boi, m);
if (p == null || p.getPolicy() == null || p.getPolicy().isEmpty()) {
continue;
}
Collection<Assertion> c = engine.getAssertions(p, true);
if (c != null) {
for (Assertion a : c) {
initializeInterceptors(reg, out, a, false, m);
initializeInterceptors(reg, out, a, true, m);
}
}
}
tmp = new ArrayList<>(out);
} else {
tmp = new ArrayList<>(out);
}
interceptors = tmp;
}
Aggregations