diff options
| author | qidaijie <[email protected]> | 2022-03-16 16:55:18 +0800 |
|---|---|---|
| committer | qidaijie <[email protected]> | 2022-03-16 16:55:18 +0800 |
| commit | a8195cd3e23deb779258e70f95f203259b020d31 (patch) | |
| tree | 15748f123501462d532460a7b64d66b393dae0d2 /src | |
| parent | 1c8d34e39d6067c1bf93a50bba0d60b80007846b (diff) | |
新增kafka用户名密码加密 TSG-8835
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/java/com/zdjizhi/common/RadiusKnowledgeConfig.java | 18 | ||||
| -rw-r--r-- | src/main/java/com/zdjizhi/utils/kafka/CertUtils.java | 8 |
2 files changed, 14 insertions, 12 deletions
diff --git a/src/main/java/com/zdjizhi/common/RadiusKnowledgeConfig.java b/src/main/java/com/zdjizhi/common/RadiusKnowledgeConfig.java index 43d2a9d..cb9ead3 100644 --- a/src/main/java/com/zdjizhi/common/RadiusKnowledgeConfig.java +++ b/src/main/java/com/zdjizhi/common/RadiusKnowledgeConfig.java @@ -2,11 +2,19 @@ package com.zdjizhi.common; import com.zdjizhi.utils.system.RadiusKnowledgeConfigurations; +import org.jasypt.encryption.pbe.StandardPBEStringEncryptor; /** * @author Administrator */ public class RadiusKnowledgeConfig { + + private static StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); + + static { + encryptor.setPassword("galaxy"); + } + /** * 4- Accounting-Request(账户授权) */ @@ -49,10 +57,6 @@ public class RadiusKnowledgeConfig { /** - * System - */ - - /** * kafka */ public static final String SOURCE_KAFKA_SERVERS = RadiusKnowledgeConfigurations.getStringProperty(0, "source.kafka.servers"); @@ -73,10 +77,8 @@ public class RadiusKnowledgeConfig { public static final Integer BUFFER_MEMORY = RadiusKnowledgeConfigurations.getIntProperty(1, "buffer.memory"); public static final Integer MAX_REQUEST_SIZE = RadiusKnowledgeConfigurations.getIntProperty(1, "max.request.size"); public static final String TOOLS_LIBRARY = RadiusKnowledgeConfigurations.getStringProperty(0, "tools.library"); - public static final String KAFKA_SOURCE_PROTOCOL = RadiusKnowledgeConfigurations.getStringProperty(1, "kafka.source.protocol"); - public static final String KAFKA_SINK_PROTOCOL = RadiusKnowledgeConfigurations.getStringProperty(1, "kafka.sink.protocol"); - public static final String KAFKA_USER = RadiusKnowledgeConfigurations.getStringProperty(1, "kafka.user"); - public static final String KAFKA_PIN = RadiusKnowledgeConfigurations.getStringProperty(1, "kafka.pin"); + public static final String KAFKA_SASL_JAAS_USER = encryptor.decrypt(RadiusKnowledgeConfigurations.getStringProperty(1, "kafka.user")); + public static final String KAFKA_SASL_JAAS_PIN = encryptor.decrypt(RadiusKnowledgeConfigurations.getStringProperty(1, "kafka.pin")); /** * kafka source config diff --git a/src/main/java/com/zdjizhi/utils/kafka/CertUtils.java b/src/main/java/com/zdjizhi/utils/kafka/CertUtils.java index a5bce21..88bc377 100644 --- a/src/main/java/com/zdjizhi/utils/kafka/CertUtils.java +++ b/src/main/java/com/zdjizhi/utils/kafka/CertUtils.java @@ -33,15 +33,15 @@ class CertUtils { properties.put("security.protocol", "SASL_PLAINTEXT"); properties.put("sasl.mechanism", "PLAIN"); properties.put("sasl.jaas.config", "org.apache.kafka.common.security.plain.PlainLoginModule required username=" - + RadiusKnowledgeConfig.KAFKA_USER + " password=" + RadiusKnowledgeConfig.KAFKA_PIN + ";"); + + RadiusKnowledgeConfig.KAFKA_SASL_JAAS_USER + " password=" + RadiusKnowledgeConfig.KAFKA_SASL_JAAS_PIN + ";"); } else if (servers.contains(SSL_PORT)) { properties.put("security.protocol", "SSL"); properties.put(SslConfigs.SSL_ENDPOINT_IDENTIFICATION_ALGORITHM_CONFIG, ""); properties.put("ssl.keystore.location", RadiusKnowledgeConfig.TOOLS_LIBRARY + "keystore.jks"); - properties.put("ssl.keystore.password", RadiusKnowledgeConfig.KAFKA_PIN); + properties.put("ssl.keystore.password", RadiusKnowledgeConfig.KAFKA_SASL_JAAS_PIN); properties.put("ssl.truststore.location", RadiusKnowledgeConfig.TOOLS_LIBRARY + "truststore.jks"); - properties.put("ssl.truststore.password", RadiusKnowledgeConfig.KAFKA_PIN); - properties.put("ssl.key.password", RadiusKnowledgeConfig.KAFKA_PIN); + properties.put("ssl.truststore.password", RadiusKnowledgeConfig.KAFKA_SASL_JAAS_PIN); + properties.put("ssl.key.password", RadiusKnowledgeConfig.KAFKA_SASL_JAAS_PIN); } } |
