Search in sources :

Example 21 with SOAPService

use of org.apache.hello_world.services.SOAPService 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)

Example 22 with SOAPService

use of org.apache.hello_world.services.SOAPService in project cxf by apache.

the class ClientAuthTest method testChainTrust.

// Server trusts the issuer of the client cert
@org.junit.Test
public void testChainTrust() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = ClientAuthTest.class.getResource("client-auth-chain.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, PORT2);
    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 23 with SOAPService

use of org.apache.hello_world.services.SOAPService in project cxf by apache.

the class ClientAuthTest method testInvalidChainTrust.

// Server does not trust the issuer of the client cert
@org.junit.Test
public void testInvalidChainTrust() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = ClientAuthTest.class.getResource("client-auth-invalid2.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, PORT2);
    try {
        port.greetMe("Kitty");
        fail("Failure expected on no trusted cert");
    } 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)

Example 24 with SOAPService

use of org.apache.hello_world.services.SOAPService in project cxf by apache.

the class ClientAuthTest method testClientInvalidCertChain.

// Client does not trust the issuer of the server cert
@org.junit.Test
public void testClientInvalidCertChain() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = ClientAuthTest.class.getResource("client-auth-invalid2.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, PORT);
    try {
        port.greetMe("Kitty");
        fail("Failure expected on no trusted cert");
    } 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)

Example 25 with SOAPService

use of org.apache.hello_world.services.SOAPService in project cxf by apache.

the class HTTPSClientTest method testSuccessfulCall.

public final void testSuccessfulCall(String configuration, String address, URL url, boolean dynamicClient) throws Exception {
    setTheConfiguration(configuration);
    startServers();
    if (url == null) {
        url = SOAPService.WSDL_LOCATION;
    }
    // CXF-4037 - dynamic client isn't using the conduit settings to resolve schemas
    if (dynamicClient) {
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        JaxWsDynamicClientFactory.newInstance(BusFactory.getDefaultBus()).createClient(url.toExternalForm());
        Thread.currentThread().setContextClassLoader(loader);
    }
    SOAPService service = new SOAPService(url, SOAPService.SERVICE);
    assertNotNull("Service is null", service);
    final Greeter port = service.getHttpsPort();
    assertNotNull("Port is null", port);
    BindingProvider provider = (BindingProvider) port;
    provider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);
    // for (int x = 0; x < 100000; x++) {
    assertEquals(port.greetMe("Kitty"), "Hello Kitty");
    // }
    stopServers();
}
Also used : SOAPService(org.apache.hello_world.services.SOAPService) Greeter(org.apache.hello_world.Greeter) BindingProvider(javax.xml.ws.BindingProvider)

Aggregations

Greeter (org.apache.hello_world.Greeter)57 SOAPService (org.apache.hello_world.services.SOAPService)57 URL (java.net.URL)56 Bus (org.apache.cxf.Bus)41 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)40 Client (org.apache.cxf.endpoint.Client)14 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)14 Test (org.junit.Test)13 CertificateException (java.security.cert.CertificateException)9 TLSClientParameters (org.apache.cxf.configuration.jsse.TLSClientParameters)8 TrustManager (javax.net.ssl.TrustManager)7 X509TrustManager (javax.net.ssl.X509TrustManager)7 IOException (java.io.IOException)5 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)5 AuthorizationPolicy (org.apache.cxf.configuration.security.AuthorizationPolicy)4 GeneralSecurityException (java.security.GeneralSecurityException)3 BindingProvider (javax.xml.ws.BindingProvider)3 UntrustedURLConnectionIOException (org.apache.cxf.transport.http.UntrustedURLConnectionIOException)3 MalformedURLException (java.net.MalformedURLException)2 InputStream (java.io.InputStream)1