use of org.apache.cxf.service.Service in project cxf by apache.
the class DOMToStaxRoundTripTest method createService.
private Service createService() {
// Create the Service
JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
factory.setServiceBean(new EchoImpl());
factory.setAddress("local://Echo");
factory.setTransportId(LocalTransportFactory.TRANSPORT_ID);
Server server = factory.create();
Service service = server.getEndpoint().getService();
service.getInInterceptors().add(new LoggingInInterceptor());
service.getOutInterceptors().add(new LoggingOutInterceptor());
return service;
}
use of org.apache.cxf.service.Service in project cxf by apache.
the class DOMToStaxRoundTripTest method testSignedUsernameToken.
@Test
public void testSignedUsernameToken() throws Exception {
// Create + configure service
Service service = createService();
WSSSecurityProperties inProperties = new WSSSecurityProperties();
inProperties.setCallbackHandler(new TestPwdCallback());
Properties cryptoProperties = CryptoFactory.getProperties("insecurity.properties", this.getClass().getClassLoader());
inProperties.setSignatureVerificationCryptoProperties(cryptoProperties);
WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
service.getInInterceptors().add(inhandler);
// Create + configure client
Echo echo = createClientProxy();
Client client = ClientProxy.getClient(echo);
client.getInInterceptors().add(new LoggingInInterceptor());
client.getOutInterceptors().add(new LoggingOutInterceptor());
Map<String, Object> properties = new HashMap<>();
properties.put(ConfigurationConstants.ACTION, ConfigurationConstants.SIGNATURE + " " + ConfigurationConstants.USERNAME_TOKEN);
properties.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
properties.put(ConfigurationConstants.SIG_PROP_FILE, "outsecurity.properties");
properties.put(ConfigurationConstants.USER, "myalias");
WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor(properties);
client.getOutInterceptors().add(ohandler);
assertEquals("test", echo.echo("test"));
}
use of org.apache.cxf.service.Service in project cxf by apache.
the class DOMToStaxRoundTripTest method testSignatureTimestampWrongNamespace.
@Test
public void testSignatureTimestampWrongNamespace() throws Exception {
// Create + configure service
Service service = createService();
WSSSecurityProperties inProperties = new WSSSecurityProperties();
inProperties.setCallbackHandler(new TestPwdCallback());
Properties cryptoProperties = CryptoFactory.getProperties("insecurity.properties", this.getClass().getClassLoader());
inProperties.setSignatureVerificationCryptoProperties(cryptoProperties);
WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
service.getInInterceptors().add(inhandler);
// Create + configure client
Echo echo = createClientProxy();
Client client = ClientProxy.getClient(echo);
client.getInInterceptors().add(new LoggingInInterceptor());
client.getOutInterceptors().add(new LoggingOutInterceptor());
Map<String, Object> properties = new HashMap<>();
properties.put(ConfigurationConstants.ACTION, ConfigurationConstants.TIMESTAMP + " " + ConfigurationConstants.SIGNATURE);
properties.put(ConfigurationConstants.SIGNATURE_PARTS, "{}{" + WSSConstants.NS_WSSE10 + "}Timestamp;" + "{}{" + WSSConstants.NS_SOAP11 + "}Body;");
properties.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
properties.put(ConfigurationConstants.SIG_PROP_FILE, "outsecurity.properties");
properties.put(ConfigurationConstants.USER, "myalias");
WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor(properties);
client.getOutInterceptors().add(ohandler);
try {
echo.echo("test");
fail("Failure expected on a wrong namespace");
} catch (javax.xml.ws.soap.SOAPFaultException ex) {
// expected
}
}
use of org.apache.cxf.service.Service in project cxf by apache.
the class AbstractJMSTester method setupServiceInfo.
protected static EndpointInfo setupServiceInfo(String ns, String wsdl, String serviceName, String portName) {
URL wsdlUrl = AbstractJMSTester.class.getResource(wsdl);
if (wsdlUrl == null) {
throw new IllegalArgumentException("Wsdl file not found on class path " + wsdl);
}
WSDLServiceFactory factory = new WSDLServiceFactory(bus, wsdlUrl.toExternalForm(), new QName(ns, serviceName));
Service service = factory.create();
return service.getEndpointInfo(new QName(ns, portName));
}
use of org.apache.cxf.service.Service in project cxf by apache.
the class RMManagerTest method setUpRecoverReliableEndpointWithAttachment.
void setUpRecoverReliableEndpointWithAttachment(Endpoint endpoint, Conduit conduit, SourceSequence ss, DestinationSequence ds, RMMessage m, Capture<Message> mc) throws IOException {
RMStore store = control.createMock(RMStore.class);
RetransmissionQueue oqueue = control.createMock(RetransmissionQueue.class);
RedeliveryQueue iqueue = control.createMock(RedeliveryQueue.class);
manager.setStore(store);
manager.setRetransmissionQueue(oqueue);
manager.setRedeliveryQueue(iqueue);
Collection<SourceSequence> sss = new ArrayList<>();
if (null != ss) {
sss.add(ss);
}
EasyMock.expect(store.getSourceSequences("{S}s.{P}p@cxf")).andReturn(sss);
if (null == ss) {
return;
}
Collection<DestinationSequence> dss = new ArrayList<>();
if (null != ds) {
dss.add(ds);
}
EasyMock.expect(store.getDestinationSequences("{S}s.{P}p@cxf")).andReturn(dss);
if (null == ds) {
return;
}
Collection<RMMessage> ms = new ArrayList<>();
if (null != m) {
ms.add(m);
}
Identifier id = new Identifier();
id.setValue("S1");
EasyMock.expect(ss.getIdentifier()).andReturn(id).times(null == m ? 1 : 2);
EasyMock.expect(ss.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
EasyMock.expect(store.getMessages(id, true)).andReturn(ms);
RMEndpoint rme = control.createMock(RMEndpoint.class);
EasyMock.expect(manager.createReliableEndpoint(endpoint)).andReturn(rme);
Source source = control.createMock(Source.class);
EasyMock.expect(rme.getSource()).andReturn(source).anyTimes();
Destination destination = control.createMock(Destination.class);
EasyMock.expect(rme.getDestination()).andReturn(destination);
destination.addSequence(ds, false);
EasyMock.expectLastCall();
Service service = control.createMock(Service.class);
EasyMock.expect(endpoint.getService()).andReturn(service).anyTimes();
Binding binding = control.createMock(Binding.class);
EasyMock.expect(endpoint.getBinding()).andReturn(binding).anyTimes();
EasyMock.expect(ss.isLastMessage()).andReturn(true).anyTimes();
EasyMock.expect(ss.getCurrentMessageNr()).andReturn(Long.valueOf(10)).anyTimes();
if (null == m) {
return;
}
oqueue.addUnacknowledged(EasyMock.capture(mc));
EasyMock.expectLastCall();
oqueue.start();
EasyMock.expectLastCall();
iqueue.start();
EasyMock.expectLastCall();
}
Aggregations