.gitignore | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/system/controller/LicenseCreatorController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/system/entity/license/LicenseCheckListener.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/system/entity/license/LicenseVerify.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/license.lic | 补丁 | 查看 | 原始文档 | blame | 历史 |
.gitignore
@@ -3,6 +3,7 @@ !.mvn/wrapper/maven-wrapper.jar !**/src/main/** !**/src/test/** /src/main/resources/license.lic ### STS ### .apt_generated src/main/java/com/zy/system/controller/LicenseCreatorController.java
@@ -87,8 +87,11 @@ @RequestMapping(value = "/updateLicense") public R updateLicense(@RequestParam("file") MultipartFile[] files){ MultipartFile file = files[0]; String licensePathFileName = this.getClass().getClassLoader().getResource(licensePath).getPath(); File licensePathFile = new File(licensePathFileName); //服务器端保存的文件对象 File serverFile = new File(licensePath); File serverFile = new File(licensePathFile.getPath()); if (serverFile.exists()) { try { serverFile.delete();//存在文件,删除 src/main/java/com/zy/system/entity/license/LicenseCheckListener.java
@@ -63,26 +63,30 @@ if(!Cools.isEmpty(licensePath)){ logger.info("++++++++ 开始加载许可证 ++++++++"); String publicKeysStoreFileName = this.getClass().getClassLoader().getResource(publicKeysStorePath).getPath(); File publicKeysStoreFile = new File(publicKeysStoreFileName); 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 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()); LicenseVerifyParam param = new LicenseVerifyParam(); param.setSubject(subject); param.setPublicAlias(publicAlias); param.setStorePass(storePass); param.setLicensePath(licensePathFile.getPath()); param.setPublicKeysStorePath(publicKeysStoreFile.getPath()); LicenseVerify licenseVerify = new LicenseVerify(); //安装证书 LicenseContent install = licenseVerify.install(param); LicenseVerify licenseVerify = new LicenseVerify(); //安装证书 LicenseContent install = licenseVerify.install(param); logger.info("++++++++ 许可证加载结束 ++++++++"); logger.info("++++++++ 许可证加载结束 ++++++++"); return install != null; return install != null; } catch (Exception e) { return false; } } return false; src/main/java/com/zy/system/entity/license/LicenseVerify.java
@@ -41,19 +41,16 @@ * 校验License证书 */ public boolean verify(){ LicenseManager licenseManager = LicenseManagerHolder.getInstance(null); DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); if (!updateSystemTime()) { //时间更新失败,系统时间被更改 return false; } //2. 校验证书 try { LicenseContent licenseContent = licenseManager.verify(); // System.out.println(licenseContent.getSubject()); LicenseManager licenseManager = LicenseManagerHolder.getInstance(null); DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); if (!updateSystemTime()) { //时间更新失败,系统时间被更改 return false; } LicenseContent licenseContent = licenseManager.verify(); logger.info(MessageFormat.format("许可证校验通过,许可证有效期:{0} - {1}",format.format(licenseContent.getNotBefore()),format.format(licenseContent.getNotAfter()))); return true; }catch (Exception e){ src/main/resources/license.licBinary files differ