use of org.apache.cxf.ws.policy.AssertionInfoMap in project tesb-rt-se by Talend.
the class CompressionPolicyBuilderTest method testCompressionPolicyBuilder.
@Test
public void testCompressionPolicyBuilder() {
Collection<Assertion> c = new ArrayList<Assertion>();
AssertionInfoMap aim = new AssertionInfoMap(c);
Message m = CompressionCommonTest.getMessageStub(aim, null);
try {
assertNull(CompressionPolicyBuilder.getAssertion(m));
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ParserConfigurationException e) {
e.printStackTrace();
}
}
use of org.apache.cxf.ws.policy.AssertionInfoMap in project cxf by apache.
the class AbstractTokenInterceptor method policyNotAsserted.
protected void policyNotAsserted(AbstractToken assertion, String reason, SoapMessage message) {
if (assertion == null) {
return;
}
AssertionInfoMap aim = message.get(AssertionInfoMap.class);
Collection<AssertionInfo> ais = aim.get(assertion.getName());
if (ais != null) {
for (AssertionInfo ai : ais) {
if (ai.getAssertion() == assertion) {
ai.setNotAsserted(reason);
}
}
}
if (!assertion.isOptional()) {
throw new PolicyException(new Message(reason, LOG));
}
}
use of org.apache.cxf.ws.policy.AssertionInfoMap in project cxf by apache.
the class AbstractTokenInterceptor method assertTokens.
protected AbstractToken assertTokens(SoapMessage message, String localname, boolean signed) {
AssertionInfoMap aim = message.get(AssertionInfoMap.class);
Collection<AssertionInfo> ais = PolicyUtils.getAllAssertionsByLocalname(aim, localname);
AbstractToken tok = null;
for (AssertionInfo ai : ais) {
tok = (AbstractToken) ai.getAssertion();
ai.setAsserted(true);
}
PolicyUtils.assertPolicy(aim, SPConstants.SUPPORTING_TOKENS);
if (signed || isTLSInUse(message)) {
PolicyUtils.assertPolicy(aim, SPConstants.SIGNED_SUPPORTING_TOKENS);
}
return tok;
}
use of org.apache.cxf.ws.policy.AssertionInfoMap in project cxf by apache.
the class PolicyBasedWSS4JInInterceptor method handleMessage.
public void handleMessage(SoapMessage msg) throws Fault {
AssertionInfoMap aim = msg.get(AssertionInfoMap.class);
boolean enableStax = MessageUtils.getContextualBoolean(msg, SecurityConstants.ENABLE_STREAMING_SECURITY);
if (aim != null && !enableStax && !msg.containsKey(SECURITY_PROCESSED) && !isGET(msg) && msg.getExchange() != null) {
try {
// First check to see if we have a security header before we apply the SAAJInInterceptor
// If there is no security header then we can just assert the policies and proceed
String actor = (String) getOption(ConfigurationConstants.ACTOR);
if (actor == null) {
actor = (String) msg.getContextualProperty(SecurityConstants.ACTOR);
}
if (!containsSecurityHeader(msg, actor, msg.getVersion().getVersion() != 1.1)) {
LOG.fine("The request contains no security header, so the SAAJInInterceptor is not applied");
computeAction(msg, new RequestData());
boolean utWithCallbacks = MessageUtils.getContextualBoolean(msg, SecurityConstants.VALIDATE_TOKEN, true);
doResults(msg, actor, null, null, new WSHandlerResult(actor, Collections.emptyList(), Collections.emptyMap()), utWithCallbacks);
msg.put(SECURITY_PROCESSED, Boolean.TRUE);
return;
}
} catch (WSSecurityException e) {
throw WSS4JUtils.createSoapFault(msg, msg.getVersion(), e);
} catch (XMLStreamException e) {
throw new SoapFault(new Message("STAX_EX", LOG), e, msg.getVersion().getSender());
} catch (SOAPException e) {
throw new SoapFault(new Message("SAAJ_EX", LOG), e, msg.getVersion().getSender());
}
super.handleMessage(msg);
}
}
use of org.apache.cxf.ws.policy.AssertionInfoMap in project cxf by apache.
the class KerberosTokenInterceptor method assertTokens.
protected AbstractToken assertTokens(SoapMessage message) {
AssertionInfoMap aim = message.get(AssertionInfoMap.class);
PolicyUtils.assertPolicy(aim, "WssKerberosV5ApReqToken11");
PolicyUtils.assertPolicy(aim, "WssGssKerberosV5ApReqToken11");
return assertTokens(message, SPConstants.KERBEROS_TOKEN, false);
}
Aggregations