Search in sources :

Example 6 with AssertionInfoMap

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();
    }
}
Also used : Message(org.apache.cxf.message.Message) Assertion(org.apache.neethi.Assertion) ArrayList(java.util.ArrayList) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) AssertionInfoMap(org.apache.cxf.ws.policy.AssertionInfoMap) SAXException(org.xml.sax.SAXException) Test(org.junit.Test)

Example 7 with AssertionInfoMap

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));
    }
}
Also used : AssertionInfo(org.apache.cxf.ws.policy.AssertionInfo) Message(org.apache.cxf.common.i18n.Message) SoapMessage(org.apache.cxf.binding.soap.SoapMessage) PolicyException(org.apache.cxf.ws.policy.PolicyException) AssertionInfoMap(org.apache.cxf.ws.policy.AssertionInfoMap)

Example 8 with AssertionInfoMap

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;
}
Also used : AssertionInfo(org.apache.cxf.ws.policy.AssertionInfo) AbstractToken(org.apache.wss4j.policy.model.AbstractToken) AssertionInfoMap(org.apache.cxf.ws.policy.AssertionInfoMap)

Example 9 with AssertionInfoMap

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);
    }
}
Also used : SoapFault(org.apache.cxf.binding.soap.SoapFault) XMLStreamException(javax.xml.stream.XMLStreamException) Message(org.apache.cxf.common.i18n.Message) SoapMessage(org.apache.cxf.binding.soap.SoapMessage) RequestData(org.apache.wss4j.dom.handler.RequestData) SOAPException(javax.xml.soap.SOAPException) WSSecurityException(org.apache.wss4j.common.ext.WSSecurityException) WSHandlerResult(org.apache.wss4j.dom.handler.WSHandlerResult) AssertionInfoMap(org.apache.cxf.ws.policy.AssertionInfoMap)

Example 10 with AssertionInfoMap

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);
}
Also used : AssertionInfoMap(org.apache.cxf.ws.policy.AssertionInfoMap)

Aggregations

AssertionInfoMap (org.apache.cxf.ws.policy.AssertionInfoMap)65 AssertionInfo (org.apache.cxf.ws.policy.AssertionInfo)44 QName (javax.xml.namespace.QName)15 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)12 Message (org.apache.cxf.message.Message)10 ArrayList (java.util.ArrayList)9 PolicyException (org.apache.cxf.ws.policy.PolicyException)7 Fault (org.apache.cxf.interceptor.Fault)6 WSSecurityException (org.apache.wss4j.common.ext.WSSecurityException)6 Element (org.w3c.dom.Element)6 Exchange (org.apache.cxf.message.Exchange)5 TokenStoreException (org.apache.cxf.ws.security.tokenstore.TokenStoreException)5 Policy (org.apache.neethi.Policy)5 Message (org.apache.cxf.common.i18n.Message)4 SecurityToken (org.apache.cxf.ws.security.tokenstore.SecurityToken)4 SamlAssertionWrapper (org.apache.wss4j.common.saml.SamlAssertionWrapper)4 SOAPException (javax.xml.soap.SOAPException)3 Header (org.apache.cxf.headers.Header)3 PolicyAssertion (org.apache.cxf.ws.policy.PolicyAssertion)3 WSSecUsernameToken (org.apache.wss4j.dom.message.WSSecUsernameToken)3