use of org.apache.activemq.ActiveMQSslConnectionFactory in project syndesis by syndesisio.
the class ActiveMQUtil method createActiveMQConnectionFactory.
@SuppressWarnings("PMD.CyclomaticComplexity")
public static ActiveMQConnectionFactory createActiveMQConnectionFactory(String brokerUrl, String username, String password, String brokerCertificate, String clientCertificate, boolean skipCertificateCheck) {
if (brokerUrl.contains("ssl:")) {
final ActiveMQSslConnectionFactory connectionFactory;
if (ObjectHelper.isEmpty(username)) {
connectionFactory = new ActiveMQSslConnectionFactory(brokerUrl);
} else {
connectionFactory = new ActiveMQSslConnectionFactory(brokerUrl);
connectionFactory.setUserName(username);
connectionFactory.setPassword(password);
}
try {
// create client key manager
final KeyManager[] keyManagers;
if (ObjectHelper.isEmpty(clientCertificate)) {
keyManagers = null;
} else {
keyManagers = CertificateUtil.createKeyManagers(clientCertificate, "amq-client");
}
// create client trust manager
final TrustManager[] trustManagers;
if (ObjectHelper.isEmpty(brokerCertificate)) {
if (skipCertificateCheck) {
// use a trust all TrustManager
LOG.warn("Skipping Certificate check for Broker {}", brokerUrl);
trustManagers = CertificateUtil.createTrustAllTrustManagers();
} else {
LOG.debug("Using default JVM Trust Manager for Broker {}", brokerUrl);
trustManagers = null;
}
} else {
trustManagers = CertificateUtil.createTrustManagers(brokerCertificate, "amq-broker");
}
connectionFactory.setKeyAndTrustManagers(keyManagers, trustManagers, new SecureRandom());
return connectionFactory;
} catch (GeneralSecurityException | IOException e) {
throw new IllegalArgumentException("SSL configuration error: " + e.getMessage(), e);
}
} else {
// non-ssl connection
return ObjectHelper.isEmpty(username) ? new ActiveMQConnectionFactory(brokerUrl) : new ActiveMQConnectionFactory(username, password, brokerUrl);
}
}
use of org.apache.activemq.ActiveMQSslConnectionFactory in project alfresco-repository by Alfresco.
the class ConnectionFactoryConfiguration method createSecureConnectionFactory.
protected ConnectionFactory createSecureConnectionFactory() {
ActiveMQSslConnectionFactory factory = new ActiveMQSslConnectionFactory(brokerUrl);
factory.setKeyAndTrustManagers(keyStore.createKeyManagers(), trustStore.createTrustManagers(), new SecureRandom());
factory.setUserName(username);
factory.setPassword(password);
return factory;
}
Aggregations