use of com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider in project cxf by apache.
the class JweJwsAlgorithmTest method testWrongSignatureAlgorithm.
@org.junit.Test
public void testWrongSignatureAlgorithm() throws Exception {
URL busFile = JweJwsAlgorithmTest.class.getResource("client.xml");
List<Object> providers = new ArrayList<>();
providers.add(new JacksonJsonProvider());
providers.add(new JwsWriterInterceptor());
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", "PS256");
WebClient.getConfig(client).getRequestContext().putAll(properties);
Response response = client.post(new Book("book", 123L));
assertNotEquals(response.getStatus(), 200);
}
use of com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider in project cxf by apache.
the class JweJwsAlgorithmTest method testWrongKeyEncryptionAlgorithmKeyIncluded.
@org.junit.Test
public void testWrongKeyEncryptionAlgorithmKeyIncluded() throws Exception {
URL busFile = JweJwsAlgorithmTest.class.getResource("client.xml");
List<Object> providers = new ArrayList<>();
providers.add(new JacksonJsonProvider());
providers.add(new JweWriterInterceptor());
String address = "http://localhost:" + PORT + "/jweoaepgcm/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/jwkPublicSet.txt");
properties.put("rs.security.encryption.content.algorithm", "A128GCM");
properties.put("rs.security.encryption.key.algorithm", "RSA1_5");
properties.put("rs.security.encryption.include.public.key", "true");
WebClient.getConfig(client).getRequestContext().putAll(properties);
Response response = client.post(new Book("book", 123L));
assertNotEquals(response.getStatus(), 200);
}
use of com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider in project cxf by apache.
the class JweJwsAlgorithmTest method testSignatureEllipticCurve.
@org.junit.Test
public void testSignatureEllipticCurve() throws Exception {
URL busFile = JweJwsAlgorithmTest.class.getResource("client.xml");
List<Object> providers = new ArrayList<>();
providers.add(new JacksonJsonProvider());
providers.add(new JwsWriterInterceptor());
String address = "http://localhost:" + PORT + "/jwsec/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", "ECKey");
properties.put("rs.security.keystore.file", "org/apache/cxf/systest/jaxrs/security/certs/jwkPrivateSet.txt");
properties.put("rs.security.signature.algorithm", "ES256");
WebClient.getConfig(client).getRequestContext().putAll(properties);
Response response = client.post(new Book("book", 123L));
assertEquals(response.getStatus(), 200);
Book returnedBook = response.readEntity(Book.class);
assertEquals(returnedBook.getName(), "book");
assertEquals(returnedBook.getId(), 123L);
}
use of com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider in project cxf by apache.
the class JwsHTTPHeaderTest method testSignHTTPHeaders.
@org.junit.Test
public void testSignHTTPHeaders() throws Exception {
URL busFile = JwsHTTPHeaderTest.class.getResource("client.xml");
List<Object> providers = new ArrayList<>();
providers.add(new JacksonJsonProvider());
JwsWriterInterceptor jwsWriterInterceptor = new JwsWriterInterceptor();
providers.add(jwsWriterInterceptor);
String address = "http://localhost:" + PORT + "/jwsheaderdefault/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", "RS256");
WebClient.getConfig(client).getRequestContext().putAll(properties);
// Expect failure on not signing the default headers
Response response = client.post(new Book("book", 123L));
assertNotEquals(response.getStatus(), 200);
jwsWriterInterceptor.setProtectHttpHeaders(true);
response = client.post(new Book("book", 123L));
assertEquals(response.getStatus(), 200);
}
use of com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider in project cxf by apache.
the class JwsHTTPHeaderTest method testSpecifyHeadersToSign.
@org.junit.Test
public void testSpecifyHeadersToSign() throws Exception {
URL busFile = JwsHTTPHeaderTest.class.getResource("client.xml");
List<Object> providers = new ArrayList<>();
providers.add(new JacksonJsonProvider());
JwsWriterInterceptor jwsWriterInterceptor = new JwsWriterInterceptor();
jwsWriterInterceptor.setProtectHttpHeaders(true);
Set<String> headersToSign = new HashSet<>();
headersToSign.add(HttpHeaders.CONTENT_TYPE);
jwsWriterInterceptor.setProtectedHttpHeaders(headersToSign);
providers.add(jwsWriterInterceptor);
String address = "http://localhost:" + PORT + "/jwsheaderdefault/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", "RS256");
WebClient.getConfig(client).getRequestContext().putAll(properties);
// Expect failure on not signing all of the default headers
Response response = client.post(new Book("book", 123L));
assertNotEquals(response.getStatus(), 200);
headersToSign.add(HttpHeaders.ACCEPT);
response = client.post(new Book("book", 123L));
assertEquals(response.getStatus(), 200);
}
Aggregations