Search in sources :

Example 1 with HelloWorldService

use of org.apache.cxf.hello_world_jms.HelloWorldService 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 2 with HelloWorldService

use of org.apache.cxf.hello_world_jms.HelloWorldService 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 3 with HelloWorldService

use of org.apache.cxf.hello_world_jms.HelloWorldService 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 4 with HelloWorldService

use of org.apache.cxf.hello_world_jms.HelloWorldService 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)

Example 5 with HelloWorldService

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

the class JMSContinuationsClientServerTest method testContinuationWithTimeout.

@Test
public void testContinuationWithTimeout() 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("/org/apache/cxf/systest/jms/continuations/jms_test.wsdl");
    HelloWorldService service = new HelloWorldService(wsdl, serviceName);
    HelloWorldPortType greeter = markForClose(service.getPort(portName, HelloWorldPortType.class, cff));
    Assert.assertEquals("Hi Fred Ruby", greeter.greetMe("Fred"));
}
Also used : QName(javax.xml.namespace.QName) HelloWorldService(org.apache.cxf.hello_world_jms.HelloWorldService) HelloWorldPortType(org.apache.cxf.hello_world_jms.HelloWorldPortType) URL(java.net.URL) AbstractVmJMSTest(org.apache.cxf.systest.jms.AbstractVmJMSTest) Test(org.junit.Test)

Aggregations

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