Search in sources :

Example 71 with DoubleItPortType

use of org.example.contract.doubleit.DoubleItPortType in project cxf by apache.

the class ModifiedRequestTest method testModifiedSignature.

@org.junit.Test
public void testModifiedSignature() throws Exception {
    if (!unrestrictedPoliciesInstalled) {
        return;
    }
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = ModifiedRequestTest.class.getResource("client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = ModifiedRequestTest.class.getResource("DoubleItFault.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricPort");
    DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(port, PORT);
    Client cxfClient = ClientProxy.getClient(port);
    ModifiedSignatureInterceptor modifyInterceptor = new ModifiedSignatureInterceptor();
    cxfClient.getOutInterceptors().add(modifyInterceptor);
    makeInvocation(port, false);
    // Streaming invocation
    port = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(port, STAX_PORT);
    cxfClient = ClientProxy.getClient(port);
    modifyInterceptor = new ModifiedSignatureInterceptor();
    cxfClient.getOutInterceptors().add(modifyInterceptor);
    makeInvocation(port, true);
    ((java.io.Closeable) port).close();
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) DoubleItPortType(org.example.contract.doubleit.DoubleItPortType) Client(org.apache.cxf.endpoint.Client) URL(java.net.URL)

Example 72 with DoubleItPortType

use of org.example.contract.doubleit.DoubleItPortType in project cxf by apache.

the class GCMTest method testAESGCM192.

@org.junit.Test
public void testAESGCM192() throws Exception {
    if (!unrestrictedPoliciesInstalled) {
        return;
    }
    // 
    if ("IBM Corporation".equals(System.getProperty("java.vendor")) && System.getProperty("java.version") != null && System.getProperty("java.version").startsWith("1.7")) {
        return;
    }
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = GCMTest.class.getResource("client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = GCMTest.class.getResource("DoubleItGCM.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItGCM192Port");
    DoubleItPortType gcmPort = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(gcmPort, test.getPort());
    if (test.isStreaming()) {
        SecurityTestUtil.enableStreaming(gcmPort);
    }
    assertEquals(50, gcmPort.doubleIt(25));
    ((java.io.Closeable) gcmPort).close();
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) DoubleItPortType(org.example.contract.doubleit.DoubleItPortType) URL(java.net.URL)

Example 73 with DoubleItPortType

use of org.example.contract.doubleit.DoubleItPortType in project cxf by apache.

the class GCMTest method testAESGCM256MGFSHA256.

@org.junit.Test
public void testAESGCM256MGFSHA256() throws Exception {
    if (!unrestrictedPoliciesInstalled) {
        return;
    }
    // 
    if ("IBM Corporation".equals(System.getProperty("java.vendor")) && System.getProperty("java.version") != null && System.getProperty("java.version").startsWith("1.7")) {
        return;
    }
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = GCMTest.class.getResource("mgf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = GCMTest.class.getResource("DoubleItGCM.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItGCM256MGFSHA256Port");
    DoubleItPortType gcmPort = service.getPort(portQName, DoubleItPortType.class);
    String port = MGF_PORT;
    if (STAX_PORT.equals(test.getPort())) {
        port = MGF_STAX_PORT;
    }
    updateAddressPort(gcmPort, port);
    if (test.isStreaming()) {
        SecurityTestUtil.enableStreaming(gcmPort);
    }
    assertEquals(50, gcmPort.doubleIt(25));
    ((java.io.Closeable) gcmPort).close();
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) DoubleItPortType(org.example.contract.doubleit.DoubleItPortType) URL(java.net.URL)

Example 74 with DoubleItPortType

use of org.example.contract.doubleit.DoubleItPortType in project cxf by apache.

the class GCMTest method testAESGCM128.

@org.junit.Test
public void testAESGCM128() throws Exception {
    // 
    if ("IBM Corporation".equals(System.getProperty("java.vendor")) && System.getProperty("java.version") != null && System.getProperty("java.version").startsWith("1.7")) {
        return;
    }
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = GCMTest.class.getResource("client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = GCMTest.class.getResource("DoubleItGCM.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItGCM128Port");
    DoubleItPortType gcmPort = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(gcmPort, test.getPort());
    if (test.isStreaming()) {
        SecurityTestUtil.enableStreaming(gcmPort);
    }
    assertEquals(50, gcmPort.doubleIt(25));
    ((java.io.Closeable) gcmPort).close();
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) DoubleItPortType(org.example.contract.doubleit.DoubleItPortType) URL(java.net.URL)

Example 75 with DoubleItPortType

use of org.example.contract.doubleit.DoubleItPortType in project cxf by apache.

the class HTTPGetTest method testSignedBodyTimestamp.

@org.junit.Test
public void testSignedBodyTimestamp() throws Exception {
    if (!unrestrictedPoliciesInstalled) {
        return;
    }
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = HTTPGetTest.class.getResource("client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = HTTPGetTest.class.getResource("DoubleItHTTPGet.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItSignBodyPort");
    DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(port, PORT);
    Map<String, Object> outProps = new HashMap<>();
    outProps.put("action", "Timestamp Signature");
    outProps.put("signaturePropFile", "alice.properties");
    outProps.put("user", "alice");
    outProps.put("passwordCallbackClass", "org.apache.cxf.systest.ws.common.KeystorePasswordCallback");
    outProps.put("signatureParts", "{}{http://schemas.xmlsoap.org/soap/envelope/}Body;" + "{}{http://docs.oasis-open.org/wss/2004/01/oasis-" + "200401-wss-wssecurity-utility-1.0.xsd}Timestamp;");
    bus.getOutInterceptors().add(new WSS4JOutInterceptor(outProps));
    int result = port.doubleIt(25);
    assertEquals(result, 50);
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) DoubleItPortType(org.example.contract.doubleit.DoubleItPortType) WSS4JOutInterceptor(org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor) URL(java.net.URL)

Aggregations

URL (java.net.URL)360 QName (javax.xml.namespace.QName)360 Service (javax.xml.ws.Service)360 DoubleItPortType (org.example.contract.doubleit.DoubleItPortType)360 Bus (org.apache.cxf.Bus)354 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)352 SamlCallbackHandler (org.apache.cxf.systest.ws.saml.client.SamlCallbackHandler)31 Client (org.apache.cxf.endpoint.Client)22 STSClient (org.apache.cxf.ws.security.trust.STSClient)21 HashMap (java.util.HashMap)20 BindingProvider (javax.xml.ws.BindingProvider)17 WSS4JOutInterceptor (org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor)15 WSS4JStaxOutInterceptor (org.apache.cxf.ws.security.wss4j.WSS4JStaxOutInterceptor)13 KeystorePasswordCallback (org.apache.cxf.systest.ws.common.KeystorePasswordCallback)9 Test (org.junit.Test)9 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)8 BusException (org.apache.cxf.BusException)8 EndpointException (org.apache.cxf.endpoint.EndpointException)8 TokenStore (org.apache.cxf.ws.security.tokenstore.TokenStore)8 WebService (javax.jws.WebService)5