Search in sources :

Example 1 with HelloWorldPortType

use of org.apache.cxf.hello_world_jms.HelloWorldPortType in project cxf by apache.

the class JMSClientServerTest method testByteMessage.

@Test
public void testByteMessage() throws Exception {
    QName serviceName = new QName("http://cxf.apache.org/hello_world_jms", "HWByteMsgService");
    URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl");
    HWByteMsgService service = new HWByteMsgService(wsdl, serviceName);
    String response1 = new String("Hello Milestone-");
    String response2 = new String("Bonjour");
    HelloWorldPortType greeter = service.getHWSByteMsgPort();
    for (int idx = 0; idx < 2; idx++) {
        String greeting = greeter.greetMe("Milestone-" + idx);
        assertNotNull("no response received from service", greeting);
        String exResponse = response1 + idx;
        assertEquals(exResponse, greeting);
        String reply = greeter.sayHi();
        assertNotNull("no response received from service", reply);
        assertEquals(response2, reply);
    }
    ((java.io.Closeable) greeter).close();
}
Also used : QName(javax.xml.namespace.QName) Closeable(java.io.Closeable) HelloWorldPortType(org.apache.cxf.hello_world_jms.HelloWorldPortType) HWByteMsgService(org.apache.cxf.hello_world_jms.HWByteMsgService) URL(java.net.URL) Endpoint(javax.xml.ws.Endpoint) Test(org.junit.Test)

Example 2 with HelloWorldPortType

use of org.apache.cxf.hello_world_jms.HelloWorldPortType in project cxf by apache.

the class JMSSoapActionTest method testSayHi2.

@Test
public void testSayHi2() throws Exception {
    QName serviceName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldServiceSoapAction");
    QName portName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldPort");
    URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl");
    HelloWorldService service = new HelloWorldService(wsdl, serviceName);
    HelloWorldPortType greeter = service.getPort(portName, HelloWorldPortType.class);
    ClientProxy.getClient(greeter).getOutInterceptors().add(new LoggingOutInterceptor());
    ClientProxy.getClient(greeter).getOutInterceptors().add(new LoggingInInterceptor());
    ((BindingProvider) greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, "true");
    ((BindingProvider) greeter).getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, "SAY_HI_2");
    try {
        greeter.sayHi();
        fail("Failure expected on spoofing attack");
    } catch (Exception ex) {
    // expected
    }
    ((java.io.Closeable) greeter).close();
}
Also used : QName(javax.xml.namespace.QName) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) HelloWorldService(org.apache.cxf.hello_world_jms.HelloWorldService) HelloWorldPortType(org.apache.cxf.hello_world_jms.HelloWorldPortType) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) URL(java.net.URL) Test(org.junit.Test)

Example 3 with HelloWorldPortType

use of org.apache.cxf.hello_world_jms.HelloWorldPortType in project cxf by apache.

the class JMSWSSecurityTest method testUnsignedSAML2AudienceRestrictionTokenServiceName.

@Test
public void testUnsignedSAML2AudienceRestrictionTokenServiceName() throws Exception {
    QName serviceName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldService");
    QName portName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldPort");
    URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl");
    HelloWorldService service = new HelloWorldService(wsdl, serviceName);
    String response = new String("Bonjour");
    HelloWorldPortType greeter = service.getPort(portName, HelloWorldPortType.class);
    SamlCallbackHandler callbackHandler = new SamlCallbackHandler();
    callbackHandler.setSignAssertion(true);
    callbackHandler.setConfirmationMethod(SAML2Constants.CONF_BEARER);
    ConditionsBean conditions = new ConditionsBean();
    conditions.setTokenPeriodMinutes(5);
    List<String> audiences = new ArrayList<>();
    audiences.add("{http://cxf.apache.org/hello_world_jms}HelloWorldService");
    AudienceRestrictionBean audienceRestrictionBean = new AudienceRestrictionBean();
    audienceRestrictionBean.setAudienceURIs(audiences);
    conditions.setAudienceRestrictions(Collections.singletonList(audienceRestrictionBean));
    callbackHandler.setConditions(conditions);
    Map<String, Object> outProperties = new HashMap<>();
    outProperties.put(ConfigurationConstants.ACTION, ConfigurationConstants.SAML_TOKEN_UNSIGNED);
    outProperties.put(ConfigurationConstants.SAML_CALLBACK_REF, callbackHandler);
    WSS4JOutInterceptor outInterceptor = new WSS4JOutInterceptor(outProperties);
    Client client = ClientProxy.getClient(greeter);
    client.getOutInterceptors().add(outInterceptor);
    String reply = greeter.sayHi();
    assertNotNull("no response received from service", reply);
    assertEquals(response, reply);
    ((java.io.Closeable) greeter).close();
}
Also used : AudienceRestrictionBean(org.apache.wss4j.common.saml.bean.AudienceRestrictionBean) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) HelloWorldService(org.apache.cxf.hello_world_jms.HelloWorldService) ConditionsBean(org.apache.wss4j.common.saml.bean.ConditionsBean) ArrayList(java.util.ArrayList) HelloWorldPortType(org.apache.cxf.hello_world_jms.HelloWorldPortType) URL(java.net.URL) WSS4JOutInterceptor(org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor) Client(org.apache.cxf.endpoint.Client) Test(org.junit.Test)

Example 4 with HelloWorldPortType

use of org.apache.cxf.hello_world_jms.HelloWorldPortType in project cxf by apache.

the class JMSWSSecurityTest method testUnsignedSAML2AudienceRestrictionTokenBadServiceName.

@Test
public void testUnsignedSAML2AudienceRestrictionTokenBadServiceName() throws Exception {
    QName serviceName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldService");
    QName portName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldPort");
    URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl");
    HelloWorldService service = new HelloWorldService(wsdl, serviceName);
    HelloWorldPortType greeter = service.getPort(portName, HelloWorldPortType.class);
    SamlCallbackHandler callbackHandler = new SamlCallbackHandler();
    callbackHandler.setSignAssertion(true);
    callbackHandler.setConfirmationMethod(SAML2Constants.CONF_BEARER);
    ConditionsBean conditions = new ConditionsBean();
    conditions.setTokenPeriodMinutes(5);
    List<String> audiences = new ArrayList<>();
    audiences.add("{http://cxf.apache.org/hello_world_jms}BadHelloWorldService");
    AudienceRestrictionBean audienceRestrictionBean = new AudienceRestrictionBean();
    audienceRestrictionBean.setAudienceURIs(audiences);
    conditions.setAudienceRestrictions(Collections.singletonList(audienceRestrictionBean));
    callbackHandler.setConditions(conditions);
    Map<String, Object> outProperties = new HashMap<>();
    outProperties.put(ConfigurationConstants.ACTION, ConfigurationConstants.SAML_TOKEN_UNSIGNED);
    outProperties.put(ConfigurationConstants.SAML_CALLBACK_REF, callbackHandler);
    WSS4JOutInterceptor outInterceptor = new WSS4JOutInterceptor(outProperties);
    Client client = ClientProxy.getClient(greeter);
    client.getOutInterceptors().add(outInterceptor);
    try {
        greeter.sayHi();
        fail("Failure expected on a bad audience restriction");
    } catch (SOAPFaultException ex) {
    // expected
    }
    ((java.io.Closeable) greeter).close();
}
Also used : AudienceRestrictionBean(org.apache.wss4j.common.saml.bean.AudienceRestrictionBean) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) HelloWorldService(org.apache.cxf.hello_world_jms.HelloWorldService) ConditionsBean(org.apache.wss4j.common.saml.bean.ConditionsBean) ArrayList(java.util.ArrayList) HelloWorldPortType(org.apache.cxf.hello_world_jms.HelloWorldPortType) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) URL(java.net.URL) WSS4JOutInterceptor(org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor) Client(org.apache.cxf.endpoint.Client) Test(org.junit.Test)

Example 5 with HelloWorldPortType

use of org.apache.cxf.hello_world_jms.HelloWorldPortType in project cxf by apache.

the class JMSWSSecurityTest method testUnsignedSAML2AudienceRestrictionTokenURI.

@Test
public void testUnsignedSAML2AudienceRestrictionTokenURI() throws Exception {
    QName serviceName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldService");
    QName portName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldPort");
    URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl");
    HelloWorldService service = new HelloWorldService(wsdl, serviceName);
    String response = new String("Bonjour");
    HelloWorldPortType greeter = service.getPort(portName, HelloWorldPortType.class);
    SamlCallbackHandler callbackHandler = new SamlCallbackHandler();
    callbackHandler.setSignAssertion(true);
    callbackHandler.setConfirmationMethod(SAML2Constants.CONF_BEARER);
    ConditionsBean conditions = new ConditionsBean();
    conditions.setTokenPeriodMinutes(5);
    List<String> audiences = new ArrayList<>();
    audiences.add("jms:jndi:dynamicQueues/test.jmstransport.text");
    AudienceRestrictionBean audienceRestrictionBean = new AudienceRestrictionBean();
    audienceRestrictionBean.setAudienceURIs(audiences);
    conditions.setAudienceRestrictions(Collections.singletonList(audienceRestrictionBean));
    callbackHandler.setConditions(conditions);
    Map<String, Object> outProperties = new HashMap<>();
    outProperties.put(ConfigurationConstants.ACTION, ConfigurationConstants.SAML_TOKEN_UNSIGNED);
    outProperties.put(ConfigurationConstants.SAML_CALLBACK_REF, callbackHandler);
    WSS4JOutInterceptor outInterceptor = new WSS4JOutInterceptor(outProperties);
    Client client = ClientProxy.getClient(greeter);
    client.getOutInterceptors().add(outInterceptor);
    String reply = greeter.sayHi();
    assertNotNull("no response received from service", reply);
    assertEquals(response, reply);
    ((java.io.Closeable) greeter).close();
}
Also used : AudienceRestrictionBean(org.apache.wss4j.common.saml.bean.AudienceRestrictionBean) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) HelloWorldService(org.apache.cxf.hello_world_jms.HelloWorldService) ConditionsBean(org.apache.wss4j.common.saml.bean.ConditionsBean) ArrayList(java.util.ArrayList) HelloWorldPortType(org.apache.cxf.hello_world_jms.HelloWorldPortType) URL(java.net.URL) WSS4JOutInterceptor(org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor) Client(org.apache.cxf.endpoint.Client) Test(org.junit.Test)

Aggregations

HelloWorldPortType (org.apache.cxf.hello_world_jms.HelloWorldPortType)20 Test (org.junit.Test)20 QName (javax.xml.namespace.QName)19 URL (java.net.URL)18 HelloWorldService (org.apache.cxf.hello_world_jms.HelloWorldService)12 ArrayList (java.util.ArrayList)7 AbstractVmJMSTest (org.apache.cxf.systest.jms.AbstractVmJMSTest)7 Closeable (java.io.Closeable)5 HashMap (java.util.HashMap)5 Client (org.apache.cxf.endpoint.Client)5 WSS4JOutInterceptor (org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor)5 AudienceRestrictionBean (org.apache.wss4j.common.saml.bean.AudienceRestrictionBean)4 ConditionsBean (org.apache.wss4j.common.saml.bean.ConditionsBean)4 Endpoint (javax.xml.ws.Endpoint)3 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)3 ExecutionException (java.util.concurrent.ExecutionException)2 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)2 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)2 BadRecordLitFault (org.apache.cxf.hello_world_jms.BadRecordLitFault)2 NoSuchCodeLitFault (org.apache.cxf.hello_world_jms.NoSuchCodeLitFault)2