Search in sources :

Example 31 with AssertionInfoMap

use of org.apache.cxf.ws.policy.AssertionInfoMap in project cxf by apache.

the class AbstractCommonBindingHandler method getWss10.

protected Wss10 getWss10() {
    AssertionInfoMap aim = message.get(AssertionInfoMap.class);
    AssertionInfo ai = PolicyUtils.getFirstAssertionByLocalname(aim, SPConstants.WSS10);
    if (ai == null) {
        ai = PolicyUtils.getFirstAssertionByLocalname(aim, SPConstants.WSS11);
    }
    if (ai != null) {
        return (Wss10) ai.getAssertion();
    }
    return null;
}
Also used : AssertionInfo(org.apache.cxf.ws.policy.AssertionInfo) Wss10(org.apache.wss4j.policy.model.Wss10) AssertionInfoMap(org.apache.cxf.ws.policy.AssertionInfoMap)

Example 32 with AssertionInfoMap

use of org.apache.cxf.ws.policy.AssertionInfoMap in project cxf by apache.

the class AbstractCommonBindingHandler method unassertPolicy.

protected void unassertPolicy(Assertion assertion, Exception reason) {
    if (assertion == null) {
        return;
    }
    if (LOG.isLoggable(Level.FINE)) {
        LOG.log(Level.FINE, "Not asserting " + assertion.getName() + ": " + reason);
    }
    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.getMessage());
            }
        }
    }
    if (!assertion.isOptional()) {
        throw new PolicyException(new Message(reason.getMessage(), LOG), reason);
    }
}
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 33 with AssertionInfoMap

use of org.apache.cxf.ws.policy.AssertionInfoMap in project cxf by apache.

the class AbstractCommonBindingHandler method assertAlgorithmSuite.

protected void assertAlgorithmSuite(AlgorithmSuite algorithmSuite) {
    if (algorithmSuite == null) {
        return;
    }
    AssertionInfoMap aim = message.get(AssertionInfoMap.class);
    Collection<AssertionInfo> algorithmSuiteAis = aim.get(algorithmSuite.getName());
    for (AssertionInfo ai : algorithmSuiteAis) {
        ai.setAsserted(true);
    }
    AlgorithmSuiteType algorithmSuiteType = algorithmSuite.getAlgorithmSuiteType();
    String namespace = algorithmSuiteType.getNamespace();
    if (namespace != null) {
        Collection<AssertionInfo> algAis = aim.get(new QName(namespace, algorithmSuiteType.getName()));
        if (algAis != null) {
            for (AssertionInfo algAi : algAis) {
                algAi.setAsserted(true);
            }
        }
    }
}
Also used : AssertionInfo(org.apache.cxf.ws.policy.AssertionInfo) AlgorithmSuiteType(org.apache.wss4j.policy.model.AlgorithmSuite.AlgorithmSuiteType) QName(javax.xml.namespace.QName) AssertionInfoMap(org.apache.cxf.ws.policy.AssertionInfoMap)

Example 34 with AssertionInfoMap

use of org.apache.cxf.ws.policy.AssertionInfoMap 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);
    }
}
Also used : AssertionInfo(org.apache.cxf.ws.policy.AssertionInfo) QName(javax.xml.namespace.QName) Collection(java.util.Collection) AssertionInfoMap(org.apache.cxf.ws.policy.AssertionInfoMap)

Example 35 with AssertionInfoMap

use of org.apache.cxf.ws.policy.AssertionInfoMap in project cxf by apache.

the class AbstractRMInterceptorTest method testAssertReliability.

@Test
public void testAssertReliability() {
    RMInterceptor interceptor = new RMInterceptor();
    Message message = control.createMock(Message.class);
    EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(null);
    AssertionInfoMap aim = control.createMock(AssertionInfoMap.class);
    Collection<AssertionInfo> ais = new ArrayList<>();
    EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(aim).times(2);
    PolicyAssertion a = control.createMock(PolicyAssertion.class);
    AssertionInfo ai = new AssertionInfo(a);
    EasyMock.expectLastCall();
    control.replay();
    interceptor.assertReliability(message);
    assertFalse(ai.isAsserted());
    aim.put(RM10Constants.RMASSERTION_QNAME, ais);
    interceptor.assertReliability(message);
    assertFalse(ai.isAsserted());
    ais.add(ai);
    interceptor.assertReliability(message);
}
Also used : PolicyAssertion(org.apache.cxf.ws.policy.PolicyAssertion) AssertionInfo(org.apache.cxf.ws.policy.AssertionInfo) Message(org.apache.cxf.message.Message) ArrayList(java.util.ArrayList) AssertionInfoMap(org.apache.cxf.ws.policy.AssertionInfoMap) Test(org.junit.Test)

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