diff --git a/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/cf/JMSConnectionFactoryHandler.java b/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/cf/JMSConnectionFactoryHandler.java index 6e369210c8..44de835738 100644 --- a/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/cf/JMSConnectionFactoryHandler.java +++ b/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/cf/JMSConnectionFactoryHandler.java @@ -175,7 +175,19 @@ public class JMSConnectionFactoryHandler implements IJMSConnectionFactoryProvide SSLContextService sslContextService = context.getProperty(JMS_SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class); if (sslContextService != null) { SSLContext sslContext = sslContextService.createContext(); - if (connectionFactoryValue.startsWith("org.apache.qpid.jms")) { + if (connectionFactoryValue.startsWith("org.apache.activemq")) { + if (sslContextService.isTrustStoreConfigured()) { + setProperty("trustStore", sslContextService.getTrustStoreFile()); + setProperty("trustStorePassword", sslContextService.getTrustStorePassword()); + setProperty("trustStoreType", sslContextService.getTrustStoreType()); + } + if (sslContextService.isKeyStoreConfigured()) { + setProperty("keyStore", sslContextService.getKeyStoreFile()); + setProperty("keyStorePassword", sslContextService.getKeyStorePassword()); + setProperty("keyStoreKeyPassword", sslContextService.getKeyPassword()); + setProperty("keyStoreType", sslContextService.getKeyStoreType()); + } + } else if (connectionFactoryValue.startsWith("org.apache.qpid.jms")) { setProperty("sslContext", sslContext); } else { // IBM MQ (and others) diff --git a/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/test/java/org/apache/nifi/jms/cf/JMSConnectionFactoryProviderTest.java b/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/test/java/org/apache/nifi/jms/cf/JMSConnectionFactoryProviderTest.java index 1dcdbb3b55..725ed013a1 100644 --- a/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/test/java/org/apache/nifi/jms/cf/JMSConnectionFactoryProviderTest.java +++ b/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/test/java/org/apache/nifi/jms/cf/JMSConnectionFactoryProviderTest.java @@ -402,6 +402,55 @@ public class JMSConnectionFactoryProviderTest { assertEquals(ImmutableMap.of("brokerURL", MULTIPLE_ACTIVEMQ_BROKERS), cfProvider.getConfiguredProperties()); } + @Test + public void propertiesSetOnSingleActiveMqBrokerWithSslConnectionFactory() throws Exception { + TestRunner runner = TestRunners.newTestRunner(mock(Processor.class)); + + JMSConnectionFactoryProviderForTest cfProvider = new JMSConnectionFactoryProviderForTest(); + runner.addControllerService(CF_PROVIDER_SERVICE_ID, cfProvider); + + runner.setProperty(cfProvider, JMSConnectionFactoryProperties.JMS_BROKER_URI, SINGLE_ACTIVEMQ_BROKER); + runner.setProperty(cfProvider, JMSConnectionFactoryProperties.JMS_CLIENT_LIBRARIES, dummyResource); + runner.setProperty(cfProvider, JMSConnectionFactoryProperties.JMS_CONNECTION_FACTORY_IMPL, ACTIVEMQ_CONNECTION_FACTORY_IMPL); + + String trustStoreFile = "/path/to/truststore"; + String trustStorePassword = "truststore_password"; + String trustStoreType = "JKS"; + String keyStoreFile = "/path/to/keystore"; + String keyStorePassword = "keystore_password"; + String keyPassword = "key_password"; + String keyStoreType = "PKCS12"; + + SSLContextService sslContextService = mock(SSLContextService.class); + when(sslContextService.getIdentifier()).thenReturn(SSL_CONTEXT_SERVICE_ID); + when(sslContextService.isTrustStoreConfigured()).thenReturn(true); + when(sslContextService.getTrustStoreFile()).thenReturn(trustStoreFile); + when(sslContextService.getTrustStorePassword()).thenReturn(trustStorePassword); + when(sslContextService.getTrustStoreType()).thenReturn(trustStoreType); + when(sslContextService.isKeyStoreConfigured()).thenReturn(true); + when(sslContextService.getKeyStoreFile()).thenReturn(keyStoreFile); + when(sslContextService.getKeyStorePassword()).thenReturn(keyStorePassword); + when(sslContextService.getKeyPassword()).thenReturn(keyPassword); + when(sslContextService.getKeyStoreType()).thenReturn(keyStoreType); + + runner.addControllerService(SSL_CONTEXT_SERVICE_ID, sslContextService); + runner.setProperty(cfProvider, JMSConnectionFactoryProperties.JMS_SSL_CONTEXT_SERVICE, SSL_CONTEXT_SERVICE_ID); + + runner.enableControllerService(cfProvider); + + assertEquals(ImmutableMap.builder() + .put("brokerURL", SINGLE_ACTIVEMQ_BROKER) + .put("trustStore", trustStoreFile) + .put("trustStorePassword", trustStorePassword) + .put("trustStoreType", trustStoreType) + .put("keyStore", keyStoreFile) + .put("keyStorePassword", keyStorePassword) + .put("keyStoreKeyPassword", keyPassword) + .put("keyStoreType", keyStoreType) + .build(), + cfProvider.getConfiguredProperties()); + } + @Test public void propertiesSetOnSingleTibcoBrokerConnectionFactory() throws InitializationException { TestRunner runner = TestRunners.newTestRunner(mock(Processor.class));