增加jasypt配置加密方式
This commit is contained in:
7
pom.xml
7
pom.xml
@@ -102,6 +102,13 @@
|
|||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.jasypt/jasypt -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jasypt</groupId>
|
||||||
|
<artifactId>jasypt</artifactId>
|
||||||
|
<version>1.9.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.zdjizhi.common;
|
package com.zdjizhi.common;
|
||||||
|
|
||||||
import com.zdjizhi.utils.CommonConfigurations;
|
import com.zdjizhi.utils.CommonConfigurations;
|
||||||
|
import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author wlh
|
* @author wlh
|
||||||
@@ -8,6 +9,12 @@ import com.zdjizhi.utils.CommonConfigurations;
|
|||||||
*/
|
*/
|
||||||
public class CommonConfig {
|
public class CommonConfig {
|
||||||
|
|
||||||
|
private static StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
|
||||||
|
|
||||||
|
static {
|
||||||
|
encryptor.setPassword("galaxy");
|
||||||
|
}
|
||||||
|
|
||||||
public static final int STREAM_EXECUTION_ENVIRONMENT_PARALLELISM = CommonConfigurations.getIntProperty("stream.execution.environment.parallelism");
|
public static final int STREAM_EXECUTION_ENVIRONMENT_PARALLELISM = CommonConfigurations.getIntProperty("stream.execution.environment.parallelism");
|
||||||
public static final String STREAM_EXECUTION_JOB_NAME = CommonConfigurations.getStringProperty("stream.execution.job.name");
|
public static final String STREAM_EXECUTION_JOB_NAME = CommonConfigurations.getStringProperty("stream.execution.job.name");
|
||||||
|
|
||||||
@@ -66,7 +73,20 @@ public class CommonConfig {
|
|||||||
public static final int BASELINE_THRESHOLD_SCHEDULE_DAYS = CommonConfigurations.getIntProperty("baseline.threshold.schedule.days");
|
public static final int BASELINE_THRESHOLD_SCHEDULE_DAYS = CommonConfigurations.getIntProperty("baseline.threshold.schedule.days");
|
||||||
|
|
||||||
public static final String SASL_JAAS_CONFIG_USER = CommonConfigurations.getStringProperty("sasl.jaas.config.user");
|
public static final String SASL_JAAS_CONFIG_USER = CommonConfigurations.getStringProperty("sasl.jaas.config.user");
|
||||||
public static final String SASL_JAAS_CONFIG_PASSWORD = CommonConfigurations.getStringProperty("sasl.jaas.config.password");
|
public static final String SASL_JAAS_CONFIG_PASSWORD = encryptor.decrypt(CommonConfigurations.getStringProperty("sasl.jaas.config.password"));
|
||||||
|
|
||||||
public static final int SASL_JAAS_CONFIG_FLAG = CommonConfigurations.getIntProperty("sasl.jaas.config.flag");
|
public static final int SASL_JAAS_CONFIG_FLAG = CommonConfigurations.getIntProperty("sasl.jaas.config.flag");
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
|
||||||
|
// 配置加密解密的密码/salt值
|
||||||
|
encryptor.setPassword("galaxy");
|
||||||
|
// 对"raw_password"进行加密:S5kR+Y7CI8k7MaecZpde25yK8NKUnd6p
|
||||||
|
String password = "galaxy2019";
|
||||||
|
String encPwd = encryptor.encrypt(password);
|
||||||
|
System.out.println(encPwd);
|
||||||
|
// 再进行解密:raw_password
|
||||||
|
String rawPwd = encryptor.decrypt(encPwd);
|
||||||
|
System.out.println(rawPwd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,7 +131,9 @@ baseline.threshold.schedule.days=1
|
|||||||
|
|
||||||
#kafka用户认证配置参数
|
#kafka用户认证配置参数
|
||||||
sasl.jaas.config.user=admin
|
sasl.jaas.config.user=admin
|
||||||
sasl.jaas.config.password=galaxy2019
|
#sasl.jaas.config.password=galaxy2019
|
||||||
|
#sasl.jaas.config.password=ENC(6MleDyA3Z73HSaXiKsDJ2k7Ys8YWLhEJ)
|
||||||
|
sasl.jaas.config.password=6MleDyA3Z73HSaXiKsDJ2k7Ys8YWLhEJ
|
||||||
|
|
||||||
#是否开启kafka用户认证配置,1:是;0:否
|
#是否开启kafka用户认证配置,1:是;0:否
|
||||||
sasl.jaas.config.flag=1
|
sasl.jaas.config.flag=1
|
||||||
Reference in New Issue
Block a user