Search in sources :

Example 41 with DoubleItPortType

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

the class SenderVouchesTest method testSenderVouches.

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

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

the class SymmetricBindingTest method testUsernameTokenSAML2.

@org.junit.Test
public void testUsernameTokenSAML2() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = SymmetricBindingTest.class.getResource("cxf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = SymmetricBindingTest.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 43 with DoubleItPortType

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

the class SymmetricBindingTest method testUsernameTokenSAML1Encrypted.

@org.junit.Test
public void testUsernameTokenSAML1Encrypted() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = SymmetricBindingTest.class.getResource("cxf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = SymmetricBindingTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItSymmetricSAML1EncryptedPort");
    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 44 with DoubleItPortType

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

the class SymmetricBindingTest method testUsernameTokenSAML2ProtectTokens.

@org.junit.Test
public void testUsernameTokenSAML2ProtectTokens() throws Exception {
    if (test.isStreaming()) {
        // We don't support ProtectTokens + the streaming clients.
        return;
    }
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = SymmetricBindingTest.class.getResource("cxf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = SymmetricBindingTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItSymmetricSAML2ProtectTokensPort");
    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 45 with DoubleItPortType

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

the class TemplateTest method testBearerToSAML2PublicKey.

@org.junit.Test
public void testBearerToSAML2PublicKey() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = TemplateTest.class.getResource("cxf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = TemplateTest.class.getResource("DoubleItNoTemplate2.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML2PublicKeyPort");
    DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(port, test.getPort());
    // Setup STSClient
    STSClient stsClient = createSTSClient(bus);
    stsClient.setKeyType("http://docs.oasis-open.org/ws-sx/ws-trust/200512/Bearer");
    stsClient.setTokenType("http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0");
    String wsdlLocation = "https://localhost:" + test.getStsPort() + "/SecurityTokenService/Transport?wsdl";
    stsClient.setWsdlLocation(wsdlLocation);
    ((BindingProvider) port).getRequestContext().put(SecurityConstants.STS_CLIENT, stsClient);
    if (test.isStreaming()) {
        SecurityTestUtil.enableStreaming(port);
    }
    try {
        doubleIt(port, 25);
        fail("Failure expected on sending a SAML 2.0 Bearer token");
    } catch (Exception ex) {
    // expected
    }
    ((java.io.Closeable) port).close();
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) STSClient(org.apache.cxf.ws.security.trust.STSClient) 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