String address = "https://localhost:" + PORT + "/xmlsig";
doTestSignatureProxy(address, true, "file:");
}
private void doTestSignatureProxy(String address, boolean enveloping, String cryptoUrlPrefix) 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);
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("ws-security.callback-handler",
"org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback");
properties.put("ws-security.signature.username", "alice");
String cryptoUrl = "org/apache/cxf/systest/jaxrs/security/alice.properties";
if (cryptoUrlPrefix != null) {
cryptoUrl = cryptoUrlPrefix + this.getClass().getResource("/" + cryptoUrl).toURI().getPath();
}
properties.put("ws-security.signature.properties", cryptoUrl);
bean.setProperties(properties);
XmlSigOutInterceptor sigInterceptor = new XmlSigOutInterceptor();
if (enveloping) {
sigInterceptor.setStyle(XmlSigOutInterceptor.ENVELOPING_SIG);
}
bean.getOutInterceptors().add(sigInterceptor);
bean.setServiceClass(BookStore.class);
BookStore store = bean.create(BookStore.class);
try {
Book book = store.addBook(new Book("CXF", 126L));
assertEquals(126L, book.getId());
} catch (WebApplicationException ex) {
fail(ex.getMessage());