Search in sources :

Example 1 with NoneJwsSignatureProvider

use of org.apache.cxf.rs.security.jose.jws.NoneJwsSignatureProvider in project cxf by apache.

the class JweJwsAlgorithmTest method testUnsignedTokenFailure.

@org.junit.Test
public void testUnsignedTokenFailure() throws Exception {
    URL busFile = JweJwsAlgorithmTest.class.getResource("client.xml");
    List<Object> providers = new ArrayList<>();
    providers.add(new JacksonJsonProvider());
    JwsWriterInterceptor writerInterceptor = new JwsWriterInterceptor();
    writerInterceptor.setSignatureProvider(new NoneJwsSignatureProvider());
    providers.add(writerInterceptor);
    String address = "http://localhost:" + PORT + "/jws/bookstore/books";
    WebClient client = WebClient.create(address, providers, busFile.toString());
    client.type("application/json").accept("application/json");
    Map<String, Object> properties = new HashMap<>();
    properties.put("rs.security.keystore.type", "jwk");
    properties.put("rs.security.keystore.alias", "2011-04-29");
    properties.put("rs.security.keystore.file", "org/apache/cxf/systest/jaxrs/security/certs/jwkPrivateSet.txt");
    properties.put("rs.security.signature.algorithm", "none");
    WebClient.getConfig(client).getRequestContext().putAll(properties);
    Response response = client.post(new Book("book", 123L));
    assertNotEquals(response.getStatus(), 200);
}
Also used : HashMap(java.util.HashMap) JacksonJsonProvider(com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider) ArrayList(java.util.ArrayList) WebClient(org.apache.cxf.jaxrs.client.WebClient) URL(java.net.URL) Response(javax.ws.rs.core.Response) Book(org.apache.cxf.systest.jaxrs.security.Book) JwsWriterInterceptor(org.apache.cxf.rs.security.jose.jaxrs.JwsWriterInterceptor) NoneJwsSignatureProvider(org.apache.cxf.rs.security.jose.jws.NoneJwsSignatureProvider)

Aggregations

JacksonJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Response (javax.ws.rs.core.Response)1 WebClient (org.apache.cxf.jaxrs.client.WebClient)1 JwsWriterInterceptor (org.apache.cxf.rs.security.jose.jaxrs.JwsWriterInterceptor)1 NoneJwsSignatureProvider (org.apache.cxf.rs.security.jose.jws.NoneJwsSignatureProvider)1 Book (org.apache.cxf.systest.jaxrs.security.Book)1