From c635d78b479510ebe2556a420948effcd30a0731 Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期六, 21 十二月 2024 18:40:43 +0800
Subject: [PATCH] 新建德森项目分支

---
 zy-asrs-wms/src/main/java/com/zy/asrs/wms/system/license/entity/license/LicenseVerify.java |  280 ++++++++++++++++++++++++++++----------------------------
 1 files changed, 140 insertions(+), 140 deletions(-)

diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/system/license/entity/license/LicenseVerify.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/system/license/entity/license/LicenseVerify.java
index 08dd64b..bd30124 100644
--- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/system/license/entity/license/LicenseVerify.java
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/system/license/entity/license/LicenseVerify.java
@@ -1,141 +1,141 @@
-package com.zy.asrs.wms.system.license.entity.license;
-
-import de.schlichtherle.license.*;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.poi.util.IOUtils;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.text.DateFormat;
-import java.text.MessageFormat;
-import java.text.SimpleDateFormat;
-import java.util.prefs.Preferences;
-
-/**
- * License鏍¢獙绫�
- */
-public class LicenseVerify {
-    private static Logger logger = LogManager.getLogger(LicenseVerify.class);
-
-    /**
-     * 瀹夎License璇佷功
-     */
-    public synchronized LicenseContent install(LicenseVerifyParam param){
-        LicenseContent result = null;
-        DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-
-        //1. 瀹夎璇佷功
-        try{
-            LicenseManager licenseManager = LicenseManagerHolder.getInstance(initLicenseParam(param));
-            licenseManager.uninstall();
-
-            InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(param.getLicensePath());
-            File file = new File(param.getLicensePath());
-            try (FileOutputStream out = new FileOutputStream(file)) {
-                IOUtils.copy(inputStream, out);
-            }
-            result = licenseManager.install(file);
-            logger.info(MessageFormat.format("璁稿彲璇佸姞杞芥垚鍔燂紝璁稿彲璇佹湁鏁堟湡锛歿0} - {1}",format.format(result.getNotBefore()),format.format(result.getNotAfter())));
-        }catch (Exception e){
-            logger.error("璁稿彲璇佸姞杞藉け璐ワ紒",e);
-        }
-
-        return result;
-    }
-
-    /**
-     * 鏍¢獙License璇佷功
-     */
-    public boolean verify(){
-        try {
-            LicenseManager licenseManager = LicenseManagerHolder.getInstance(null);
-            DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-
-            if (!updateSystemTime()) {
-                //鏃堕棿鏇存柊澶辫触锛岀郴缁熸椂闂磋鏇存敼
-                return false;
-            }
-
-            LicenseContent licenseContent = licenseManager.verify();
-            logger.info(MessageFormat.format("璁稿彲璇佹牎楠岄�氳繃锛岃鍙瘉鏈夋晥鏈燂細{0} - {1}",format.format(licenseContent.getNotBefore()),format.format(licenseContent.getNotAfter())));
-            return true;
-        }catch (Exception e){
-            logger.error("璁稿彲璇佹牎楠屽け璐ワ紒",e);
-            return false;
-        }
-    }
-
-    /**
-     * 鏍¢獙License璇佷功骞惰幏鍙栬瘉涔︿俊鎭�
-     */
-    public LicenseContent getVerifyInfo(){
-        LicenseManager licenseManager = LicenseManagerHolder.getInstance(null);
-
-        if (!updateSystemTime()) {
-            //鏃堕棿鏇存柊澶辫触锛岀郴缁熸椂闂磋鏇存敼
-            return null;
-        }
-
-        //鏍¢獙璇佷功
-        try {
-            LicenseContent licenseContent = licenseManager.verify();
-            return licenseContent;
-        }catch (Exception e){
-            logger.error("璁稿彲璇佹牎楠屽け璐ワ紒",e);
-            return null;
-        }
-    }
-
-    /**
-     * 鍒濆鍖栬瘉涔︾敓鎴愬弬鏁�
-     * @param param License鏍¢獙绫婚渶瑕佺殑鍙傛暟
-     * @return de.schlichtherle.license.LicenseParam
-     */
-    private LicenseParam initLicenseParam(LicenseVerifyParam param){
-        Preferences preferences = Preferences.userNodeForPackage(LicenseVerify.class);
-
-        CipherParam cipherParam = new DefaultCipherParam(param.getStorePass());
-
-        KeyStoreParam publicStoreParam = new CustomKeyStoreParam(LicenseVerify.class
-                ,param.getPublicKeysStorePath()
-                ,param.getPublicAlias()
-                ,param.getStorePass()
-                ,null);
-
-        return new DefaultLicenseParam(param.getSubject()
-                ,preferences
-                ,publicStoreParam
-                ,cipherParam);
-    }
-
-    /**
-     * 鏇存柊鏃堕棿鍒版敞鍐岃〃涓�
-     */
-    private boolean updateSystemTime() {
-        // 鑾峰彇鐢ㄦ埛鏍硅妭鐐�
-        Preferences userRoot = Preferences.userRoot();
-        // 鑾峰彇鎸囧畾璺緞涓嬬殑鑺傜偣
-        Preferences node = userRoot.node("/zhongyang");
-        String key = "time";
-        // 璇诲彇娉ㄥ唽琛�
-        String value = node.get(key, null);
-        if (value != null) {
-            long originTime = Long.parseLong(value);
-            long now = System.currentTimeMillis();
-            long diff = now - originTime;//鐜板湪鏃堕棿 - 婧愭椂闂� = 鏃堕棿宸�
-            if (diff > 0) {
-                //鏃堕棿宸ぇ浜�0鎵嶅厑璁告洿鏂版敞鍐岃〃鏃堕棿
-                node.put(key, String.valueOf(System.currentTimeMillis()));
-                return true;
-            }
-        }else {
-            // 鍐欏叆娉ㄥ唽琛�
-            node.put(key, String.valueOf(System.currentTimeMillis()));
-            return true;
-        }
-        return false;
-    }
-
+package com.zy.asrs.wms.system.license.entity.license;
+
+import de.schlichtherle.license.*;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.poi.util.IOUtils;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.text.DateFormat;
+import java.text.MessageFormat;
+import java.text.SimpleDateFormat;
+import java.util.prefs.Preferences;
+
+/**
+ * License鏍¢獙绫�
+ */
+public class LicenseVerify {
+    private static Logger logger = LogManager.getLogger(LicenseVerify.class);
+
+    /**
+     * 瀹夎License璇佷功
+     */
+    public synchronized LicenseContent install(LicenseVerifyParam param){
+        LicenseContent result = null;
+        DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+        //1. 瀹夎璇佷功
+        try{
+            LicenseManager licenseManager = LicenseManagerHolder.getInstance(initLicenseParam(param));
+            licenseManager.uninstall();
+
+            InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(param.getLicensePath());
+            File file = new File(param.getLicensePath());
+            try (FileOutputStream out = new FileOutputStream(file)) {
+                IOUtils.copy(inputStream, out);
+            }
+            result = licenseManager.install(file);
+            logger.info(MessageFormat.format("璁稿彲璇佸姞杞芥垚鍔燂紝璁稿彲璇佹湁鏁堟湡锛歿0} - {1}",format.format(result.getNotBefore()),format.format(result.getNotAfter())));
+        }catch (Exception e){
+            logger.error("璁稿彲璇佸姞杞藉け璐ワ紒",e);
+        }
+
+        return result;
+    }
+
+    /**
+     * 鏍¢獙License璇佷功
+     */
+    public boolean verify(){
+        try {
+            LicenseManager licenseManager = LicenseManagerHolder.getInstance(null);
+            DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+            if (!updateSystemTime()) {
+                //鏃堕棿鏇存柊澶辫触锛岀郴缁熸椂闂磋鏇存敼
+                return false;
+            }
+
+            LicenseContent licenseContent = licenseManager.verify();
+            logger.info(MessageFormat.format("璁稿彲璇佹牎楠岄�氳繃锛岃鍙瘉鏈夋晥鏈燂細{0} - {1}",format.format(licenseContent.getNotBefore()),format.format(licenseContent.getNotAfter())));
+            return true;
+        }catch (Exception e){
+            logger.error("璁稿彲璇佹牎楠屽け璐ワ紒",e);
+            return false;
+        }
+    }
+
+    /**
+     * 鏍¢獙License璇佷功骞惰幏鍙栬瘉涔︿俊鎭�
+     */
+    public LicenseContent getVerifyInfo(){
+        LicenseManager licenseManager = LicenseManagerHolder.getInstance(null);
+
+        if (!updateSystemTime()) {
+            //鏃堕棿鏇存柊澶辫触锛岀郴缁熸椂闂磋鏇存敼
+            return null;
+        }
+
+        //鏍¢獙璇佷功
+        try {
+            LicenseContent licenseContent = licenseManager.verify();
+            return licenseContent;
+        }catch (Exception e){
+            logger.error("璁稿彲璇佹牎楠屽け璐ワ紒",e);
+            return null;
+        }
+    }
+
+    /**
+     * 鍒濆鍖栬瘉涔︾敓鎴愬弬鏁�
+     * @param param License鏍¢獙绫婚渶瑕佺殑鍙傛暟
+     * @return de.schlichtherle.license.LicenseParam
+     */
+    private LicenseParam initLicenseParam(LicenseVerifyParam param){
+        Preferences preferences = Preferences.userNodeForPackage(LicenseVerify.class);
+
+        CipherParam cipherParam = new DefaultCipherParam(param.getStorePass());
+
+        KeyStoreParam publicStoreParam = new CustomKeyStoreParam(LicenseVerify.class
+                ,param.getPublicKeysStorePath()
+                ,param.getPublicAlias()
+                ,param.getStorePass()
+                ,null);
+
+        return new DefaultLicenseParam(param.getSubject()
+                ,preferences
+                ,publicStoreParam
+                ,cipherParam);
+    }
+
+    /**
+     * 鏇存柊鏃堕棿鍒版敞鍐岃〃涓�
+     */
+    private boolean updateSystemTime() {
+        // 鑾峰彇鐢ㄦ埛鏍硅妭鐐�
+        Preferences userRoot = Preferences.userRoot();
+        // 鑾峰彇鎸囧畾璺緞涓嬬殑鑺傜偣
+        Preferences node = userRoot.node("/zhongyang");
+        String key = "time";
+        // 璇诲彇娉ㄥ唽琛�
+        String value = node.get(key, null);
+        if (value != null) {
+            long originTime = Long.parseLong(value);
+            long now = System.currentTimeMillis();
+            long diff = now - originTime;//鐜板湪鏃堕棿 - 婧愭椂闂� = 鏃堕棿宸�
+            if (diff > 0) {
+                //鏃堕棿宸ぇ浜�0鎵嶅厑璁告洿鏂版敞鍐岃〃鏃堕棿
+                node.put(key, String.valueOf(System.currentTimeMillis()));
+                return true;
+            }
+        }else {
+            // 鍐欏叆娉ㄥ唽琛�
+            node.put(key, String.valueOf(System.currentTimeMillis()));
+            return true;
+        }
+        return false;
+    }
+
 }
\ No newline at end of file

--
Gitblit v1.9.1