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.controller;
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.Json;
import net.cdkj.gjj.adapter.domain.PropertyqUtil;
......@@ -12,13 +12,16 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.io.*;
import java.net.HttpURLConnection;
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.util.*;
import java.util.Date;
/**
......@@ -28,6 +31,17 @@ import java.util.Date;
@RequestMapping(value = "InternalLogic")
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 {
public static String ProvidentFundServices() {
Properties prop = PropertyqUtil.getConfig("application.properties");
JSONObject jsonObject = new JSONObject();
String type= PropertyqUtil.getPropValue( prop ,"timetype");
if("1".equals(type)){//表示正式环境
String type = PropertyqUtil.getPropValue(prop, "timetype");
if ("1".equals(type)) {//表示正式环境
jsonObject.put("startTime", currenttime(0));//正式环境
jsonObject.put("endTime", currenttime(24));//正式环境
}else if("2".equals(type)){//表示测试环境或本地环境
jsonObject.put("startTime", PropertyqUtil.getPropValue( prop ,"startTime"));//测试环境或本地环境
jsonObject.put("endTime", PropertyqUtil.getPropValue( prop ,"endTime"));//测试环境或本地环境
} else if ("2".equals(type)) {//表示测试环境或本地环境
jsonObject.put("startTime", PropertyqUtil.getPropValue(prop, "startTime"));//测试环境或本地环境
jsonObject.put("endTime", PropertyqUtil.getPropValue(prop, "endTime"));//测试环境或本地环境
}
jsonObject.put("app_id", "eb453ca78b354f2c9163a703530f5186");
jsonObject.put("app_secret", "9a31b84878654a72a999e38ef55aa186");
......@@ -173,7 +187,7 @@ public class ProvidentFundServicesController {
//得到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.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对象
CallableStatement pstm = connection.prepareCall("{call JGJ_KSYW_DWKH.DWXX_IMP(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}");
//调完第一个存储过程DWXX_IMP之后再调DWKH_SAVE存储过程
......@@ -192,7 +206,7 @@ public class ProvidentFundServicesController {
//421181
//421182
//421101
List<String> wo=new ArrayList<>();
List<String> wo = new ArrayList<>();
wo.add("421102");
wo.add("421121");
wo.add("421122");
......@@ -207,138 +221,138 @@ public class ProvidentFundServicesController {
if (!bills.isEmpty()) {
for (UnitAccountOpeningInformation uniInfom : bills) {
if (!"".equals(uniInfom.getOplocdistrict()) && uniInfom.getOplocdistrict() != null) {
if(wo.contains(uniInfom.getOplocdistrict())){
System.out.println("oplocdistrict"+"在规定的值里面,调imp过程");
if (!"".equals(uniInfom.getBusId()) && uniInfom.getBusId() != null) {
pstm.setString(1, uniInfom.getBusId());
} else {
pstm.setString(1, "");
}
if (!"".equals(uniInfom.getUscc()) && uniInfom.getUscc() != null) {
pstm.setString(2, uniInfom.getUscc());
} else {
pstm.setString(2, "");
}
if (!"".equals(uniInfom.getEntName()) && uniInfom.getEntName() != null) {
pstm.setString(3, uniInfom.getEntName());
} else {
pstm.setString(3, "");
}
if (!"".equals(uniInfom.getDom()) && uniInfom.getDom() != null) {
pstm.setString(4, uniInfom.getDom());
} else {
pstm.setString(4, "");
}
if (!"".equals(uniInfom.getEstDate()) && uniInfom.getEstDate() != null) {
pstm.setDate(5, new java.sql.Date(uniInfom.getEstDate().getTime()));
} else {
pstm.setString(5, "");
}
if (!"".equals(uniInfom.getLerep()) && uniInfom.getLerep() != null) {
pstm.setString(6, uniInfom.getLerep());
} else {
pstm.setString(6, "");
}
if (!"".equals(uniInfom.getCerType()) && uniInfom.getCerType() != null) {
pstm.setString(7, uniInfom.getCerType());
} else {
pstm.setString(7, "");
}
if (!"".equals(uniInfom.getCerNo()) && uniInfom.getCerNo() != null) {
pstm.setString(8, uniInfom.getCerNo());
} else {
pstm.setString(8, "");
}
if (!"".equals(uniInfom.getOperatorName()) && uniInfom.getOperatorName() != null) {
pstm.setString(9, uniInfom.getOperatorName());
} else {
pstm.setString(9, "");
}
if (!"".equals(uniInfom.getOperatorCerNo()) && uniInfom.getOperatorCerNo() != null) {
pstm.setString(10, uniInfom.getOperatorCerNo());
} else {
pstm.setString(10, "");
}
if (!"".equals(uniInfom.getOperatorPhone()) && uniInfom.getOperatorPhone() != null) {
pstm.setString(11, uniInfom.getOperatorPhone());
} else {
pstm.setString(11, "");
}
if (!"".equals(uniInfom.getOplocdistrict()) && uniInfom.getOplocdistrict() != null) {
pstm.setString(12, uniInfom.getOplocdistrict());
} else {
pstm.setString(12, "");
}
if (!"".equals(uniInfom.getUnitNature()) && uniInfom.getUnitNature() != null) {
pstm.setString(13, uniInfom.getUnitNature());
} else {
pstm.setString(13, "");
}
if (!"".equals(uniInfom.getEconomicType()) && uniInfom.getEconomicType() != null) {
pstm.setString(14, uniInfom.getEconomicType());
} else {
pstm.setString(14, "");
}
if (!"".equals(uniInfom.getIndustryphy()) && uniInfom.getIndustryphy() != null) {
pstm.setString(15, uniInfom.getIndustryphy());
} else {
pstm.setString(15, "");
}
if (!"".equals(uniInfom.getUnitPayDay()) && uniInfom.getUnitPayDay() != null) {
pstm.setString(16, uniInfom.getUnitPayDay());
} else {
pstm.setString(16, "");
}
if (!"".equals(uniInfom.getUnitDepPro()) && uniInfom.getUnitDepPro() != null) {
pstm.setString(17, uniInfom.getUnitDepPro());
} else {
pstm.setString(17, "");
}
if (!"".equals(uniInfom.getPersonalDepPro()) && uniInfom.getPersonalDepPro() != null) {
pstm.setString(18, uniInfom.getPersonalDepPro());
} else {
pstm.setString(18, "");
}
pstm.registerOutParameter(19, oracle.jdbc.OracleTypes.VARCHAR);
pstm.registerOutParameter(20, oracle.jdbc.OracleTypes.VARCHAR);
//执行数据库查询操作
pstm.execute();
//输出结果[第二个参数]
System.out.println(pstm.getString(19));
System.out.println(pstm.getString(20));
if ("".equals(pstm.getString(19)) || pstm.getString(19) == null) {
break;
} else {
try {
// 避免批量插入高并发,此处设置每次停顿5秒
Thread.currentThread().sleep(2000);
System.out.println("间隔2秒传一条数据调一次存储过程");
} catch (InterruptedException e) {
e.printStackTrace();
}
}
} else{
System.out.println("oplocdistrict"+"不在规定的值里面,不调imp过程");
}
}
if (wo.contains(uniInfom.getOplocdistrict())) {
System.out.println("oplocdistrict" + "在规定的值里面,调imp过程");
if (!"".equals(uniInfom.getBusId()) && uniInfom.getBusId() != null) {
pstm.setString(1, uniInfom.getBusId());
} else {
pstm.setString(1, "");
}
if (!"".equals(uniInfom.getUscc()) && uniInfom.getUscc() != null) {
pstm.setString(2, uniInfom.getUscc());
} else {
pstm.setString(2, "");
}
if (!"".equals(uniInfom.getEntName()) && uniInfom.getEntName() != null) {
pstm.setString(3, uniInfom.getEntName());
} else {
pstm.setString(3, "");
}
if (!"".equals(uniInfom.getDom()) && uniInfom.getDom() != null) {
pstm.setString(4, uniInfom.getDom());
} else {
pstm.setString(4, "");
}
if (!"".equals(uniInfom.getEstDate()) && uniInfom.getEstDate() != null) {
pstm.setDate(5, new java.sql.Date(uniInfom.getEstDate().getTime()));
} else {
pstm.setString(5, "");
}
if (!"".equals(uniInfom.getLerep()) && uniInfom.getLerep() != null) {
pstm.setString(6, uniInfom.getLerep());
} else {
pstm.setString(6, "");
}
if (!"".equals(uniInfom.getCerType()) && uniInfom.getCerType() != null) {
pstm.setString(7, uniInfom.getCerType());
} else {
pstm.setString(7, "");
}
if (!"".equals(uniInfom.getCerNo()) && uniInfom.getCerNo() != null) {
pstm.setString(8, uniInfom.getCerNo());
} else {
pstm.setString(8, "");
}
if (!"".equals(uniInfom.getOperatorName()) && uniInfom.getOperatorName() != null) {
pstm.setString(9, uniInfom.getOperatorName());
} else {
pstm.setString(9, "");
}
if (!"".equals(uniInfom.getOperatorCerNo()) && uniInfom.getOperatorCerNo() != null) {
pstm.setString(10, uniInfom.getOperatorCerNo());
} else {
pstm.setString(10, "");
}
if (!"".equals(uniInfom.getOperatorPhone()) && uniInfom.getOperatorPhone() != null) {
pstm.setString(11, uniInfom.getOperatorPhone());
} else {
pstm.setString(11, "");
}
if (!"".equals(uniInfom.getOplocdistrict()) && uniInfom.getOplocdistrict() != null) {
pstm.setString(12, uniInfom.getOplocdistrict());
} else {
pstm.setString(12, "");
}
if (!"".equals(uniInfom.getUnitNature()) && uniInfom.getUnitNature() != null) {
pstm.setString(13, uniInfom.getUnitNature());
} else {
pstm.setString(13, "");
}
if (!"".equals(uniInfom.getEconomicType()) && uniInfom.getEconomicType() != null) {
pstm.setString(14, uniInfom.getEconomicType());
} else {
pstm.setString(14, "");
}
if (!"".equals(uniInfom.getIndustryphy()) && uniInfom.getIndustryphy() != null) {
pstm.setString(15, uniInfom.getIndustryphy());
} else {
pstm.setString(15, "");
}
if (!"".equals(uniInfom.getUnitPayDay()) && uniInfom.getUnitPayDay() != null) {
pstm.setString(16, uniInfom.getUnitPayDay());
} else {
pstm.setString(16, "");
}
if (!"".equals(uniInfom.getUnitDepPro()) && uniInfom.getUnitDepPro() != null) {
pstm.setString(17, uniInfom.getUnitDepPro());
} else {
pstm.setString(17, "");
}
if (!"".equals(uniInfom.getPersonalDepPro()) && uniInfom.getPersonalDepPro() != null) {
pstm.setString(18, uniInfom.getPersonalDepPro());
} else {
pstm.setString(18, "");
}
pstm.registerOutParameter(19, oracle.jdbc.OracleTypes.VARCHAR);
pstm.registerOutParameter(20, oracle.jdbc.OracleTypes.VARCHAR);
//执行数据库查询操作
pstm.execute();
//输出结果[第二个参数]
System.out.println(pstm.getString(19));
System.out.println(pstm.getString(20));
if ("".equals(pstm.getString(19)) || pstm.getString(19) == null) {
break;
} else {
try {
// 避免批量插入高并发,此处设置每次停顿5秒
Thread.currentThread().sleep(2000);
System.out.println("间隔2秒传一条数据调一次存储过程");
} catch (InterruptedException e) {
e.printStackTrace();
}
}
} else {
System.out.println("oplocdistrict" + "不在规定的值里面,不调imp过程");
}
}
}
pstm2.execute();
} else {
......@@ -401,105 +415,105 @@ public class ProvidentFundServicesController {
e.printStackTrace();
}
// if(!list.isEmpty()){//查到数据才请求第三方接口推送
System.out.println("调第二个接口了存储过程返回的list" + list);
JSONObject jsonObject = new JSONObject();
jsonObject.put("state", "1");
if (!list.isEmpty()) {
jsonObject.put("timestamp", list.stream().min(Comparator.comparing(BusinessProcessing::getTime)).get().getTime());
} else {
jsonObject.put("timestamp", "");
}
System.out.println("调第二个接口了存储过程返回的list" + list);
JSONObject jsonObject = new JSONObject();
jsonObject.put("state", "1");
if (!list.isEmpty()) {
jsonObject.put("timestamp", list.stream().min(Comparator.comparing(BusinessProcessing::getTime)).get().getTime());
} else {
jsonObject.put("timestamp", "");
}
if (!list.isEmpty()) {
jsonObject.put("busId", list.stream().min(Comparator.comparing(BusinessProcessing::getTime)).get().getBusId());
} else {
jsonObject.put("busId", "");
}
jsonObject.put("departCode", "10");
jsonObject.put("nodeList", list);
String str = jsonObject.toString();
StringBuffer sb = new StringBuffer();
HttpURLConnection conn = null;
OutputStream out = null;
try {
// 创建url 资源
URL url = new URL("http://192.168.1.252:8888/FrontEndProcessor/FrontEndProcessor/BusinessProcessing");//(测试环境)调用前置机将业务机封装的业务json数据发给前置机,让前置机去请求第三方的公积金系统服务接口
if (!list.isEmpty()) {
jsonObject.put("busId", list.stream().min(Comparator.comparing(BusinessProcessing::getTime)).get().getBusId());
} else {
jsonObject.put("busId", "");
}
jsonObject.put("departCode", "10");
jsonObject.put("nodeList", list);
String str = jsonObject.toString();
StringBuffer sb = new StringBuffer();
HttpURLConnection conn = null;
OutputStream out = null;
try {
// 创建url 资源
URL url = new URL("http://192.168.1.252:8888/FrontEndProcessor/FrontEndProcessor/BusinessProcessing");//(测试环境)调用前置机将业务机封装的业务json数据发给前置机,让前置机去请求第三方的公积金系统服务接口
// URL url = new URL("http://192.168.101.34:8080/FrontEndProcessor/FrontEndProcessor/BusinessProcessing");//(本地环境)调用前置机将业务机封装的业务json数据发给前置机,让前置机去请求第三方的公积金系统服务接口
// 创建http 连接
conn = (HttpURLConnection) url.openConnection();
// 设置允许输出
conn.setDoOutput(true);
// 设置允许输入
conn.setDoInput(true);
// 设置不使用缓存
conn.setUseCaches(false);
// 设置传递方式
conn.setRequestMethod("POST");
// 设置维持长连接
conn.setRequestProperty("Connection", "Keep-Alive");
// 设置文件类型:
conn.setRequestProperty("Content-Type", "application/json");
// 设置文件字符集:
conn.setRequestProperty("Charset", "UTF-8");
// 转换为字节数组
byte[] data = (str).getBytes("UTF-8");
// 设置文件长度
conn.setRequestProperty("Content-Length", String.valueOf(data.length));
// 开始连接请求
conn.connect();
//创建写入流,写入请求的字符串
out = new DataOutputStream(conn.getOutputStream());
out.write(data);
// 请求返回的状态
if (HttpURLConnection.HTTP_OK == conn.getResponseCode()) {
// 请求返回的数据
InputStream is = conn.getInputStream();
String readLine = new String();
BufferedReader responseReader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
while ((readLine = responseReader.readLine()) != null) {
sb.append(readLine);
}
responseReader.close();
System.out.println("前置机返回第三方解压之后的进度推送结果" + sb.toString());
String uscc = "";
if (!list.isEmpty()) {
uscc = list.get(0).getUscc();
} else {
}
System.out.println(uscc);
JSONObject jsonObj = JSONObject.parseObject(sb.toString());
String success = jsonObj.getString("success");
Integer value = 0;
if ("true".equals(success)) {
value = 1;
} else if ("false".equals(success)) {
value = 0;
}
try {
zjbmfhywtosjHX(uscc, value);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(value);
return sb.toString();
// 创建http 连接
conn = (HttpURLConnection) url.openConnection();
// 设置允许输出
conn.setDoOutput(true);
// 设置允许输入
conn.setDoInput(true);
// 设置不使用缓存
conn.setUseCaches(false);
// 设置传递方式
conn.setRequestMethod("POST");
// 设置维持长连接
conn.setRequestProperty("Connection", "Keep-Alive");
// 设置文件类型:
conn.setRequestProperty("Content-Type", "application/json");
// 设置文件字符集:
conn.setRequestProperty("Charset", "UTF-8");
// 转换为字节数组
byte[] data = (str).getBytes("UTF-8");
// 设置文件长度
conn.setRequestProperty("Content-Length", String.valueOf(data.length));
// 开始连接请求
conn.connect();
//创建写入流,写入请求的字符串
out = new DataOutputStream(conn.getOutputStream());
out.write(data);
// 请求返回的状态
if (HttpURLConnection.HTTP_OK == conn.getResponseCode()) {
// 请求返回的数据
InputStream is = conn.getInputStream();
String readLine = new String();
BufferedReader responseReader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
while ((readLine = responseReader.readLine()) != null) {
sb.append(readLine);
}
responseReader.close();
System.out.println("前置机返回第三方解压之后的进度推送结果" + sb.toString());
String uscc = "";
if (!list.isEmpty()) {
uscc = list.get(0).getUscc();
} else {
System.out.println("请求失败!!!");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (out != null) {
try {
out.flush();
out.close();
} catch (IOException e) {
}
System.out.println(uscc);
JSONObject jsonObj = JSONObject.parseObject(sb.toString());
String success = jsonObj.getString("success");
Integer value = 0;
if ("true".equals(success)) {
value = 1;
} else if ("false".equals(success)) {
value = 0;
}
if (conn != null) {
conn.disconnect();
try {
zjbmfhywtosjHX(uscc, value);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(value);
return sb.toString();
} else {
System.out.println("请求失败!!!");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (out != null) {
try {
out.flush();
out.close();
} catch (IOException e) {
}
}
if (conn != null) {
conn.disconnect();
}
}
return null;
......@@ -521,7 +535,7 @@ public class ProvidentFundServicesController {
//得到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.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对象
CallableStatement pstm = connection.prepareCall("{call JGJ_KSYW_DWKH.DWKH_CX(?)}");
//给参数赋值
......@@ -591,7 +605,7 @@ public class ProvidentFundServicesController {
//得到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.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对象
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
#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