use of org.apache.cxf.rs.security.jose.jaxrs.JwsJsonWriterInterceptor in project testcases by coheigea.
the class JWEJWSTest method testEncryptionSignatureListProperties.
@org.junit.Test
public void testEncryptionSignatureListProperties() throws Exception {
URL busFile = JWEJWSTest.class.getResource("cxf-client.xml");
List<Object> providers = new ArrayList<Object>();
providers.add(new JacksonJsonProvider());
providers.add(new JweWriterInterceptor());
JwsJsonWriterInterceptor writer = new JwsJsonWriterInterceptor();
writer.setUseJwsJsonOutputStream(true);
providers.add(writer);
String address = "http://localhost:" + PORT + "/doubleit/services";
WebClient client = WebClient.create(address, providers, busFile.toString());
client.type("application/json").accept("application/json");
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("rs.security.encryption.properties", "clientEncKeystore.properties");
properties.put("rs.security.signature.out.properties", "clientKeystore.properties");
WebClient.getConfig(client).getRequestContext().putAll(properties);
Number numberToDouble = new Number();
numberToDouble.setDescription("This is the number to double");
numberToDouble.setNumber(25);
Response response = client.post(numberToDouble);
assertEquals(response.getStatus(), 200);
assertEquals(response.readEntity(Number.class).getNumber(), 50);
}
use of org.apache.cxf.rs.security.jose.jaxrs.JwsJsonWriterInterceptor in project testcases by coheigea.
the class JWSSignatureTest method testSignatureListProperties.
@org.junit.Test
public void testSignatureListProperties() throws Exception {
URL busFile = JWSSignatureTest.class.getResource("cxf-client.xml");
List<Object> providers = new ArrayList<Object>();
providers.add(new JacksonJsonProvider());
JwsJsonWriterInterceptor writer = new JwsJsonWriterInterceptor();
writer.setUseJwsJsonOutputStream(true);
providers.add(writer);
String address = "http://localhost:" + PORT + "/doubleit/services";
WebClient client = WebClient.create(address, providers, busFile.toString());
client.type("application/json").accept("application/json");
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("rs.security.signature.out.properties", "clientKeystore.properties");
WebClient.getConfig(client).getRequestContext().putAll(properties);
Number numberToDouble = new Number();
numberToDouble.setDescription("This is the number to double");
numberToDouble.setNumber(25);
Response response = client.post(numberToDouble);
assertEquals(response.getStatus(), 200);
assertEquals(response.readEntity(Number.class).getNumber(), 50);
}
use of org.apache.cxf.rs.security.jose.jaxrs.JwsJsonWriterInterceptor in project cxf by apache.
the class JAXRSJwsJsonTest method createBookStore.
private BookStore createBookStore(String address, Map<String, Object> mapProperties, List<?> extraProviders, boolean encodePayload) throws Exception {
JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
SpringBusFactory bf = new SpringBusFactory();
URL busFile = JAXRSJwsJsonTest.class.getResource("client.xml");
Bus springBus = bf.createBus(busFile.toString());
bean.setBus(springBus);
bean.setServiceClass(BookStore.class);
bean.setAddress(address);
List<Object> providers = new LinkedList<>();
JwsJsonWriterInterceptor writer = new JwsJsonWriterInterceptor();
writer.setUseJwsJsonOutputStream(true);
writer.setEncodePayload(encodePayload);
providers.add(writer);
providers.add(new JwsJsonClientResponseFilter());
if (extraProviders != null) {
providers.addAll(extraProviders);
}
bean.setProviders(providers);
bean.getProperties(true).putAll(mapProperties);
return bean.create(BookStore.class);
}
Aggregations