Search in sources :

Example 71 with Bus

use of org.apache.cxf.Bus in project cxf by apache.

the class ClaimsTest method testSaml2Claims.

@org.junit.Test
public void testSaml2Claims() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = ClaimsTest.class.getResource("cxf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = ClaimsTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML2ClaimsPort");
    DoubleItPortType transportClaimsPort = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(transportClaimsPort, test.getPort());
    TokenTestUtils.updateSTSPort((BindingProvider) transportClaimsPort, test.getStsPort());
    if (test.isStreaming()) {
        SecurityTestUtil.enableStreaming(transportClaimsPort);
    }
    doubleIt(transportClaimsPort, 25);
    ((java.io.Closeable) transportClaimsPort).close();
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) DoubleItPortType(org.example.contract.doubleit.DoubleItPortType) URL(java.net.URL)

Example 72 with Bus

use of org.apache.cxf.Bus in project cxf by apache.

the class ClaimsTest method testSaml2ClaimsCallbackHandler.

// In this test, the WSDL the client is using has no Claims Element (however the service
// is using a WSDL that requires Claims). A CallbackHandler is used to send the Claims
// Element to the STS.
@org.junit.Test
public void testSaml2ClaimsCallbackHandler() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = ClaimsTest.class.getResource("cxf-client-cbhandler.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = ClaimsTest.class.getResource("DoubleItNoClaims.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML2ClaimsPort");
    DoubleItPortType transportClaimsPort = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(transportClaimsPort, test.getPort());
    TokenTestUtils.updateSTSPort((BindingProvider) transportClaimsPort, test.getStsPort());
    if (test.isStreaming()) {
        SecurityTestUtil.enableStreaming(transportClaimsPort);
    }
    doubleIt(transportClaimsPort, 25);
    ((java.io.Closeable) transportClaimsPort).close();
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) DoubleItPortType(org.example.contract.doubleit.DoubleItPortType) URL(java.net.URL)

Example 73 with Bus

use of org.apache.cxf.Bus in project cxf by apache.

the class CrossDomainTest method testCrossDomain.

// In this test, a CXF client checks to see that the location defined on its STSClient is different
// from that configured in the Issuer of the IssuedToken policy supplied in the WSDL of the
// service provider. It obtains a SAML Token from the configured STS first, and then sends it in
// the security header to the second STS. The returned token is then sent to the service provider.
// This illustrates cross-domain SSO: https://issues.apache.org/jira/browse/CXF-3520
@org.junit.Test
@org.junit.Ignore
public void testCrossDomain() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = CrossDomainTest.class.getResource("cxf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = CrossDomainTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItCrossDomainPort");
    DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(transportPort, PORT);
    // Transport port
    doubleIt(transportPort, 25);
    ((java.io.Closeable) transportPort).close();
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) DoubleItPortType(org.example.contract.doubleit.DoubleItPortType) URL(java.net.URL)

Example 74 with Bus

use of org.apache.cxf.Bus in project cxf by apache.

the class CrossDomainTest method testCrossDomainMEX.

// The Service references STS "b". The WSDL of STS "b" has an IssuedToken that references STS "a".
// So the client gets the WSDL of "b" via WS-MEX, which in turn has an IssuedToken policy.
// The client has a configured STSClient for this + uses it to get a token from "a", and in
// turn to use the returned token to get a token from "b", to access the service.
@org.junit.Test
public void testCrossDomainMEX() throws Exception {
    if (!portFree) {
        return;
    }
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = CrossDomainTest.class.getResource("cxf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = CrossDomainTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItCrossDomainMEXPort");
    DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(transportPort, PORT);
    // Transport port
    doubleIt(transportPort, 25);
    ((java.io.Closeable) transportPort).close();
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) DoubleItPortType(org.example.contract.doubleit.DoubleItPortType) URL(java.net.URL)

Example 75 with Bus

use of org.apache.cxf.Bus in project cxf by apache.

the class STSServer2 method run.

protected void run() {
    URL busFile = STSServer2.class.getResource("cxf-sts-saml2.xml");
    Bus busLocal = new SpringBusFactory().createBus(busFile);
    BusFactory.setDefaultBus(busLocal);
    setBus(busLocal);
    try {
        new STSServer2();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) URL(java.net.URL)

Aggregations

Bus (org.apache.cxf.Bus)1144 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)800 URL (java.net.URL)748 QName (javax.xml.namespace.QName)436 Service (javax.xml.ws.Service)400 DoubleItPortType (org.example.contract.doubleit.DoubleItPortType)354 Test (org.junit.Test)219 HashMap (java.util.HashMap)63 Message (org.apache.cxf.message.Message)60 WebClient (org.apache.cxf.jaxrs.client.WebClient)50 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)48 Client (org.apache.cxf.endpoint.Client)43 Greeter (org.apache.hello_world.Greeter)42 SecurityToken (org.apache.cxf.ws.security.tokenstore.SecurityToken)41 SOAPService (org.apache.hello_world.services.SOAPService)41 JAXRSClientFactoryBean (org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean)40 Endpoint (org.apache.cxf.endpoint.Endpoint)38 ExtensionManagerBus (org.apache.cxf.bus.extension.ExtensionManagerBus)36 STSClient (org.apache.cxf.ws.security.trust.STSClient)36 Document (org.w3c.dom.Document)36