Search in sources :

Example 46 with JaxWsProxyFactoryBean

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
    }
}
Also used : JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) WrappedGreeter(org.apache.hello_world_soap_action.WrappedGreeter) Test(org.junit.Test)

Example 47 with JaxWsProxyFactoryBean

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
    }
}
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 48 with JaxWsProxyFactoryBean

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);
}
Also used : Greeter(org.apache.hello_world_soap_http.Greeter) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) Test(org.junit.Test)

Example 49 with JaxWsProxyFactoryBean

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();
    }
}
Also used : SubscriptionEnd(org.apache.cxf.ws.eventing.SubscriptionEnd) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) EndToEndpoint(org.apache.cxf.ws.eventing.client.EndToEndpoint) ReferenceParametersAddingHandler(org.apache.cxf.ws.eventing.shared.handlers.ReferenceParametersAddingHandler) LanguageSpecificStringType(org.apache.cxf.ws.eventing.LanguageSpecificStringType)

Example 50 with JaxWsProxyFactoryBean

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();
}
Also used : LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) SubscriptionManagerEndpoint(org.apache.cxf.ws.eventing.manager.SubscriptionManagerEndpoint) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) ReferenceParametersAddingHandler(org.apache.cxf.ws.eventing.shared.handlers.ReferenceParametersAddingHandler)

Aggregations

JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)152 Test (org.junit.Test)71 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)21 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)19 AegisDatabinding (org.apache.cxf.aegis.databinding.AegisDatabinding)14 Greeter (org.apache.hello_world_soap_http.Greeter)14 Client (org.apache.cxf.endpoint.Client)13 HashMap (java.util.HashMap)10 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)9 QName (javax.xml.namespace.QName)8 WrappedGreeter (org.apache.hello_world_soap_action.WrappedGreeter)8 BookStoreService (org.apache.cxf.systest.jaxws.tracing.BookStoreService)7 ArrayList (java.util.ArrayList)6 ClientFactoryBean (org.apache.cxf.frontend.ClientFactoryBean)6 Holder (javax.xml.ws.Holder)5 Server (org.apache.cxf.endpoint.Server)5 Greeter (org.apache.cxf.greeter_control.Greeter)5 Service (org.apache.cxf.service.Service)5 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)5 Metadata (org.apache.cxf.ws.mex.model._2004_09.Metadata)5