Search in sources :

Example 16 with HelloWorldPortType

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

the class JMSWSSecurityTest method testUnsignedSAML2Token.

@Test
public void testUnsignedSAML2Token() 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);
    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 : HashMap(java.util.HashMap) 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) WSS4JOutInterceptor(org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor) Client(org.apache.cxf.endpoint.Client) Test(org.junit.Test)

Example 17 with HelloWorldPortType

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

the class JMSSharedQueueTest method testTwoWayQueueAppCorrelationID.

@Test
public void testTwoWayQueueAppCorrelationID() throws Throwable {
    QName serviceName = new QName(SERVICE_NS, "HelloWorldServiceAppCorrelationID");
    QName portNameEng = new QName(SERVICE_NS, "HelloWorldPortAppCorrelationIDEng");
    QName portNameSales = new QName(SERVICE_NS, "HelloWorldPortAppCorrelationIDSales");
    URL wsdl = getWSDLURL(WSDL);
    HelloWorldServiceAppCorrelationID service = new HelloWorldServiceAppCorrelationID(wsdl, serviceName);
    HelloWorldPortType portEng = markForClose(service.getPort(portNameEng, HelloWorldPortType.class, cff));
    ClientRunnable engClient = new ClientRunnable(portEng, new CorrelationIDFactory() {

        private int counter;

        public String createCorrealtionID() {
            return "com.mycompany.eng:" + counter++;
        }
    });
    HelloWorldPortType portSales = markForClose(service.getPort(portNameSales, HelloWorldPortType.class, cff));
    ClientRunnable salesClient = new ClientRunnable(portSales, new CorrelationIDFactory() {

        private int counter;

        public String createCorrealtionID() {
            return "com.mycompany.sales:" + counter++;
        }
    });
    executeAsync(new ClientRunnable[] { engClient, salesClient });
}
Also used : QName(javax.xml.namespace.QName) HelloWorldPortType(org.apache.cxf.hello_world_jms.HelloWorldPortType) URL(java.net.URL) HelloWorldServiceAppCorrelationID(org.apache.cxf.hello_world_jms.HelloWorldServiceAppCorrelationID) Test(org.junit.Test) AbstractVmJMSTest(org.apache.cxf.systest.jms.AbstractVmJMSTest)

Example 18 with HelloWorldPortType

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

the class JMSSharedQueueTest method testTwoWayQueueAppCorrelationIDNoPrefix.

/* TO DO:
     * This tests shows a missing QoS. When CXF clients share a named (persistent) reply queue
     *  with an application provided correlationID there will be a guaranteed response
     * message loss.
     *
     * A large number of threads is used to ensure message loss and avoid a false
     * positive assertion
     */
@Test
public void testTwoWayQueueAppCorrelationIDNoPrefix() throws Throwable {
    QName serviceName = new QName(SERVICE_NS, "HelloWorldServiceAppCorrelationIDNoPrefix");
    QName portName = new QName(SERVICE_NS, "HelloWorldPortAppCorrelationIDNoPrefix");
    URL wsdl = getWSDLURL(WSDL);
    HelloWorldServiceAppCorrelationIDNoPrefix service = new HelloWorldServiceAppCorrelationIDNoPrefix(wsdl, serviceName);
    HelloWorldPortType port = markForClose(service.getPort(portName, HelloWorldPortType.class, cff));
    Collection<ClientRunnable> clients = new ArrayList<>();
    for (int i = 0; i < 1; ++i) {
        clients.add(new ClientRunnable(port));
    }
    executeAsync(clients);
}
Also used : HelloWorldServiceAppCorrelationIDNoPrefix(org.apache.cxf.hello_world_jms.HelloWorldServiceAppCorrelationIDNoPrefix) 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)

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