use of org.apache.coheigea.cxf.jaxrs.json.common.Number in project testcases by coheigea.
the class JWTEncryptedTest method testEncryptedToken.
@org.junit.Test
public void testEncryptedToken() throws Exception {
URL busFile = JWETest.class.getResource("cxf-client.xml");
List<Object> providers = new ArrayList<Object>();
providers.add(new JacksonJsonProvider());
JwtAuthenticationClientFilter jwtFilter = new JwtAuthenticationClientFilter();
jwtFilter.setJwsRequired(false);
jwtFilter.setJweRequired(true);
providers.add(jwtFilter);
String address = "http://localhost:" + PORT + "/doubleit/services";
WebClient client = WebClient.create(address, providers, busFile.toString());
client.type("application/json").accept("application/json");
// Create the JWT Token
JwtClaims claims = new JwtClaims();
claims.setSubject("alice");
claims.setIssuer("DoubleItSTSIssuer");
claims.setIssuedAt(new Date().getTime() / 1000L);
claims.setAudiences(Collections.singletonList(address));
JwtToken token = new JwtToken(claims);
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("rs.security.encryption.properties", "clientEncKeystore.properties");
properties.put(JwtConstants.JWT_TOKEN, token);
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 testEncryptionProperties.
@org.junit.Test
public void testEncryptionProperties() 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.encryption.properties", "clientEncKeystore.properties");
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 testEncryptingXMLPayload.
@org.junit.Test
public void testEncryptingXMLPayload() 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:" + PORT3 + "/doubleit/services";
WebClient client = WebClient.create(address, providers, busFile.toString());
client.type("application/xml").accept("application/xml");
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("rs.security.encryption.properties", "clientEncKeystore.properties");
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 JWEJWSTest method testEncryptionSignatureCompactProperties.
@org.junit.Test
public void testEncryptionSignatureCompactProperties() throws Exception {
URL busFile = JWEJWSTest.class.getResource("cxf-client.xml");
List<Object> providers = new ArrayList<Object>();
providers.add(new JacksonJsonProvider());
providers.add(new JweWriterInterceptor());
providers.add(new JwsWriterInterceptor());
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.encryption.properties", "clientEncKeystore.properties");
properties.put("rs.security.signature.out.properties", "clientKeystore.properties");
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 JWSSignatureTest method testSignatureCertificateSha1Test.
// Include the cert digest in the "x5t" header
@org.junit.Test
public void testSignatureCertificateSha1Test() throws Exception {
URL busFile = JWSSignatureTest.class.getResource("cxf-client.xml");
List<Object> providers = new ArrayList<Object>();
providers.add(new JacksonJsonProvider());
JwsWriterInterceptor writer = new JwsWriterInterceptor();
providers.add(writer);
String address = "http://localhost:" + PORT8 + "/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", "cspass");
properties.put("rs.security.keystore.alias", "myclientkey");
properties.put("rs.security.keystore.file", "clientstore.jks");
properties.put("rs.security.key.password", "ckpass");
properties.put("rs.security.signature.algorithm", "RS256");
properties.put("rs.security.signature.include.cert.sha1", "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);
}
Aggregations