Skip to content

Commit 44f0f64

Browse files
authored
Make Jasypt configuration optional (#225)
1 parent eba3591 commit 44f0f64

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<version>2.0.5</version>
1010
</parent>
1111
<properties>
12-
<eiffel-remrem-publish.version>2.0.21</eiffel-remrem-publish.version>
12+
<eiffel-remrem-publish.version>2.0.22</eiffel-remrem-publish.version>
1313
<eiffel-remrem-shared.version>2.0.5</eiffel-remrem-shared.version>
1414
<eiffel-remrem-semantics.version>2.0.13</eiffel-remrem-semantics.version>
1515
</properties>

publish-common/pom.xml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,17 @@
113113
<version>2.4.0</version>
114114
<scope>compile</scope>
115115
</dependency>
116-
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
116+
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
117117
<dependency>
118-
<groupId>com.fasterxml.jackson.core</groupId>
119-
<artifactId>jackson-databind</artifactId>
120-
</dependency>
118+
<groupId>com.fasterxml.jackson.core</groupId>
119+
<artifactId>jackson-databind</artifactId>
120+
<version>2.13.0</version>
121+
</dependency>
122+
<dependency>
123+
<groupId>com.fasterxml.jackson.core</groupId>
124+
<artifactId>jackson-core</artifactId>
125+
<version>2.13.0</version>
126+
</dependency>
121127
<dependency>
122128
<groupId>junit</groupId>
123129
<artifactId>junit</artifactId>

publish-common/src/main/java/com/ericsson/eiffel/remrem/publish/config/RabbitMqPropertiesConfig.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ public class RabbitMqPropertiesConfig {
4848
@Autowired
4949
Environment env;
5050

51-
@Value("${rabbitmq.instances.jsonlist:{null}}")
51+
@Value("${rabbitmq.instances.jsonlist:#{null}}")
5252
private String rabbitmqInstancesJsonListContent;
5353

54-
@Value("${jasypt.encryptor.jasyptKeyFilePath:{null}}")
54+
@Value("${jasypt.encryptor.jasyptKeyFilePath:#{null}}")
5555
private String jasyptKeyFilePath;
5656

5757
private Map<String, RabbitMqProperties> rabbitMqPropertiesMap = new HashMap<String, RabbitMqProperties>();
@@ -80,8 +80,12 @@ public Map<String, RabbitMqProperties> getRabbitMqProperties() {
8080
*/
8181
private void readSpringProperties() {
8282
JsonNode rabbitmqInstancesJsonListJsonArray = null;
83+
String jasyptKey = null;
8384
final ObjectMapper objMapper = new ObjectMapper();
84-
final String jasyptKey = readJasyptKeyFile(jasyptKeyFilePath);
85+
if (jasyptKeyFilePath != null && !jasyptKeyFilePath.equals("\"\"") && !jasyptKeyFilePath.equals("''")) {
86+
log.info("Initiating Jasypt Key File");
87+
jasyptKey = readJasyptKeyFile(jasyptKeyFilePath);
88+
}
8589

8690
try {
8791
rabbitmqInstancesJsonListJsonArray = objMapper.readTree(rabbitmqInstancesJsonListContent);
@@ -101,8 +105,11 @@ private void readSpringProperties() {
101105
String rabbitMqPassword = rabbitmqInstanceObject.get("password").asText();
102106
if (rabbitMqPassword.startsWith("{ENC(") && rabbitMqPassword.endsWith("}")) {
103107
rabbitMqPassword = rabbitMqPassword.substring(1, rabbitMqPassword.length() - 1);
108+
rabbitMqProperties.setPassword(DecryptionUtils.decryptString(rabbitMqPassword, jasyptKey));
109+
}
110+
else{
111+
rabbitMqProperties.setPassword(rabbitMqPassword);
104112
}
105-
rabbitMqProperties.setPassword(DecryptionUtils.decryptString(rabbitMqPassword, jasyptKey));
106113
rabbitMqProperties.setTlsVer(rabbitmqInstanceObject.get("tls").asText());
107114
rabbitMqProperties.setExchangeName(rabbitmqInstanceObject.get("exchangeName").asText());
108115
rabbitMqProperties.setCreateExchangeIfNotExisting(rabbitmqInstanceObject.get("createExchangeIfNotExisting").asBoolean());

0 commit comments

Comments
 (0)