use of org.apache.cxf.rs.security.jose.jwe.AesCbcHmacJweDecryption in project cxf by apache.
the class JAXRSJweJwsTest method testJweAesCbcHmac.
@Test
public void testJweAesCbcHmac() throws Exception {
String address = "https://localhost:" + PORT + "/jweaescbchmac";
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>();
// writer
JweWriterInterceptor jweWriter = new JweWriterInterceptor();
jweWriter.setUseJweOutputStream(true);
final String cekEncryptionKey = "GawgguFyGrWKav7AX4VKUg";
AesWrapKeyEncryptionAlgorithm keyEncryption = new AesWrapKeyEncryptionAlgorithm(cekEncryptionKey, KeyAlgorithm.A128KW);
jweWriter.setEncryptionProvider(new AesCbcHmacJweEncryption(ContentAlgorithm.A128CBC_HS256, keyEncryption));
// reader
JweClientResponseFilter jweReader = new JweClientResponseFilter();
jweReader.setDecryptionProvider(new AesCbcHmacJweDecryption(new AesWrapKeyDecryptionAlgorithm(cekEncryptionKey)));
providers.add(jweWriter);
providers.add(jweReader);
bean.setProviders(providers);
BookStore bs = bean.create(BookStore.class);
String text = bs.echoText("book");
assertEquals("book", text);
}
Aggregations