use of org.apache.hello_world.Greeter in project cxf by apache.
the class ClientAuthTest method testClientInvalidDirectTrust.
// Client does not directly trust the server cert
@org.junit.Test
public void testClientInvalidDirectTrust() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = ClientAuthTest.class.getResource("client-auth-invalid.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);
}
use of org.apache.hello_world.Greeter in project cxf by apache.
the class ClientAuthTest method testNoClientCert.
// Client does not specify a KeyStore, only a TrustStore
@org.junit.Test
public void testNoClientCert() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = ClientAuthTest.class.getResource("client-no-auth.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);
}
use of org.apache.hello_world.Greeter in project cxf by apache.
the class ClientAuthTest method testInvalidDirectTrust.
// Server does not (directly) trust the client cert
@org.junit.Test
public void testInvalidDirectTrust() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = ClientAuthTest.class.getResource("client-auth-invalid.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 an untrusted cert");
} catch (Exception ex) {
// expected
}
((java.io.Closeable) port).close();
bus.shutdown(true);
}
use of org.apache.hello_world.Greeter in project cxf by apache.
the class HTTPSConduitTest method testHttpsTrust.
@Test
public void testHttpsTrust() throws Exception {
startServer("Bethal");
URL wsdl = getClass().getResource("greeting.wsdl");
assertNotNull("WSDL is null", wsdl);
SOAPService service = new SOAPService(wsdl, serviceName);
assertNotNull("Service is null", service);
Greeter bethal = service.getPort(bethalQ, Greeter.class);
assertNotNull("Port is null", bethal);
updateAddressPort(bethal, getPort("PORT4"));
// Okay, I'm sick of configuration files.
// This also tests dynamic configuration of the conduit.
Client client = ClientProxy.getClient(bethal);
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setAutoRedirect(false);
// If we set any name, but Edward, Mary, or George,
// and a password of "password" we will get through
// Bethal.
AuthorizationPolicy authPolicy = new AuthorizationPolicy();
authPolicy.setUserName("Betty");
authPolicy.setPassword("password");
http.setClient(httpClientPolicy);
http.setTlsClientParameters(tlsClientParameters);
http.setAuthorization(authPolicy);
// Our expected server should be OU=Bethal
http.setTrustDecider(new MyHttpsTrustDecider("Bethal"));
configureProxy(client);
String answer = bethal.sayHi();
assertTrue("Unexpected answer: " + answer, "Bonjour from Bethal".equals(answer));
assertProxyRequestCount(0);
// Nobody will not equal OU=Bethal
MyHttpsTrustDecider trustDecider = new MyHttpsTrustDecider("Nobody");
http.setTrustDecider(trustDecider);
try {
answer = bethal.sayHi();
fail("Unexpected answer from Bethal: " + answer);
} catch (Exception e) {
// e.printStackTrace();
// assertTrue("Trust Decider was not called",
// 0 > trustDecider.wasCalled());
}
assertProxyRequestCount(0);
}
use of org.apache.hello_world.Greeter in project cxf by apache.
the class HTTPSConduitTest method testHttpsRedirectToHttpFail.
@Test
public void testHttpsRedirectToHttpFail() throws Exception {
startServer("Mortimer");
startServer("Poltim");
URL wsdl = getClass().getResource("greeting.wsdl");
assertNotNull("WSDL is null", wsdl);
SOAPService service = new SOAPService(wsdl, serviceName);
assertNotNull("Service is null", service);
Greeter poltim = service.getPort(poltimQ, Greeter.class);
assertNotNull("Port is null", poltim);
updateAddressPort(poltim, getPort("PORT2"));
// Okay, I'm sick of configuration files.
// This also tests dynamic configuration of the conduit.
Client client = ClientProxy.getClient(poltim);
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setAutoRedirect(true);
http.setClient(httpClientPolicy);
http.setTlsClientParameters(tlsClientParameters);
configureProxy(client);
poltim.sayHi();
// client -> poltim is https and thus not recorded but then redirected to mortimer
// client -> mortimer is http and recoreded
assertProxyRequestCount(1);
}
Aggregations