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();
}
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);
}
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);
}
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) });
}
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();
}
}
Aggregations