Commit 75ad70ec authored by 明松's avatar 明松

配置文件加解密处理

parent 3faadd44
Pipeline #132 failed with stages
......@@ -55,7 +55,11 @@
<artifactId>ojdbc7</artifactId>
<version>12.1.0.1.0</version>
</dependency>
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>3.0.2</version>
</dependency>
</dependencies>
<repositories>
......
......@@ -12,41 +12,47 @@ import java.util.Date;
/**
* 定时任务类
* @author huarun
*
* @author huarun
*/
@Component
@EnableScheduling
//@Async
public class AlarmTask {
//系统服务定时器
/**第一次延迟(initialDelay)?秒后执行,之后按fixedDelay的规则每?秒执行一次*/
@Scheduled(initialDelay = 5*1000, fixedDelay = 60*1000)
public void run3(){
String dqsj = "";
Date dt = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
dqsj = sdf.format(dt);
System.out.println("第一个接口开始时间"+dqsj);
try {
ProvidentFundServicesController.gjjxtfwjk();
} catch (Exception e) {
e.printStackTrace();
}
}
//系统服务定时器
/**
* 第一次延迟(initialDelay)?秒后执行,之后按fixedDelay的规则每?秒执行一次
*/
@Scheduled(initialDelay = 5 * 1000, fixedDelay = 60 * 1000)
public void run3() {
String dqsj = "";
Date dt = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
dqsj = sdf.format(dt);
System.out.println("第一个接口开始时间" + dqsj);
try {
ProvidentFundServicesController.gjjxtfwjk();
} catch (Exception e) {
e.printStackTrace();
}
}
//进度数据定时器
/**第一次延迟(initialDelay)?秒后执行,之后按fixedDelay的规则每?秒执行一次*/
@Scheduled(initialDelay = 20*1000, fixedDelay = 60*1000)
public void run4(){
String dqsj = "";
Date dt = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
dqsj = sdf.format(dt);
System.out.println("第二个接口开始时间"+dqsj);
ProvidentFundServicesController.BusinessProcessing();
/**
* 第一次延迟(initialDelay)?秒后执行,之后按fixedDelay的规则每?秒执行一次
*/
@Scheduled(initialDelay = 20 * 1000, fixedDelay = 60 * 1000)
public void run4() {
String dqsj = "";
Date dt = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
dqsj = sdf.format(dt);
System.out.println("第二个接口开始时间" + dqsj);
ProvidentFundServicesController.BusinessProcessing();
}
}
package net.cdkj.gjj.adapter.encryptor;
import org.jasypt.encryption.StringEncryptor;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/encrypt")
@CrossOrigin(origins = "*", maxAge = 3600)
public class EncryptController {
@PostMapping("/jasyptEnc")
public String encrypt(@RequestParam String encStr) throws Exception {
StringEncryptor encryptor = new JasyptConfig().stringEncryptor();
return encryptor.encrypt(encStr);
}
@PostMapping("/jasyptDec")
public String decrypt(@RequestParam String decStr) throws Exception {
StringEncryptor encryptor = new JasyptConfig().stringEncryptor();
return encryptor.decrypt(decStr);
}
}
package net.cdkj.gjj.adapter.encryptor;
import org.jasypt.encryption.StringEncryptor;
import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
import org.jasypt.encryption.pbe.StandardPBEByteEncryptor;
import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* Jasypt 配置
*/
@Configuration
public class JasyptConfig {
@Bean("jasyptStringEncryptor")
public StringEncryptor stringEncryptor() {
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
SimpleStringPBEConfig config = new SimpleStringPBEConfig();
// 加密盐值
config.setPassword("gjjcdgs856177110");
// 加密算法
config.setAlgorithm(StandardPBEByteEncryptor.DEFAULT_ALGORITHM);
// key迭代次数
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 decryptStr) {
StringEncryptor encryptor = new JasyptConfig().stringEncryptor();
return encryptor.decrypt(decryptStr);
}
}
......@@ -10,9 +10,9 @@ timetype:1
#endTime:20210520 23:00:00
#数据库(正式环境)
url:jdbc:oracle:thin:@192.168.1.33:1596:zfgjj
user:gjj80
password:HG80_Y9E1C5
#url:jdbc:oracle:thin:@192.168.1.33:1596:zfgjj
#user:gjj80
#password:HG80_Y9E1C5
#数据库(测试环境)
#url:jdbc:oracle:thin:@192.168.1.36:1521:zfgjj
......@@ -20,7 +20,7 @@ password:HG80_Y9E1C5
#password:GJJ80
#数据库(本地环境)
#url:jdbc:oracle:thin:@192.168.101.194:1521:zfgjj
#user:HG2020
#password:HG2020
url:75DhD+XOzqnR0zqzR5qjr0iDdvT+n0oXo2eJOu5Hf6folEOl21MdF4Up8AszcxhxGQNsaR8fClxBOH4ZQ3l6mQ==
user:m28AAzNwsW76djvPXGA34gg9FtY6iqxM
password:m28AAzNwsW76djvPXGA34gg9FtY6iqxM
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment