use of org.apache.coheigea.cxf.jaxrs.xmlsecurity.common.Number in project testcases by coheigea.
the class XMLEncryptionInteropTest method testXMLEncryption.
@org.junit.Test
public void testXMLEncryption() throws Exception {
URL busFile = XMLEncryptionInteropTest.class.getResource("cxf-client.xml");
String address = "http://localhost:" + test.port + "/doubleit/services";
WebClient client = WebClient.create(address, busFile.toString());
client = client.type("application/xml");
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("ws-security.callback-handler", "org.apache.coheigea.cxf.jaxrs.xmlsecurity.common.CommonCallbackHandler");
properties.put("ws-security.encryption.username", "myservicekey");
properties.put("ws-security.encryption.properties", "serviceKeystore.properties");
WebClient.getConfig(client).getRequestContext().putAll(properties);
if (test.streaming) {
XmlSecOutInterceptor encInterceptor = new XmlSecOutInterceptor();
encInterceptor.setEncryptRequest(true);
WebClient.getConfig(client).getOutInterceptors().add(encInterceptor);
XmlSecInInterceptor encInInterceptor = new XmlSecInInterceptor();
// encInInterceptor.setRequireEncryption(true);
WebClient.getConfig(client).getInInterceptors().add(encInInterceptor);
} else {
XmlEncOutInterceptor encInterceptor = new XmlEncOutInterceptor();
WebClient.getConfig(client).getOutInterceptors().add(encInterceptor);
XmlEncInInterceptor encInInterceptor = new XmlEncInInterceptor();
WebClient.getConfig(client).getInInterceptors().add(encInInterceptor);
}
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.xmlsecurity.common.Number in project testcases by coheigea.
the class XMLSignatureDOMTest method testXMLSignatureDOM.
@org.junit.Test
public void testXMLSignatureDOM() throws Exception {
URL busFile = XMLSignatureDOMTest.class.getResource("cxf-client.xml");
String address = "http://localhost:" + PORT + "/doubleit/services";
WebClient client = WebClient.create(address, busFile.toString());
client = client.type("application/xml");
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("ws-security.callback-handler", "org.apache.coheigea.cxf.jaxrs.xmlsecurity.common.CommonCallbackHandler");
properties.put("ws-security.signature.username", "myclientkey");
properties.put("ws-security.signature.properties", "clientKeystore.properties");
WebClient.getConfig(client).getRequestContext().putAll(properties);
XmlSigOutInterceptor sigInterceptor = new XmlSigOutInterceptor();
WebClient.getConfig(client).getOutInterceptors().add(sigInterceptor);
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.xmlsecurity.common.Number in project testcases by coheigea.
the class XMLEncryptionStaxTest method testXMLEncryption.
@org.junit.Test
public void testXMLEncryption() throws Exception {
URL busFile = XMLEncryptionStaxTest.class.getResource("cxf-client.xml");
String address = "http://localhost:" + STAX_PORT + "/doubleit/services";
WebClient client = WebClient.create(address, busFile.toString());
client = client.type("application/xml");
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("ws-security.callback-handler", "org.apache.coheigea.cxf.jaxrs.xmlsecurity.common.CommonCallbackHandler");
properties.put("ws-security.encryption.username", "myservicekey");
properties.put("ws-security.encryption.properties", "serviceKeystore.properties");
WebClient.getConfig(client).getRequestContext().putAll(properties);
XmlSecOutInterceptor encInterceptor = new XmlSecOutInterceptor();
encInterceptor.setEncryptRequest(true);
WebClient.getConfig(client).getOutInterceptors().add(encInterceptor);
XmlSecInInterceptor encInInterceptor = new XmlSecInInterceptor();
// encInInterceptor.setRequireEncryption(true);
WebClient.getConfig(client).getInInterceptors().add(encInInterceptor);
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.xmlsecurity.common.Number in project testcases by coheigea.
the class XMLSignatureInteropTest method testXMLSignature.
@org.junit.Test
public void testXMLSignature() throws Exception {
URL busFile = XMLSignatureInteropTest.class.getResource("cxf-client.xml");
String address = "http://localhost:" + test.port + "/doubleit/services";
WebClient client = WebClient.create(address, busFile.toString());
client = client.type("application/xml");
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("ws-security.callback-handler", "org.apache.coheigea.cxf.jaxrs.xmlsecurity.common.CommonCallbackHandler");
properties.put("ws-security.signature.username", "myclientkey");
properties.put("ws-security.signature.properties", "clientKeystore.properties");
WebClient.getConfig(client).getRequestContext().putAll(properties);
if (test.streaming) {
XmlSecOutInterceptor sigInterceptor = new XmlSecOutInterceptor();
sigInterceptor.setSignRequest(true);
WebClient.getConfig(client).getOutInterceptors().add(sigInterceptor);
} else {
XmlSigOutInterceptor sigInterceptor = new XmlSigOutInterceptor();
WebClient.getConfig(client).getOutInterceptors().add(sigInterceptor);
}
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.xmlsecurity.common.Number in project testcases by coheigea.
the class XMLEncryptionDOMTest method testXMLEncryptionDOM.
@org.junit.Test
public void testXMLEncryptionDOM() throws Exception {
URL busFile = XMLEncryptionDOMTest.class.getResource("cxf-client.xml");
String address = "http://localhost:" + PORT + "/doubleit/services";
WebClient client = WebClient.create(address, busFile.toString());
client = client.type("application/xml");
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("ws-security.callback-handler", "org.apache.coheigea.cxf.jaxrs.xmlsecurity.common.CommonCallbackHandler");
properties.put("ws-security.encryption.username", "myservicekey");
properties.put("ws-security.encryption.properties", "serviceKeystore.properties");
WebClient.getConfig(client).getRequestContext().putAll(properties);
XmlEncOutInterceptor encInterceptor = new XmlEncOutInterceptor();
WebClient.getConfig(client).getOutInterceptors().add(encInterceptor);
XmlEncInInterceptor encInInterceptor = new XmlEncInInterceptor();
WebClient.getConfig(client).getInInterceptors().add(encInInterceptor);
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