From 1b230d7961b2d5068298f0cba13287cabd2fd649 Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期三, 17 七月 2024 18:47:35 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/system/entity/license/LicenseCheckListener.java |   15 ++++++++-------
 src/main/java/com/zy/system/entity/license/CustomKeyStoreParam.java  |    4 +++-
 src/main/java/com/zy/system/entity/license/LicenseVerify.java        |   10 +++++++++-
 3 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/src/main/java/com/zy/system/entity/license/CustomKeyStoreParam.java b/src/main/java/com/zy/system/entity/license/CustomKeyStoreParam.java
index 3d4e4b9..74d3e41 100644
--- a/src/main/java/com/zy/system/entity/license/CustomKeyStoreParam.java
+++ b/src/main/java/com/zy/system/entity/license/CustomKeyStoreParam.java
@@ -1,6 +1,7 @@
 package com.zy.system.entity.license;
 
 import de.schlichtherle.license.AbstractKeyStoreParam;
+import org.apache.poi.util.IOUtils;
 
 import java.io.*;
 
@@ -47,7 +48,8 @@
      */
     @Override
     public InputStream getStream() throws IOException {
-        final InputStream in = new FileInputStream(new File(storePath));
+        final InputStream in = this.getClass().getClassLoader().getResourceAsStream(storePath);
+//        final InputStream in = new FileInputStream(new File(storePath));
         if (null == in) {
             throw new FileNotFoundException(storePath);
         }
diff --git a/src/main/java/com/zy/system/entity/license/LicenseCheckListener.java b/src/main/java/com/zy/system/entity/license/LicenseCheckListener.java
index 1659df2..e268997 100644
--- a/src/main/java/com/zy/system/entity/license/LicenseCheckListener.java
+++ b/src/main/java/com/zy/system/entity/license/LicenseCheckListener.java
@@ -11,6 +11,7 @@
 import org.springframework.stereotype.Component;
 
 import java.io.File;
+import java.io.InputStream;
 
 /**
  * 鍦ㄩ」鐩惎鍔ㄦ椂瀹夎璇佷功
@@ -64,18 +65,18 @@
             logger.info("++++++++ 寮�濮嬪姞杞借鍙瘉 ++++++++");
 
             try {
-                String publicKeysStoreFileName = this.getClass().getClassLoader().getResource(publicKeysStorePath).getPath();
-                File publicKeysStoreFile = new File(publicKeysStoreFileName);
-
-                String licensePathFileName = this.getClass().getClassLoader().getResource(licensePath).getPath();
-                File licensePathFile = new File(licensePathFileName);
+//                String publicKeysStoreFileName = this.getClass().getClassLoader().getResource(publicKeysStorePath).getPath();
+//                File publicKeysStoreFile = new File(publicKeysStoreFileName);
+//
+//                String licensePathFileName = this.getClass().getClassLoader().getResource(licensePath).getPath();
+//                File licensePathFile = new File(licensePathFileName);
 
                 LicenseVerifyParam param = new LicenseVerifyParam();
                 param.setSubject(subject);
                 param.setPublicAlias(publicAlias);
                 param.setStorePass(storePass);
-                param.setLicensePath(licensePathFile.getPath());
-                param.setPublicKeysStorePath(publicKeysStoreFile.getPath());
+                param.setLicensePath(licensePath);
+                param.setPublicKeysStorePath(publicKeysStorePath);
 
                 LicenseVerify licenseVerify = new LicenseVerify();
                 //瀹夎璇佷功
diff --git a/src/main/java/com/zy/system/entity/license/LicenseVerify.java b/src/main/java/com/zy/system/entity/license/LicenseVerify.java
index 2175930..597648a 100644
--- a/src/main/java/com/zy/system/entity/license/LicenseVerify.java
+++ b/src/main/java/com/zy/system/entity/license/LicenseVerify.java
@@ -3,8 +3,11 @@
 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;
@@ -28,7 +31,12 @@
             LicenseManager licenseManager = LicenseManagerHolder.getInstance(initLicenseParam(param));
             licenseManager.uninstall();
 
-            result = licenseManager.install(new File(param.getLicensePath()));
+            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);

--
Gitblit v1.9.1