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

配置文件加解密处理

parent 3faadd44
Pipeline #132 failed with stages
...@@ -55,7 +55,11 @@ ...@@ -55,7 +55,11 @@
<artifactId>ojdbc7</artifactId> <artifactId>ojdbc7</artifactId>
<version>12.1.0.1.0</version> <version>12.1.0.1.0</version>
</dependency> </dependency>
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>3.0.2</version>
</dependency>
</dependencies> </dependencies>
<repositories> <repositories>
......
...@@ -12,8 +12,8 @@ import java.util.Date; ...@@ -12,8 +12,8 @@ import java.util.Date;
/** /**
* 定时任务类 * 定时任务类
* @author huarun
* *
* @author huarun
*/ */
@Component @Component
@EnableScheduling @EnableScheduling
...@@ -22,14 +22,17 @@ public class AlarmTask { ...@@ -22,14 +22,17 @@ public class AlarmTask {
//系统服务定时器 //系统服务定时器
/**第一次延迟(initialDelay)?秒后执行,之后按fixedDelay的规则每?秒执行一次*/
@Scheduled(initialDelay = 5*1000, fixedDelay = 60*1000) /**
public void run3(){ * 第一次延迟(initialDelay)?秒后执行,之后按fixedDelay的规则每?秒执行一次
*/
@Scheduled(initialDelay = 5 * 1000, fixedDelay = 60 * 1000)
public void run3() {
String dqsj = ""; String dqsj = "";
Date dt = new Date(); Date dt = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
dqsj = sdf.format(dt); dqsj = sdf.format(dt);
System.out.println("第一个接口开始时间"+dqsj); System.out.println("第一个接口开始时间" + dqsj);
try { try {
ProvidentFundServicesController.gjjxtfwjk(); ProvidentFundServicesController.gjjxtfwjk();
} catch (Exception e) { } catch (Exception e) {
...@@ -38,14 +41,17 @@ public class AlarmTask { ...@@ -38,14 +41,17 @@ public class AlarmTask {
} }
//进度数据定时器 //进度数据定时器
/**第一次延迟(initialDelay)?秒后执行,之后按fixedDelay的规则每?秒执行一次*/
@Scheduled(initialDelay = 20*1000, fixedDelay = 60*1000) /**
public void run4(){ * 第一次延迟(initialDelay)?秒后执行,之后按fixedDelay的规则每?秒执行一次
*/
@Scheduled(initialDelay = 20 * 1000, fixedDelay = 60 * 1000)
public void run4() {
String dqsj = ""; String dqsj = "";
Date dt = new Date(); Date dt = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
dqsj = sdf.format(dt); dqsj = sdf.format(dt);
System.out.println("第二个接口开始时间"+dqsj); System.out.println("第二个接口开始时间" + dqsj);
ProvidentFundServicesController.BusinessProcessing(); ProvidentFundServicesController.BusinessProcessing();
} }
} }
......
package net.cdkj.gjj.adapter.controller; package net.cdkj.gjj.adapter.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import net.cdkj.gjj.adapter.encryptor.JasyptConfig;
import net.cdkj.gjj.adapter.domain.BusinessProcessing; import net.cdkj.gjj.adapter.domain.BusinessProcessing;
import net.cdkj.gjj.adapter.domain.Json; import net.cdkj.gjj.adapter.domain.Json;
import net.cdkj.gjj.adapter.domain.PropertyqUtil; import net.cdkj.gjj.adapter.domain.PropertyqUtil;
...@@ -12,13 +12,16 @@ import org.springframework.web.bind.annotation.PostMapping; ...@@ -12,13 +12,16 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.io.*; import java.io.*;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.sql.*; import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.Date;
/** /**
...@@ -28,6 +31,17 @@ import java.util.Date; ...@@ -28,6 +31,17 @@ import java.util.Date;
@RequestMapping(value = "InternalLogic") @RequestMapping(value = "InternalLogic")
public class ProvidentFundServicesController { public class ProvidentFundServicesController {
private static String url;
private static String user;
private static String password;
static {
Properties prop = PropertyqUtil.getConfig("application.properties");
url = JasyptConfig.encryptStr(PropertyqUtil.getPropValue(prop, "url"));
user = JasyptConfig.encryptStr(PropertyqUtil.getPropValue(prop, "user"));
password = JasyptConfig.encryptStr(PropertyqUtil.getPropValue(prop, "password"));
}
/** /**
* 公积金系统服务接口内置机调前置机中间接口 * 公积金系统服务接口内置机调前置机中间接口
* *
...@@ -39,13 +53,13 @@ public class ProvidentFundServicesController { ...@@ -39,13 +53,13 @@ public class ProvidentFundServicesController {
public static String ProvidentFundServices() { public static String ProvidentFundServices() {
Properties prop = PropertyqUtil.getConfig("application.properties"); Properties prop = PropertyqUtil.getConfig("application.properties");
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
String type= PropertyqUtil.getPropValue( prop ,"timetype"); String type = PropertyqUtil.getPropValue(prop, "timetype");
if("1".equals(type)){//表示正式环境 if ("1".equals(type)) {//表示正式环境
jsonObject.put("startTime", currenttime(0));//正式环境 jsonObject.put("startTime", currenttime(0));//正式环境
jsonObject.put("endTime", currenttime(24));//正式环境 jsonObject.put("endTime", currenttime(24));//正式环境
}else if("2".equals(type)){//表示测试环境或本地环境 } else if ("2".equals(type)) {//表示测试环境或本地环境
jsonObject.put("startTime", PropertyqUtil.getPropValue( prop ,"startTime"));//测试环境或本地环境 jsonObject.put("startTime", PropertyqUtil.getPropValue(prop, "startTime"));//测试环境或本地环境
jsonObject.put("endTime", PropertyqUtil.getPropValue( prop ,"endTime"));//测试环境或本地环境 jsonObject.put("endTime", PropertyqUtil.getPropValue(prop, "endTime"));//测试环境或本地环境
} }
jsonObject.put("app_id", "eb453ca78b354f2c9163a703530f5186"); jsonObject.put("app_id", "eb453ca78b354f2c9163a703530f5186");
jsonObject.put("app_secret", "9a31b84878654a72a999e38ef55aa186"); jsonObject.put("app_secret", "9a31b84878654a72a999e38ef55aa186");
...@@ -173,7 +187,7 @@ public class ProvidentFundServicesController { ...@@ -173,7 +187,7 @@ public class ProvidentFundServicesController {
//得到Connection连接 //得到Connection连接
// Connection connection= DriverManager.getConnection("jdbc:oracle:thin:@192.168.101.194:1521:zfgjj", "HG2020", "HG2020");//本地环境 // Connection connection= DriverManager.getConnection("jdbc:oracle:thin:@192.168.101.194:1521:zfgjj", "HG2020", "HG2020");//本地环境
// Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.36:1521:zfgjj", "GJJ80", "GJJ80");//测试环境 // Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.36:1521:zfgjj", "GJJ80", "GJJ80");//测试环境
Connection connection = DriverManager.getConnection(PropertyqUtil.getPropValue( prop ,"url"), PropertyqUtil.getPropValue( prop ,"user"), PropertyqUtil.getPropValue( prop ,"password"));//正式环境 Connection connection = DriverManager.getConnection(url, user, password);//正式环境
//得到预编译的Statement对象 //得到预编译的Statement对象
CallableStatement pstm = connection.prepareCall("{call JGJ_KSYW_DWKH.DWXX_IMP(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}"); CallableStatement pstm = connection.prepareCall("{call JGJ_KSYW_DWKH.DWXX_IMP(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}");
//调完第一个存储过程DWXX_IMP之后再调DWKH_SAVE存储过程 //调完第一个存储过程DWXX_IMP之后再调DWKH_SAVE存储过程
...@@ -192,7 +206,7 @@ public class ProvidentFundServicesController { ...@@ -192,7 +206,7 @@ public class ProvidentFundServicesController {
//421181 //421181
//421182 //421182
//421101 //421101
List<String> wo=new ArrayList<>(); List<String> wo = new ArrayList<>();
wo.add("421102"); wo.add("421102");
wo.add("421121"); wo.add("421121");
wo.add("421122"); wo.add("421122");
...@@ -207,8 +221,8 @@ public class ProvidentFundServicesController { ...@@ -207,8 +221,8 @@ public class ProvidentFundServicesController {
if (!bills.isEmpty()) { if (!bills.isEmpty()) {
for (UnitAccountOpeningInformation uniInfom : bills) { for (UnitAccountOpeningInformation uniInfom : bills) {
if (!"".equals(uniInfom.getOplocdistrict()) && uniInfom.getOplocdistrict() != null) { if (!"".equals(uniInfom.getOplocdistrict()) && uniInfom.getOplocdistrict() != null) {
if(wo.contains(uniInfom.getOplocdistrict())){ if (wo.contains(uniInfom.getOplocdistrict())) {
System.out.println("oplocdistrict"+"在规定的值里面,调imp过程"); System.out.println("oplocdistrict" + "在规定的值里面,调imp过程");
if (!"".equals(uniInfom.getBusId()) && uniInfom.getBusId() != null) { if (!"".equals(uniInfom.getBusId()) && uniInfom.getBusId() != null) {
pstm.setString(1, uniInfom.getBusId()); pstm.setString(1, uniInfom.getBusId());
} else { } else {
...@@ -334,8 +348,8 @@ public class ProvidentFundServicesController { ...@@ -334,8 +348,8 @@ public class ProvidentFundServicesController {
e.printStackTrace(); e.printStackTrace();
} }
} }
} else{ } else {
System.out.println("oplocdistrict"+"不在规定的值里面,不调imp过程"); System.out.println("oplocdistrict" + "不在规定的值里面,不调imp过程");
} }
} }
} }
...@@ -521,7 +535,7 @@ public class ProvidentFundServicesController { ...@@ -521,7 +535,7 @@ public class ProvidentFundServicesController {
//得到Connection连接 //得到Connection连接
// Connection connection= DriverManager.getConnection("jdbc:oracle:thin:@192.168.101.194:1521:zfgjj", "HG2020", "HG2020");//本地环境 // Connection connection= DriverManager.getConnection("jdbc:oracle:thin:@192.168.101.194:1521:zfgjj", "HG2020", "HG2020");//本地环境
// Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.36:1521:zfgjj", "GJJ80", "GJJ80");//测试环境 // Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.36:1521:zfgjj", "GJJ80", "GJJ80");//测试环境
Connection connection = DriverManager.getConnection(PropertyqUtil.getPropValue( prop ,"url"), PropertyqUtil.getPropValue( prop ,"user"), PropertyqUtil.getPropValue( prop ,"password"));//正式环境 Connection connection = DriverManager.getConnection(url, user, password);//正式环境
//得到预编译的Statement对象 //得到预编译的Statement对象
CallableStatement pstm = connection.prepareCall("{call JGJ_KSYW_DWKH.DWKH_CX(?)}"); CallableStatement pstm = connection.prepareCall("{call JGJ_KSYW_DWKH.DWKH_CX(?)}");
//给参数赋值 //给参数赋值
...@@ -591,7 +605,7 @@ public class ProvidentFundServicesController { ...@@ -591,7 +605,7 @@ public class ProvidentFundServicesController {
//得到Connection连接 //得到Connection连接
// Connection connection= DriverManager.getConnection("jdbc:oracle:thin:@192.168.101.194:1521:zfgjj", "HG2020", "HG2020");//本地环境 // Connection connection= DriverManager.getConnection("jdbc:oracle:thin:@192.168.101.194:1521:zfgjj", "HG2020", "HG2020");//本地环境
// Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.36:1521:zfgjj", "GJJ80", "GJJ80");//测试环境 // Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.36:1521:zfgjj", "GJJ80", "GJJ80");//测试环境
Connection connection = DriverManager.getConnection(PropertyqUtil.getPropValue( prop ,"url"), PropertyqUtil.getPropValue( prop ,"user"), PropertyqUtil.getPropValue( prop ,"password"));//正式环境 Connection connection = DriverManager.getConnection(url, user, password);//正式环境
//得到预编译的Statement对象 //得到预编译的Statement对象
CallableStatement pstm = connection.prepareCall("{call JGJ_KSYW_DWKH.DWKH_HX(?,?)}"); CallableStatement pstm = connection.prepareCall("{call JGJ_KSYW_DWKH.DWKH_HX(?,?)}");
//给参数赋值 //给参数赋值
......
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 ...@@ -10,9 +10,9 @@ timetype:1
#endTime:20210520 23:00:00 #endTime:20210520 23:00:00
#数据库(正式环境) #数据库(正式环境)
url:jdbc:oracle:thin:@192.168.1.33:1596:zfgjj #url:jdbc:oracle:thin:@192.168.1.33:1596:zfgjj
user:gjj80 #user:gjj80
password:HG80_Y9E1C5 #password:HG80_Y9E1C5
#数据库(测试环境) #数据库(测试环境)
#url:jdbc:oracle:thin:@192.168.1.36:1521:zfgjj #url:jdbc:oracle:thin:@192.168.1.36:1521:zfgjj
...@@ -20,7 +20,7 @@ password:HG80_Y9E1C5 ...@@ -20,7 +20,7 @@ password:HG80_Y9E1C5
#password:GJJ80 #password:GJJ80
#数据库(本地环境) #数据库(本地环境)
#url:jdbc:oracle:thin:@192.168.101.194:1521:zfgjj url:75DhD+XOzqnR0zqzR5qjr0iDdvT+n0oXo2eJOu5Hf6folEOl21MdF4Up8AszcxhxGQNsaR8fClxBOH4ZQ3l6mQ==
#user:HG2020 user:m28AAzNwsW76djvPXGA34gg9FtY6iqxM
#password:HG2020 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