@@ -48,10 +48,10 @@ public class RabbitMqPropertiesConfig {
48
48
@ Autowired
49
49
Environment env ;
50
50
51
- @ Value ("${rabbitmq.instances.jsonlist:{null}}" )
51
+ @ Value ("${rabbitmq.instances.jsonlist:# {null}}" )
52
52
private String rabbitmqInstancesJsonListContent ;
53
53
54
- @ Value ("${jasypt.encryptor.jasyptKeyFilePath:{null}}" )
54
+ @ Value ("${jasypt.encryptor.jasyptKeyFilePath:# {null}}" )
55
55
private String jasyptKeyFilePath ;
56
56
57
57
private Map <String , RabbitMqProperties > rabbitMqPropertiesMap = new HashMap <String , RabbitMqProperties >();
@@ -80,8 +80,12 @@ public Map<String, RabbitMqProperties> getRabbitMqProperties() {
80
80
*/
81
81
private void readSpringProperties () {
82
82
JsonNode rabbitmqInstancesJsonListJsonArray = null ;
83
+ String jasyptKey = null ;
83
84
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
+ }
85
89
86
90
try {
87
91
rabbitmqInstancesJsonListJsonArray = objMapper .readTree (rabbitmqInstancesJsonListContent );
@@ -101,8 +105,11 @@ private void readSpringProperties() {
101
105
String rabbitMqPassword = rabbitmqInstanceObject .get ("password" ).asText ();
102
106
if (rabbitMqPassword .startsWith ("{ENC(" ) && rabbitMqPassword .endsWith ("}" )) {
103
107
rabbitMqPassword = rabbitMqPassword .substring (1 , rabbitMqPassword .length () - 1 );
108
+ rabbitMqProperties .setPassword (DecryptionUtils .decryptString (rabbitMqPassword , jasyptKey ));
109
+ }
110
+ else {
111
+ rabbitMqProperties .setPassword (rabbitMqPassword );
104
112
}
105
- rabbitMqProperties .setPassword (DecryptionUtils .decryptString (rabbitMqPassword , jasyptKey ));
106
113
rabbitMqProperties .setTlsVer (rabbitmqInstanceObject .get ("tls" ).asText ());
107
114
rabbitMqProperties .setExchangeName (rabbitmqInstanceObject .get ("exchangeName" ).asText ());
108
115
rabbitMqProperties .setCreateExchangeIfNotExisting (rabbitmqInstanceObject .get ("createExchangeIfNotExisting" ).asBoolean ());
0 commit comments