Search in sources :

Example 66 with DoubleItPortType

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

the class FaultTest method testSoap12.

@org.junit.Test
public void testSoap12() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = FaultTest.class.getResource("client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = FaultTest.class.getResource("DoubleItFault.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItSoap12Port");
    DoubleItPortType utPort = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(utPort, PORT);
    // Make a successful invocation
    ((BindingProvider) utPort).getRequestContext().put(SecurityConstants.USERNAME, "alice");
    assertEquals(50, utPort.doubleIt(25));
    // Now make an invocation using another username
    ((BindingProvider) utPort).getRequestContext().put(SecurityConstants.USERNAME, "bob");
    ((BindingProvider) utPort).getRequestContext().put("security.password", "password");
    try {
        utPort.doubleIt(25);
        fail("Expected failure on bob");
    } catch (Exception ex) {
        assertTrue(ex.getMessage().contains("This is a fault"));
    }
    ((java.io.Closeable) utPort).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 67 with DoubleItPortType

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

the class FaultTest method testUnsecuredSoap11ActionStAX.

@org.junit.Test
public void testUnsecuredSoap11ActionStAX() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = FaultTest.class.getResource("client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = FaultTest.class.getResource("DoubleItFault.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItSoap11UnsecuredPort2");
    DoubleItPortType utPort = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(utPort, PORT);
    try {
        utPort.doubleIt(25);
        fail("Expected failure on bob");
    } catch (Exception ex) {
        assertTrue(ex.getMessage().contains("This is a fault"));
    }
    ((java.io.Closeable) utPort).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 68 with DoubleItPortType

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

the class ModifiedRequestTest method testModifiedEncryptedSOAPBody.

@org.junit.Test
public void testModifiedEncryptedSOAPBody() 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);
    ModifiedEncryptedSOAPBody modifyInterceptor = new ModifiedEncryptedSOAPBody();
    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 ModifiedEncryptedSOAPBody();
    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 69 with DoubleItPortType

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

the class ModifiedRequestTest method testUntrustedSignature.

@org.junit.Test
public void testUntrustedSignature() throws Exception {
    if (!unrestrictedPoliciesInstalled) {
        return;
    }
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = ModifiedRequestTest.class.getResource("client-untrusted.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);
    makeInvocation(port, false);
    // Streaming invocation
    port = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(port, STAX_PORT);
    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) URL(java.net.URL)

Example 70 with DoubleItPortType

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

the class ModifiedRequestTest method testModifiedSignedTimestamp.

@org.junit.Test
public void testModifiedSignedTimestamp() 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);
    ModifiedTimestampInterceptor modifyInterceptor = new ModifiedTimestampInterceptor();
    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 ModifiedTimestampInterceptor();
    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)

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