use of org.apache.cxf.rs.security.saml.SamlFormOutInterceptor in project cxf by apache.
the class JAXRSSamlTest method testGetBookPreviousSAMLTokenInForm.
@Test
public void testGetBookPreviousSAMLTokenInForm() throws Exception {
String address = "https://localhost:" + PORT + "/samlform/bookstore/books";
FormEncodingProvider<Form> formProvider = new FormEncodingProvider<Form>();
formProvider.setExpectedEncoded(true);
WebClient wc = createWebClientForExistingToken(address, new SamlFormOutInterceptor(), formProvider);
wc.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_XML);
try {
Book book = wc.post(new Form(new MetadataMap<String, String>()).param("name", "CXF").param("id", "125"), 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());
}
}
}
use of org.apache.cxf.rs.security.saml.SamlFormOutInterceptor in project cxf by apache.
the class JAXRSSamlTest method testGetBookSAMLTokenInForm.
@Test
public void testGetBookSAMLTokenInForm() throws Exception {
String address = "https://localhost:" + PORT + "/samlform/bookstore/books";
FormEncodingProvider<Form> formProvider = new FormEncodingProvider<Form>();
formProvider.setExpectedEncoded(true);
WebClient wc = createWebClient(address, new SamlFormOutInterceptor(), formProvider);
wc.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_XML);
try {
Book book = wc.post(new Form(new MetadataMap<String, String>()).param("name", "CXF").param("id", "125"), 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