Search in sources :

Example 1 with BookStore

use of org.apache.cxf.systest.jaxrs.security.jose.BookStore in project cxf by apache.

the class JAXRSJweJsonTest method testJweJsontTwoRecipientsKeyWrapAndAesGcm.

@Test
public void testJweJsontTwoRecipientsKeyWrapAndAesGcm() throws Exception {
    String address = "https://localhost:" + PORT + "/jwejsonTwoRecipients";
    BookStore bs = createBookStoreTwoRecipients(address);
    String text = bs.echoTextJweJsonIn("book");
    assertEquals("bookbook", text);
}
Also used : BookStore(org.apache.cxf.systest.jaxrs.security.jose.BookStore) Test(org.junit.Test)

Example 2 with BookStore

use of org.apache.cxf.systest.jaxrs.security.jose.BookStore in project cxf by apache.

the class JAXRSJweJwsTest method testJweRsaJwsPlainTextHMac.

@Test
public void testJweRsaJwsPlainTextHMac() throws Exception {
    String address = "https://localhost:" + PORT + "/jwejwshmac";
    HmacJwsSignatureProvider hmacProvider = new HmacJwsSignatureProvider(ENCODED_MAC_KEY, SignatureAlgorithm.HS256);
    BookStore bs = createJweJwsBookStore(address, hmacProvider, null);
    String text = bs.echoText("book");
    assertEquals("book", text);
}
Also used : BookStore(org.apache.cxf.systest.jaxrs.security.jose.BookStore) HmacJwsSignatureProvider(org.apache.cxf.rs.security.jose.jws.HmacJwsSignatureProvider) Test(org.junit.Test)

Example 3 with BookStore

use of org.apache.cxf.systest.jaxrs.security.jose.BookStore in project cxf by apache.

the class JAXRSJweJwsTest method testJwsJwkBookHMac.

@Test
public void testJwsJwkBookHMac() throws Exception {
    String address = "https://localhost:" + PORT + "/jwsjwkhmac";
    BookStore bs = createJwsBookStore(address, Collections.singletonList(new JacksonJsonProvider()));
    Book book = bs.echoBook(new Book("book", 123L));
    assertEquals("book", book.getName());
    assertEquals(123L, book.getId());
}
Also used : BookStore(org.apache.cxf.systest.jaxrs.security.jose.BookStore) Book(org.apache.cxf.systest.jaxrs.security.Book) JacksonJsonProvider(com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider) Test(org.junit.Test)

Example 4 with BookStore

use of org.apache.cxf.systest.jaxrs.security.jose.BookStore in project cxf by apache.

the class JAXRSJweJwsTest method testJwsJwkPlainTextHMacHttpHeadersModified.

@Test(expected = BadRequestException.class)
public void testJwsJwkPlainTextHMacHttpHeadersModified() throws Exception {
    String address = "https://localhost:" + PORT + "/jwsjwkhmacHttpHeaders";
    BookStore bs = createJwsBookStore(address, null, true, true);
    WebClient.client(bs).header("Modify", "true");
    bs.echoText("book");
}
Also used : BookStore(org.apache.cxf.systest.jaxrs.security.jose.BookStore) Test(org.junit.Test)

Example 5 with BookStore

use of org.apache.cxf.systest.jaxrs.security.jose.BookStore in project cxf by apache.

the class JAXRSJweJwsTest method testJwsJwkEC.

@Test
public void testJwsJwkEC() throws Exception {
    String address = "https://localhost:" + PORT + "/jwsjwkec";
    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>();
    JwsWriterInterceptor jwsWriter = new JwsWriterInterceptor();
    jwsWriter.setUseJwsOutputStream(true);
    providers.add(jwsWriter);
    providers.add(new JwsClientResponseFilter());
    bean.setProviders(providers);
    bean.getProperties(true).put("rs.security.signature.out.properties", "org/apache/cxf/systest/jaxrs/security/jws.ec.private.properties");
    bean.getProperties(true).put("rs.security.signature.in.properties", "org/apache/cxf/systest/jaxrs/security/jws.ec.public.properties");
    BookStore bs = bean.create(BookStore.class);
    String text = bs.echoText("book");
    assertEquals("book", text);
}
Also used : Bus(org.apache.cxf.Bus) BookStore(org.apache.cxf.systest.jaxrs.security.jose.BookStore) JwsClientResponseFilter(org.apache.cxf.rs.security.jose.jaxrs.JwsClientResponseFilter) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) JAXRSClientFactoryBean(org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean) JwsWriterInterceptor(org.apache.cxf.rs.security.jose.jaxrs.JwsWriterInterceptor) URL(java.net.URL) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

BookStore (org.apache.cxf.systest.jaxrs.security.jose.BookStore)37 Test (org.junit.Test)35 Book (org.apache.cxf.systest.jaxrs.security.Book)15 LinkedList (java.util.LinkedList)8 URL (java.net.URL)7 Bus (org.apache.cxf.Bus)7 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)7 JAXRSClientFactoryBean (org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean)7 JweClientResponseFilter (org.apache.cxf.rs.security.jose.jaxrs.JweClientResponseFilter)6 JweWriterInterceptor (org.apache.cxf.rs.security.jose.jaxrs.JweWriterInterceptor)6 JacksonJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider)5 JwsClientResponseFilter (org.apache.cxf.rs.security.jose.jaxrs.JwsClientResponseFilter)3 JwsWriterInterceptor (org.apache.cxf.rs.security.jose.jaxrs.JwsWriterInterceptor)3 HashMap (java.util.HashMap)2 PrivateKeyPasswordProvider (org.apache.cxf.rs.security.jose.common.PrivateKeyPasswordProvider)2 HmacJwsSignatureProvider (org.apache.cxf.rs.security.jose.jws.HmacJwsSignatureProvider)2 ArrayList (java.util.ArrayList)1 BadRequestException (javax.ws.rs.BadRequestException)1 AesCbcHmacJweDecryption (org.apache.cxf.rs.security.jose.jwe.AesCbcHmacJweDecryption)1 AesCbcHmacJweEncryption (org.apache.cxf.rs.security.jose.jwe.AesCbcHmacJweEncryption)1