From 9022b337f1342601adbc4a3eaed8f543c2b000a1 Mon Sep 17 00:00:00 2001 From: caiyuchao Date: Tue, 15 Apr 2025 16:05:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20privateKey=E5=8F=96resource=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- license/keystore/privateKeys.keystore | Bin 1285 -> 0 bytes .../controller/LicenseCreatorController.java | 7 ++++--- .../license/license/CustomKeyStoreParam.java | 7 +++++-- src/main/resources/application.properties | 1 - 4 files changed, 9 insertions(+), 6 deletions(-) delete mode 100644 license/keystore/privateKeys.keystore diff --git a/license/keystore/privateKeys.keystore b/license/keystore/privateKeys.keystore deleted file mode 100644 index 295a84d0281b92d3872c321591c2321df148cded..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1285 zcmezO_TO6u1_mY|W&~rdf}+f_#FEtP)JmYxG!wIlw}EuOK@(%Q0UsNeHX9=gqZX4O zBO@yVOA}+cTKe`HyH=l=DeD4nE6isKGYD(F6>hgONAPTfOrU`m|JH|k>)B>Y2i$G{ zQ~1Arg~Uarq>WoOj%vUgXYoXP@Xa9VEdjIOQbga7;KS7$a(Sq|*{e2s= zIVVq~RaG5Qj9PEX-Qw2Zo1n3>{3&n4rHq&h548UaPyBt*X1nrV`_S1PTb}%CE?z4r zW}tbb+ectW$0x={USp9vehZuK&0lt!sb=!w#2@<>eOtEgl;X9EOd{bW%l6LHnU@(C z74+c2PW`a5Hs)0t2k(EkTY7g>?3?Ev7sO^xpJd^4;=WPsZFYUbn9KJqi)xz{RX2ES zjQ84l%SA^#w&ZJKtxTR#M2nr^>vMK*=SElTT$pK8)XNoBr=7!|f2+syq0LfuljG7` zdK9u1#ZKl$Hm4tUyl)*L`hJGB%(BbgqITT2fsta|e)H8co`R!_HA2tSz>2$C>CpmaCPpSE7M=F5&IY_}oC$3njH%2l%uK8d2FZrp2Apinp)72|OwN8V4u>#P zum_C84(13M2!NDv33KM;Cnx4)a7Z9gXc!#e!=u@%ci`B{E9f4h8C?l6;Sh;WqHM5Aw|pVw(8Ue|j6 zNr_oKz?hg?%UqMd${%}F-wb{1!PVZSAW40rF zXXTXjyMI}|YWf-O!)?pnlpYuv-nZ*Yr2n%*c7eu*EuLb9$}fC0#Duq>=QQd$vFxFZ zSXFmOO|Qm-#p~p>H!mxln76o|`ErxtT#3j_`dnU3YEieUcGW}f4X>O z@a^4RpJ!^W+jDMz$HV2OxopoOBRZqs`kbteXJ<0qRpFv{Z-2UVY}`YBc8S(JkL|Xv zCY`I@wI_(Zr0>$lN_(!lt^->?w3ht{I;rgD&vv-r$)z{Ehr+`bUl6lOwNAWgI$w6h zVnqXa16g3|ljUO(V-b0gZP=+^dGh|JPgkzkg_yosdzkM4TC!#~U@*`H25g(tnSJZL z@BBPAi6`Q_0`t=+k-bluL^38`f700h#^JY%N34GYtCf>b9VwRa)_gMs#G diff --git a/src/main/java/org/wfc/common/license/controller/LicenseCreatorController.java b/src/main/java/org/wfc/common/license/controller/LicenseCreatorController.java index 5fd3375..c6a2085 100644 --- a/src/main/java/org/wfc/common/license/controller/LicenseCreatorController.java +++ b/src/main/java/org/wfc/common/license/controller/LicenseCreatorController.java @@ -34,8 +34,8 @@ public class LicenseCreatorController { @Value("${license.licensePath}") private String licensePath; - @Value("${license.privateKeysPath}") - private String privateKeysPath; +// @Value("${license.privateKeysPath}") +// private String privateKeysPath; /** * 获取服务器硬件信息 @@ -113,7 +113,8 @@ public class LicenseCreatorController { } // 相对路径resources资源目录 // String resourcePath = getClass().getClassLoader().getResource("").getPath(); - param.setPrivateKeysStorePath(privateKeysPath); +// param.setPrivateKeysStorePath(privateKeysPath); + param.setPrivateKeysStorePath("privateKeys.keystore"); // param.setPrivateKeysStorePath("D:\\projects\\testdir\\spring-boot2-license\\cloud-license-serve\\target\\classes\\privateCerts.keystore"); param.setIssuedTime(new Date()); param.setExpiryTime(genParam.getExpiryTime()); diff --git a/src/main/java/org/wfc/common/license/license/CustomKeyStoreParam.java b/src/main/java/org/wfc/common/license/license/CustomKeyStoreParam.java index a28faf4..7abf962 100644 --- a/src/main/java/org/wfc/common/license/license/CustomKeyStoreParam.java +++ b/src/main/java/org/wfc/common/license/license/CustomKeyStoreParam.java @@ -2,7 +2,9 @@ package org.wfc.common.license.license; import de.schlichtherle.license.AbstractKeyStoreParam; -import java.io.*; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; /** * 自定义KeyStoreParam,用于将公私钥存储文件存放到其他磁盘位置而不是项目中 @@ -50,7 +52,8 @@ public class CustomKeyStoreParam extends AbstractKeyStoreParam { */ @Override public InputStream getStream() throws IOException { - final InputStream in = new FileInputStream(new File(storePath)); +// final InputStream in = new FileInputStream(new File(storePath)); + InputStream in = this.getClass().getClassLoader().getResourceAsStream(storePath); if (null == in) { throw new FileNotFoundException(storePath); } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 74b5348..64f8cae 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -6,6 +6,5 @@ server.shutdown=graceful spring.lifecycle.timeout-per-shutdown-phase=10s #License������� -license.privateKeysPath=/opt/license/keystore/privateKeys.keystore license.licensePath=/opt/license/license.lic