use of org.apache.coheigea.cxf.jaxrs.json.common.Number in project testcases by coheigea.
the class JWETest method testRSAEncryption.
@org.junit.Test
public void testRSAEncryption() throws Exception {
URL busFile = JWETest.class.getResource("cxf-client.xml");
List<Object> providers = new ArrayList<Object>();
providers.add(new JacksonJsonProvider());
providers.add(new JweWriterInterceptor());
String address = "http://localhost:" + PORT + "/doubleit/services";
WebClient client = WebClient.create(address, providers, busFile.toString());
client.type("application/json").accept("application/json");
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("rs.security.keystore.type", "jks");
properties.put("rs.security.keystore.password", "sspass");
properties.put("rs.security.keystore.alias", "myservicekey");
properties.put("rs.security.keystore.file", "servicestore.jks");
properties.put("rs.security.encryption.key.algorithm", "RSA-OAEP");
properties.put("rs.security.encryption.content.algorithm", "A128CBC-HS256");
WebClient.getConfig(client).getRequestContext().putAll(properties);
Number numberToDouble = new Number();
numberToDouble.setDescription("This is the number to double");
numberToDouble.setNumber(25);
Response response = client.post(numberToDouble);
assertEquals(response.getStatus(), 200);
assertEquals(response.readEntity(Number.class).getNumber(), 50);
}
use of org.apache.coheigea.cxf.jaxrs.json.common.Number in project testcases by coheigea.
the class JWETest method testAESKWEncryption.
@org.junit.Test
public void testAESKWEncryption() throws Exception {
URL busFile = JWETest.class.getResource("cxf-client.xml");
List<Object> providers = new ArrayList<Object>();
providers.add(new JacksonJsonProvider());
providers.add(new JweWriterInterceptor());
String address = "http://localhost:" + PORT5 + "/doubleit/services";
WebClient client = WebClient.create(address, providers, busFile.toString());
client.type("application/json").accept("application/json");
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("rs.security.keystore.type", "jwk");
properties.put("rs.security.keystore.alias", "AesWrapKey");
properties.put("rs.security.keystore.file", "jwk.txt");
properties.put("rs.security.encryption.content.algorithm", "A128CBC-HS256");
WebClient.getConfig(client).getRequestContext().putAll(properties);
Number numberToDouble = new Number();
numberToDouble.setDescription("This is the number to double");
numberToDouble.setNumber(25);
Response response = client.post(numberToDouble);
assertEquals(response.getStatus(), 200);
assertEquals(response.readEntity(Number.class).getNumber(), 50);
}
use of org.apache.coheigea.cxf.jaxrs.json.common.Number in project testcases by coheigea.
the class JWETest method testECEncryption.
// TODO
@org.junit.Test
@org.junit.Ignore
public void testECEncryption() throws Exception {
URL busFile = JWETest.class.getResource("cxf-client.xml");
List<Object> providers = new ArrayList<Object>();
providers.add(new JacksonJsonProvider());
providers.add(new JweWriterInterceptor());
String address = "http://localhost:" + PORT2 + "/doubleit/services";
WebClient client = WebClient.create(address, providers, busFile.toString());
client.type("application/json").accept("application/json");
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("rs.security.keystore.type", "jks");
properties.put("rs.security.keystore.password", "security");
properties.put("rs.security.keystore.alias", "ECDSA");
properties.put("rs.security.keystore.file", "ecdsa.jks");
properties.put("rs.security.encryption.key.algorithm", "ECDH-ES+A128KW");
properties.put("rs.security.encryption.content.algorithm", "A128CBC-HS256");
WebClient.getConfig(client).getRequestContext().putAll(properties);
Number numberToDouble = new Number();
numberToDouble.setDescription("This is the number to double");
numberToDouble.setNumber(25);
Response response = client.post(numberToDouble);
assertEquals(response.getStatus(), 200);
assertEquals(response.readEntity(Number.class).getNumber(), 50);
}
use of org.apache.coheigea.cxf.jaxrs.json.common.Number in project testcases by coheigea.
the class JWETest method testEncryptionCertificateTest.
// Include the cert in the "x5c" header
@org.junit.Test
public void testEncryptionCertificateTest() throws Exception {
URL busFile = JWETest.class.getResource("cxf-client.xml");
List<Object> providers = new ArrayList<Object>();
providers.add(new JacksonJsonProvider());
providers.add(new JweWriterInterceptor());
String address = "http://localhost:" + PORT6 + "/doubleit/services";
WebClient client = WebClient.create(address, providers, busFile.toString());
client.type("application/json").accept("application/json");
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("rs.security.keystore.type", "jks");
properties.put("rs.security.keystore.password", "sspass");
properties.put("rs.security.keystore.alias", "myservicekey");
properties.put("rs.security.keystore.file", "servicestore.jks");
properties.put("rs.security.encryption.key.algorithm", "RSA-OAEP");
properties.put("rs.security.encryption.content.algorithm", "A128CBC-HS256");
properties.put("rs.security.encryption.include.cert", "true");
WebClient.getConfig(client).getRequestContext().putAll(properties);
Number numberToDouble = new Number();
numberToDouble.setDescription("This is the number to double");
numberToDouble.setNumber(25);
Response response = client.post(numberToDouble);
assertEquals(response.getStatus(), 200);
assertEquals(response.readEntity(Number.class).getNumber(), 50);
}
use of org.apache.coheigea.cxf.jaxrs.json.common.Number in project testcases by coheigea.
the class JWETest method testRSAv15Encryption.
@org.junit.Test
public void testRSAv15Encryption() throws Exception {
URL busFile = JWETest.class.getResource("cxf-client.xml");
List<Object> providers = new ArrayList<Object>();
providers.add(new JacksonJsonProvider());
providers.add(new JweWriterInterceptor());
String address = "http://localhost:" + PORT4 + "/doubleit/services";
WebClient client = WebClient.create(address, providers, busFile.toString());
client.type("application/json").accept("application/json");
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("rs.security.keystore.type", "jks");
properties.put("rs.security.keystore.password", "sspass");
properties.put("rs.security.keystore.alias", "myservicekey");
properties.put("rs.security.keystore.file", "servicestore.jks");
properties.put("rs.security.encryption.key.algorithm", "RSA1_5");
properties.put("rs.security.encryption.content.algorithm", "A128CBC-HS256");
WebClient.getConfig(client).getRequestContext().putAll(properties);
Number numberToDouble = new Number();
numberToDouble.setDescription("This is the number to double");
numberToDouble.setNumber(25);
Response response = client.post(numberToDouble);
assertEquals(response.getStatus(), 200);
assertEquals(response.readEntity(Number.class).getNumber(), 50);
}
Aggregations