use of org.apache.cxf.rs.security.jose.jaxrs.JweClientResponseFilter in project cxf by apache.
the class JAXRSJweJwsTest method createJweBookStore.
private BookStore createJweBookStore(String address, List<?> mbProviders) throws Exception {
JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
SpringBusFactory bf = new SpringBusFactory();
URL busFile = JAXRSJweJwsTest.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<Object>();
JweWriterInterceptor jweWriter = new JweWriterInterceptor();
jweWriter.setUseJweOutputStream(true);
providers.add(jweWriter);
providers.add(new JweClientResponseFilter());
if (mbProviders != null) {
providers.addAll(mbProviders);
}
bean.setProviders(providers);
bean.getProperties(true).put("rs.security.encryption.out.properties", "org/apache/cxf/systest/jaxrs/security/bob.jwk.properties");
bean.getProperties(true).put("rs.security.encryption.in.properties", "org/apache/cxf/systest/jaxrs/security/alice.jwk.properties");
return bean.create(BookStore.class);
}
use of org.apache.cxf.rs.security.jose.jaxrs.JweClientResponseFilter in project cxf by apache.
the class JAXRSJweJwsTest method testJweJwkAesWrap.
@Test
public void testJweJwkAesWrap() throws Exception {
String address = "https://localhost:" + PORT + "/jwejwkaeswrap";
JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
SpringBusFactory bf = new SpringBusFactory();
URL busFile = JAXRSJweJwsTest.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<Object>();
JweWriterInterceptor jweWriter = new JweWriterInterceptor();
jweWriter.setUseJweOutputStream(true);
providers.add(jweWriter);
providers.add(new JweClientResponseFilter());
bean.setProviders(providers);
bean.getProperties(true).put("rs.security.encryption.properties", "org/apache/cxf/systest/jaxrs/security/secret.jwk.properties");
bean.getProperties(true).put("jose.debug", true);
BookStore bs = bean.create(BookStore.class);
String text = bs.echoText("book");
assertEquals("book", text);
}
use of org.apache.cxf.rs.security.jose.jaxrs.JweClientResponseFilter in project cxf by apache.
the class JAXRSJwsJsonTest method testJweCompactJwsJsonBookBeanHmac.
@Test
public void testJweCompactJwsJsonBookBeanHmac() throws Exception {
if (!SecurityTestUtil.checkUnrestrictedPoliciesInstalled()) {
return;
}
String address = "https://localhost:" + PORT + "/jwejwsjsonhmac";
List<?> extraProviders = Arrays.asList(new JacksonJsonProvider(), new JweWriterInterceptor(), new JweClientResponseFilter());
String jwkStoreProperty = "org/apache/cxf/systest/jaxrs/security/secret.jwk.properties";
Map<String, Object> props = new HashMap<>();
props.put(JoseConstants.RSSEC_SIGNATURE_PROPS, jwkStoreProperty);
props.put(JoseConstants.RSSEC_ENCRYPTION_PROPS, jwkStoreProperty);
BookStore bs = createBookStore(address, props, extraProviders);
Book book = bs.echoBook(new Book("book", 123L));
assertEquals("book", book.getName());
assertEquals(123L, book.getId());
}
Aggregations