This commit is contained in:
Madhura Bhave 2021-10-20 19:45:46 -07:00
parent 07aeb2156d
commit ea65c28bfa
1 changed files with 12 additions and 8 deletions

View File

@ -1186,14 +1186,7 @@ public class KafkaProperties {
}
public Map<String, Object> buildProperties() {
MutuallyExclusiveConfigurationPropertiesException.throwIfMultipleNonNullValuesIn((entries) -> {
entries.put("spring.kafka.ssl.key-store-key", this.getKeyStoreKey());
entries.put("spring.kafka.ssl.key-store-location", this.getKeyStoreLocation());
});
MutuallyExclusiveConfigurationPropertiesException.throwIfMultipleNonNullValuesIn((entries) -> {
entries.put("spring.kafka.ssl.trust-store-certificates", this.getTrustStoreCertificates());
entries.put("spring.kafka.ssl.trust-store-location", this.getTrustStoreLocation());
});
validate();
Properties properties = new Properties();
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
map.from(this::getKeyPassword).to(properties.in(SslConfigs.SSL_KEY_PASSWORD_CONFIG));
@ -1213,6 +1206,17 @@ public class KafkaProperties {
return properties;
}
private void validate() {
MutuallyExclusiveConfigurationPropertiesException.throwIfMultipleNonNullValuesIn((entries) -> {
entries.put("spring.kafka.ssl.key-store-key", this.getKeyStoreKey());
entries.put("spring.kafka.ssl.key-store-location", this.getKeyStoreLocation());
});
MutuallyExclusiveConfigurationPropertiesException.throwIfMultipleNonNullValuesIn((entries) -> {
entries.put("spring.kafka.ssl.trust-store-certificates", this.getTrustStoreCertificates());
entries.put("spring.kafka.ssl.trust-store-location", this.getTrustStoreLocation());
});
}
private String resourceToPath(Resource resource) {
try {
return resource.getFile().getAbsolutePath();