فهرست منبع

解决jar路径问题

周箭河 5 سال پیش
والد
کامیت
f6903557e7

+ 7 - 1
pom.xml

@@ -203,11 +203,17 @@
 				<executions>
 					<execution>
 						<goals>
-							<goal>build-info</goal>
 							<goal>repackage</goal>
 						</goals>
 					</execution>
 				</executions>
+				<configuration>
+					<includeSystemScope>true</includeSystemScope>
+					<addResources>true</addResources>
+					<fork>true</fork>
+					<mainClass>com.ym.mec.collectfee.CollectFeeServerApplication</mainClass>
+					<layout>ZIP</layout>
+				</configuration>
 			</plugin>
 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>

+ 41 - 4
src/main/java/com/ym/mec/collectfee/controller/YqRegController.java

@@ -1,5 +1,6 @@
 package com.ym.mec.collectfee.controller;
 
+import com.ym.mec.collectfee.utils.GenerateNum;
 import com.ym.mec.collectfee.utils.yqpay.YqPayUtil;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.ModelMap;
@@ -22,15 +23,17 @@ public class YqRegController {
      * @return
      * @throws Exception
      */
-    @GetMapping("/register")
-    public String register(ModelMap map) throws Exception {
+    @GetMapping("/per")
+    public String per(ModelMap map) throws Exception {
 
         String notifyUrl = "http://47.99.212.176:9000/yqpay/notify"; //主动通知地址
 
+        String seraialNumber = GenerateNum.getInstance().GenerateOrderNo();
+
         Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
         resultMap.put("type", "H5");
-        resultMap.put("returnUrl", "https://www.baidu.com");
-        resultMap.put("seraialNumber", "785679");
+        resultMap.put("returnUrl", "http://dev.dayaedu.com/");
+        resultMap.put("seraialNumber", seraialNumber);
         resultMap.put("merType", "per");
 
         Map<String, Object> requestMap = new YqPayUtil(notifyUrl, resultMap).getRequestMap();
@@ -38,4 +41,38 @@ public class YqRegController {
         return "/reg/register";
     }
 
+    @GetMapping("/com")
+    public String com(ModelMap map) throws Exception {
+        String notifyUrl = "http://47.99.212.176:9000/yqpay/notify"; //主动通知地址
+
+        String seraialNumber = GenerateNum.getInstance().GenerateOrderNo();
+
+        Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
+        resultMap.put("type", "H5");
+        resultMap.put("returnUrl", "http://dev.dayaedu.com/");
+        resultMap.put("seraialNumber", seraialNumber);
+        resultMap.put("merType", "com");
+
+        Map<String, Object> requestMap = new YqPayUtil(notifyUrl, resultMap).getRequestMap();
+        map.addAttribute("info", requestMap);
+        return "/reg/register";
+    }
+
+    @GetMapping("/pcy")
+    public String pcy(ModelMap map) throws Exception {
+        String notifyUrl = "http://47.99.212.176:9000/yqpay/notify"; //主动通知地址
+
+        String seraialNumber = GenerateNum.getInstance().GenerateOrderNo();
+
+        Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
+        resultMap.put("type", "H5");
+        resultMap.put("returnUrl", "http://dev.dayaedu.com/");
+        resultMap.put("seraialNumber", seraialNumber);
+        resultMap.put("merType", "pcy");
+
+        Map<String, Object> requestMap = new YqPayUtil(notifyUrl, resultMap).getRequestMap();
+        map.addAttribute("info", requestMap);
+        return "/reg/register";
+    }
+
 }

+ 6 - 4
src/main/java/com/ym/mec/collectfee/utils/yqpay/CFCARAUtil.java

@@ -11,6 +11,7 @@ import org.springframework.core.io.ClassPathResource;
 import javax.crypto.spec.SecretKeySpec;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.InputStreamReader;
 import java.security.Key;
 import java.security.KeyFactory;
 import java.security.PrivateKey;
@@ -47,8 +48,9 @@ public class CFCARAUtil {
      *
      */
     public static String signMessageByP1(String message, String pfxPath, String passWord) throws Exception{
-        File file = new ClassPathResource(pfxPath).getFile();
-        PrivateKey userPriKey = KeyUtil.getPrivateKeyFromPFX(new FileInputStream(file), passWord);
+       // File file = new ClassPathResource(pfxPath).getFile();
+
+        PrivateKey userPriKey = KeyUtil.getPrivateKeyFromPFX(new ClassPathResource(pfxPath).getInputStream(), passWord);
         Signature signature = new Signature();
         byte[] base64P7SignedData = signature.p1SignMessage(Mechanism.SHA256_RSA, message.getBytes("UTF-8"), userPriKey, session);
         return new String(base64P7SignedData);
@@ -63,8 +65,8 @@ public class CFCARAUtil {
      * @throws Exception
      */
     public static boolean verifyMessageByP1(String beforeSignedData, String afterSignedData, String certPath) throws Exception{
-        File file = new ClassPathResource(certPath).getFile();
-        X509Cert cert = new X509Cert(new FileInputStream(file));
+        //File file = new ClassPathResource(certPath).getFile();
+        X509Cert cert = new X509Cert(new ClassPathResource(certPath).getInputStream());
         PublicKey publicKey = cert.getPublicKey();
         Signature signature = new Signature();
         return signature.p1VerifyMessage(Mechanism.SHA256_RSA, beforeSignedData.getBytes("UTF-8"), afterSignedData.getBytes("UTF-8"), publicKey, session);

+ 2 - 2
src/main/java/com/ym/mec/collectfee/utils/yqpay/YqPayUtil.java

@@ -28,7 +28,7 @@ public class YqPayUtil {
         rqMap.put("apiContent", JSON.toJSONString(resultMap));
         rqMap.put("signType", signType);
         String beforeSignedData = CFCARAUtil.joinMapValue(rqMap, '&');
-        this.sign = CFCARAUtil.signMessageByP1(beforeSignedData, "certificate/yqpay.pfx", "aaa123123");
+        this.sign = CFCARAUtil.signMessageByP1(beforeSignedData, "classpath:certificate/yqpay.pfx", "aaa123123");
         rqMap.put("sign", this.sign);
         this.requestMap = rqMap;
     }
@@ -43,7 +43,7 @@ public class YqPayUtil {
         rsMap.remove("sign");
         String beforeSignedData = CFCARAUtil.joinMapValue(rsMap, '&');
         try {
-            return CFCARAUtil.verifyMessageByP1(beforeSignedData, sign, "certificate/yqpay.cer");
+            return CFCARAUtil.verifyMessageByP1(beforeSignedData, sign, "classpath:certificate/yqpay.cer");
         } catch (Exception e) {
             return false;
         }