From c1cf02563eb667944181b2e4638d36e6dc7f2354 Mon Sep 17 00:00:00 2001
From: chenjiahe <763432473@qq.com>
Date: 星期四, 11 八月 2022 12:02:18 +0800
Subject: [PATCH] Merge remote-tracking branch 'blit_origin/master'

---
 src/main/java/com/platform/verification/VerificationTool.java |   67 +++++++++++++++++++++++++++------
 1 files changed, 55 insertions(+), 12 deletions(-)

diff --git a/src/main/java/com/platform/verification/VerificationTool.java b/src/main/java/com/platform/verification/VerificationTool.java
index 705f492..42d4536 100644
--- a/src/main/java/com/platform/verification/VerificationTool.java
+++ b/src/main/java/com/platform/verification/VerificationTool.java
@@ -1,10 +1,16 @@
 package com.platform.verification;
 
-
+import com.hx.util.DateUtil;
 import com.hx.util.StringUtils;
 import com.hx.util.rsa.RSAUtil;
+import com.platform.constants.LoginConstant;
+import com.platform.entity.ThirtApplication;
 import com.platform.resultTool.PlatformCode;
 import com.platform.resultTool.PlatformResult;
+
+import javax.servlet.http.HttpServletRequest;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 
 /**骞冲彴鏍¢獙鏂规硶
  * @author CJH
@@ -13,47 +19,84 @@
 public class VerificationTool {
 
     /**鏍¢獙鏂规硶璇锋眰
-     * @param appId 鐢ㄦ埛鐨凙PPID
+     * @param appId 鐢ㄦ埛鐨凙PPID `
      * @param sign 鐢ㄦ埛绛惧悕
-     * @param sys_appId 绯荤粺鐨刟ppid
-     * @param sys_private_key 绯荤粺鐨凴SA绉橀挜
+     * @param thirtApplication ThirtApplication
      * @return
      */
-    public static PlatformResult verification(String appId,String sign,String sys_appId,String sys_private_key){
+    public static PlatformResult verification(String appId, String sign, ThirtApplication thirtApplication,HttpServletRequest request){
 
         if (StringUtils.isEmpty(sign)) {
-            return PlatformResult.failure(PlatformCode.ERROR_SIGN, "绛惧悕閿欒");
+            return PlatformResult.failure(PlatformCode.ERROR_SIGN, "绛惧悕閿欒01");
         }
         if (StringUtils.isEmpty(appId)) {
             return PlatformResult.failure(PlatformCode.ERROR_APPIS, "APPID閿欒");
         }
 
         //鏍¢獙appid鏄惁瀛樺湪
-        if(!sys_appId.equals("appId")){
-            return PlatformResult.failure(PlatformCode.ERROR_APPIS, "APPID閿欒");
+        if(thirtApplication == null){
+            return PlatformResult.failure(PlatformCode.ERROR_APPIS, "APPID鏃犳晥");
+        }
+
+        if(StringUtils.isEmpty(thirtApplication.getPrivateKey())){
+            return PlatformResult.failure(PlatformCode.ERROR_SIGN, "绛惧悕閿欒,APPID鏃犳晥");
         }
 
         //瑙e瘑RSA
         String decrypt = null;
         try{
-            decrypt = RSAUtil.privateDecrypt(sign, sys_private_key);
+            decrypt = RSAUtil.privateDecrypt(sign, thirtApplication.getPrivateKey());
         }catch (Exception e){
 
         }
         if(StringUtils.isEmpty(decrypt)){
-            return PlatformResult.failure(PlatformCode.ERROR_SIGN, "绛惧悕閿欒");
+            return PlatformResult.failure(PlatformCode.ERROR_SIGN, "绛惧悕閿欒02");
         }
 
         //decrypt鏍煎紡锛歛ppId_鏃堕棿鎴砡闅忔満鏁帮紙灏介噺灏戯級
         String[] decrypts = decrypt.split("_");
         if(decrypts.length != 3){
-            return PlatformResult.failure(PlatformCode.ERROR_SIGN, "绛惧悕閿欒");
+            return PlatformResult.failure(PlatformCode.ERROR_SIGN, "绛惧悕閿欒03");
         }
 
         if (!appId.equals(decrypts[0])) {
-            return PlatformResult.failure(PlatformCode.ERROR_SIGN, "绛惧悕閿欒");
+            return PlatformResult.failure(PlatformCode.ERROR_SIGN, "绛惧悕閿欒04");
         }
+
+        Date date  = null;
+        try{
+            //鍒ゆ柇鎺ュ彛鏃堕棿
+            SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            String sd = sdf.format(new Date(Long.parseLong(String.valueOf(decrypts[1]))));      // 鏃堕棿鎴宠浆鎹㈡垚鏃堕棿
+            date = DateUtil.parseString(sd,"yyyy-MM-dd HH:mm:ss");
+        }catch (Exception e){
+            return PlatformResult.failure(PlatformCode.ERROR_SIGN, "绛惧悕閿欒05");
+        }
+
+        //鎺ュ彛鏈夋晥5绉掗挓
+       /* if(System.currentTimeMillis()-date.getTime() > 10000){
+            return PlatformResult.failure(PlatformCode.ERRO_VISIT_OVERTIMR, "璁块棶瓒呮椂");
+        }*/
+
+        thirtApplication.setPrivateKey(null);
+        request.getSession().setAttribute(LoginConstant.LOGIN_APPLY,thirtApplication);
+
         return PlatformResult.success();
     }
 
+    public static void main(String[] args) {
+
+        Long timeStamp = System.currentTimeMillis();  //鑾峰彇褰撳墠鏃堕棿鎴�
+        SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String sd = sdf.format(new Date(Long.parseLong(String.valueOf(timeStamp))));
+
+        Date date = DateUtil.parseString(sd,"yyyy-MM-dd HH:mm:ss");
+
+        System.out.println();
+
+        // 鏃堕棿鎴宠浆鎹㈡垚鏃堕棿
+        System.out.println("鏍煎紡鍖栫粨鏋滐細" + sd);
+
+    }
+
 }

--
Gitblit v1.8.0