Search in sources :

Example 16 with BookStore

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

the class JAXRSJwsJsonTest method testJwsJsonBookDoubleHmacManyProps.

@Test
public void testJwsJsonBookDoubleHmacManyProps() throws Exception {
    String address = "https://localhost:" + PORT + "/jwsjsonhmac2";
    List<String> properties = new ArrayList<>();
    properties.add("org/apache/cxf/systest/jaxrs/security/secret.jwk.properties");
    properties.add("org/apache/cxf/systest/jaxrs/security/secret.jwk.hmac.properties");
    Map<String, Object> map = new HashMap<>();
    map.put(JoseConstants.RSSEC_SIGNATURE_OUT_PROPS, properties);
    map.put(JoseConstants.RSSEC_SIGNATURE_IN_PROPS, "org/apache/cxf/systest/jaxrs/security/secret.jwk.hmac.properties");
    BookStore bs = createBookStore(address, map, null);
    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) HashMap(java.util.HashMap) Book(org.apache.cxf.systest.jaxrs.security.Book) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 17 with BookStore

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

the class JAXRSJwsMultipartTest method testJwsJwkBookHMacMultipartModified.

@Test(expected = BadRequestException.class)
public void testJwsJwkBookHMacMultipartModified() throws Exception {
    String address = "https://localhost:" + PORT + "/jwsjwkhmacModified";
    BookStore bs = createJwsBookStoreHMac(address, false, false);
    bs.echoBookMultipartModified(new Book("book", 123L));
}
Also used : BookStore(org.apache.cxf.systest.jaxrs.security.jose.BookStore) Book(org.apache.cxf.systest.jaxrs.security.Book) Test(org.junit.Test)

Example 18 with BookStore

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

the class JAXRSJwsMultipartTest method testJwsJwkBooksHMacMultipart.

@Test
public void testJwsJwkBooksHMacMultipart() throws Exception {
    String address = "https://localhost:" + PORT + "/jwsjwkhmac";
    BookStore bs = createJwsBookStoreHMac(address, false, false);
    List<Book> books = new LinkedList<Book>();
    books.add(new Book("book", 123L));
    books.add(new Book("book2", 124L));
    List<Book> returnBooks = bs.echoBooksMultipart(books);
    assertEquals("book", returnBooks.get(0).getName());
    assertEquals(123L, returnBooks.get(0).getId());
    assertEquals("book2", returnBooks.get(1).getName());
    assertEquals(124L, returnBooks.get(1).getId());
}
Also used : BookStore(org.apache.cxf.systest.jaxrs.security.jose.BookStore) Book(org.apache.cxf.systest.jaxrs.security.Book) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 19 with BookStore

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

the class JAXRSJwsMultipartTest method testJwsJwkBookHMacMultipartJwsJson.

@Test
public void testJwsJwkBookHMacMultipartJwsJson() throws Exception {
    String address = "https://localhost:" + PORT + "/jwsjwkhmacJwsJson";
    BookStore bs = createJwsBookStoreHMac(address, false, true);
    Book book = bs.echoBookMultipart(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) Test(org.junit.Test)

Example 20 with BookStore

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

the class JAXRSJweJsonTest method testJweJsonSingleRecipientKeyWrapAndAesCbcHmac.

@Test
public void testJweJsonSingleRecipientKeyWrapAndAesCbcHmac() throws Exception {
    String address = "https://localhost:" + PORT + "/jwejsonkeywrap";
    BookStore bs = createBookStore(address, "org/apache/cxf/systest/jaxrs/security/secret.jwk.properties");
    String text = bs.echoText("book");
    assertEquals("book", text);
}
Also used : BookStore(org.apache.cxf.systest.jaxrs.security.jose.BookStore) 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