use of org.apache.cxf.transport.Conduit in project cxf by apache.
the class PolicyEngineTest method testEndpointPolicyWithEqualPolicies.
@Test
public void testEndpointPolicyWithEqualPolicies() throws Exception {
engine = new PolicyEngineImpl();
EndpointInfo ei = createMockEndpointInfo();
ServiceInfo si = control.createMock(ServiceInfo.class);
ei.setService(si);
si.getExtensor(Policy.class);
EasyMock.expectLastCall().andReturn(null).times(2);
EndpointPolicyImpl epi = control.createMock(EndpointPolicyImpl.class);
control.replay();
engine.setServerEndpointPolicy(ei, epi);
engine.setClientEndpointPolicy(ei, epi);
assertSame(epi, engine.getClientEndpointPolicy(ei, (Conduit) null, msg));
assertSame(epi, engine.getServerEndpointPolicy(ei, (Destination) null, msg));
control.reset();
ei.setService(si);
Policy p = new Policy();
si.getExtensor(Policy.class);
EasyMock.expectLastCall().andReturn(p).times(2);
epi.getPolicy();
EasyMock.expectLastCall().andReturn(p).times(2);
control.replay();
assertSame(epi, engine.getServerEndpointPolicy(ei, (Destination) null, msg));
}
use of org.apache.cxf.transport.Conduit in project cxf by apache.
the class JMSConfigFeature method initialize.
@Override
public void initialize(Client client, Bus bus) {
checkJmsConfig();
Conduit conduit = client.getConduit();
if (!(conduit instanceof JMSConduit)) {
throw new ConfigurationException(new Message("JMSCONFIGFEATURE_ONLY_JMS", LOG));
}
JMSConduit jmsConduit = (JMSConduit) conduit;
jmsConduit.setJmsConfig(jmsConfig);
super.initialize(client, bus);
}
use of org.apache.cxf.transport.Conduit in project cxf by apache.
the class JMSDestinationTest method testRoundTripDestination.
private Message testRoundTripDestination(boolean createSecurityContext) throws Exception {
EndpointInfo ei = setupServiceInfo("HelloWorldService", "HelloWorldPort");
JMSConduit conduit = setupJMSConduitWithObserver(ei);
conduit.getJmsConfig().setCreateSecurityContext(createSecurityContext);
final Message outMessage = new MessageImpl();
setupMessageHeader(outMessage, null);
final JMSDestination destination = setupJMSDestination(ei);
// set up MessageObserver for handling the conduit message
MessageObserver observer = new MessageObserver() {
public void onMessage(Message m) {
Exchange exchange = new ExchangeImpl();
exchange.setInMessage(m);
m.setExchange(exchange);
verifyReceivedMessage(m);
verifyHeaders(m, outMessage);
// setup the message for
Conduit backConduit;
try {
backConduit = destination.getBackChannel(m);
// wait for the message to be got from the conduit
Message replyMessage = new MessageImpl();
sendOneWayMessage(backConduit, replyMessage);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
};
destination.setMessageObserver(observer);
sendMessageSync(conduit, outMessage);
// wait for the message to be got from the destination,
// create the thread to handler the Destination incoming message
waitForReceiveInMessage();
verifyReceivedMessage(inMessage);
// wait for a while for the jms session recycling
inMessage = null;
// Send a second message to check for an issue
// Where the session was closed the second time
sendMessageSync(conduit, outMessage);
waitForReceiveInMessage();
verifyReceivedMessage(inMessage);
// wait for a while for the jms session recycling
Thread.sleep(1000);
conduit.close();
destination.shutdown();
return inMessage;
}
use of org.apache.cxf.transport.Conduit in project cxf by apache.
the class CXFAuthenticator method getPasswordAuthentication.
protected PasswordAuthentication getPasswordAuthentication() {
PasswordAuthentication auth = null;
Message m = PhaseInterceptorChain.getCurrentMessage();
if (m != null) {
Exchange exchange = m.getExchange();
Conduit conduit = exchange.getConduit(m);
if (conduit instanceof HTTPConduit) {
HTTPConduit httpConduit = (HTTPConduit) conduit;
if (getRequestorType() == RequestorType.PROXY && httpConduit.getProxyAuthorization() != null) {
String un = httpConduit.getProxyAuthorization().getUserName();
String pwd = httpConduit.getProxyAuthorization().getPassword();
if (un != null && pwd != null) {
auth = new PasswordAuthentication(un, pwd.toCharArray());
}
} else if (getRequestorType() == RequestorType.SERVER && httpConduit.getAuthorization() != null) {
if ("basic".equals(getRequestingScheme()) || "digest".equals(getRequestingScheme())) {
return null;
}
String un = httpConduit.getAuthorization().getUserName();
String pwd = httpConduit.getAuthorization().getPassword();
if (un != null && pwd != null) {
auth = new PasswordAuthentication(un, pwd.toCharArray());
}
}
}
}
// this HTTP call has therefore not been generated by CXF
return auth;
}
use of org.apache.cxf.transport.Conduit in project cxf by apache.
the class UndertowHTTPDestinationTest method testGetAnonBackChannel.
@Test
public void testGetAnonBackChannel() throws Exception {
destination = setUpDestination(false, false);
setUpDoService(false);
destination.doService(request, response);
setUpInMessage();
Conduit backChannel = destination.getBackChannel(inMessage);
assertNotNull("expected back channel", backChannel);
assertEquals("unexpected target", EndpointReferenceUtils.ANONYMOUS_ADDRESS, backChannel.getTarget().getAddress().getValue());
}
Aggregations