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

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

Introduction

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

Prototype

public void setKeyStorePassphrase(String keyStorePassphrase) 

Source Link

Document

Set the key store pass phrase - overrides the property in #setSslPropertiesLocation(Resource) .

Usage

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  w w  w . j av  a  2s. c  o m*/
 * @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
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   ww w. j a  v  a2  s.  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.")));
}

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);/*  w ww  . ja va  2s  . c om*/
    fb.setKeyStoreType("JKS");
    fb.setKeyStoreResource(new ClassPathResource("test.ks"));
    fb.setKeyStorePassphrase("secret");
    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: 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);/*w w  w  . j  a v a2s.c  o  m*/
    fb.setKeyStoreType("JKS");
    fb.setTrustStoreResource(new ClassPathResource("test.truststore.ks"));
    fb.setKeyStorePassphrase("secret");
    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: null"), containsString("TM: ["), containsString("random: null")));
}