Package org.apache.cxf

Examples of org.apache.cxf.Bus


        createStaticBus();
    }
    @AfterClass
    public static void reset() {
        System.clearProperty("org.apache.cxf.transports.http_jetty.DontClosePort." + PORT);
        Bus b = BusFactory.getDefaultBus(false);
        if (b == null) {
            b = BusFactory.getThreadDefaultBus(false);
        }
        if (b == null) {
            b = BusFactory.getDefaultBus();
        }
        b.shutdown(true);
    }
View Full Code Here


    public void testSAML2Bearer() throws Exception {

        SpringBusFactory bf = new SpringBusFactory();
        URL busFile = BearerTest.class.getResource("cxf-client.xml");

        Bus bus = bf.createBus(busFile.toString());
        SpringBusFactory.setDefaultBus(bus);
        SpringBusFactory.setThreadDefaultBus(bus);

        URL wsdl = BearerTest.class.getResource("DoubleIt.wsdl");
        Service service = Service.create(wsdl, SERVICE_QNAME);
        QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML2BearerPort");
        DoubleItPortType transportSaml2Port =
            service.getPort(portQName, DoubleItPortType.class);
        updateAddressPort(transportSaml2Port, PORT);
        if (standalone) {
            TokenTestUtils.updateSTSPort((BindingProvider)transportSaml2Port, STSPORT);
        }
       
        doubleIt(transportSaml2Port, 45);
       
        ((java.io.Closeable)transportSaml2Port).close();
        bus.shutdown(true);
    }
View Full Code Here

    public void testSAML2UnsignedBearer() throws Exception {

        SpringBusFactory bf = new SpringBusFactory();
        URL busFile = BearerTest.class.getResource("cxf-unsigned-client.xml");

        Bus bus = bf.createBus(busFile.toString());
        SpringBusFactory.setDefaultBus(bus);
        SpringBusFactory.setThreadDefaultBus(bus);

        URL wsdl = BearerTest.class.getResource("DoubleIt.wsdl");
        Service service = Service.create(wsdl, SERVICE_QNAME);
        QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML2BearerPort");
        DoubleItPortType transportSaml2Port =
            service.getPort(portQName, DoubleItPortType.class);
        updateAddressPort(transportSaml2Port, PORT);
        if (standalone) {
            TokenTestUtils.updateSTSPort((BindingProvider)transportSaml2Port, STSPORT);
        }
       
        //
        // Create a SAML2 Bearer Assertion and add it to the TokenStore so that the
        // IssuedTokenInterceptorProvider does not invoke on the STS
        //
        Client client = ClientProxy.getClient(transportSaml2Port);
        Endpoint ep = client.getEndpoint();
        String id = "1234";
        ep.getEndpointInfo().setProperty(TokenStore.class.getName(), new MemoryTokenStore());
        ep.getEndpointInfo().setProperty(SecurityConstants.TOKEN_ID, id);
        TokenStore store = (TokenStore)ep.getEndpointInfo().getProperty(TokenStore.class.getName());

        SAMLParms samlParms = new SAMLParms();
        samlParms.setCallbackHandler(new Saml2CallbackHandler());
        AssertionWrapper assertion = new AssertionWrapper(samlParms);
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);
        DocumentBuilder db = dbf.newDocumentBuilder();
        Element assertionElement = assertion.toDOM(db.newDocument());
       
        SecurityToken tok = new SecurityToken(id);
        tok.setTokenType(WSConstants.WSS_SAML2_TOKEN_TYPE);
        tok.setToken(assertionElement);
        store.add(tok);
       
        doubleIt(transportSaml2Port, 50);
       
        ((java.io.Closeable)transportSaml2Port).close();
        bus.shutdown(true);
    }
View Full Code Here

    public void testSAML2BearerNoBinding() throws Exception {

        SpringBusFactory bf = new SpringBusFactory();
        URL busFile = BearerTest.class.getResource("cxf-client.xml");

        Bus bus = bf.createBus(busFile.toString());
        SpringBusFactory.setDefaultBus(bus);
        SpringBusFactory.setThreadDefaultBus(bus);

        URL wsdl = BearerTest.class.getResource("DoubleIt.wsdl");
        Service service = Service.create(wsdl, SERVICE_QNAME);
        QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML2BearerPort2");
        DoubleItPortType transportSaml2Port =
            service.getPort(portQName, DoubleItPortType.class);
        updateAddressPort(transportSaml2Port, PORT);
        if (standalone) {
            TokenTestUtils.updateSTSPort((BindingProvider)transportSaml2Port, STSPORT);
        }
       
        doubleIt(transportSaml2Port, 45);
       
        ((java.io.Closeable)transportSaml2Port).close();
        bus.shutdown(true);
    }
View Full Code Here

    public void testSymmetric() throws Exception {

        SpringBusFactory bf = new SpringBusFactory();
        URL busFile = CachingTest.class.getResource("client/client.xml");

        Bus bus = bf.createBus(busFile.toString());
        SpringBusFactory.setDefaultBus(bus);
        SpringBusFactory.setThreadDefaultBus(bus);
       
        URL wsdl = CachingTest.class.getResource("DoubleItCache.wsdl");
        Service service = Service.create(wsdl, SERVICE_QNAME);
        QName portQName = new QName(NAMESPACE, "DoubleItCacheSymmetricPort");
       
        // First invocation
        DoubleItPortType port =
                service.getPort(portQName, DoubleItPortType.class);
        updateAddressPort(port, PORT);
       
        port.doubleIt(25);

        Client client = ClientProxy.getClient(port);
        TokenStore tokenStore =
            (TokenStore)client.getEndpoint().getEndpointInfo().getProperty(
                SecurityConstants.TOKEN_STORE_CACHE_INSTANCE
            );
        assertNotNull(tokenStore);
        // We expect 1 token
        assertEquals(tokenStore.getTokenIdentifiers().size(), 1);
       
        // Second invocation
        port = service.getPort(portQName, DoubleItPortType.class);
        updateAddressPort(port, PORT);
       
        port.doubleIt(35);

        client = ClientProxy.getClient(port);
        tokenStore =
            (TokenStore)client.getEndpoint().getEndpointInfo().getProperty(
                SecurityConstants.TOKEN_STORE_CACHE_INSTANCE
            );
        assertNotNull(tokenStore);
        // There should now be 2 tokens as both proxies share the same TokenStore
        assertEquals(tokenStore.getTokenIdentifiers().size(), 2);
       
        ((java.io.Closeable)port).close();
        bus.shutdown(true);
    }
View Full Code Here

    public void testCachePerProxySymmetric() throws Exception {

        SpringBusFactory bf = new SpringBusFactory();
        URL busFile = CachingTest.class.getResource("client/client.xml");

        Bus bus = bf.createBus(busFile.toString());
        SpringBusFactory.setDefaultBus(bus);
        SpringBusFactory.setThreadDefaultBus(bus);
       
        URL wsdl = CachingTest.class.getResource("DoubleItCache.wsdl");
        Service service = Service.create(wsdl, SERVICE_QNAME);
        QName portQName = new QName(NAMESPACE, "DoubleItCachePerProxySymmetricPort");
       
        // First invocation
        DoubleItPortType port =
                service.getPort(portQName, DoubleItPortType.class);
        updateAddressPort(port, PORT);
       
        ((BindingProvider)port).getRequestContext().put(
            SecurityConstants.CACHE_IDENTIFIER, "proxy1"
        );
        ((BindingProvider)port).getRequestContext().put(
            SecurityConstants.CACHE_CONFIG_FILE, "client/per-proxy-cache.xml"
        );
       
        port.doubleIt(25);

        Client client = ClientProxy.getClient(port);
        TokenStore tokenStore =
            (TokenStore)client.getEndpoint().getEndpointInfo().getProperty(
                SecurityConstants.TOKEN_STORE_CACHE_INSTANCE
            );
        assertNotNull(tokenStore);
        // We expect 1 token
        assertEquals(tokenStore.getTokenIdentifiers().size(), 1);
       
        // Second invocation
        port = service.getPort(portQName, DoubleItPortType.class);
        updateAddressPort(port, PORT);
       
        ((BindingProvider)port).getRequestContext().put(
            SecurityConstants.CACHE_IDENTIFIER, "proxy2"
        );
        ((BindingProvider)port).getRequestContext().put(
            SecurityConstants.CACHE_CONFIG_FILE, "client/per-proxy-cache.xml"
        );
       
        port.doubleIt(35);

        client = ClientProxy.getClient(port);
        tokenStore =
            (TokenStore)client.getEndpoint().getEndpointInfo().getProperty(
                SecurityConstants.TOKEN_STORE_CACHE_INSTANCE
            );
        assertNotNull(tokenStore);
        // We expect 1 token
        assertEquals(tokenStore.getTokenIdentifiers().size(), 1);
       
        ((java.io.Closeable)port).close();
        bus.shutdown(true);
    }
View Full Code Here

    public void testSymmetricBinding() throws Exception {

        SpringBusFactory bf = new SpringBusFactory();
        URL busFile = XKMSTest.class.getResource("client.xml");

        Bus bus = bf.createBus(busFile.toString());
        SpringBusFactory.setDefaultBus(bus);
        SpringBusFactory.setThreadDefaultBus(bus);
       
        URL wsdl = XKMSTest.class.getResource("DoubleItXKMS.wsdl");
        Service service = Service.create(wsdl, SERVICE_QNAME);
        QName portQName = new QName(NAMESPACE, "DoubleItSymmetricPort");
        DoubleItPortType port =
                service.getPort(portQName, DoubleItPortType.class);
        updateAddressPort(port, PORT);
       
        port.doubleIt(25);
       
        ((java.io.Closeable)port).close();
        bus.shutdown(true);
    }
View Full Code Here

    public void testAsymmetricBinding() throws Exception {

        SpringBusFactory bf = new SpringBusFactory();
        URL busFile = XKMSTest.class.getResource("client.xml");

        Bus bus = bf.createBus(busFile.toString());
        SpringBusFactory.setDefaultBus(bus);
        SpringBusFactory.setThreadDefaultBus(bus);
       
        URL wsdl = XKMSTest.class.getResource("DoubleItXKMS.wsdl");
        Service service = Service.create(wsdl, SERVICE_QNAME);
        QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricPort");
        DoubleItPortType port =
                service.getPort(portQName, DoubleItPortType.class);
        updateAddressPort(port, PORT);
       
        port.doubleIt(25);
       
        ((java.io.Closeable)port).close();
        bus.shutdown(true);
    }
View Full Code Here

    public static class Server extends AbstractBusTestServerBase {

        Endpoint ep;
        protected void run() {
            SpringBusFactory factory = new SpringBusFactory();
            Bus bus = factory.createBus();
            BusFactory.setDefaultBus(bus);
            setBus(bus);

            ControlImpl implementor = new ControlImpl();
            implementor.setAddress("http://localhost:" + PORT + "/SoapContext/GreeterPort");
View Full Code Here

    }

    protected void run()  {
        URL busFile = JavaFirstPolicyServer.class.getResource("javafirstserver.xml");
        Bus busLocal = new SpringBusFactory().createBus(busFile);
        BusFactory.setDefaultBus(busLocal);
        Assert.assertNotNull(busLocal);
        setBus(busLocal);

        try {
View Full Code Here

TOP

Related Classes of org.apache.cxf.Bus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.