Search in sources :

Example 1 with Greeter

use of org.apache.hello_world_soap_action.Greeter in project cxf by apache.

the class SoapActionTest method testSoap12Endpoint.

@Test
public void testSoap12Endpoint() throws Exception {
    JaxWsProxyFactoryBean pf = new JaxWsProxyFactoryBean();
    pf.setServiceClass(Greeter.class);
    pf.setAddress(add12);
    SoapBindingConfiguration config = new SoapBindingConfiguration();
    config.setVersion(Soap12.getInstance());
    pf.setBindingConfig(config);
    pf.setBus(bus);
    Greeter greeter = (Greeter) pf.create();
    assertEquals("sayHi", greeter.sayHi("test"));
    assertEquals("sayHi2", greeter.sayHi2("test"));
}
Also used : SoapBindingConfiguration(org.apache.cxf.binding.soap.SoapBindingConfiguration) WrappedGreeter(org.apache.hello_world_soap_action.WrappedGreeter) RPCGreeter(org.apache.hello_world_soap_action.RPCGreeter) Greeter(org.apache.hello_world_soap_action.Greeter) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) Test(org.junit.Test)

Example 2 with Greeter

use of org.apache.hello_world_soap_action.Greeter in project cxf by apache.

the class SoapActionTest method testEndpoint.

@Test
public void testEndpoint() throws Exception {
    JaxWsProxyFactoryBean pf = new JaxWsProxyFactoryBean();
    pf.setServiceClass(Greeter.class);
    pf.setAddress(add11);
    pf.setBus(bus);
    Greeter greeter = (Greeter) pf.create();
    assertEquals("sayHi", greeter.sayHi("test"));
    assertEquals("sayHi2", greeter.sayHi2("test"));
}
Also used : WrappedGreeter(org.apache.hello_world_soap_action.WrappedGreeter) RPCGreeter(org.apache.hello_world_soap_action.RPCGreeter) Greeter(org.apache.hello_world_soap_action.Greeter) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) Test(org.junit.Test)

Example 3 with Greeter

use of org.apache.hello_world_soap_action.Greeter in project cxf by apache.

the class SoapActionTest method testBareSoapActionSpoofing.

@Test
public void testBareSoapActionSpoofing() throws Exception {
    JaxWsProxyFactoryBean pf = new JaxWsProxyFactoryBean();
    pf.setServiceClass(Greeter.class);
    pf.setAddress(add11);
    pf.setBus(bus);
    Greeter greeter = (Greeter) pf.create();
    assertEquals("sayHi", greeter.sayHi("test"));
    assertEquals("sayHi2", greeter.sayHi2("test"));
    // Now test spoofing attack
    ((BindingProvider) greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, "true");
    ((BindingProvider) greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, "SAY_HI_2");
    try {
        greeter.sayHi("test");
        fail("Failure expected on spoofing attack");
    } catch (Exception ex) {
    // expected
    }
    // Test the other operation
    ((BindingProvider) greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, "true");
    ((BindingProvider) greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, "SAY_HI_1");
    try {
        greeter.sayHi2("test");
        fail("Failure expected on spoofing attack");
    } catch (Exception ex) {
    // expected
    }
    // Test a SOAP Action that does not exist in the binding
    ((BindingProvider) greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, "true");
    ((BindingProvider) greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, "SAY_HI_UNKNOWN");
    try {
        greeter.sayHi("test");
        fail("Failure expected on spoofing attack");
    } catch (Exception ex) {
    // expected
    }
}
Also used : WrappedGreeter(org.apache.hello_world_soap_action.WrappedGreeter) RPCGreeter(org.apache.hello_world_soap_action.RPCGreeter) Greeter(org.apache.hello_world_soap_action.Greeter) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) Test(org.junit.Test)

Example 4 with Greeter

use of org.apache.hello_world_soap_action.Greeter in project cxf by apache.

the class SoapActionTest method testBareSoap12ActionSpoofing.

@Test
public void testBareSoap12ActionSpoofing() throws Exception {
    JaxWsProxyFactoryBean pf = new JaxWsProxyFactoryBean();
    pf.setServiceClass(Greeter.class);
    pf.setAddress(add12);
    SoapBindingConfiguration config = new SoapBindingConfiguration();
    config.setVersion(Soap12.getInstance());
    pf.setBindingConfig(config);
    pf.setBus(bus);
    Greeter greeter = (Greeter) pf.create();
    assertEquals("sayHi", greeter.sayHi("test"));
    assertEquals("sayHi2", greeter.sayHi2("test"));
    // Now test spoofing attack
    ((BindingProvider) greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, "true");
    ((BindingProvider) greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, "SAY_HI_2");
    try {
        greeter.sayHi("test");
        fail("Failure expected on spoofing attack");
    } catch (Exception ex) {
    // expected
    }
    // Test the other operation
    ((BindingProvider) greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, "true");
    ((BindingProvider) greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, "SAY_HI_1");
    try {
        greeter.sayHi2("test");
        fail("Failure expected on spoofing attack");
    } catch (Exception ex) {
    // expected
    }
    // Test a SOAP Action that does not exist in the binding
    ((BindingProvider) greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, "true");
    ((BindingProvider) greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, "SAY_HI_UNKNOWN");
    try {
        greeter.sayHi("test");
        fail("Failure expected on spoofing attack");
    } catch (Exception ex) {
    // expected
    }
}
Also used : SoapBindingConfiguration(org.apache.cxf.binding.soap.SoapBindingConfiguration) WrappedGreeter(org.apache.hello_world_soap_action.WrappedGreeter) RPCGreeter(org.apache.hello_world_soap_action.RPCGreeter) Greeter(org.apache.hello_world_soap_action.Greeter) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) Test(org.junit.Test)

Aggregations

JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)4 Greeter (org.apache.hello_world_soap_action.Greeter)4 RPCGreeter (org.apache.hello_world_soap_action.RPCGreeter)4 WrappedGreeter (org.apache.hello_world_soap_action.WrappedGreeter)4 Test (org.junit.Test)4 SoapBindingConfiguration (org.apache.cxf.binding.soap.SoapBindingConfiguration)2