use of org.apache.cxf.rs.security.saml.SamlEnvelopedOutInterceptor in project cxf by apache.
the class JAXRSSamlAuthorizationTest method createWebClient.
private WebClient createWebClient(String address, Map<String, Object> extraProperties) {
JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
bean.setAddress(address);
SpringBusFactory bf = new SpringBusFactory();
URL busFile = JAXRSSamlAuthorizationTest.class.getResource("client.xml");
Bus springBus = bf.createBus(busFile.toString());
bean.setBus(springBus);
Map<String, Object> properties = new HashMap<>();
properties.put(SecurityConstants.SAML_CALLBACK_HANDLER, "org.apache.cxf.systest.jaxrs.security.saml.SamlCallbackHandler");
if (extraProperties != null) {
properties.putAll(extraProperties);
}
bean.setProperties(properties);
bean.getOutInterceptors().add(new SamlEnvelopedOutInterceptor());
return bean.createWebClient();
}
use of org.apache.cxf.rs.security.saml.SamlEnvelopedOutInterceptor in project cxf by apache.
the class JAXRSSamlTest method doTestEnvelopedSAMLToken.
public void doTestEnvelopedSAMLToken(boolean signed, CallbackHandler samlCallbackHandler) throws Exception {
String address = "https://localhost:" + PORT + "/samlxml/bookstore/books";
WebClient wc = createWebClient(address, new SamlEnvelopedOutInterceptor(!signed), null, samlCallbackHandler);
XmlSigOutInterceptor xmlSig = new XmlSigOutInterceptor();
if (signed) {
xmlSig.setStyle(XmlSigOutInterceptor.DETACHED_SIG);
}
WebClient.getConfig(wc).getOutInterceptors().add(xmlSig);
wc.type(MediaType.APPLICATION_XML).accept(MediaType.APPLICATION_XML);
try {
Book book = wc.post(new Book("CXF", 125L), Book.class);
assertEquals(125L, book.getId());
} catch (WebApplicationException ex) {
fail(ex.getMessage());
} catch (ProcessingException ex) {
if (ex.getCause() != null && ex.getCause().getMessage() != null) {
fail(ex.getCause().getMessage());
} else {
fail(ex.getMessage());
}
}
}
Aggregations