自动化立体仓库 - WMS系统
#
whycq
2024-05-31 af4d44146a102f8f8f95f5db39e65986f6b096b5
src/main/java/com/zy/system/entity/license/LicenseCheckListener.java
@@ -10,6 +10,8 @@
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;
import java.io.File;
/**
 * 在项目启动时安装证书
 */
@@ -52,7 +54,7 @@
        //root application context 没有parent
        ApplicationContext context = event.getApplicationContext().getParent();
        if(context == null){
            loadLicense();
            //loadLicense();
        }
    }
@@ -61,20 +63,30 @@
        if(!Cools.isEmpty(licensePath)){
            logger.info("++++++++ 开始加载许可证 ++++++++");
            LicenseVerifyParam param = new LicenseVerifyParam();
            param.setSubject(subject);
            param.setPublicAlias(publicAlias);
            param.setStorePass(storePass);
            param.setLicensePath(licensePath);
            param.setPublicKeysStorePath(publicKeysStorePath);
            try {
                String publicKeysStoreFileName = this.getClass().getClassLoader().getResource(publicKeysStorePath).getPath();
                File publicKeysStoreFile = new File(publicKeysStoreFileName);
            LicenseVerify licenseVerify = new LicenseVerify();
            //安装证书
            LicenseContent install = licenseVerify.install(param);
                String licensePathFileName = this.getClass().getClassLoader().getResource(licensePath).getPath();
                File licensePathFile = new File(licensePathFileName);
            logger.info("++++++++ 许可证加载结束 ++++++++");
                LicenseVerifyParam param = new LicenseVerifyParam();
                param.setSubject(subject);
                param.setPublicAlias(publicAlias);
                param.setStorePass(storePass);
                param.setLicensePath(licensePathFile.getPath());
                param.setPublicKeysStorePath(publicKeysStoreFile.getPath());
            return install != null;
                LicenseVerify licenseVerify = new LicenseVerify();
                //安装证书
                LicenseContent install = licenseVerify.install(param);
                logger.info("++++++++ 许可证加载结束 ++++++++");
                return install != null;
            } catch (Exception e) {
                return false;
            }
        }
        return false;