org.apache.cxf.Bus Java Examples
The following examples show how to use
org.apache.cxf.Bus.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServiceInvocationAckBase.java From cxf with Apache License 2.0 | 7 votes |
protected void run() { SpringBusFactory factory = new SpringBusFactory(); Bus bus = factory.createBus(); BusFactory.setDefaultBus(bus); setBus(bus); ControlImpl implementor = new ControlImpl(); implementor.setDbName(pfx + "-server"); implementor.setAddress("http://localhost:" + port + "/SoapContext/GreeterPort"); GreeterImpl greeterImplementor = new GreeterImpl(); implementor.setImplementor(greeterImplementor); ep = Endpoint.publish("http://localhost:" + port + "/SoapContext/ControlPort", implementor); LOG.fine("Published control endpoint."); BusFactory.setDefaultBus(null); BusFactory.setThreadDefaultBus(null); }
Example #2
Source File: MTOMSecurityTest.java From cxf with Apache License 2.0 | 6 votes |
@org.junit.Test public void testAsymmetricBytesInAttachment() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = MTOMSecurityTest.class.getResource("client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = MTOMSecurityTest.class.getResource("DoubleItMtom.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricPort"); DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class); updateAddressPort(port, PORT); int result = port.doubleIt(25); assertEquals(result, 50); ((java.io.Closeable)port).close(); bus.shutdown(true); }
Example #3
Source File: SecurityContextTokenUnitTest.java From cxf with Apache License 2.0 | 6 votes |
@org.junit.Test public void testSecurityContextTokenNoEntropy() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = SecurityContextTokenUnitTest.class.getResource("cxf-client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); String wsdlLocation = "https://localhost:" + test.getStsPort() + "/SecurityTokenService/TransportSCT?wsdl"; SecurityToken token = requestSecurityToken(bus, wsdlLocation, false); assertTrue(token.getSecret() != null && token.getSecret().length > 0); bus.shutdown(true); }
Example #4
Source File: PolicyExtensionsTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testCXF4258() { Bus bus = null; try { bus = new SpringBusFactory().createBus("/org/apache/cxf/ws/policy/disable-policy-bus.xml", false); AssertionBuilderRegistry abr = bus.getExtension(AssertionBuilderRegistry.class); assertNotNull(abr); PolicyEngine e = bus.getExtension(PolicyEngine.class); assertNotNull(e); assertNoPolicyInterceptors(bus.getInInterceptors()); assertNoPolicyInterceptors(bus.getInFaultInterceptors()); assertNoPolicyInterceptors(bus.getOutFaultInterceptors()); assertNoPolicyInterceptors(bus.getOutInterceptors()); } finally { if (null != bus) { bus.shutdown(true); BusFactory.setDefaultBus(null); } } }
Example #5
Source File: SAMLRenewUnitTest.java From cxf with Apache License 2.0 | 6 votes |
private SecurityToken renewSecurityToken( Bus bus, String wsdlLocation, SecurityToken securityToken, boolean enableAppliesTo ) throws Exception { STSClient stsClient = new STSClient(bus); stsClient.setWsdlLocation(wsdlLocation); stsClient.setServiceName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}SecurityTokenService"); stsClient.setEndpointName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}Transport_Port"); Map<String, Object> properties = new HashMap<>(); properties.put(SecurityConstants.USERNAME, "alice"); properties.put( SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.sts.common.CommonCallbackHandler" ); properties.put(SecurityConstants.STS_TOKEN_PROPERTIES, "serviceKeystore.properties"); stsClient.setEnableAppliesTo(enableAppliesTo); // Request a token with a TTL of 60 minutes stsClient.setTtl(60 * 60); stsClient.setEnableLifetime(true); stsClient.setProperties(properties); stsClient.setAddressingNamespace("http://www.w3.org/2005/08/addressing"); return stsClient.renewSecurityToken(securityToken); }
Example #6
Source File: MetricsFeature.java From cxf with Apache License 2.0 | 6 votes |
private void createDefaultProvidersIfNeeded(Bus bus) { if (providers == null) { ConfiguredBeanLocator b = bus.getExtension(ConfiguredBeanLocator.class); if (b != null) { Collection<?> coll = b.getBeansOfType(MetricsProvider.class); if (coll != null) { providers = coll.toArray(new MetricsProvider[]{}); } } } if (providers == null) { try { Class<?> cls = ClassLoaderUtils.loadClass("org.apache.cxf.metrics.codahale.CodahaleMetricsProvider", org.apache.cxf.metrics.MetricsFeature.class); Constructor<?> c = cls.getConstructor(Bus.class); providers = new MetricsProvider[] {(MetricsProvider)c.newInstance(bus)}; } catch (Throwable t) { // ignore; } } }
Example #7
Source File: ActionTest.java From cxf with Apache License 2.0 | 6 votes |
@org.junit.Test public void test3DESEncryptionGivenKey() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = ActionTest.class.getResource("client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = ActionTest.class.getResource("DoubleItAction.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleIt3DESEncryptionPort"); DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class); updateAddressPort(port, PORT); assertEquals(50, port.doubleIt(25)); ((java.io.Closeable)port).close(); bus.shutdown(true); }
Example #8
Source File: EHCacheManagerHolder.java From steady with Apache License 2.0 | 6 votes |
public static CacheManager getCacheManager(Bus bus, URL configFileURL) { CacheManager cacheManager = null; if (configFileURL == null) { //using the default cacheManager = findDefaultCacheManager(bus); } if (cacheManager == null) { if (configFileURL == null) { cacheManager = CacheManager.create(); } else { cacheManager = CacheManager.create(configFileURL); } } AtomicInteger a = COUNTS.get(cacheManager.getName()); if (a == null) { COUNTS.putIfAbsent(cacheManager.getName(), new AtomicInteger()); a = COUNTS.get(cacheManager.getName()); } if (a.incrementAndGet() == 1) { //System.out.println("Create!! " + cacheManager.getName()); } return cacheManager; }
Example #9
Source File: RMPolicyWsdlTestBase.java From cxf with Apache License 2.0 | 6 votes |
protected void run() { SpringBusFactory bf = new SpringBusFactory(); Bus bus = bf.createBus(getConfigPath()); BusFactory.setDefaultBus(bus); setBus(bus); ServerRegistry sr = bus.getExtension(ServerRegistry.class); PolicyEngine pe = bus.getExtension(PolicyEngine.class); List<PolicyAssertion> assertions1 = getAssertions(pe, sr.getServers().get(0)); assertEquals("2 assertions should be available", 2, assertions1.size()); List<PolicyAssertion> assertions2 = getAssertions(pe, sr.getServers().get(1)); assertEquals("1 assertion should be available", 1, assertions2.size()); LOG.info("Published greeter endpoints."); }
Example #10
Source File: NettyServerTest.java From cxf with Apache License 2.0 | 6 votes |
@BeforeClass public static void start() throws Exception { Bus b = createStaticBus(); BusFactory.setThreadDefaultBus(b); ep = Endpoint.publish("netty://http://localhost:" + PORT + "/SoapContext/SoapPort", new org.apache.hello_world_soap_http.GreeterImpl()); URL wsdl = NettyServerTest.class.getResource("/wsdl/hello_world.wsdl"); assertNotNull("WSDL is null", wsdl); SOAPService service = new SOAPService(wsdl); assertNotNull("Service is null", service); g = service.getSoapPort(); assertNotNull("Port is null", g); }
Example #11
Source File: BusWiringBeanFactoryPostProcessor.java From cxf with Apache License 2.0 | 6 votes |
private Object getBusForName(String name, ConfigurableListableBeanFactory factory, boolean create, String cn) { if (!factory.containsBeanDefinition(name) && (create || Bus.DEFAULT_BUS_ID.equals(name))) { DefaultListableBeanFactory df = (DefaultListableBeanFactory)factory; RootBeanDefinition rbd = new RootBeanDefinition(SpringBus.class); if (cn != null) { rbd.setAttribute("busConfig", new RuntimeBeanReference(cn)); } df.registerBeanDefinition(name, rbd); } else if (cn != null) { BeanDefinition bd = factory.getBeanDefinition(name); bd.getPropertyValues().addPropertyValue("busConfig", new RuntimeBeanReference(cn)); } return new RuntimeBeanReference(name); }
Example #12
Source File: WSDLAddrPolicyAttachmentJaxwsMMProviderTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testUsingAddressing() throws Exception { SpringBusFactory bf = new SpringBusFactory(); Bus bus = bf.createBus("org/apache/cxf/systest/ws/policy/addr-inline-policy-old.xml"); BusFactory.setDefaultBus(bus); URL wsdlURL = new URL(WSDL_ADDRESS); AsyncMessagingService ams = new AsyncMessagingService(wsdlURL, ENDPOINT_NAME); AsyncMessaging am = ams.getAsyncMessagingImplPort(); ConnectionHelper.setKeepAliveConnection(am, true); testInterceptors(bus); // oneway am.deliver("This is a test"); am.deliver("This is another test"); bus.shutdown(true); }
Example #13
Source File: BusCompleter.java From cxf with Apache License 2.0 | 6 votes |
@Override public int complete(Session session, CommandLine commandLine, List<String> list) { StringsCompleter delegate = new StringsCompleter(); try { List<Bus> busses = getBusses(); for (Bus bus : busses) { delegate.getStrings().add(bus.getId()); } } catch (Exception e) { // Ignore } return delegate.complete(session, commandLine, list); }
Example #14
Source File: ColocOutInterceptorTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testColocOutInvalidEndpoint() throws Exception { Bus bus = setupBus(); ServerRegistry sr = control.createMock(ServerRegistry.class); EasyMock.expect(bus.getExtension(ServerRegistry.class)).andReturn(sr); control.replay(); try { colocOut.handleMessage(msg); fail("Should have thrown a fault"); } catch (Fault f) { assertEquals("Consumer Endpoint not found in exchange.", f.getMessage()); } }
Example #15
Source File: BusDefinitionParserTest.java From cxf with Apache License 2.0 | 6 votes |
@Test @SuppressWarnings("deprecation") public void testFeatures() { String cfgFile = "org/apache/cxf/bus/spring/bus.xml"; Bus bus = new SpringBusFactory().createBus(cfgFile, true); List<Interceptor<? extends Message>> in = bus.getInInterceptors(); assertTrue("could not find logging interceptor.", in.stream().anyMatch(i -> i.getClass() == org.apache.cxf.interceptor.LoggingInInterceptor.class)); Collection<Feature> features = bus.getFeatures(); TestFeature tf = null; for (Feature f : features) { if (f instanceof TestFeature) { tf = (TestFeature)f; break; } } assertNotNull(tf); assertTrue("test feature has not been initialised", tf.initialised); assertNotNull("test feature has not been injected", tf.testBean); assertTrue("bean injected into test feature has not been initialised", tf.testBean.initialised); }
Example #16
Source File: ManagedBusTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testManagedSpringBus() throws Exception { SpringBusFactory factory = new SpringBusFactory(); Bus bus = factory.createBus(); InstrumentationManager im = bus.getExtension(InstrumentationManager.class); assertNotNull(im); InstrumentationManagerImpl imi = (InstrumentationManagerImpl)im; assertFalse(imi.isEnabled()); assertNull(imi.getMBeanServer()); //Test that registering without an MBeanServer is a no-op im.register(imi, new ObjectName("org.apache.cxf:foo=bar")); bus.shutdown(true); }
Example #17
Source File: SecurityContextTokenUnitTest.java From cxf with Apache License 2.0 | 6 votes |
@org.junit.Test public void testSecurityContextTokenEncrypted() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = SecurityContextTokenUnitTest.class.getResource("cxf-client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); String wsdlLocation = "https://localhost:" + test.getStsPort() + "/SecurityTokenService/TransportSCTEncrypted?wsdl"; SecurityToken token = requestSecurityToken(bus, wsdlLocation, true); assertTrue(token.getSecret() != null && token.getSecret().length > 0); bus.shutdown(true); }
Example #18
Source File: AbstractPolicySecurityTest.java From steady with Apache License 2.0 | 6 votes |
/** * Gets a SoapMessage, but with the needed SecurityConstants in the context properties * so that it can be passed to PolicyBasedWSS4JOutInterceptor. * * @see #getSoapMessageForDom(Document, AssertionInfoMap) */ protected SoapMessage getOutSoapMessageForDom(Document doc, AssertionInfoMap aim) throws SOAPException { SoapMessage msg = this.getSoapMessageForDom(doc, aim); msg.put(SecurityConstants.SIGNATURE_PROPERTIES, "outsecurity.properties"); msg.put(SecurityConstants.ENCRYPT_PROPERTIES, "outsecurity.properties"); msg.put(SecurityConstants.CALLBACK_HANDLER, TestPwdCallback.class.getName()); msg.put(SecurityConstants.SIGNATURE_USERNAME, "myalias"); msg.put(SecurityConstants.ENCRYPT_USERNAME, "myalias"); msg.getExchange().put(Endpoint.class, new MockEndpoint()); msg.getExchange().put(Bus.class, this.bus); msg.put(Message.REQUESTOR_ROLE, true); return msg; }
Example #19
Source File: DispatchTest.java From cxf with Apache License 2.0 | 6 votes |
@Test // CXF-2822 public void testInterceptorsConfiguration() throws Exception { String cfgFile = "org/apache/cxf/jaxws/dispatch/bus-dispatch.xml"; Bus bus = new SpringBusFactory().createBus(cfgFile, true); ServiceImpl service = new ServiceImpl(bus, getClass().getResource("/wsdl/hello_world.wsdl"), SERVICE_NAME, null); Dispatch<Source> disp = service.createDispatch(PORT_NAME, Source.class, Service.Mode.MESSAGE); List<Interceptor<? extends Message>> interceptors = ((DispatchImpl<?>)disp).getClient() .getInInterceptors(); boolean exists = false; for (Interceptor<? extends Message> interceptor : interceptors) { if (interceptor instanceof LoggingInInterceptor) { exists = true; } } assertTrue("The LoggingInInterceptor is not configured to dispatch client", exists); }
Example #20
Source File: SSLNettyServerTest.java From cxf with Apache License 2.0 | 6 votes |
@BeforeClass public static void start() throws Exception { Bus b = createStaticBus("/org/apache/cxf/transport/http/netty/server/integration/ServerConfig.xml"); // setup the ssl interceptor MySSLInterceptor myInterceptor = new MySSLInterceptor(); b.getInInterceptors().add(myInterceptor); BusFactory.setThreadDefaultBus(b); address = "https://localhost:" + PORT + "/SoapContext/SoapPort"; ep = Endpoint.publish(address, new org.apache.hello_world_soap_http.GreeterImpl()); URL wsdl = NettyServerTest.class.getResource("/wsdl/hello_world.wsdl"); assertNotNull("WSDL is null", wsdl); SOAPService service = new SOAPService(wsdl); assertNotNull("Service is null", service); g = service.getSoapPort(); assertNotNull("Port is null", g); }
Example #21
Source File: SamlSubjectConfTest.java From cxf with Apache License 2.0 | 5 votes |
@org.junit.Test public void testSVNoClientAuthentication() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = SamlSubjectConfTest.class.getResource("client-noauth.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = SamlSubjectConfTest.class.getResource("DoubleItSamlSubjectConf.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItSaml2TransportPort"); DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class); updateAddressPort(port, test.getPort()); // Successful call SamlCallbackHandler callbackHandler = new SamlCallbackHandler(true, false); callbackHandler.setConfirmationMethod(SAML2Constants.CONF_SENDER_VOUCHES); ((BindingProvider)port).getRequestContext().put( SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler ); try { port.doubleIt(25); fail("Failure expected on no client auth"); } catch (javax.xml.ws.soap.SOAPFaultException ex) { // expected } ((java.io.Closeable)port).close(); bus.shutdown(true); }
Example #22
Source File: BookServerHTTPHeaders.java From cxf with Apache License 2.0 | 5 votes |
protected void run() { SpringBusFactory bf = new SpringBusFactory(); Bus springBus = bf.createBus(SERVER_CONFIG_FILE); BusFactory.setDefaultBus(springBus); setBus(springBus); try { new BookServerHTTPHeaders(); } catch (Exception e) { throw new RuntimeException(e); } }
Example #23
Source File: BookServerJwsMultipart.java From cxf with Apache License 2.0 | 5 votes |
protected void run() { SpringBusFactory bf = new SpringBusFactory(); Bus springBus = bf.createBus(SERVER_CONFIG_FILE); BusFactory.setDefaultBus(springBus); setBus(springBus); try { new BookServerJwsMultipart(); } catch (Exception e) { throw new RuntimeException(e); } }
Example #24
Source File: ProxyTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testRMClientGetConduit() throws Exception { Proxy proxy = new Proxy(rme); Bus bus = control.createMock(Bus.class); Endpoint endpoint = control.createMock(Endpoint.class); Conduit conduit = control.createMock(Conduit.class); ConduitSelector cs = control.createMock(ConduitSelector.class); EasyMock.expect(cs.selectConduit(EasyMock.isA(Message.class))).andReturn(conduit).anyTimes(); control.replay(); Proxy.RMClient client = proxy.new RMClient(bus, endpoint, cs); assertSame(conduit, client.getConduit()); client.close(); }
Example #25
Source File: JAXRSJweJwsTest.java From cxf with Apache License 2.0 | 5 votes |
private BookStore createJweJwsBookStore(String address, JwsSignatureProvider jwsSigProvider, List<?> mbProviders) throws Exception { JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); SpringBusFactory bf = new SpringBusFactory(); URL busFile = JAXRSJweJwsTest.class.getResource("client.xml"); Bus springBus = bf.createBus(busFile.toString()); bean.setBus(springBus); bean.setServiceClass(BookStore.class); bean.setAddress(address); List<Object> providers = new LinkedList<>(); JweWriterInterceptor jweWriter = new JweWriterInterceptor(); jweWriter.setUseJweOutputStream(true); providers.add(jweWriter); providers.add(new JweClientResponseFilter()); JwsWriterInterceptor jwsWriter = new JwsWriterInterceptor(); if (jwsSigProvider != null) { jwsWriter.setSignatureProvider(jwsSigProvider); } jwsWriter.setUseJwsOutputStream(true); providers.add(jwsWriter); providers.add(new JwsClientResponseFilter()); if (mbProviders != null) { providers.addAll(mbProviders); } bean.setProviders(providers); bean.getProperties(true).put("rs.security.encryption.out.properties", SERVER_JWEJWS_PROPERTIES); bean.getProperties(true).put("rs.security.signature.out.properties", CLIENT_JWEJWS_PROPERTIES); bean.getProperties(true).put("rs.security.encryption.in.properties", CLIENT_JWEJWS_PROPERTIES); bean.getProperties(true).put("rs.security.signature.in.properties", SERVER_JWEJWS_PROPERTIES); PrivateKeyPasswordProvider provider = new PrivateKeyPasswordProviderImpl(); bean.getProperties(true).put("rs.security.signature.key.password.provider", provider); bean.getProperties(true).put("rs.security.decryption.key.password.provider", provider); return bean.create(BookStore.class); }
Example #26
Source File: CXFBusImplTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testExtensions() { Bus bus = new ExtensionManagerBus(); String extension = "CXF"; bus.setExtension(extension, String.class); assertSame(extension, bus.getExtension(String.class)); bus.shutdown(true); }
Example #27
Source File: FailoverFeature.java From cxf with Apache License 2.0 | 5 votes |
@Override public void doInitializeProvider(InterceptorProvider provider, Bus bus) { if (provider instanceof ConduitSelectorHolder) { ConduitSelectorHolder csHolder = (ConduitSelectorHolder) provider; Endpoint endpoint = csHolder.getConduitSelector().getEndpoint(); ConduitSelector conduitSelector = initTargetSelector(endpoint); csHolder.setConduitSelector(conduitSelector); } }
Example #28
Source File: AuthorizationGrantNegativeTest.java From cxf with Apache License 2.0 | 5 votes |
protected void run() { SpringBusFactory bf = new SpringBusFactory(); Bus springBus = bf.createBus(SERVER_CONFIG_FILE); BusFactory.setDefaultBus(springBus); setBus(springBus); try { new BookServerOAuth2GrantsNegativeJCache(); } catch (Exception e) { throw new RuntimeException(e); } }
Example #29
Source File: Server12.java From cxf with Apache License 2.0 | 5 votes |
protected void run() { Bus busLocal = new SpringBusFactory().createBus( "org/apache/cxf/systest/ws/wssec11/server.xml"); BusFactory.setDefaultBus(busLocal); setBus(busLocal); super.run(); }
Example #30
Source File: StaxServer.java From cxf with Apache License 2.0 | 5 votes |
protected void run() { URL busFile = StaxServer.class.getResource("cxf-stax-service.xml"); Bus busLocal = new SpringBusFactory().createBus(busFile); BusFactory.setDefaultBus(busLocal); setBus(busLocal); try { new StaxServer(); } catch (Exception e) { e.printStackTrace(); } }