From c6e431c93fe9cae625e3c944e09bd4bf0de5647f Mon Sep 17 00:00:00 2001
From: XinYi Song <2037158277@qq.com>
Date: Wed, 29 Dec 2021 17:17:07 +0800
Subject: [PATCH] =?UTF-8?q?springboot=E6=95=B4=E5=90=88=E4=BA=86=E9=93=B6?=
=?UTF-8?q?=E8=81=94=E6=94=AF=E4=BB=98=E6=89=AB=E7=A0=81=E6=94=AF=E4=BB=98?=
=?UTF-8?q?=E7=9A=84=E5=8A=9F=E8=83=BD=E6=A8=A1=E5=9D=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 14 +
.../xkrs/common/config/WebSecurityConfig.java | 1 +
.../java/com/xkrs/unionpay/bean/DemoBase.java | 227 +++++
.../xkrs/unionpay/config/UnionpayConfig.java | 20 +
.../controller/UnionpayController.java | 130 +++
.../unionpay/service/UnionpayService.java | 9 +
.../service/impl/UnionpayServiceImpl.java | 91 ++
.../com/xkrs/unionpay/util/AcpService.java | 676 ++++++++++++++
.../util/BaseHttpSSLSocketFactory.java | 125 +++
.../java/com/xkrs/unionpay/util/CertUtil.java | 790 ++++++++++++++++
.../com/xkrs/unionpay/util/HttpClient.java | 316 +++++++
.../java/com/xkrs/unionpay/util/LogUtil.java | 115 +++
.../com/xkrs/unionpay/util/SDKConfig.java | 835 +++++++++++++++++
.../com/xkrs/unionpay/util/SDKConstants.java | 391 ++++++++
.../java/com/xkrs/unionpay/util/SDKUtil.java | 855 ++++++++++++++++++
.../com/xkrs/unionpay/util/SecureUtil.java | 577 ++++++++++++
src/main/resources/application.properties | 75 ++
src/main/resources/log4j2.xml | 6 +-
18 files changed, 5250 insertions(+), 3 deletions(-)
create mode 100644 src/main/java/com/xkrs/unionpay/bean/DemoBase.java
create mode 100644 src/main/java/com/xkrs/unionpay/config/UnionpayConfig.java
create mode 100644 src/main/java/com/xkrs/unionpay/controller/UnionpayController.java
create mode 100644 src/main/java/com/xkrs/unionpay/service/UnionpayService.java
create mode 100644 src/main/java/com/xkrs/unionpay/service/impl/UnionpayServiceImpl.java
create mode 100644 src/main/java/com/xkrs/unionpay/util/AcpService.java
create mode 100644 src/main/java/com/xkrs/unionpay/util/BaseHttpSSLSocketFactory.java
create mode 100644 src/main/java/com/xkrs/unionpay/util/CertUtil.java
create mode 100644 src/main/java/com/xkrs/unionpay/util/HttpClient.java
create mode 100644 src/main/java/com/xkrs/unionpay/util/LogUtil.java
create mode 100644 src/main/java/com/xkrs/unionpay/util/SDKConfig.java
create mode 100644 src/main/java/com/xkrs/unionpay/util/SDKConstants.java
create mode 100644 src/main/java/com/xkrs/unionpay/util/SDKUtil.java
create mode 100644 src/main/java/com/xkrs/unionpay/util/SecureUtil.java
diff --git a/pom.xml b/pom.xml
index 7564f54..0553bb8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -236,6 +236,20 @@
gson
+
+
+ com.google.zxing
+ core
+ 3.3.0
+
+
+
+
+ com.google.zxing
+ javase
+ 3.3.0
+
+
diff --git a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java
index 85c8dfb..700d8ea 100644
--- a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java
+++ b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java
@@ -46,6 +46,7 @@ class WebSecurityConfig extends WebSecurityConfigurerAdapter {
.antMatchers(HttpMethod.POST,"/qiNiuUploadFile").permitAll()
.antMatchers(HttpMethod.POST,"/merchantSettlement").permitAll()
.antMatchers(HttpMethod.POST,"/api/user/updateRememberPassword").permitAll()
+ .antMatchers("/pay").permitAll()
// 所有其它请求需要身份认证
.anyRequest().authenticated()
.and()
diff --git a/src/main/java/com/xkrs/unionpay/bean/DemoBase.java b/src/main/java/com/xkrs/unionpay/bean/DemoBase.java
new file mode 100644
index 0000000..85f54ec
--- /dev/null
+++ b/src/main/java/com/xkrs/unionpay/bean/DemoBase.java
@@ -0,0 +1,227 @@
+package com.xkrs.unionpay.bean;
+
+import com.xkrs.unionpay.util.SDKConfig;
+import com.xkrs.unionpay.util.SDKConstants;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import java.util.TreeMap;
+
+/**
+ * 名称: demo中用到的方法
+ * 日期: 2015-09
+
+ * 版权: 中国银联
+ * 说明:以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己需要,按照技术文档编写。该代码仅供参考。
+ */
+public class DemoBase {
+
+ //默认配置的是UTF-8
+ public static String encoding = "UTF-8";
+
+ //全渠道固定值
+ public static String version = SDKConfig.getConfig().getVersion();
+
+ //后台服务对应的写法参照 FrontRcvResponse.java
+ public static String frontUrl = SDKConfig.getConfig().getFrontUrl();
+
+ //后台服务对应的写法参照 BackRcvResponse.java
+ public static String backUrl = SDKConfig.getConfig().getBackUrl();//受理方和发卡方自选填写的域[O]--后台通知地址
+
+ // 商户发送交易时间 格式:YYYYMMDDhhmmss
+ public static String getCurrentTime() {
+ return new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
+ }
+
+ // AN8..40 商户订单号,不能含"-"或"_"
+ public static String getOrderId() {
+ return new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
+ }
+
+ /**
+ * 组装请求,返回报文字符串用于显示
+ * @param data
+ * @return
+ */
+ public static String genHtmlResult(Map data){
+
+ TreeMap tree = new TreeMap();
+ Iterator> it = data.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry en = it.next();
+ tree.put(en.getKey(), en.getValue());
+ }
+ it = tree.entrySet().iterator();
+ StringBuffer sf = new StringBuffer();
+ while (it.hasNext()) {
+ Entry en = it.next();
+ String key = en.getKey();
+ String value = en.getValue();
+ if("respCode".equals(key)){
+ sf.append(""+key + SDKConstants.EQUAL + value+"");
+ }else {
+ sf.append(key + SDKConstants.EQUAL + value+"");
+ }
+ }
+ return sf.toString();
+ }
+ /**
+ * 功能:解析全渠道商户对账文件中的ZM文件并以List