List of usage examples for org.springframework.amqp.rabbit.connection RabbitConnectionFactoryBean setUseSSL
public void setUseSSL(boolean useSSL)
From source file:org.springframework.amqp.rabbit.connection.LocalizedQueueConnectionFactory.java
/** * Create a dedicated connection factory for the address. * @param address the address to which the factory should connect. * @param node the node.//from ww w .j a v a 2 s .com * @return the connection factory. * @throws Exception if errors occur during creation. */ protected ConnectionFactory createConnectionFactory(String address, String node) throws Exception { RabbitConnectionFactoryBean rcfb = new RabbitConnectionFactoryBean(); rcfb.setUseSSL(this.useSSL); rcfb.setSslPropertiesLocation(this.sslPropertiesLocation); rcfb.setKeyStore(this.keyStore); rcfb.setTrustStore(this.trustStore); rcfb.setKeyStorePassphrase(this.keyStorePassPhrase); rcfb.setTrustStorePassphrase(this.trustStorePassPhrase); rcfb.afterPropertiesSet(); CachingConnectionFactory ccf = new CachingConnectionFactory(rcfb.getObject()); ccf.setAddresses(address); ccf.setUsername(this.username); ccf.setPassword(this.password); ccf.setVirtualHost(this.vhost); ccf.setBeanName("node:" + node); return ccf; }
From source file:org.springframework.amqp.rabbit.connection.SSLConnectionTests.java
@Test @Ignore/*from w w w .jav a2 s. c om*/ public void test() throws Exception { RabbitConnectionFactoryBean fb = new RabbitConnectionFactoryBean(); fb.setUseSSL(true); fb.setSslPropertiesLocation(new ClassPathResource("ssl.properties")); fb.setClientProperties(Collections.<String, Object>singletonMap("foo", "bar")); fb.afterPropertiesSet(); ConnectionFactory cf = fb.getObject(); assertEquals("bar", cf.getClientProperties().get("foo")); Connection conn = cf.newConnection(); Channel chan = conn.createChannel(); chan.close(); conn.close(); }
From source file:org.springframework.amqp.rabbit.connection.SSLConnectionTests.java
@Test public void testAlgNoProps() throws Exception { RabbitConnectionFactoryBean fb = new RabbitConnectionFactoryBean(); ConnectionFactory rabbitCf = spy(// w w w. j ava 2 s . c om TestUtils.getPropertyValue(fb, "connectionFactory", ConnectionFactory.class)); new DirectFieldAccessor(fb).setPropertyValue("connectionFactory", rabbitCf); fb.setUseSSL(true); fb.setSslAlgorithm("TLSv1.2"); fb.afterPropertiesSet(); fb.getObject(); verify(rabbitCf).useSslProtocol("TLSv1.2"); }
From source file:org.springframework.amqp.rabbit.connection.SSLConnectionTests.java
@Test public void testNoAlgNoProps() throws Exception { RabbitConnectionFactoryBean fb = new RabbitConnectionFactoryBean(); ConnectionFactory rabbitCf = spy(//w w w . j a va2 s . co m TestUtils.getPropertyValue(fb, "connectionFactory", ConnectionFactory.class)); new DirectFieldAccessor(fb).setPropertyValue("connectionFactory", rabbitCf); fb.setUseSSL(true); fb.afterPropertiesSet(); fb.getObject(); verify(rabbitCf).useSslProtocol(); }
From source file:org.springframework.amqp.rabbit.connection.SSLConnectionTests.java
@Test public void testKSTS() throws Exception { RabbitConnectionFactoryBean fb = new RabbitConnectionFactoryBean(); Log logger = spy(TestUtils.getPropertyValue(fb, "logger", Log.class)); given(logger.isDebugEnabled()).willReturn(true); new DirectFieldAccessor(fb).setPropertyValue("logger", logger); fb.setUseSSL(true); fb.setKeyStoreType("JKS"); fb.setKeyStoreResource(new ClassPathResource("test.ks")); fb.setKeyStorePassphrase("secret"); fb.setTrustStoreResource(new ClassPathResource("test.truststore.ks")); fb.setKeyStorePassphrase("secret"); fb.setSecureRandom(SecureRandom.getInstanceStrong()); fb.afterPropertiesSet();/* w ww.j a v a 2 s . com*/ fb.getObject(); ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); verify(logger).debug(captor.capture()); final String log = captor.getValue(); assertThat(log, allOf(containsString("KM: ["), containsString("TM: ["), containsString("random: java."))); }
From source file:org.springframework.amqp.rabbit.connection.SSLConnectionTests.java
@Test public void testNullTS() throws Exception { RabbitConnectionFactoryBean fb = new RabbitConnectionFactoryBean(); Log logger = spy(TestUtils.getPropertyValue(fb, "logger", Log.class)); given(logger.isDebugEnabled()).willReturn(true); new DirectFieldAccessor(fb).setPropertyValue("logger", logger); fb.setUseSSL(true); fb.setKeyStoreType("JKS"); fb.setKeyStoreResource(new ClassPathResource("test.ks")); fb.setKeyStorePassphrase("secret"); fb.afterPropertiesSet();/*from ww w .j a v a 2 s .c om*/ fb.getObject(); ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); verify(logger).debug(captor.capture()); final String log = captor.getValue(); assertThat(log, allOf(containsString("KM: ["), containsString("TM: null"), containsString("random: null"))); }
From source file:org.springframework.amqp.rabbit.connection.SSLConnectionTests.java
@Test public void testNullKS() throws Exception { RabbitConnectionFactoryBean fb = new RabbitConnectionFactoryBean(); Log logger = spy(TestUtils.getPropertyValue(fb, "logger", Log.class)); given(logger.isDebugEnabled()).willReturn(true); new DirectFieldAccessor(fb).setPropertyValue("logger", logger); fb.setUseSSL(true); fb.setKeyStoreType("JKS"); fb.setTrustStoreResource(new ClassPathResource("test.truststore.ks")); fb.setKeyStorePassphrase("secret"); fb.afterPropertiesSet();//from w w w. j av a 2s. c om fb.getObject(); ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); verify(logger).debug(captor.capture()); final String log = captor.getValue(); assertThat(log, allOf(containsString("KM: null"), containsString("TM: ["), containsString("random: null"))); }
From source file:org.springframework.cloud.stream.binder.rabbit.LocalizedQueueConnectionFactory.java
/** * Create a dedicated connection factory for the address. * @param address the address to which the factory should connect. * @return the connection factory.//from w w w .java 2 s . c o m * @throws Exception if errors occur during creation. */ protected ConnectionFactory createConnectionFactory(String address) throws Exception { RabbitConnectionFactoryBean rcfb = new RabbitConnectionFactoryBean(); rcfb.setUseSSL(this.useSSL); rcfb.setSslPropertiesLocation(this.sslPropertiesLocation); rcfb.afterPropertiesSet(); CachingConnectionFactory ccf = new CachingConnectionFactory(rcfb.getObject()); ccf.setAddresses(address); ccf.setUsername(this.username); ccf.setPassword(this.password); ccf.setVirtualHost(this.vhost); return ccf; }