Search in sources :

Example 1 with Number

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);
}
Also used : Response(javax.ws.rs.core.Response) Number(org.apache.coheigea.cxf.jaxrs.xmlsecurity.common.Number) HashMap(java.util.HashMap) XmlSecInInterceptor(org.apache.cxf.rs.security.xml.XmlSecInInterceptor) XmlEncOutInterceptor(org.apache.cxf.rs.security.xml.XmlEncOutInterceptor) XmlSecOutInterceptor(org.apache.cxf.rs.security.xml.XmlSecOutInterceptor) WebClient(org.apache.cxf.jaxrs.client.WebClient) XmlEncInInterceptor(org.apache.cxf.rs.security.xml.XmlEncInInterceptor) URL(java.net.URL)

Example 2 with Number

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);
}
Also used : Response(javax.ws.rs.core.Response) XmlSigOutInterceptor(org.apache.cxf.rs.security.xml.XmlSigOutInterceptor) Number(org.apache.coheigea.cxf.jaxrs.xmlsecurity.common.Number) HashMap(java.util.HashMap) WebClient(org.apache.cxf.jaxrs.client.WebClient) URL(java.net.URL)

Example 3 with Number

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);
}
Also used : Response(javax.ws.rs.core.Response) Number(org.apache.coheigea.cxf.jaxrs.xmlsecurity.common.Number) HashMap(java.util.HashMap) XmlSecInInterceptor(org.apache.cxf.rs.security.xml.XmlSecInInterceptor) XmlSecOutInterceptor(org.apache.cxf.rs.security.xml.XmlSecOutInterceptor) WebClient(org.apache.cxf.jaxrs.client.WebClient) URL(java.net.URL)

Example 4 with Number

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);
}
Also used : Response(javax.ws.rs.core.Response) XmlSigOutInterceptor(org.apache.cxf.rs.security.xml.XmlSigOutInterceptor) Number(org.apache.coheigea.cxf.jaxrs.xmlsecurity.common.Number) HashMap(java.util.HashMap) XmlSecOutInterceptor(org.apache.cxf.rs.security.xml.XmlSecOutInterceptor) WebClient(org.apache.cxf.jaxrs.client.WebClient) URL(java.net.URL)

Example 5 with Number

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);
}
Also used : Response(javax.ws.rs.core.Response) Number(org.apache.coheigea.cxf.jaxrs.xmlsecurity.common.Number) HashMap(java.util.HashMap) XmlEncOutInterceptor(org.apache.cxf.rs.security.xml.XmlEncOutInterceptor) WebClient(org.apache.cxf.jaxrs.client.WebClient) XmlEncInInterceptor(org.apache.cxf.rs.security.xml.XmlEncInInterceptor) URL(java.net.URL)

Aggregations

URL (java.net.URL)8 HashMap (java.util.HashMap)8 Response (javax.ws.rs.core.Response)8 Number (org.apache.coheigea.cxf.jaxrs.xmlsecurity.common.Number)8 WebClient (org.apache.cxf.jaxrs.client.WebClient)8 XmlSecOutInterceptor (org.apache.cxf.rs.security.xml.XmlSecOutInterceptor)4 XmlSigOutInterceptor (org.apache.cxf.rs.security.xml.XmlSigOutInterceptor)4 XmlEncInInterceptor (org.apache.cxf.rs.security.xml.XmlEncInInterceptor)2 XmlEncOutInterceptor (org.apache.cxf.rs.security.xml.XmlEncOutInterceptor)2 XmlSecInInterceptor (org.apache.cxf.rs.security.xml.XmlSecInInterceptor)2