Search in sources :

Example 31 with BookStore

use of org.apache.cxf.systest.jaxrs.security.jose.BookStore 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());
}
Also used : BookStore(org.apache.cxf.systest.jaxrs.security.jose.BookStore) HashMap(java.util.HashMap) JweWriterInterceptor(org.apache.cxf.rs.security.jose.jaxrs.JweWriterInterceptor) JweClientResponseFilter(org.apache.cxf.rs.security.jose.jaxrs.JweClientResponseFilter) Book(org.apache.cxf.systest.jaxrs.security.Book) JacksonJsonProvider(com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider) Test(org.junit.Test)

Example 32 with BookStore

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

the class JAXRSJwsJsonTest method testJwsJsonPlaintextHMACBadKey.

// Test signing with a bad signature key
@Test
public void testJwsJsonPlaintextHMACBadKey() throws Exception {
    String address = "https://localhost:" + PORT + "/jwsjsonhmac";
    BookStore bs = createBookStore(address, "org/apache/cxf/systest/jaxrs/security/secret.jwk.bad.properties", null);
    try {
        bs.echoText("book");
        fail("Failure expected on a bad signature key");
    } catch (BadRequestException ex) {
    // expected
    }
}
Also used : BookStore(org.apache.cxf.systest.jaxrs.security.jose.BookStore) BadRequestException(javax.ws.rs.BadRequestException) Test(org.junit.Test)

Example 33 with BookStore

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

the class JAXRSJwsMultipartTest method testJwsJwkBookHMacMultipartBuffered.

@Test
public void testJwsJwkBookHMacMultipartBuffered() throws Exception {
    String address = "https://localhost:" + PORT + "/jwsjwkhmac";
    BookStore bs = createJwsBookStoreHMac(address, true, false);
    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 34 with BookStore

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

the class JAXRSJwsMultipartTest method testJwsJwkBookHMacMultipart.

@Test
public void testJwsJwkBookHMacMultipart() throws Exception {
    String address = "https://localhost:" + PORT + "/jwsjwkhmac";
    BookStore bs = createJwsBookStoreHMac(address, false, false);
    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 35 with BookStore

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

the class JAXRSJwsMultipartTest method testJwsJwkBooksHMacMultipartUnsigned.

@Test(expected = BadRequestException.class)
public void testJwsJwkBooksHMacMultipartUnsigned() throws Exception {
    String address = "https://localhost:" + PORT + "/jwsjwkhmac";
    BookStore bs = JAXRSClientFactory.create(address, BookStore.class, JAXRSJwsMultipartTest.class.getResource("client.xml").toString());
    bs.echoBookMultipart(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)

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