Search in sources :

Example 36 with DoubleItPortType

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

the class X509AsymmetricBindingTest method testX509SAML2.

@org.junit.Test
public void testX509SAML2() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = X509AsymmetricBindingTest.class.getResource("cxf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = X509AsymmetricBindingTest.class.getResource("DoubleItAsymmetric.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricSAML2Port");
    DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(port, PORT);
    TokenTestUtils.updateSTSPort((BindingProvider) port, STSPORT2);
    doubleIt(port, 30);
    ((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 37 with DoubleItPortType

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

the class X509SymmetricBindingTest method testX509SAML1.

@org.junit.Test
public void testX509SAML1() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = X509SymmetricBindingTest.class.getResource("cxf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = X509SymmetricBindingTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItSymmetricSAML1Port");
    DoubleItPortType symmetricSaml1Port = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(symmetricSaml1Port, test.getPort());
    TokenTestUtils.updateSTSPort((BindingProvider) symmetricSaml1Port, test.getStsPort());
    if (test.isStreaming()) {
        SecurityTestUtil.enableStreaming(symmetricSaml1Port);
    }
    doubleIt(symmetricSaml1Port, 25);
    ((java.io.Closeable) symmetricSaml1Port).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 38 with DoubleItPortType

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

the class X509SymmetricBindingTest method testX509SAML2.

@org.junit.Test
public void testX509SAML2() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = X509SymmetricBindingTest.class.getResource("cxf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = X509SymmetricBindingTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItSymmetricSAML2Port");
    DoubleItPortType symmetricSaml2Port = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(symmetricSaml2Port, test.getPort());
    TokenTestUtils.updateSTSPort((BindingProvider) symmetricSaml2Port, test.getStsPort());
    if (test.isStreaming()) {
        SecurityTestUtil.enableStreaming(symmetricSaml2Port);
    }
    doubleIt(symmetricSaml2Port, 30);
    TokenTestUtils.verifyToken(symmetricSaml2Port);
    ((java.io.Closeable) symmetricSaml2Port).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 39 with DoubleItPortType

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

the class X509SymmetricBindingTest method testX509SAML2Endorsing.

@org.junit.Test
public void testX509SAML2Endorsing() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = X509SymmetricBindingTest.class.getResource("cxf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = X509SymmetricBindingTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItSymmetricSAML2EndorsingPort");
    DoubleItPortType symmetricSaml2Port = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(symmetricSaml2Port, test.getPort());
    TokenTestUtils.updateSTSPort((BindingProvider) symmetricSaml2Port, test.getStsPort());
    if (test.isStreaming()) {
        SecurityTestUtil.enableStreaming(symmetricSaml2Port);
    }
    // TODO Streaming client is not including a separate main Signature
    if (!test.isStreaming()) {
        doubleIt(symmetricSaml2Port, 30);
    }
    ((java.io.Closeable) symmetricSaml2Port).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 40 with DoubleItPortType

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

the class DoubleItPortTypeImpl method doubleIt.

public int doubleIt(int numberToDouble) {
    // Delegate request to a provider
    URL wsdl = DoubleItPortTypeImpl.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML2SupportingPort");
    DoubleItPortType transportSAML2SupportingPort = service.getPort(portQName, DoubleItPortType.class);
    try {
        updateAddressPort(transportSAML2SupportingPort, getPort());
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    // 
    // Get the principal from the request context and construct a SAML Assertion
    // 
    Saml2CallbackHandler callbackHandler = new Saml2CallbackHandler(wsc.getUserPrincipal());
    ((BindingProvider) transportSAML2SupportingPort).getRequestContext().put(SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler);
    return transportSAML2SupportingPort.doubleIt(numberToDouble);
}
Also used : QName(javax.xml.namespace.QName) WebService(javax.jws.WebService) 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