use of org.apache.cxf.binding.soap.SoapBindingConfiguration 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"));
}
use of org.apache.cxf.binding.soap.SoapBindingConfiguration in project cxf by apache.
the class SoapActionTest method testWrappedSoap12ActionSpoofing.
@Test
public void testWrappedSoap12ActionSpoofing() throws Exception {
JaxWsProxyFactoryBean pf = new JaxWsProxyFactoryBean();
pf.setServiceClass(WrappedGreeter.class);
pf.setAddress(add14);
SoapBindingConfiguration config = new SoapBindingConfiguration();
config.setVersion(Soap12.getInstance());
pf.setBindingConfig(config);
pf.setBus(bus);
WrappedGreeter greeter = (WrappedGreeter) pf.create();
assertEquals("sayHi", greeter.sayHiRequestWrapped("test"));
assertEquals("sayHi2", greeter.sayHiRequest2Wrapped("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.sayHiRequestWrapped("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.sayHiRequest2Wrapped("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.sayHiRequestWrapped("test");
fail("Failure expected on spoofing attack");
} catch (Exception ex) {
// expected
}
}
use of org.apache.cxf.binding.soap.SoapBindingConfiguration in project cxf by apache.
the class SoapActionTest method createServers.
@BeforeClass
public static void createServers() throws Exception {
bus = BusFactory.getDefaultBus();
JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
sf.setServiceBean(new SoapActionGreeterImpl());
sf.setAddress(add11);
sf.setBus(bus);
sf.create();
sf = new JaxWsServerFactoryBean();
sf.setServiceBean(new SoapActionGreeterImpl());
sf.setAddress(add12);
sf.setBus(bus);
SoapBindingConfiguration config = new SoapBindingConfiguration();
config.setVersion(Soap12.getInstance());
sf.setBindingConfig(config);
sf.create();
sf = new JaxWsServerFactoryBean();
sf.setServiceBean(new WrappedSoapActionGreeterImpl());
sf.setAddress(add13);
sf.setBus(bus);
sf.create();
sf = new JaxWsServerFactoryBean();
sf.setServiceBean(new WrappedSoapActionGreeterImpl());
sf.setAddress(add14);
sf.setBus(bus);
config.setVersion(Soap12.getInstance());
sf.setBindingConfig(config);
sf.create();
sf = new JaxWsServerFactoryBean();
sf.setServiceBean(new RPCLitSoapActionGreeterImpl());
sf.setAddress(add15);
sf.setBus(bus);
sf.create();
sf = new JaxWsServerFactoryBean();
sf.setServiceBean(new RPCEncodedSoapActionGreeterImpl());
sf.setAddress(add16);
sf.setBus(bus);
sf.create();
sf = new JaxWsServerFactoryBean();
sf.setServiceBean(new WrappedEncodedSoapActionGreeterImpl());
sf.setAddress(add17);
sf.setBus(bus);
sf.create();
}
use of org.apache.cxf.binding.soap.SoapBindingConfiguration in project camel by apache.
the class CxfConsumerSoap12Test method testCxfEndpointBeanDefinitionParser.
@Test
public void testCxfEndpointBeanDefinitionParser() {
CxfEndpoint routerEndpoint = context.getEndpoint("routerEndpoint", CxfEndpoint.class);
assertEquals("Got the wrong endpoint address", routerEndpoint.getAddress(), "http://localhost:" + CXFTestSupport.getPort1() + "/CxfConsumerSoap12Test/router");
assertEquals("Got the wrong endpont service class", "org.apache.hello_world_soap_http.Greeter", routerEndpoint.getServiceClass().getName());
BindingConfiguration binding = routerEndpoint.getBindingConfig();
assertTrue("Got no soap binding", binding instanceof SoapBindingConfiguration);
assertEquals("Got the wrong soap version", "http://schemas.xmlsoap.org/wsdl/soap12/", ((SoapBindingConfiguration) binding).getVersion().getBindingId());
assertTrue("Mtom not enabled", ((SoapBindingConfiguration) binding).isMtomEnabled());
}
use of org.apache.cxf.binding.soap.SoapBindingConfiguration in project cxf by apache.
the class SpringBeansTest method testClients.
@Test
public void testClients() throws Exception {
AbstractFactoryBeanDefinitionParser.setFactoriesAreAbstract(false);
ctx = new ClassPathXmlApplicationContext(new String[] { "/org/apache/cxf/frontend/spring/clients.xml" });
Object bean = ctx.getBean("client1.proxyFactory");
assertNotNull(bean);
ClientProxyFactoryBean cpfbean = (ClientProxyFactoryBean) bean;
BindingConfiguration bc = cpfbean.getBindingConfig();
assertTrue(bc instanceof SoapBindingConfiguration);
SoapBindingConfiguration sbc = (SoapBindingConfiguration) bc;
assertTrue(sbc.getVersion() instanceof Soap12);
HelloService greeter = (HelloService) ctx.getBean("client1");
assertNotNull(greeter);
Client client = ClientProxy.getClient(greeter);
assertNotNull("expected ConduitSelector", client.getConduitSelector());
assertTrue("unexpected ConduitSelector", client.getConduitSelector() instanceof NullConduitSelector);
List<Interceptor<? extends Message>> inInterceptors = client.getInInterceptors();
boolean saaj = false;
boolean logging = false;
for (Interceptor<? extends Message> i : inInterceptors) {
if (i instanceof SAAJInInterceptor) {
saaj = true;
} else if (i instanceof LoggingInInterceptor) {
logging = true;
}
}
assertTrue(saaj);
assertTrue(logging);
saaj = false;
logging = false;
for (Interceptor<?> i : client.getOutInterceptors()) {
if (i instanceof SAAJOutInterceptor) {
saaj = true;
} else if (i instanceof LoggingOutInterceptor) {
logging = true;
}
}
assertTrue(saaj);
assertTrue(logging);
ClientProxyFactoryBean clientProxyFactoryBean = (ClientProxyFactoryBean) ctx.getBean("client2.proxyFactory");
assertNotNull(clientProxyFactoryBean);
assertEquals("get the wrong transportId", clientProxyFactoryBean.getTransportId(), "http://cxf.apache.org/transports/local");
assertEquals("get the wrong bindingId", clientProxyFactoryBean.getBindingId(), "http://cxf.apache.org/bindings/xformat");
greeter = (HelloService) ctx.getBean("client2");
assertNotNull(greeter);
greeter = (HelloService) ctx.getBean("client3");
assertNotNull(greeter);
client = ClientProxy.getClient(greeter);
EndpointInfo epi = client.getEndpoint().getEndpointInfo();
AuthorizationPolicy ap = epi.getExtensor(AuthorizationPolicy.class);
assertNotNull("The AuthorizationPolicy instance should not be null", ap);
assertEquals("Get the wrong username", ap.getUserName(), "testUser");
assertEquals("Get the wrong password", ap.getPassword(), "password");
}
Aggregations