|
@@ -7,6 +7,7 @@ import com.doc.common.utils.encrypt.Sm2Util;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.boot.system.ApplicationHome;
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
import org.springframework.context.ApplicationListener;
|
|
|
import org.springframework.context.ConfigurableApplicationContext;
|
|
@@ -21,7 +22,6 @@ import org.springframework.stereotype.Component;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.File;
|
|
|
import java.io.FileWriter;
|
|
|
-import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
* 授权许可验证监听器
|
|
@@ -46,6 +46,11 @@ public class DataListener implements ApplicationListener<ContextRefreshedEvent>
|
|
|
*/
|
|
|
@Value("${license.licensePath}")
|
|
|
private String licensePath;
|
|
|
+ /**
|
|
|
+ * 公钥存放路径
|
|
|
+ */
|
|
|
+ @Value("${license.keyStore}")
|
|
|
+ private String keyStore;
|
|
|
|
|
|
public DataListener() {
|
|
|
}
|
|
@@ -58,16 +63,12 @@ public class DataListener implements ApplicationListener<ContextRefreshedEvent>
|
|
|
try {
|
|
|
logger.info("++++++++ 开始安装证书 ++++++++");
|
|
|
|
|
|
- //公钥存放位置
|
|
|
- File file = new File(Objects.requireNonNull(this.getClass().getResource("/")).getPath());
|
|
|
- String publicKeysStorePath = file.getAbsolutePath() + File.separator + "license/publicKeys.keystore";
|
|
|
-
|
|
|
DataPara param = new DataPara();
|
|
|
param.setSubject(subject);
|
|
|
param.setLicensePath(licensePath);
|
|
|
param.setPublicAlias("publicKey");
|
|
|
param.setStorePass("jjt@2023");
|
|
|
- param.setPublicKeysStorePath(publicKeysStorePath);
|
|
|
+ param.setPublicKeysStorePath(keyStore);
|
|
|
|
|
|
DataVerify dataVerify = new DataVerify();
|
|
|
//安装证书
|
|
@@ -107,9 +108,9 @@ public class DataListener implements ApplicationListener<ContextRefreshedEvent>
|
|
|
} else {//其他服务器类型
|
|
|
infos = new LinuxInfos();
|
|
|
}
|
|
|
- File file = new File(Objects.requireNonNull(this.getClass().getResource("/")).getPath());
|
|
|
- String path = file.getParentFile().getParentFile().getParentFile().getAbsolutePath();
|
|
|
- path = path + File.separator + "register_code.txt";
|
|
|
+
|
|
|
+ ApplicationHome home = new ApplicationHome(getClass());
|
|
|
+ String path = home.getSource().getParent() + File.separator + "register_code.txt";
|
|
|
File codeFile = new File(path);
|
|
|
try (FileWriter fw = new FileWriter(codeFile)) {
|
|
|
//json对象转字符串
|