Search in sources :

Example 6 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 7 with HelloWorldPortType

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

the class JMSSharedQueueTest method testTwoWayQueueRuntimeCorrelationDynamicPrefix.

@Test
public void testTwoWayQueueRuntimeCorrelationDynamicPrefix() throws Throwable {
    QName serviceName = new QName(SERVICE_NS, "HelloWorldServiceRuntimeCorrelationIDDynamicPrefix");
    QName portName = new QName(SERVICE_NS, "HelloWorldPortRuntimeCorrelationIDDynamicPrefix");
    URL wsdl = getWSDLURL(WSDL);
    HelloWorldServiceRuntimeCorrelationIDDynamicPrefix service = new HelloWorldServiceRuntimeCorrelationIDDynamicPrefix(wsdl, serviceName);
    HelloWorldPortType port = markForClose(service.getPort(portName, HelloWorldPortType.class, cff));
    Collection<ClientRunnable> clients = new ArrayList<>();
    for (int i = 0; i < 10; ++i) {
        clients.add(new ClientRunnable(port));
    }
    executeAsync(clients);
}
Also used : HelloWorldServiceRuntimeCorrelationIDDynamicPrefix(org.apache.cxf.hello_world_jms.HelloWorldServiceRuntimeCorrelationIDDynamicPrefix) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) HelloWorldPortType(org.apache.cxf.hello_world_jms.HelloWorldPortType) URL(java.net.URL) Test(org.junit.Test) AbstractVmJMSTest(org.apache.cxf.systest.jms.AbstractVmJMSTest)

Example 8 with HelloWorldPortType

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

the class JMSSharedQueueTest method testTwoWayQueueRuntimeCorrelationIDStaticPrefix.

/*
     * This tests a use case where there is a shared request and reply queues between
     * two servers (Eng and Sales). However each server has a design time provided selector
     * which allows them to share the same queue and do not consume the other's
     * messages.
     *
     * The clients to these two servers use the same request and reply queues.
     * An Eng client uses a design time selector prefix to form request message
     * correlationID and to form a reply consumer that filters only reply
     * messages originated from the Eng server. To differentiate between
     * one Eng client instance from another this suffix is supplemented by
     * a runtime value of ConduitId which has 1-1 relation to a client instance
     * This guarantees that an Eng client instance will only consume its own reply
     * messages.
     *
     * In case of a single client instance being shared among multiple threads
     * the third portion of the request message correlationID,
     * an atomic rolling message counter, ensures that each message gets a unique ID
     *
     * So the model is:
     *
     * Many concurrent Sales clients to a single request and reply queues (Q1, Q2)
     * to a single Sales server
     * Many concurrent Eng clients to a single request and reply queues (Q1, Q2)
     * to a single Eng server
     */
@Test
public void testTwoWayQueueRuntimeCorrelationIDStaticPrefix() throws Throwable {
    QName serviceName = new QName(SERVICE_NS, "HelloWorldServiceRuntimeCorrelationIDStaticPrefix");
    QName portNameEng = new QName(SERVICE_NS, "HelloWorldPortRuntimeCorrelationIDStaticPrefixEng");
    QName portNameSales = new QName(SERVICE_NS, "HelloWorldPortRuntimeCorrelationIDStaticPrefixSales");
    URL wsdl = getWSDLURL(WSDL);
    HelloWorldServiceRuntimeCorrelationIDStaticPrefix service = new HelloWorldServiceRuntimeCorrelationIDStaticPrefix(wsdl, serviceName);
    HelloWorldPortType portEng = markForClose(service.getPort(portNameEng, HelloWorldPortType.class, cff));
    HelloWorldPortType portSales = markForClose(service.getPort(portNameSales, HelloWorldPortType.class, cff));
    Collection<ClientRunnable> clients = new ArrayList<>();
    for (int i = 0; i < 10; ++i) {
        clients.add(new ClientRunnable(portEng, "com.mycompany.eng:"));
        clients.add(new ClientRunnable(portSales, "com.mycompany.sales:"));
    }
    executeAsync(clients);
}
Also used : HelloWorldServiceRuntimeCorrelationIDStaticPrefix(org.apache.cxf.hello_world_jms.HelloWorldServiceRuntimeCorrelationIDStaticPrefix) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) HelloWorldPortType(org.apache.cxf.hello_world_jms.HelloWorldPortType) URL(java.net.URL) Test(org.junit.Test) AbstractVmJMSTest(org.apache.cxf.systest.jms.AbstractVmJMSTest)

Example 9 with HelloWorldPortType

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

the class JMSSharedQueueTest method testTwoWayQueueAppCorrelationIDStaticPrefix.

@Test
public void testTwoWayQueueAppCorrelationIDStaticPrefix() throws Throwable {
    QName serviceName = new QName(SERVICE_NS, "HelloWorldServiceAppCorrelationIDStaticPrefix");
    QName portNameEng = new QName(SERVICE_NS, "HelloWorldPortAppCorrelationIDStaticPrefixEng");
    QName portNameSales = new QName(SERVICE_NS, "HelloWorldPortAppCorrelationIDStaticPrefixSales");
    URL wsdl = getWSDLURL(WSDL);
    HelloWorldServiceAppCorrelationIDStaticPrefix service = new HelloWorldServiceAppCorrelationIDStaticPrefix(wsdl, serviceName);
    HelloWorldPortType portEng = markForClose(service.getPort(portNameEng, HelloWorldPortType.class, cff));
    HelloWorldPortType portSales = markForClose(service.getPort(portNameSales, HelloWorldPortType.class, cff));
    executeAsync(new ClientRunnable[] { new ClientRunnable(portEng), new ClientRunnable(portSales) });
}
Also used : QName(javax.xml.namespace.QName) HelloWorldServiceAppCorrelationIDStaticPrefix(org.apache.cxf.hello_world_jms.HelloWorldServiceAppCorrelationIDStaticPrefix) HelloWorldPortType(org.apache.cxf.hello_world_jms.HelloWorldPortType) URL(java.net.URL) Test(org.junit.Test) AbstractVmJMSTest(org.apache.cxf.systest.jms.AbstractVmJMSTest)

Example 10 with HelloWorldPortType

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

the class JMSClientServerTest method testReplyAndReplyToDestinations.

@Test(expected = SOAPFaultException.class)
public void testReplyAndReplyToDestinations() throws Exception {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setWsdlLocation("classpath:/wsdl/jms_test.wsdl");
    factory.setServiceName(new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldService"));
    factory.setEndpointName(new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldPort"));
    factory.setAddress("jms://");
    JMSConfigFeature feature = new JMSConfigFeature();
    JMSConfiguration config = new JMSConfiguration();
    config.setConnectionFactory(new ActiveMQConnectionFactory(broker.getBrokerURL()));
    config.setRequestURI("test.jmstransport.text");
    config.setTargetDestination("test.jmstransport.text");
    // replyDestination and replyToDestination intentionally differ in this test scenario
    // replyDestination = Destination name to listen on for reply messages
    config.setReplyDestination("test.jmstransport.text.reply");
    // replyToDestination = Destination name to send out as replyTo address in the message
    config.setReplyToDestination("test.jmstransport.text.replyTo");
    config.setReceiveTimeout(1000L);
    feature.setJmsConfig(config);
    factory.getFeatures().add(feature);
    HelloWorldPortType greeter = factory.create(HelloWorldPortType.class);
    try {
        greeter.greetMe("FooBar");
    // Timeout exception should be thrown
    } finally {
        ((java.io.Closeable) greeter).close();
    }
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) JMSConfiguration(org.apache.cxf.transport.jms.JMSConfiguration) JMSConfigFeature(org.apache.cxf.transport.jms.JMSConfigFeature) QName(javax.xml.namespace.QName) Closeable(java.io.Closeable) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) HelloWorldPortType(org.apache.cxf.hello_world_jms.HelloWorldPortType) Test(org.junit.Test)

Aggregations

HelloWorldPortType (org.apache.cxf.hello_world_jms.HelloWorldPortType)18 Test (org.junit.Test)18 QName (javax.xml.namespace.QName)17 URL (java.net.URL)16 HelloWorldService (org.apache.cxf.hello_world_jms.HelloWorldService)10 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 BadRecordLitFault (org.apache.cxf.hello_world_jms.BadRecordLitFault)2 NoSuchCodeLitFault (org.apache.cxf.hello_world_jms.NoSuchCodeLitFault)2 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 AsyncHandler (javax.xml.ws.AsyncHandler)1