use of org.apache.cxf.binding.soap.saaj.SAAJInInterceptor in project cxf by apache.
the class CryptoCoverageCheckerTest method testOrder.
@Test
public void testOrder() throws Exception {
// make sure the interceptors get ordered correctly
SortedSet<Phase> phases = new TreeSet<>();
phases.add(new Phase(Phase.PRE_PROTOCOL, 1));
List<Interceptor<? extends Message>> lst = new ArrayList<>();
lst.add(new MustUnderstandInterceptor());
lst.add(new WSS4JInInterceptor());
lst.add(new SAAJInInterceptor());
lst.add(new CryptoCoverageChecker());
PhaseInterceptorChain chain = new PhaseInterceptorChain(phases);
chain.add(lst);
String output = chain.toString();
assertTrue(output.contains("MustUnderstandInterceptor, SAAJInInterceptor, " + "WSS4JInInterceptor, CryptoCoverageChecker"));
}
use of org.apache.cxf.binding.soap.saaj.SAAJInInterceptor in project cxf by apache.
the class RoundTripTest method setUpService.
@Before
public void setUpService() throws Exception {
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 SAAJInInterceptor());
service.getInInterceptors().add(new LoggingInInterceptor());
service.getOutInterceptors().add(new SAAJOutInterceptor());
service.getOutInterceptors().add(new LoggingOutInterceptor());
wsIn = new WSS4JInInterceptor();
wsIn.setProperty(ConfigurationConstants.SIG_VER_PROP_FILE, "insecurity.properties");
wsIn.setProperty(ConfigurationConstants.DEC_PROP_FILE, "insecurity.properties");
wsIn.setProperty(ConfigurationConstants.PW_CALLBACK_CLASS, TestPwdCallback.class.getName());
service.getInInterceptors().add(wsIn);
wsOut = new WSS4JOutInterceptor();
wsOut.setProperty(ConfigurationConstants.SIG_PROP_FILE, "outsecurity.properties");
wsOut.setProperty(ConfigurationConstants.ENC_PROP_FILE, "outsecurity.properties");
wsOut.setProperty(ConfigurationConstants.USER, "myalias");
wsOut.setProperty("password", "myAliasPassword");
wsOut.setProperty(ConfigurationConstants.PW_CALLBACK_CLASS, TestPwdCallback.class.getName());
service.getOutInterceptors().add(wsOut);
// Create the client
JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
proxyFac.setServiceClass(Echo.class);
proxyFac.setAddress("local://Echo");
proxyFac.getClientFactoryBean().setTransportId(LocalTransportFactory.TRANSPORT_ID);
echo = (Echo) proxyFac.create();
client = ClientProxy.getClient(echo);
client.getInInterceptors().add(new LoggingInInterceptor());
client.getInInterceptors().add(wsIn);
client.getInInterceptors().add(new SAAJInInterceptor());
client.getOutInterceptors().add(new LoggingOutInterceptor());
client.getOutInterceptors().add(wsOut);
client.getOutInterceptors().add(new SAAJOutInterceptor());
}
use of org.apache.cxf.binding.soap.saaj.SAAJInInterceptor in project cxf by apache.
the class ClientMtomXopTest method testMtomXop.
@Test
public void testMtomXop() throws Exception {
TestMtom mtomPort = createPort(MTOM_SERVICE, MTOM_PORT, TestMtom.class, true, true);
try {
Holder<DataHandler> param = new Holder<>();
Holder<String> name;
byte[] bytes;
InputStream in;
InputStream pre = this.getClass().getResourceAsStream("/wsdl/mtom_xop.wsdl");
int fileSize = 0;
for (int i = pre.read(); i != -1; i = pre.read()) {
fileSize++;
}
int count = 50;
byte[] data = new byte[fileSize * count];
for (int x = 0; x < count; x++) {
this.getClass().getResourceAsStream("/wsdl/mtom_xop.wsdl").read(data, fileSize * x, fileSize);
}
Object[] validationTypes = new Object[] { Boolean.TRUE, SchemaValidationType.IN, SchemaValidationType.BOTH };
for (Object validationType : validationTypes) {
((BindingProvider) mtomPort).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED, validationType);
param.value = new DataHandler(new ByteArrayDataSource(data, "application/octet-stream"));
name = new Holder<>("call detail");
mtomPort.testXop(name, param);
assertEquals("name unchanged", "return detail + call detail", name.value);
assertNotNull(param.value);
in = param.value.getInputStream();
bytes = IOUtils.readBytesFromStream(in);
assertEquals(data.length, bytes.length);
in.close();
param.value = new DataHandler(new ByteArrayDataSource(data, "application/octet-stream"));
name = new Holder<>("call detail");
mtomPort.testXop(name, param);
assertEquals("name unchanged", "return detail + call detail", name.value);
assertNotNull(param.value);
in = param.value.getInputStream();
bytes = IOUtils.readBytesFromStream(in);
assertEquals(data.length, bytes.length);
in.close();
}
validationTypes = new Object[] { Boolean.FALSE, SchemaValidationType.OUT, SchemaValidationType.NONE };
for (Object validationType : validationTypes) {
((BindingProvider) mtomPort).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED, validationType);
SAAJOutInterceptor saajOut = new SAAJOutInterceptor();
SAAJInInterceptor saajIn = new SAAJInInterceptor();
param.value = new DataHandler(new ByteArrayDataSource(data, "application/octet-stream"));
name = new Holder<>("call detail");
mtomPort.testXop(name, param);
assertEquals("name unchanged", "return detail + call detail", name.value);
assertNotNull(param.value);
in = param.value.getInputStream();
bytes = IOUtils.readBytesFromStream(in);
assertEquals(data.length, bytes.length);
in.close();
ClientProxy.getClient(mtomPort).getInInterceptors().add(saajIn);
ClientProxy.getClient(mtomPort).getInInterceptors().add(saajOut);
param.value = new DataHandler(new ByteArrayDataSource(data, "application/octet-stream"));
name = new Holder<>("call detail");
mtomPort.testXop(name, param);
assertEquals("name unchanged", "return detail + call detail", name.value);
assertNotNull(param.value);
in = param.value.getInputStream();
bytes = IOUtils.readBytesFromStream(in);
assertEquals(data.length, bytes.length);
in.close();
ClientProxy.getClient(mtomPort).getInInterceptors().remove(saajIn);
ClientProxy.getClient(mtomPort).getInInterceptors().remove(saajOut);
}
} catch (UndeclaredThrowableException ex) {
throw (Exception) ex.getCause();
} catch (Exception ex) {
System.out.println(System.getProperties());
throw ex;
}
}
use of org.apache.cxf.binding.soap.saaj.SAAJInInterceptor in project ddf by codice.
the class SamlProtocol method parseSoapMessage.
public static SOAPPart parseSoapMessage(String samlRequest) throws XMLStreamException {
XMLStreamReader xmlStreamReader = xmlInputFactory.createXMLStreamReader(new StringReader(samlRequest));
SoapMessage soapMessage = new SoapMessage(Soap11.getInstance());
SAAJInInterceptor.SAAJPreInInterceptor preInInterceptor = new SAAJInInterceptor.SAAJPreInInterceptor();
soapMessage.setContent(XMLStreamReader.class, xmlStreamReader);
preInInterceptor.handleMessage(soapMessage);
SAAJInInterceptor inInterceptor = new SAAJInInterceptor();
inInterceptor.handleMessage(soapMessage);
return ((SOAPPart) soapMessage.getContent(Node.class));
}
use of org.apache.cxf.binding.soap.saaj.SAAJInInterceptor in project ddf by codice.
the class SamlProtocol method parseSoapMessage.
public static SOAPPart parseSoapMessage(String samlRequest) throws XMLStreamException {
XMLStreamReader xmlStreamReader = xmlInputFactory.createXMLStreamReader(new StringReader(samlRequest));
SoapMessage soapMessage = new SoapMessage(Soap11.getInstance());
SAAJInInterceptor.SAAJPreInInterceptor preInInterceptor = new SAAJInInterceptor.SAAJPreInInterceptor();
soapMessage.setContent(XMLStreamReader.class, xmlStreamReader);
preInInterceptor.handleMessage(soapMessage);
SAAJInInterceptor inInterceptor = new SAAJInInterceptor();
inInterceptor.handleMessage(soapMessage);
return ((SOAPPart) soapMessage.getContent(Node.class));
}
Aggregations