Search in sources :

Example 76 with Service

use of javax.xml.ws.Service in project cxf by apache.

the class CustomOnBehalfOfTest method testUsernameOnBehalfOfSTS.

@org.junit.Test
public void testUsernameOnBehalfOfSTS() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = CustomOnBehalfOfTest.class.getResource("cxf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = CustomOnBehalfOfTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItTransportCustomBSTPort");
    DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(transportPort, PORT);
    // Transport port
    ((BindingProvider) transportPort).getRequestContext().put(SecurityConstants.USERNAME, "alice");
    doubleIt(transportPort, 25);
    ((java.io.Closeable) transportPort).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 77 with Service

use of javax.xml.ws.Service in project cxf by apache.

the class DistributedCachingTest method testSAMLToken.

@org.junit.Test
public void testSAMLToken() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = DistributedCachingTest.class.getResource("cxf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = DistributedCachingTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItSAMLPort");
    DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(transportPort, PORT);
    // Transport port
    doubleIt(transportPort, 25);
    ((java.io.Closeable) transportPort).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 78 with Service

use of javax.xml.ws.Service in project cxf by apache.

the class DistributedCachingTest method testUsernameToken.

@org.junit.Test
public void testUsernameToken() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = DistributedCachingTest.class.getResource("cxf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = DistributedCachingTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItUsernameTokenPort");
    DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(transportPort, PORT);
    // Transport port
    doubleIt(transportPort, 25);
    ((java.io.Closeable) transportPort).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 79 with Service

use of javax.xml.ws.Service in project cxf by apache.

the class DistributedCachingTest method testSecurityContextToken.

@org.junit.Test
public void testSecurityContextToken() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = DistributedCachingTest.class.getResource("cxf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = DistributedCachingTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItSCTPort");
    DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(transportPort, PORT);
    // Transport port
    doubleIt(transportPort, 25);
    ((java.io.Closeable) transportPort).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 80 with Service

use of javax.xml.ws.Service in project cxf by apache.

the class DifferentRealmTest method testUnknownRealm.

/**
 * In this test, a token is issued by the first STS in realm "C". The second STS is not
 * configured to trust realm "C" (via a cert constraint) and so authentication does not succeed.
 */
@org.junit.Test
public void testUnknownRealm() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = DifferentRealmTest.class.getResource("cxf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = DifferentRealmTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItRealmCPort");
    DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(transportPort, PORT);
    // Transport port
    try {
        doubleIt(transportPort, 25);
    } catch (Exception ex) {
    // expected
    }
    ((java.io.Closeable) transportPort).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)

Aggregations

Service (javax.xml.ws.Service)598 URL (java.net.URL)547 QName (javax.xml.namespace.QName)524 Bus (org.apache.cxf.Bus)399 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)384 DoubleItPortType (org.example.contract.doubleit.DoubleItPortType)361 Test (org.junit.Test)143 BindingProvider (javax.xml.ws.BindingProvider)63 Client (org.apache.cxf.endpoint.Client)43 HashMap (java.util.HashMap)36 SamlCallbackHandler (org.apache.cxf.systest.ws.saml.client.SamlCallbackHandler)31 STSClient (org.apache.cxf.ws.security.trust.STSClient)28 WSS4JOutInterceptor (org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor)25 WebServiceException (javax.xml.ws.WebServiceException)20 WebService (javax.jws.WebService)18 IOException (java.io.IOException)16 File (java.io.File)15 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)15 Greeter (org.apache.hello_world_soap_http.Greeter)15 KeystorePasswordCallback (org.apache.cxf.systest.ws.common.KeystorePasswordCallback)14