use of org.apache.cxf.systest.jaxrs.security.jose.BookStore in project cxf by apache.
the class JAXRSJweJwsTest method testJweRsaJwsRsaCert.
@Test
public void testJweRsaJwsRsaCert() throws Exception {
String address = "https://localhost:" + PORT + "/jwejwsrsacert";
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());
JwsWriterInterceptor jwsWriter = new JwsWriterInterceptor();
jwsWriter.setUseJwsOutputStream(true);
providers.add(jwsWriter);
providers.add(new JwsClientResponseFilter());
bean.setProviders(providers);
bean.getProperties(true).put("rs.security.keystore.file", "org/apache/cxf/systest/jaxrs/security/certs/jwkPublicSet.txt");
bean.getProperties(true).put("rs.security.signature.out.properties", CLIENT_JWEJWS_PROPERTIES);
bean.getProperties(true).put("rs.security.encryption.in.properties", CLIENT_JWEJWS_PROPERTIES);
PrivateKeyPasswordProvider provider = new PrivateKeyPasswordProviderImpl();
bean.getProperties(true).put("rs.security.signature.key.password.provider", provider);
bean.getProperties(true).put("rs.security.decryption.key.password.provider", provider);
BookStore bs = bean.create(BookStore.class);
WebClient.getConfig(bs).getRequestContext().put("rs.security.keystore.alias.jwe.out", "AliceCert");
WebClient.getConfig(bs).getRequestContext().put("rs.security.keystore.alias.jws.in", "AliceCert");
String text = bs.echoText("book");
assertEquals("book", text);
}
use of org.apache.cxf.systest.jaxrs.security.jose.BookStore in project cxf by apache.
the class JAXRSJweJwsTest method testJwsJwkPlainTextHMacHttpHeaders.
@Test
public void testJwsJwkPlainTextHMacHttpHeaders() throws Exception {
String address = "https://localhost:" + PORT + "/jwsjwkhmacHttpHeaders";
BookStore bs = createJwsBookStore(address, null, true, true);
String text = bs.echoText("book");
assertEquals("book", text);
}
use of org.apache.cxf.systest.jaxrs.security.jose.BookStore in project cxf by apache.
the class JAXRSJwsJsonTest method testJwsJsonBookBeanHmac.
@Test
public void testJwsJsonBookBeanHmac() throws Exception {
String address = "https://localhost:" + PORT + "/jwsjsonhmac";
BookStore bs = createBookStore(address, "org/apache/cxf/systest/jaxrs/security/secret.jwk.properties", Collections.singletonList(new JacksonJsonProvider()));
Book book = bs.echoBook(new Book("book", 123L));
assertEquals("book", book.getName());
assertEquals(123L, book.getId());
}
use of org.apache.cxf.systest.jaxrs.security.jose.BookStore in project cxf by apache.
the class JAXRSJwsJsonTest method testJwsJsonPlainTextHmacUnencoded.
@Test
public void testJwsJsonPlainTextHmacUnencoded() throws Exception {
String address = "https://localhost:" + PORT + "/jwsjsonhmac";
BookStore bs = createBookStore(address, Collections.singletonMap(JoseConstants.RSSEC_SIGNATURE_PROPS, "org/apache/cxf/systest/jaxrs/security/secret.jwk.properties"), null, false);
String text = bs.echoText("book");
assertEquals("book", text);
}
use of org.apache.cxf.systest.jaxrs.security.jose.BookStore in project cxf by apache.
the class JAXRSJwsJsonTest method testJwsJsonPlainTextHmacXML.
// Test signing an XML payload
@Test
public void testJwsJsonPlainTextHmacXML() throws Exception {
String address = "https://localhost:" + PORT + "/jwsjsonhmac";
BookStore bs = createBookStore(address, "org/apache/cxf/systest/jaxrs/security/secret.jwk.properties", null);
String text = bs.echoText("book");
assertEquals("book", text);
}
Aggregations