use of org.apache.cxf.ws.policy.AssertionInfo in project cxf by apache.
the class AbstractRMInterceptor method assertReliability.
/**
* Asserts all RMAssertion assertions for the current message, regardless their attributes
* (if there is more than one we have ensured that they are all supported by considering
* e.g. the minimum acknowledgment interval).
* @param message the current message
*/
void assertReliability(Message message) {
AssertionInfoMap aim = message.get(AssertionInfoMap.class);
Collection<AssertionInfo> ais = RMPolicyUtilities.collectRMAssertions(aim);
for (AssertionInfo ai : ais) {
ai.setAsserted(true);
}
}
use of org.apache.cxf.ws.policy.AssertionInfo in project cxf by apache.
the class AbstractPolicySecurityTest method runOutInterceptorAndValidate.
protected Document runOutInterceptorAndValidate(SoapMessage msg, Policy policy, AssertionInfoMap aim, List<QName> assertedOutAssertions, List<QName> notAssertedOutAssertions) throws Exception {
if (msg.getExchange().getEndpoint() != null && msg.getExchange().getEndpoint().getEndpointInfo().getProperty(TokenStore.class.getName()) == null) {
msg.put(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, new MemoryTokenStore());
}
this.getOutInterceptor().handleMessage(msg);
try {
aim.checkEffectivePolicy(policy);
} catch (PolicyException e) {
// Expected but not relevant
} finally {
if (assertedOutAssertions != null) {
for (QName assertionType : assertedOutAssertions) {
Collection<AssertionInfo> ais = aim.get(assertionType);
assertNotNull(ais);
for (AssertionInfo ai : ais) {
checkAssertion(aim, assertionType, ai, true);
}
}
}
if (notAssertedOutAssertions != null) {
for (QName assertionType : notAssertedOutAssertions) {
Collection<AssertionInfo> ais = aim.get(assertionType);
assertNotNull(ais);
for (AssertionInfo ai : ais) {
checkAssertion(aim, assertionType, ai, false);
}
}
}
}
return msg.getContent(SOAPMessage.class).getSOAPPart();
}
use of org.apache.cxf.ws.policy.AssertionInfo in project cxf by apache.
the class AbstractPolicySecurityTest method checkAssertion.
protected void checkAssertion(AssertionInfoMap aim, QName name, AssertionInfo inf, boolean asserted) {
boolean pass = true;
Collection<AssertionInfo> ail = aim.getAssertionInfo(name);
for (AssertionInfo ai : ail) {
if (ai.getAssertion().equal(inf.getAssertion()) && !ai.isAsserted() && !inf.getAssertion().isOptional()) {
pass = false;
}
}
if (asserted) {
assertTrue(name + " policy erroneously failed.", pass);
} else {
assertFalse(name + " policy erroneously asserted.", pass);
}
}
use of org.apache.cxf.ws.policy.AssertionInfo in project tdi-studio-se by Talend.
the class WspPolicyInterceptor method handleMessage.
public void handleMessage(SoapMessage message) throws Fault {
AssertionInfoMap aim = (AssertionInfoMap) message.get(AssertionInfoMap.class);
if (null == aim) {
return;
}
QName qname = QNamesCollection.POLICY_WSP;
Collection<AssertionInfo> ais = (Collection<AssertionInfo>) aim.get(qname);
if ((null == ais) || (ais.size() == 0)) {
return;
}
for (AssertionInfo ai : ais) {
ai.setAsserted(true);
}
}
use of org.apache.cxf.ws.policy.AssertionInfo in project cxf by apache.
the class PolicyUtilsTest method testAssertClientPolicy.
void testAssertClientPolicy(boolean outbound) {
Message message = control.createMock(Message.class);
HTTPClientPolicy ep = new HTTPClientPolicy();
HTTPClientPolicy cmp = new HTTPClientPolicy();
cmp.setConnectionTimeout(60000L);
HTTPClientPolicy icmp = new HTTPClientPolicy();
icmp.setAllowChunking(false);
AssertionInfo eai = getClientPolicyAssertionInfo(ep);
AssertionInfo cmai = getClientPolicyAssertionInfo(cmp);
AssertionInfo icmai = getClientPolicyAssertionInfo(icmp);
AssertionInfoMap aim = new AssertionInfoMap(CastUtils.cast(Collections.EMPTY_LIST, PolicyAssertion.class));
Collection<AssertionInfo> ais = new ArrayList<>();
ais.add(eai);
ais.add(cmai);
ais.add(icmai);
aim.put(new ClientPolicyCalculator().getDataClassName(), ais);
EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(aim);
Exchange ex = control.createMock(Exchange.class);
EasyMock.expect(message.getExchange()).andReturn(ex).atLeastOnce();
EasyMock.expect(ex.getOutMessage()).andReturn(outbound ? message : null).atLeastOnce();
if (!outbound) {
EasyMock.expect(ex.getOutFaultMessage()).andReturn(null).atLeastOnce();
}
control.replay();
PolicyDataEngine pde = new PolicyDataEngineImpl(null);
pde.assertMessage(message, ep, new ClientPolicyCalculator());
assertTrue(eai.isAsserted());
assertTrue(cmai.isAsserted());
assertTrue(icmai.isAsserted());
control.verify();
}
Aggregations