Search in sources :

Example 1 with IPingService

use of wssec.wssec10.IPingService in project cxf by apache.

the class WSSecurity10Test method testClientServer.

@Test
public void testClientServer() {
    BusFactory.setDefaultBus(getStaticBus());
    BusFactory.setThreadDefaultBus(getStaticBus());
    URL wsdlLocation = null;
    PingService svc = null;
    wsdlLocation = getWsdlLocation(test.prefix, test.port);
    svc = new PingService(wsdlLocation);
    final IPingService port = svc.getPort(new QName("http://WSSec/wssec10", test.prefix + "_IPingService"), IPingService.class);
    Client cl = ClientProxy.getClient(port);
    if (test.streaming) {
        // Streaming
        ((BindingProvider) port).getRequestContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY, "true");
        ((BindingProvider) port).getResponseContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY, "true");
    }
    HTTPConduit http = (HTTPConduit) cl.getConduit();
    HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
    httpClientPolicy.setConnectionTimeout(0);
    httpClientPolicy.setReceiveTimeout(0);
    http.setClient(httpClientPolicy);
    String output = port.echo(INPUT);
    assertEquals(INPUT, output);
    cl.destroy();
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) IPingService(wssec.wssec10.IPingService) QName(javax.xml.namespace.QName) IPingService(wssec.wssec10.IPingService) PingService(wssec.wssec10.PingService) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) Client(org.apache.cxf.endpoint.Client) URL(java.net.URL) Test(org.junit.Test)

Example 2 with IPingService

use of wssec.wssec10.IPingService in project cxf by apache.

the class WSSecurity10UsernameAuthorizationTest method testClientServerUTOnlyUnauthorized.

@Test
public void testClientServerUTOnlyUnauthorized() throws IOException {
    String configName = "org/apache/cxf/systest/ws/wssec10/client_unauthorized.xml";
    Bus bus = new SpringBusFactory().createBus(configName);
    IPingService port = getUTOnlyPort(bus, true);
    try {
        port.echo(INPUT);
        fail("Frank is unauthorized");
    } catch (Exception ex) {
        assertEquals("Unauthorized", ex.getMessage());
    }
    ((java.io.Closeable) port).close();
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) IPingService(wssec.wssec10.IPingService) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) Test(org.junit.Test)

Example 3 with IPingService

use of wssec.wssec10.IPingService in project cxf by apache.

the class WSSecurity10UsernameAuthorizationTest method testClientServerUTOnlyAuthorized.

@Test
public void testClientServerUTOnlyAuthorized() throws IOException {
    String configName = "org/apache/cxf/systest/ws/wssec10/client.xml";
    Bus bus = new SpringBusFactory().createBus(configName);
    IPingService port = getUTOnlyPort(bus, false);
    final String output = port.echo(INPUT);
    assertEquals(INPUT, output);
    ((java.io.Closeable) port).close();
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) IPingService(wssec.wssec10.IPingService) Test(org.junit.Test)

Example 4 with IPingService

use of wssec.wssec10.IPingService in project cxf by apache.

the class WSSecurity10UsernameAuthorizationLegacyTest method testClientServerComplexPolicyAuthorized.

@Test
public void testClientServerComplexPolicyAuthorized() {
    String configName = "org/apache/cxf/systest/ws/wssec10/client.xml";
    Bus bus = new SpringBusFactory().createBus(configName);
    IPingService port = getComplexPolicyPort(bus);
    final String output = port.echo(INPUT);
    assertEquals(INPUT, output);
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) IPingService(wssec.wssec10.IPingService) Test(org.junit.Test)

Example 5 with IPingService

use of wssec.wssec10.IPingService in project cxf by apache.

the class WSSecurity11Common method runClientServer.

public void runClientServer(String portPrefix, String portNumber, boolean unrestrictedPoliciesInstalled, boolean streaming) throws IOException {
    Bus bus = null;
    if (unrestrictedPoliciesInstalled) {
        bus = new SpringBusFactory().createBus("org/apache/cxf/systest/ws/wssec11/client.xml");
    } else {
        bus = new SpringBusFactory().createBus("org/apache/cxf/systest/ws/wssec11/client_restricted.xml");
    }
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdlLocation = null;
    PingService11 svc = null;
    wsdlLocation = getWsdlLocation(portPrefix, portNumber);
    svc = new PingService11(wsdlLocation);
    final IPingService port = svc.getPort(new QName("http://WSSec/wssec11", portPrefix + "_IPingService"), IPingService.class);
    if (streaming) {
        ((BindingProvider) port).getRequestContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY, "true");
        ((BindingProvider) port).getResponseContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY, "true");
    }
    final String output = port.echo(INPUT);
    assertEquals(INPUT, output);
    ((java.io.Closeable) port).close();
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) IPingService(wssec.wssec11.IPingService) QName(javax.xml.namespace.QName) PingService11(wssec.wssec11.PingService11) URL(java.net.URL)

Aggregations

IPingService (wssec.wssec10.IPingService)10 Bus (org.apache.cxf.Bus)7 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)7 Test (org.junit.Test)7 QName (javax.xml.namespace.QName)5 PingService (wssec.wssec10.PingService)4 MalformedURLException (java.net.MalformedURLException)3 IOException (java.io.IOException)2 URL (java.net.URL)2 Client (org.apache.cxf.endpoint.Client)1 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)1 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)1 IPingService (wssec.wssec11.IPingService)1 PingService11 (wssec.wssec11.PingService11)1