Search in sources :

Example 1 with Assertion

use of org.apache.neethi.Assertion in project tesb-rt-se by Talend.

the class SamEnablingInterceptorProviderTest method createSamlAssertion.

public List<Assertion> createSamlAssertion(String appliesTo) throws Exception {
    List<Assertion> assertions = new ArrayList<Assertion>();
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = dbf.newDocumentBuilder();
    Document doc = builder.newDocument();
    Element element = doc.createElement("root");
    doc.appendChild(element);
    element.setAttribute("appliesTo", appliesTo);
    assertions.add(new SamEnablingPolicy(element));
    return assertions;
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) SamEnablingPolicy(org.talend.esb.policy.samenabling.SamEnablingPolicy) Element(org.w3c.dom.Element) Assertion(org.apache.neethi.Assertion) ArrayList(java.util.ArrayList) Document(org.w3c.dom.Document)

Example 2 with Assertion

use of org.apache.neethi.Assertion in project tesb-rt-se by Talend.

the class CompressionOutInterceptor method handleMessage.

public void handleMessage(Message message) throws Fault {
    try {
        // Load threshold value from policy assertion
        AssertionInfo ai = CompressionPolicyBuilder.getAssertion(message);
        if (ai != null) {
            Assertion a = ai.getAssertion();
            if (a instanceof CompressionAssertion) {
                this.setThreshold(((CompressionAssertion) a).getThreshold());
            }
        }
        wrapOriginalOutputStream(message);
        // Confirm policy processing
        if (ai != null) {
            ai.setAsserted(true);
        }
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        throw new Fault(e);
    }
}
Also used : AssertionInfo(org.apache.cxf.ws.policy.AssertionInfo) Assertion(org.apache.neethi.Assertion) Fault(org.apache.cxf.interceptor.Fault) XMLStreamException(javax.xml.stream.XMLStreamException) IOException(java.io.IOException)

Example 3 with Assertion

use of org.apache.neethi.Assertion 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 4 with Assertion

use of org.apache.neethi.Assertion in project cxf by apache.

the class HTTPClientAssertionBuilderTest method testBuildAssertion.

@Test
public void testBuildAssertion() throws Exception {
    HTTPClientAssertionBuilder ab = new HTTPClientAssertionBuilder();
    Assertion a = ab.buildAssertion();
    assertTrue(a instanceof JaxbAssertion);
    assertTrue(a instanceof HTTPClientAssertionBuilder.HTTPClientPolicyAssertion);
    assertEquals(new ClientPolicyCalculator().getDataClassName(), a.getName());
    assertFalse(a.isOptional());
}
Also used : JaxbAssertion(org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion) Assertion(org.apache.neethi.Assertion) JaxbAssertion(org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion) ClientPolicyCalculator(org.apache.cxf.transport.http.policy.impl.ClientPolicyCalculator) Test(org.junit.Test)

Example 5 with Assertion

use of org.apache.neethi.Assertion in project cxf by apache.

the class SpnegoContextTokenInInterceptor method handleMessage.

public void handleMessage(SoapMessage message) throws Fault {
    AssertionInfoMap aim = message.get(AssertionInfoMap.class);
    // extract Assertion information
    if (aim != null) {
        Collection<AssertionInfo> ais = PolicyUtils.getAllAssertionsByLocalname(aim, SPConstants.SPNEGO_CONTEXT_TOKEN);
        if (ais.isEmpty()) {
            return;
        }
        if (isRequestor(message)) {
            // client side should be checked on the way out
            for (AssertionInfo ai : ais) {
                ai.setAsserted(true);
            }
            return;
        }
        String s = (String) message.get(SoapBindingConstants.SOAP_ACTION);
        if (s == null) {
            s = SoapActionInInterceptor.getSoapAction(message);
        }
        AddressingProperties inProps = (AddressingProperties) message.getContextualProperty(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND);
        if (inProps != null && s == null) {
            // MS/WCF doesn't put a soap action out for this, must check the headers
            s = inProps.getAction().getValue();
        }
        if (s != null && s.contains("/RST/Issue") && (s.startsWith(STSUtils.WST_NS_05_02) || s.startsWith(STSUtils.WST_NS_05_12))) {
            Policy p = new Policy();
            ExactlyOne ea = new ExactlyOne();
            p.addPolicyComponent(ea);
            All all = new All();
            Assertion ass = NegotiationUtils.getAddressingPolicy(aim, false);
            all.addPolicyComponent(ass);
            ea.addPolicyComponent(all);
            // setup endpoint and forward to it.
            unmapSecurityProps(message);
            String ns = STSUtils.WST_NS_05_12;
            if (s.startsWith(STSUtils.WST_NS_05_02)) {
                ns = STSUtils.WST_NS_05_02;
            }
            NegotiationUtils.recalcEffectivePolicy(message, ns, p, new SpnegoSTSInvoker(), false);
        } else {
            message.getInterceptorChain().add(SpnegoContextTokenFinderInterceptor.INSTANCE);
        }
    }
}
Also used : Policy(org.apache.neethi.Policy) All(org.apache.neethi.All) AssertionInfo(org.apache.cxf.ws.policy.AssertionInfo) Assertion(org.apache.neethi.Assertion) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) ExactlyOne(org.apache.neethi.ExactlyOne) AssertionInfoMap(org.apache.cxf.ws.policy.AssertionInfoMap)

Aggregations

Assertion (org.apache.neethi.Assertion)64 Policy (org.apache.neethi.Policy)27 Message (org.apache.cxf.message.Message)25 Test (org.junit.Test)25 ArrayList (java.util.ArrayList)23 QName (javax.xml.namespace.QName)21 Interceptor (org.apache.cxf.interceptor.Interceptor)19 PrimitiveAssertion (org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion)19 PolicyContainingAssertion (org.apache.neethi.PolicyContainingAssertion)9 Element (org.w3c.dom.Element)9 MessageImpl (org.apache.cxf.message.MessageImpl)7 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)7 All (org.apache.neethi.All)7 ExactlyOne (org.apache.neethi.ExactlyOne)7 Bus (org.apache.cxf.Bus)6 InterceptorChain (org.apache.cxf.interceptor.InterceptorChain)6 PolicyEngine (org.apache.cxf.ws.policy.PolicyEngine)6 PolicyContainingPrimitiveAssertion (org.apache.neethi.builders.PolicyContainingPrimitiveAssertion)6 XMLPrimitiveAssertionBuilder (org.apache.neethi.builders.xml.XMLPrimitiveAssertionBuilder)6 List (java.util.List)5