Search in sources :

Example 16 with SOAPService

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

the class HTTPConduitTest method testHttp2HttpLoopRedirectFail.

/**
 * This methods tests that a redirection loop will fail.
 * Hurlon redirects to Abost, which redirects to Hurlon.
 *
 * Note: Unfortunately, the invocation may "fail" for any
 * number of reasons.
 */
@Test
public void testHttp2HttpLoopRedirectFail() throws Exception {
    startServer("Abost");
    startServer("Hurlon");
    URL config = getClass().getResource("Http2HttpLoopRedirectFail.cxf");
    // We go through the back door, setting the default bus.
    new DefaultBusFactory().createBus(config);
    URL wsdl = getClass().getResource("greeting.wsdl");
    assertNotNull("WSDL is null", wsdl);
    SOAPService service = new SOAPService(wsdl, serviceName);
    assertNotNull("Service is null", service);
    Greeter hurlon = service.getPort(hurlonQ, Greeter.class);
    assertNotNull("Port is null", hurlon);
    updateAddressPort(hurlon, getPort("PORT3"));
    configureProxy(ClientProxy.getClient(hurlon));
    String answer = null;
    try {
        answer = hurlon.sayHi();
        fail("Redirect didn't fail. Got answer: " + answer);
    } catch (Exception e) {
    // This exception will be one of not being able to
    // read from the StreamReader
    // e.printStackTrace();
    }
    assertProxyRequestCount(2);
}
Also used : SOAPService(org.apache.hello_world.services.SOAPService) Greeter(org.apache.hello_world.Greeter) URL(java.net.URL) MalformedURLException(java.net.MalformedURLException) Test(org.junit.Test)

Example 17 with SOAPService

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

the class DigestAuthTest method testDigestAuth.

@Test
public void testDigestAuth() throws Exception {
    URL wsdl = getClass().getResource("../greeting.wsdl");
    assertNotNull("WSDL is null", wsdl);
    SOAPService service = new SOAPService(wsdl, serviceName);
    assertNotNull("Service is null", service);
    Greeter mortimer = service.getPort(mortimerQ, Greeter.class);
    assertNotNull("Port is null", mortimer);
    TestUtil.setAddress(mortimer, "http://localhost:" + PORT + "/digestauth/greeter");
    Client client = ClientProxy.getClient(mortimer);
    HTTPConduit http = (HTTPConduit) client.getConduit();
    AuthorizationPolicy authPolicy = new AuthorizationPolicy();
    authPolicy.setAuthorizationType("Digest");
    authPolicy.setUserName("foo");
    authPolicy.setPassword("bar");
    http.setAuthorization(authPolicy);
    String answer = mortimer.sayHi();
    assertEquals("Unexpected answer: " + answer, "Hi", answer);
}
Also used : SOAPService(org.apache.hello_world.services.SOAPService) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) AuthorizationPolicy(org.apache.cxf.configuration.security.AuthorizationPolicy) Greeter(org.apache.hello_world.Greeter) Client(org.apache.cxf.endpoint.Client) URL(java.net.URL) Test(org.junit.Test)

Example 18 with SOAPService

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

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

the class CipherSuitesTest method testAESIncludedTLSv10.

// Both client + server include AES, client is TLSv1.0
@org.junit.Test
public void testAESIncludedTLSv10() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = CipherSuitesTest.class.getResource("ciphersuites-client-noconfig.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);
    Client client = ClientProxy.getClient(port);
    HTTPConduit conduit = (HTTPConduit) client.getConduit();
    TLSClientParameters tlsParams = new TLSClientParameters();
    X509TrustManager trustManager = new NoOpX509TrustManager();
    TrustManager[] trustManagers = new TrustManager[1];
    trustManagers[0] = trustManager;
    tlsParams.setTrustManagers(trustManagers);
    tlsParams.setDisableCNCheck(true);
    tlsParams.setSecureSocketProtocol("TLSv1");
    conduit.setTlsClientParameters(tlsParams);
    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) TLSClientParameters(org.apache.cxf.configuration.jsse.TLSClientParameters) URL(java.net.URL) TrustManager(javax.net.ssl.TrustManager) X509TrustManager(javax.net.ssl.X509TrustManager) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) X509TrustManager(javax.net.ssl.X509TrustManager) Greeter(org.apache.hello_world.Greeter) Client(org.apache.cxf.endpoint.Client)

Example 20 with SOAPService

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

the class CipherSuitesTest method testAESIncludedTLSv11.

// Both client + server include AES, client is TLSv1.1
@org.junit.Test
public void testAESIncludedTLSv11() throws Exception {
    // Doesn't work with IBM JDK
    if ("IBM Corporation".equals(System.getProperty("java.vendor"))) {
        return;
    }
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = CipherSuitesTest.class.getResource("ciphersuites-client-noconfig.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);
    Client client = ClientProxy.getClient(port);
    HTTPConduit conduit = (HTTPConduit) client.getConduit();
    TLSClientParameters tlsParams = new TLSClientParameters();
    X509TrustManager trustManager = new NoOpX509TrustManager();
    TrustManager[] trustManagers = new TrustManager[1];
    trustManagers[0] = trustManager;
    tlsParams.setTrustManagers(trustManagers);
    tlsParams.setDisableCNCheck(true);
    tlsParams.setSecureSocketProtocol("TLSv1.1");
    conduit.setTlsClientParameters(tlsParams);
    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) TLSClientParameters(org.apache.cxf.configuration.jsse.TLSClientParameters) URL(java.net.URL) TrustManager(javax.net.ssl.TrustManager) X509TrustManager(javax.net.ssl.X509TrustManager) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) X509TrustManager(javax.net.ssl.X509TrustManager) Greeter(org.apache.hello_world.Greeter) Client(org.apache.cxf.endpoint.Client)

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