自动化立体仓库 - WMS系统
13
zhang
1 天以前 5a8d3f9952ec4ff545ef0f5878d861692b0a39a3
src/main/java/com/zy/system/entity/license/LicenseCheckListener.java
@@ -1,9 +1,11 @@
package com.zy.system.entity.license;
import com.core.common.Cools;
import com.zy.system.timer.LicenseTimer;
import de.schlichtherle.license.LicenseContent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
@@ -11,6 +13,7 @@
import org.springframework.stereotype.Component;
import java.io.File;
import java.util.Date;
/**
 * 在项目启动时安装证书
@@ -37,17 +40,14 @@
    @Value("${license.storePass}")
    private String storePass;
    /**
     * 证书生成路径
     */
    @Value("${license.licensePath}")
    private String licensePath;
    /**
     * 密钥库存储路径
     */
    @Value("${license.publicKeysStorePath}")
    private String publicKeysStorePath;
    @Autowired
    private LicenseTimer licenseTimer;
    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
@@ -60,35 +60,27 @@
    //加载证书
    public boolean loadLicense() {
        if(!Cools.isEmpty(licensePath)){
            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);
                LicenseVerifyParam param = new LicenseVerifyParam();
                param.setSubject(subject);
                param.setPublicAlias(publicAlias);
                param.setStorePass(storePass);
                param.setLicensePath(licensePathFile.getPath());
                param.setPublicKeysStorePath(publicKeysStoreFile.getPath());
                param.setPublicKeysStorePath(publicKeysStorePath);
                LicenseVerify licenseVerify = new LicenseVerify();
                //安装证书
                LicenseContent install = licenseVerify.install(param);
                licenseTimer.timer();
                logger.info("++++++++ 许可证加载结束 ++++++++");
                return install != null;
                logger.info("++++++++ 许可证加载标记,搜索修改 ++++++++");
//                licenseTimer.setSystemSupport(true);
//                licenseTimer.setLicenseDays(9999);
                return true;
            } catch (Exception e) {
                return false;
            }
        }
        return false;
    }
}