use of org.apache.hello_world.services.SOAPService in project cxf by apache.
the class TrustManagerTest method testValidServerCertX509TrustManager.
// Here the Trust Manager checks the server cert
@org.junit.Test
public void testValidServerCertX509TrustManager() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = TrustManagerTest.class.getResource("client-trust.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);
String validPrincipalName = "CN=Bethal,OU=Bethal,O=ApacheTest,L=Syracuse,C=US";
TLSClientParameters tlsParams = new TLSClientParameters();
X509TrustManager trustManager = new ServerCertX509TrustManager(validPrincipalName);
TrustManager[] trustManagers = new TrustManager[1];
trustManagers[0] = trustManager;
tlsParams.setTrustManagers(trustManagers);
tlsParams.setDisableCNCheck(true);
Client client = ClientProxy.getClient(port);
HTTPConduit http = (HTTPConduit) client.getConduit();
http.setTlsClientParameters(tlsParams);
assertEquals(port.greetMe("Kitty"), "Hello Kitty");
((java.io.Closeable) port).close();
bus.shutdown(true);
}
use of org.apache.hello_world.services.SOAPService in project cxf by apache.
the class TrustManagerTest method testOSCPOverride.
@org.junit.Test
public void testOSCPOverride() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = TrustManagerTest.class.getResource("client-trust.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);
// Read truststore
KeyStore ts = KeyStore.getInstance("JKS");
try (InputStream trustStore = ClassLoaderUtils.getResourceAsStream("keys/cxfca.jks", TrustManagerTest.class)) {
ts.load(trustStore, "password".toCharArray());
}
try {
Security.setProperty("ocsp.enable", "true");
PKIXBuilderParameters param = new PKIXBuilderParameters(ts, new X509CertSelector());
param.setRevocationEnabled(true);
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(new CertPathTrustManagerParameters(param));
TLSClientParameters tlsParams = new TLSClientParameters();
tlsParams.setTrustManagers(tmf.getTrustManagers());
tlsParams.setDisableCNCheck(true);
Client client = ClientProxy.getClient(port);
HTTPConduit http = (HTTPConduit) client.getConduit();
http.setTlsClientParameters(tlsParams);
try {
port.greetMe("Kitty");
fail("Failure expected on an invalid OCSP responder URL");
} catch (Exception ex) {
// expected
}
} finally {
Security.setProperty("ocsp.enable", "false");
}
((java.io.Closeable) port).close();
bus.shutdown(true);
}
use of org.apache.hello_world.services.SOAPService in project cxf by apache.
the class SSLv3Test method testTLSClientToEndpointWithSSL3Allowed.
@org.junit.Test
public void testTLSClientToEndpointWithSSL3Allowed() 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);
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, PORT4);
port.greetMe("Kitty");
((java.io.Closeable) port).close();
bus.shutdown(true);
}
use of org.apache.hello_world.services.SOAPService 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);
}
use of org.apache.hello_world.services.SOAPService 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);
}
Aggregations