Search in sources :

Example 31 with DoubleItPortType

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

the class IntermediaryTransformationCachingTest method testIntermediaryTransformationCaching.

@org.junit.Test
public void testIntermediaryTransformationCaching() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = IntermediaryTransformationCachingTest.class.getResource("cxf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = IntermediaryTransformationCachingTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML1EndorsingPort");
    DoubleItPortType alicePort = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(alicePort, PORT);
    TokenTestUtils.updateSTSPort((BindingProvider) alicePort, STSPORT);
    ((BindingProvider) alicePort).getRequestContext().put(SecurityConstants.USERNAME, "alice");
    // Make initial successful invocation (for "alice")
    doubleIt(alicePort, 25);
    // Make another successful invocation for "bob"
    DoubleItPortType bobPort = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(bobPort, PORT);
    TokenTestUtils.updateSTSPort((BindingProvider) bobPort, STSPORT);
    ((BindingProvider) bobPort).getRequestContext().put(SecurityConstants.USERNAME, "bob");
    doubleIt(bobPort, 30);
    // Make another invocation for "bob" - this should work as the intermediary caches the token
    // even though its STSClient is disabled after the second invocation
    doubleIt(bobPort, 35);
    // Make another invocation for "alice" - this should work as the intermediary caches the token
    // even though its STSClient is disabled after the first invocation
    doubleIt(alicePort, 40);
    // Now make an invocation for "myservicekey"
    DoubleItPortType servicePort = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(servicePort, PORT);
    TokenTestUtils.updateSTSPort((BindingProvider) servicePort, STSPORT);
    ((BindingProvider) servicePort).getRequestContext().put(SecurityConstants.USERNAME, "myservicekey");
    // Make invocation for "myservicekey"...this should fail as the intermediary's STS client is disabled
    try {
        doubleIt(servicePort, 45);
        fail("Expected failure on a cache retrieval failure");
    } catch (SOAPFaultException ex) {
    // expected
    }
    ((java.io.Closeable) alicePort).close();
    ((java.io.Closeable) bobPort).close();
    ((java.io.Closeable) servicePort).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) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) DoubleItPortType(org.example.contract.doubleit.DoubleItPortType) URL(java.net.URL)

Example 32 with DoubleItPortType

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

the class IntermediaryTransformationTest method testIntermediaryTransformationBadClient.

@org.junit.Test
public void testIntermediaryTransformationBadClient() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = IntermediaryTransformationTest.class.getResource("cxf-bad-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = IntermediaryTransformationTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML1EndorsingPort");
    DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(transportPort, PORT);
    TokenTestUtils.updateSTSPort((BindingProvider) transportPort, STSPORT);
    try {
        doubleIt(transportPort, 30);
        fail("Expected failure on a bad user");
    } 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)

Example 33 with DoubleItPortType

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

the class IssuerTest method testSAML2MEXSoap12.

// Test getting the STS details via WS-MEX + SOAP 1.2
@org.junit.Test
public void testSAML2MEXSoap12() throws Exception {
    if (!portFree) {
        return;
    }
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = IssuerTest.class.getResource("cxf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = IssuerTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML2Soap12Port");
    DoubleItPortType transportSaml2Port = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(transportSaml2Port, PORT);
    doubleIt(transportSaml2Port, 25);
    ((java.io.Closeable) transportSaml2Port).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 34 with DoubleItPortType

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

the class JAASTest method testSuccessfulInvocationConfig.

// Here the service config has no TLS settings for the call to the STS...it's configured
// separately via the JAAS configuration
@org.junit.Test
@org.junit.Ignore
public void testSuccessfulInvocationConfig() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = JAASTest.class.getResource("cxf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = JAASTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItUTPort");
    DoubleItPortType utPort = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(utPort, PORT2);
    ((BindingProvider) utPort).getRequestContext().put(SecurityConstants.USERNAME, "alice");
    ((BindingProvider) utPort).getRequestContext().put(SecurityConstants.PASSWORD, "clarinet");
    doubleIt(utPort, 25);
    ((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 35 with DoubleItPortType

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

the class JAASTest method testSuccessfulInvocationWithProperties.

@org.junit.Test
public void testSuccessfulInvocationWithProperties() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = JAASTest.class.getResource("cxf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = JAASTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItUTPort2");
    DoubleItPortType utPort = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(utPort, PORT);
    ((BindingProvider) utPort).getRequestContext().put(SecurityConstants.USERNAME, "alice");
    ((BindingProvider) utPort).getRequestContext().put(SecurityConstants.PASSWORD, "clarinet");
    doubleIt(utPort, 25);
    // Note that the UsernameToken should be cached for the second invocation
    doubleIt(utPort, 35);
    ((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)

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