String address, boolean sign, Map<String, Object> properties,
EncryptionProperties encryptionProperties,
boolean propagateException,
boolean streaming
) throws Exception {
JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
bean.setAddress(address);
SpringBusFactory bf = new SpringBusFactory();
URL busFile = JAXRSXmlSecTest.class.getResource("client.xml");
Bus springBus = bf.createBus(busFile.toString());
bean.setBus(springBus);
bean.setProperties(properties);
if (streaming) {
XmlSecOutInterceptor encInterceptor = new XmlSecOutInterceptor();
encInterceptor.setEncryptionKeyIdentifierType(encryptionProperties.getEncryptionKeyIdType());
encInterceptor.setSymmetricEncAlgorithm(encryptionProperties.getEncryptionSymmetricKeyAlgo());
encInterceptor.setEncryptionDigestAlgorithm(encryptionProperties.getEncryptionDigestAlgo());
encInterceptor.setEncryptRequest(true);
if (sign) {
encInterceptor.setSignRequest(true);
}
bean.getOutInterceptors().add(encInterceptor);
XmlSecInInterceptor encInInterceptor = new XmlSecInInterceptor();
encInInterceptor.setRequireEncryption(true);
bean.getInInterceptors().add(encInInterceptor);
} else {
if (sign) {
bean.getOutInterceptors().add(new XmlSigOutInterceptor());
}
XmlEncOutInterceptor encInterceptor = new XmlEncOutInterceptor();
encInterceptor.setKeyIdentifierType(encryptionProperties.getEncryptionKeyIdType());
encInterceptor.setSymmetricEncAlgorithm(encryptionProperties.getEncryptionSymmetricKeyAlgo());
encInterceptor.setDigestAlgorithm(encryptionProperties.getEncryptionDigestAlgo());
bean.getOutInterceptors().add(encInterceptor);
bean.getInInterceptors().add(new XmlEncInInterceptor());
if (sign) {
bean.getInInterceptors().add(new XmlSigInInterceptor());
}
}
WebClient wc = bean.createWebClient();
WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000L);
try {
Book book = wc.post(new Book("CXF", 126L), Book.class);
assertEquals(126L, book.getId());
} catch (WebApplicationException ex) {