Commit 5bbeb094 authored by I Patini's avatar I Patini
Browse files

EMS: Broker-Client: Removed @Value annotations from 'BrokerClientProperties'...

EMS: Broker-Client: Removed @Value annotations from 'BrokerClientProperties' class and renamed fields where needed.
parent da2ea26c
......@@ -390,12 +390,12 @@ public class BrokerClient {
log.debug("BrokerClient.createConnectionFactory(): Creating new SSL connection factory instance: url={}", brokerUrl);
final ActiveMQSslConnectionFactory sslConnectionFactory = new ActiveMQSslConnectionFactory(brokerUrl);
try {
sslConnectionFactory.setTrustStore(properties.getTruststoreFile());
sslConnectionFactory.setTrustStoreType(properties.getTruststoreType());
sslConnectionFactory.setTrustStorePassword(properties.getTruststorePassword());
sslConnectionFactory.setKeyStore(properties.getKeystoreFile());
sslConnectionFactory.setKeyStoreType(properties.getKeystoreType());
sslConnectionFactory.setKeyStorePassword(properties.getKeystorePassword());
sslConnectionFactory.setTrustStore(properties.getSsl().getTruststoreFile());
sslConnectionFactory.setTrustStoreType(properties.getSsl().getTruststoreType());
sslConnectionFactory.setTrustStorePassword(properties.getSsl().getTruststorePassword());
sslConnectionFactory.setKeyStore(properties.getSsl().getKeystoreFile());
sslConnectionFactory.setKeyStoreType(properties.getSsl().getKeystoreType());
sslConnectionFactory.setKeyStorePassword(properties.getSsl().getKeystorePassword());
//sslConnectionFactory.setKeyStoreKeyPassword( properties........ );
connectionFactory = sslConnectionFactory;
......
......@@ -12,63 +12,48 @@ package eu.melodic.event.brokerclient.properties;
import lombok.Data;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
@Data
@ToString(exclude = {"truststorePassword", "keystorePassword", "brokerPassword"})
@Configuration
@ConfigurationProperties(prefix = "brokerclient")
//@PropertySource("file:${MELODIC_CONFIG_DIR}/eu.melodic.event.brokerclient.properties")
@Slf4j
public class BrokerClientProperties {
@Value("${broker-name:broker}")
private String brokerName;
@Value("${broker-url:tcp://localhost:61616}")
private String brokerUrl;
@Value("${broker-url-properties:}")
private String brokerName = "broker";
private String brokerUrl = "tcp://localhost:61616";
private String brokerUrlProperties;
@Value("${ssl.client-auth.required:false}")
private boolean clientAuthRequired;
@Value("${connector-port:-1}")
private int connectorPort;
@Value("${preserve-connection:false}")
private int managementConnectorPort = -1;
private boolean preserveConnection;
@Value("${ssl.truststore.file:}")
private String truststoreFile;
@Value("${ssl.truststore.type:}")
private String truststoreType;
@Value("${ssl.truststore.password:}")
private String truststorePassword;
@Value("${ssl.keystore.file:}")
private String keystoreFile;
@Value("${ssl.keystore.type:}")
private String keystoreType;
@Value("${ssl.keystore.password:}")
private String keystorePassword;
private Ssl ssl = new Ssl();
@Value("${broker-username:}")
private String brokerUsername;
@Value("${broker-password:}")
@ToString.Exclude
private String brokerPassword;
@Data
public static class Ssl {
private boolean clientAuthRequired;
private String truststoreFile;
private String truststoreType;
@ToString.Exclude
private String truststorePassword;
private String keystoreFile;
private String keystoreType;
@ToString.Exclude
private String keystorePassword;
}
public BrokerClientProperties() {
brokerName = "broker";
brokerUrl = "tcp://localhost:61616";
brokerUrlProperties = "";
connectorPort = -1;
managementConnectorPort = -1;
preserveConnection = false;
truststoreFile = "";
truststoreType = "";
truststorePassword = "";
keystoreFile = "";
keystoreType = "";
keystorePassword = "";
clientAuthRequired = false;
ssl = new Ssl();
brokerUsername = "";
brokerPassword = "";
......@@ -78,20 +63,21 @@ public class BrokerClientProperties {
brokerName = p.getProperty("brokerclient.broker-name", "broker");
brokerUrl = p.getProperty("brokerclient.broker-url", "tcp://localhost:61616");
brokerUrlProperties = p.getProperty("brokerclient.broker-url-properties", "");
connectorPort = Integer.parseInt(p.getProperty("brokerclient.connector-port", "-1"));
managementConnectorPort = Integer.parseInt(p.getProperty("brokerclient.connector-port", "-1"));
preserveConnection = Boolean.parseBoolean(p.getProperty("brokerclient.preserve-connection", "false"));
truststoreFile = p.getProperty("brokerclient.ssl.truststore.file", "");
truststoreType = p.getProperty("brokerclient.ssl.truststore.type", "");
truststorePassword = p.getProperty("brokerclient.ssl.truststore.password", "");
keystoreFile = p.getProperty("brokerclient.ssl.keystore.file", "");
keystoreType = p.getProperty("brokerclient.ssl.keystore.type", "");
keystorePassword = p.getProperty("brokerclient.ssl.keystore.password", "");
clientAuthRequired = Boolean.parseBoolean(p.getProperty("brokerclient.ssl.client-auth.required", "false"));
ssl = new Ssl();
ssl.truststoreFile = p.getProperty("brokerclient.ssl.truststore.file", "");
ssl.truststoreType = p.getProperty("brokerclient.ssl.truststore.type", "");
ssl.truststorePassword = p.getProperty("brokerclient.ssl.truststore.password", "");
ssl.keystoreFile = p.getProperty("brokerclient.ssl.keystore.file", "");
ssl.keystoreType = p.getProperty("brokerclient.ssl.keystore.type", "");
ssl.keystorePassword = p.getProperty("brokerclient.ssl.keystore.password", "");
ssl.clientAuthRequired = Boolean.parseBoolean(p.getProperty("brokerclient.ssl.client-auth.required", "false"));
brokerUsername = p.getProperty("brokerclient.broker-username", "");
brokerPassword = p.getProperty("brokerclient.broker-password", "");
brokerUrlProperties = brokerUrlProperties.replace("${brokerclient.ssl.client-auth.required}", Boolean.toString(clientAuthRequired));
brokerUrlProperties = brokerUrlProperties.replace("${brokerclient.ssl.client-auth.required}", Boolean.toString(ssl.clientAuthRequired));
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment