Search in sources :

Example 56 with SpringBusFactory

use of org.apache.cxf.bus.spring.SpringBusFactory in project cxf by apache.

the class SSLv3Test method testClientSSL3Allowed.

@org.junit.Test
public void testClientSSL3Allowed() throws Exception {
    // Doesn't work with IBM JDK
    if ("IBM Corporation".equals(System.getProperty("java.vendor"))) {
        return;
    }
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = SSLv3Test.class.getResource("sslv3-client-allow.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL url = SOAPService.WSDL_LOCATION;
    SOAPService service = new SOAPService(url, SOAPService.SERVICE);
    assertNotNull("Service is null", service);
    final Greeter port = service.getHttpsPort();
    assertNotNull("Port is null", port);
    updateAddressPort(port, PORT3);
    assertEquals(port.greetMe("Kitty"), "Hello Kitty");
    ((java.io.Closeable) port).close();
    bus.shutdown(true);
}
Also used : SOAPService(org.apache.hello_world.services.SOAPService) Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) Greeter(org.apache.hello_world.Greeter) URL(java.net.URL)

Example 57 with SpringBusFactory

use of org.apache.cxf.bus.spring.SpringBusFactory in project cxf by apache.

the class SSLv3Test method testAsyncClientSSL3NotAllowed.

@org.junit.Test
public void testAsyncClientSSL3NotAllowed() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = SSLv3Test.class.getResource("sslv3-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL url = SOAPService.WSDL_LOCATION;
    SOAPService service = new SOAPService(url, SOAPService.SERVICE);
    assertNotNull("Service is null", service);
    final Greeter port = service.getHttpsPort();
    assertNotNull("Port is null", port);
    // Enable Async
    ((BindingProvider) port).getRequestContext().put("use.async.http.conduit", true);
    updateAddressPort(port, PORT3);
    try {
        port.greetMe("Kitty");
        fail("Failure expected on the client not supporting SSLv3 by default");
    } catch (Exception ex) {
    // expected
    }
    ((java.io.Closeable) port).close();
    bus.shutdown(true);
}
Also used : SOAPService(org.apache.hello_world.services.SOAPService) Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) Greeter(org.apache.hello_world.Greeter) URL(java.net.URL) IOException(java.io.IOException)

Example 58 with SpringBusFactory

use of org.apache.cxf.bus.spring.SpringBusFactory in project cxf by apache.

the class SSLv3Test method testSSLv3ServerAllowed.

@org.junit.Test
public void testSSLv3ServerAllowed() throws Exception {
    // Doesn't work with IBM JDK
    if ("IBM Corporation".equals(System.getProperty("java.vendor"))) {
        return;
    }
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = SSLv3Test.class.getResource("sslv3-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    System.setProperty("https.protocols", "SSLv3");
    URL service = new URL("https://localhost:" + PORT2);
    HttpsURLConnection connection = (HttpsURLConnection) service.openConnection();
    connection.setHostnameVerifier(new DisableCNCheckVerifier());
    SSLContext sslContext = SSLContext.getInstance("SSL");
    KeyStore trustedCertStore = KeyStore.getInstance("jks");
    try (InputStream keystore = ClassLoaderUtils.getResourceAsStream("keys/Truststore.jks", SSLv3Test.class)) {
        trustedCertStore.load(keystore, null);
    }
    TrustManagerFactory tmf = TrustManagerFactory.getInstance("PKIX");
    tmf.init(trustedCertStore);
    TrustManager[] trustManagers = tmf.getTrustManagers();
    sslContext.init(null, trustManagers, new java.security.SecureRandom());
    connection.setSSLSocketFactory(sslContext.getSocketFactory());
    connection.connect();
    connection.disconnect();
    System.clearProperty("https.protocols");
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) InputStream(java.io.InputStream) SSLContext(javax.net.ssl.SSLContext) KeyStore(java.security.KeyStore) URL(java.net.URL) TrustManager(javax.net.ssl.TrustManager) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) TrustManagerFactory(javax.net.ssl.TrustManagerFactory) HttpsURLConnection(javax.net.ssl.HttpsURLConnection)

Example 59 with SpringBusFactory

use of org.apache.cxf.bus.spring.SpringBusFactory in project cxf by apache.

the class CipherSuitesTest method testClientAESServerRC4IncludedAsync.

// Client only includes AES, server only includes RC4
@org.junit.Test
public void testClientAESServerRC4IncludedAsync() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = CipherSuitesTest.class.getResource("ciphersuites-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL url = SOAPService.WSDL_LOCATION;
    SOAPService service = new SOAPService(url, SOAPService.SERVICE);
    assertNotNull("Service is null", service);
    final Greeter port = service.getHttpsPort();
    assertNotNull("Port is null", port);
    // Enable Async
    ((BindingProvider) port).getRequestContext().put("use.async.http.conduit", true);
    updateAddressPort(port, PORT2);
    try {
        port.greetMe("Kitty");
        fail("Failure expected on not being able to negotiate a cipher suite");
    } catch (Exception ex) {
    // expected
    }
    ((java.io.Closeable) port).close();
    bus.shutdown(true);
}
Also used : SOAPService(org.apache.hello_world.services.SOAPService) Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) Greeter(org.apache.hello_world.Greeter) URL(java.net.URL) CertificateException(java.security.cert.CertificateException)

Example 60 with SpringBusFactory

use of org.apache.cxf.bus.spring.SpringBusFactory in project cxf by apache.

the class CipherSuitesTest method testClientAESServerNULLAsync.

// Client does not allow NULL
@org.junit.Test
public void testClientAESServerNULLAsync() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = CipherSuitesTest.class.getResource("ciphersuites-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL url = SOAPService.WSDL_LOCATION;
    SOAPService service = new SOAPService(url, SOAPService.SERVICE);
    assertNotNull("Service is null", service);
    final Greeter port = service.getHttpsPort();
    assertNotNull("Port is null", port);
    // Enable Async
    ((BindingProvider) port).getRequestContext().put("use.async.http.conduit", true);
    updateAddressPort(port, PORT3);
    try {
        port.greetMe("Kitty");
        fail("Failure expected on not being able to negotiate a cipher suite");
    } catch (Exception ex) {
    // expected
    }
    ((java.io.Closeable) port).close();
    bus.shutdown(true);
}
Also used : SOAPService(org.apache.hello_world.services.SOAPService) Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) Greeter(org.apache.hello_world.Greeter) URL(java.net.URL) CertificateException(java.security.cert.CertificateException)

Aggregations

SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)936 Bus (org.apache.cxf.Bus)859 URL (java.net.URL)773 QName (javax.xml.namespace.QName)394 Service (javax.xml.ws.Service)384 DoubleItPortType (org.example.contract.doubleit.DoubleItPortType)345 Test (org.junit.Test)123 Client (org.apache.cxf.endpoint.Client)83 Greeter (org.apache.hello_world.Greeter)64 SOAPService (org.apache.hello_world.services.SOAPService)64 JAXRSClientFactoryBean (org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean)37 HashMap (java.util.HashMap)36 SamlCallbackHandler (org.apache.cxf.systest.ws.saml.client.SamlCallbackHandler)32 Greeter (org.apache.cxf.greeter_control.Greeter)23 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)22 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)21 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)20 WebClient (org.apache.cxf.jaxrs.client.WebClient)18 WSS4JOutInterceptor (org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor)18 Closeable (java.io.Closeable)16