|
21 | 21 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
22 | 22 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
|
23 | 23 | import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
|
| 24 | +import org.springframework.boot.bind.RelaxedPropertyResolver; |
24 | 25 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
25 | 26 | import org.springframework.cloud.bootstrap.encrypt.KeyProperties.KeyStore;
|
26 | 27 | import org.springframework.cloud.context.encrypt.EncryptorFactory;
|
@@ -109,21 +110,22 @@ public static class KeyCondition extends SpringBootCondition {
|
109 | 110 | public ConditionOutcome getMatchOutcome(ConditionContext context,
|
110 | 111 | AnnotatedTypeMetadata metadata) {
|
111 | 112 | Environment environment = context.getEnvironment();
|
112 |
| - if (hasProperty(environment, "encrypt.keyStore.location")) { |
113 |
| - if (hasProperty(environment, "encrypt.keyStore.password")) { |
| 113 | + RelaxedPropertyResolver propertyResolver = new RelaxedPropertyResolver(environment); |
| 114 | + if (hasProperty(propertyResolver, environment, "encrypt.keyStore.location")) { |
| 115 | + if (hasProperty(propertyResolver, environment, "encrypt.keyStore.password")) { |
114 | 116 | return ConditionOutcome.match("Keystore found in Environment");
|
115 | 117 | }
|
116 | 118 | return ConditionOutcome
|
117 | 119 | .noMatch("Keystore found but no password in Environment");
|
118 | 120 | }
|
119 |
| - else if (hasProperty(environment, "encrypt.key")) { |
| 121 | + else if (hasProperty(propertyResolver, environment, "encrypt.key")) { |
120 | 122 | return ConditionOutcome.match("Key found in Environment");
|
121 | 123 | }
|
122 | 124 | return ConditionOutcome.noMatch("Keystore nor key found in Environment");
|
123 | 125 | }
|
124 | 126 |
|
125 |
| - private boolean hasProperty(Environment environment, String key) { |
126 |
| - String value = environment.getProperty(key); |
| 127 | + private boolean hasProperty(RelaxedPropertyResolver propertyResolver, Environment environment, String key) { |
| 128 | + String value = propertyResolver.getProperty(key); |
127 | 129 | if (value == null) {
|
128 | 130 | return false;
|
129 | 131 | }
|
|
0 commit comments