更改pom

This commit is contained in:
sunyu
2025-04-01 09:49:16 +08:00
parent 93825e62e1
commit 73e52d7b4c
9 changed files with 94 additions and 155 deletions

View File

@ -1,73 +1,32 @@
package com.chinaunicom.mall.ebtp.cloud.jasypt.starter;
import org.jasypt.encryption.StringEncryptor;
import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class JasyptStarterConfiguration {
@Bean( name = "stringEncryptor" )
public StringEncryptor stringEncryptor() {
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
SimpleStringPBEConfig config = new SimpleStringPBEConfig();
config.setPassword("uniom-ebtp");
config.setAlgorithm("PBEWITHHMACSHA512ANDAES_256");
config.setKeyObtentionIterations("1000");
config.setPoolSize("1");
config.setProviderName("SunJCE");
config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator");
config.setIvGeneratorClassName("org.jasypt.iv.RandomIvGenerator");
config.setStringOutputType("base64");
encryptor.setConfig(config);
return encryptor;
}
public static String encryptStr(String encryptStr, String password) {
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
SimpleStringPBEConfig config = new SimpleStringPBEConfig();
config.setPassword(password);
config.setAlgorithm("PBEWITHHMACSHA512ANDAES_256");
config.setKeyObtentionIterations("1000");
config.setPoolSize("1");
config.setProviderName("SunJCE");
config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator");
config.setIvGeneratorClassName("org.jasypt.iv.RandomIvGenerator");
config.setStringOutputType("base64");
encryptor.setConfig(config);
String enPw = encryptor.encrypt(encryptStr);
System.out.println("加密后:" + enPw);
String decrypt = encryptor.decrypt(enPw);
System.out.println("解密的字符串:" + decrypt);
return enPw;
}
public static void main(String[] args) {
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
SimpleStringPBEConfig config = new SimpleStringPBEConfig();
config.setPassword("uniom-ebtp");// unicom uniom-ebtp
config.setAlgorithm("PBEWITHHMACSHA512ANDAES_256");// PBEWithMD5AndDES PBEWITHMD5ANDDES
config.setKeyObtentionIterations("1000");
config.setPoolSize("1");
config.setProviderName("SunJCE");
config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator");
config.setIvGeneratorClassName("org.jasypt.iv.RandomIvGenerator");
config.setStringOutputType("base64");
encryptor.setConfig(config);
// String decrypt = encryptor.decrypt("Ecrp94gdEbYqQnnHDq/ILoRM9cs44vT02BvmZMqHaUphaYuAPSciSqM/loGvFcrQMjwXuoMJD6jYSSiycgzcwnav29alP7intVCpiIhM/p6fjYGevVUp0O0H0VpRF0TvSAZjVIndW4g=");
// System.out.println("解密1的字符串" + decrypt);
String decrypt2 = encryptor.decrypt("OBATzbzsytt8pNrJGHyyfUIMhatPdUmpLrRHYICtkm/XiJRUrOvrVfcBNlylIreI");
System.out.println("解密2的字符串" + decrypt2);
// String decrypt3 = encryptor.decrypt("OBATzbzsytt8pNrJGHyyfUIMhatPdUmpLrRHYICtkm/XiJRUrOvrVfcBNlylIreI");
// System.out.println("解密3的字符串" + decrypt3);
//JasyptStarterConfiguration.encryptStr("org.apache.kafka.common.security.scram.ScramLoginModule required username=\"kafka-gjgs\" password=\"Gjgs#2023\";","uniom-ebtp");
//JasyptStarterConfiguration.encryptStr("7i6O36#eol8!","uniom-ebtp");
//JasyptStarterConfiguration.encryptStr("hzfsftpuser","uniom-ebtp");
}
}
//package com.chinaunicom.mall.ebtp.cloud.jasypt.starter;
//
//
//import org.jasypt.encryption.StringEncryptor;
//import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
//import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//@Configuration
//public class JasyptStarterConfiguration {
//
// @Bean( name = "stringEncryptor" )
// public StringEncryptor stringEncryptor() {
//
// PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
//
// SimpleStringPBEConfig config = new SimpleStringPBEConfig();
// config.setPassword("uniom-ebtp");
// config.setAlgorithm("PBEWITHHMACSHA512ANDAES_256");
// config.setKeyObtentionIterations("1000");
// config.setPoolSize("1");
// config.setProviderName("SunJCE");
// config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator");
// config.setIvGeneratorClassName("org.jasypt.iv.RandomIvGenerator");
// config.setStringOutputType("base64");
// encryptor.setConfig(config);
//
// return encryptor;
// }
//
//}

View File

@ -1,35 +1,35 @@
package com.chinaunicom.mall.ebtp.cloud.jasypt.starter.util;
import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
public class JasyptUtil {
public static String encryptStr(String encryptStr, String password) {
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
SimpleStringPBEConfig config = new SimpleStringPBEConfig();
config.setPassword(password);
config.setAlgorithm("PBEWITHHMACSHA512ANDAES_256");
config.setKeyObtentionIterations("1000");
config.setPoolSize("1");
config.setProviderName("SunJCE");
config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator");
config.setIvGeneratorClassName("org.jasypt.iv.RandomIvGenerator");
config.setStringOutputType("base64");
encryptor.setConfig(config);
String enPw = encryptor.encrypt(encryptStr);
System.out.println("加密后:" + enPw);
String decrypt = encryptor.decrypt(enPw);
System.out.println("解密的字符串:" + decrypt);
return enPw;
}
public static void main(String[] args) {
JasyptUtil.encryptStr("Eshop@2021","uniom-ebtp");
}
}
//package com.chinaunicom.mall.ebtp.cloud.jasypt.starter.util;
//
//import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
//import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
//
//public class JasyptUtil {
//
//
// public static String encryptStr(String encryptStr, String password) {
// PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
//
// SimpleStringPBEConfig config = new SimpleStringPBEConfig();
// config.setPassword(password);
// config.setAlgorithm("PBEWITHHMACSHA512ANDAES_256");
// config.setKeyObtentionIterations("1000");
// config.setPoolSize("1");
// config.setProviderName("SunJCE");
// config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator");
// config.setIvGeneratorClassName("org.jasypt.iv.RandomIvGenerator");
// config.setStringOutputType("base64");
// encryptor.setConfig(config);
//
// String enPw = encryptor.encrypt(encryptStr);
// System.out.println("加密后:" + enPw);
// String decrypt = encryptor.decrypt(enPw);
// System.out.println("解密的字符串:" + decrypt);
// return enPw;
//
// }
//
// public static void main(String[] args) {
// JasyptUtil.encryptStr("Eshop@2021","uniom-ebtp");
// }
//
//}

View File

@ -2,7 +2,7 @@ package com.chinaunicom.mall.ebtp.cloud.security.starter.common;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream;