use of org.apache.cxf.jaxws.JaxWsProxyFactoryBean in project cxf by apache.
the class SoapActionTest method testRPCEncodedSoapActionSpoofing.
@Test
public void testRPCEncodedSoapActionSpoofing() throws Exception {
JaxWsProxyFactoryBean pf = new JaxWsProxyFactoryBean();
pf.setServiceClass(WrappedGreeter.class);
pf.setAddress(add16);
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.jaxws.JaxWsProxyFactoryBean 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
}
}
use of org.apache.cxf.jaxws.JaxWsProxyFactoryBean in project cxf by apache.
the class NettyHttpConduitTest method testInovationWithNettyAddress.
@Test
public void testInovationWithNettyAddress() throws Exception {
String address = "netty://http://localhost:" + PORT + "/SoapContext/SoapPort";
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(Greeter.class);
factory.setAddress(address);
Greeter greeter = factory.create(Greeter.class);
String response = greeter.greetMe("test");
assertEquals("Get a wrong response", "Hello test", response);
}
use of org.apache.cxf.jaxws.JaxWsProxyFactoryBean in project cxf by apache.
the class SubscriptionEndNotificationTask method run.
@Override
public void run() {
try {
// needed SOAP handlers
ReferenceParametersAddingHandler handler = new ReferenceParametersAddingHandler(target.getNotificationReferenceParams());
JaxWsProxyFactoryBean service = new JaxWsProxyFactoryBean();
service.getOutInterceptors().add(new LoggingOutInterceptor());
service.setServiceClass(EndToEndpoint.class);
service.setAddress(target.getEndToURL());
service.getHandlers().add(handler);
EndToEndpoint endpoint = (EndToEndpoint) service.create();
SubscriptionEnd message = new SubscriptionEnd();
message.setStatus(status.toString());
if (reason != null) {
LanguageSpecificStringType reasonElement = new LanguageSpecificStringType();
reasonElement.setLang("en-US");
reasonElement.setValue(reason);
message.getReason().add(reasonElement);
}
endpoint.subscriptionEnd(message);
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.apache.cxf.jaxws.JaxWsProxyFactoryBean in project cxf by apache.
the class SimpleEventingIntegrationTest method createSubscriptionManagerClient.
/**
* Convenience method to create a client for the testing Subscription Manager
* which is located at local://SimpleSubscriptionManager.
* You have to specify the reference parameters you obtained from the Event Source
* when your subscription was created.
*
* @return a JAX-WS client set up for managing the subscription you had created using the Event Source
*/
public SubscriptionManagerEndpoint createSubscriptionManagerClient(ReferenceParametersType refs) {
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setBus(bus);
factory.setServiceClass(SubscriptionManagerEndpoint.class);
factory.setAddress(URL_SUBSCRIPTION_MANAGER);
factory.getInInterceptors().add(new LoggingInInterceptor());
factory.getOutInterceptors().add(new LoggingOutInterceptor());
ReferenceParametersAddingHandler handler = new ReferenceParametersAddingHandler(refs);
factory.getHandlers().add(handler);
return (SubscriptionManagerEndpoint) factory.create();
}
Aggregations