Example usage for org.springframework.amqp.rabbit.connection RabbitConnectionFactoryBean setSecureRandom

List of usage examples for org.springframework.amqp.rabbit.connection RabbitConnectionFactoryBean setSecureRandom

Introduction

In this page you can find the example usage for org.springframework.amqp.rabbit.connection RabbitConnectionFactoryBean setSecureRandom.

Prototype

public void setSecureRandom(SecureRandom secureRandom) 

Source Link

Document

Set the secure random to use when initializing the SSLContext .

Usage

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);//from   www.  j a  va  2s.c om
    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();
    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.")));
}