use of org.apache.coheigea.cxf.jaxrs.json.common.Number in project testcases by coheigea.
the class JWSSignatureTest method testSignatureCompact.
@org.junit.Test
public void testSignatureCompact() 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:" + 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.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 testHMACSignatureCompact.
@org.junit.Test
public void testHMACSignatureCompact() 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:" + PORT3 + "/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", "HMACKey");
properties.put("rs.security.keystore.file", "jwk.txt");
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 testEllipticCurveSignatureCompact.
// TODO Signature is not validating for some reason
@org.junit.Test
@org.junit.Ignore
public void testEllipticCurveSignatureCompact() throws Exception {
try {
Security.addProvider(new BouncyCastleProvider());
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:" + 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", "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.key.password", "security");
properties.put("rs.security.signature.algorithm", "ES256");
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);
} finally {
Security.removeProvider(BouncyCastleProvider.class.getName());
}
}
use of org.apache.coheigea.cxf.jaxrs.json.common.Number in project testcases by coheigea.
the class JWTAuthenticationTest method testAuthenticatedRequest.
@org.junit.Test
public void testAuthenticatedRequest() throws Exception {
URL busFile = JWTAuthenticationTest.class.getResource("cxf-client.xml");
List<Object> providers = new ArrayList<Object>();
providers.add(new JacksonJsonProvider());
providers.add(new JwtAuthenticationClientFilter());
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.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(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 JWTAuthorizationTest method testAuthorizedRequest.
@org.junit.Test
public void testAuthorizedRequest() throws Exception {
URL busFile = JWTAuthorizationTest.class.getResource("cxf-client.xml");
List<Object> providers = new ArrayList<Object>();
providers.add(new JacksonJsonProvider());
providers.add(new JwtAuthenticationClientFilter());
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.setProperty("role", "boss");
claims.setAudiences(Collections.singletonList(address));
JwtToken token = new JwtToken(claims);
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(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);
}
Aggregations