Search in sources :

Example 66 with Bus

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

the class BinarySecurityTokenTest method testBadBinarySecurityToken.

@org.junit.Test
public void testBadBinarySecurityToken() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = BinarySecurityTokenTest.class.getResource("cxf-bad-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = BinarySecurityTokenTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricBSTPort");
    DoubleItPortType asymmetricBSTPort = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(asymmetricBSTPort, test.getPort());
    if (test.isStreaming()) {
        SecurityTestUtil.enableStreaming(asymmetricBSTPort);
    }
    try {
        doubleIt(asymmetricBSTPort, 30);
        fail("Expected failure on a bad cert");
    } catch (javax.xml.ws.soap.SOAPFaultException fault) {
    // expected
    }
    ((java.io.Closeable) asymmetricBSTPort).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 67 with Bus

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

the class BinarySecurityTokenTest method testBinarySecurityToken.

@org.junit.Test
public void testBinarySecurityToken() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = BinarySecurityTokenTest.class.getResource("cxf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = BinarySecurityTokenTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricBSTPort");
    DoubleItPortType asymmetricBSTPort = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(asymmetricBSTPort, test.getPort());
    if (test.isStreaming()) {
        SecurityTestUtil.enableStreaming(asymmetricBSTPort);
    }
    doubleIt(asymmetricBSTPort, 25);
    ((java.io.Closeable) asymmetricBSTPort).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 68 with Bus

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

the class Server method run.

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

Example 69 with Bus

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

the class CachingTest method testImminentExpiry.

@org.junit.Test
public void testImminentExpiry() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = CachingTest.class.getResource("cxf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = CachingTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML1Port");
    DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
    ((BindingProvider) port).getRequestContext().put("thread.local.request.context", "true");
    updateAddressPort(port, PORT);
    // Make a successful invocation
    doubleIt(port, 25);
    Client client = ClientProxy.getClient(port);
    Endpoint ep = client.getEndpoint();
    String id = (String) ep.get(SecurityConstants.TOKEN_ID);
    TokenStore store = (TokenStore) ep.getEndpointInfo().getProperty(TokenStore.class.getName());
    SecurityToken tok = store.getToken(id);
    assertNotNull(tok);
    // Make the token "about to expire"
    tok.setExpires(Instant.now().plusSeconds(5L));
    assertTrue(tok.isAboutToExpire(10L));
    doubleIt(port, 25);
    ((java.io.Closeable) port).close();
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) URL(java.net.URL) SecurityToken(org.apache.cxf.ws.security.tokenstore.SecurityToken) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) Endpoint(org.apache.cxf.endpoint.Endpoint) DoubleItPortType(org.example.contract.doubleit.DoubleItPortType) Client(org.apache.cxf.endpoint.Client) STSClient(org.apache.cxf.ws.security.trust.STSClient) TokenStore(org.apache.cxf.ws.security.tokenstore.TokenStore)

Example 70 with Bus

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

the class Server method run.

protected void run() {
    URL busFile = Server.class.getResource("cxf-service.xml");
    Bus busLocal = new SpringBusFactory().createBus(busFile);
    BusFactory.setDefaultBus(busLocal);
    setBus(busLocal);
    try {
        new Server();
    } 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