| | |
| | | @Component |
| | | public class LicenseTimer { |
| | | |
| | | private static boolean SYSTEM_SUPPORT = false;//系统激活状态,默认关闭 |
| | | private static boolean SYSTEM_SUPPORT = false;// 系统激活状态,默认关闭 |
| | | |
| | | private static int LICENSE_DAYS = 0;//许可证天数 |
| | | private static int LICENSE_DAYS = 0;// 许可证天数 |
| | | |
| | | /** |
| | | * 证书subject |
| | |
| | | @Autowired |
| | | private LicenseInfosService licenseInfosService; |
| | | |
| | | //每天晚上11点更新系统激活状态 |
| | | // 每天晚上11点更新系统激活状态 |
| | | @Scheduled(cron = "0 0 23 * * ? ") |
| | | public void timer() { |
| | | try { |
| | |
| | | try { |
| | | AbstractServerInfos abstractServerInfos = null; |
| | | String osName = System.getProperty("os.name"); |
| | | //根据不同操作系统类型选择不同的数据获取方法 |
| | | // 根据不同操作系统类型选择不同的数据获取方法 |
| | | if (osName.startsWith("windows")) { |
| | | abstractServerInfos = new WindowsServerInfos(); |
| | | } else if (osName.startsWith("linux")) { |
| | | abstractServerInfos = new LinuxServerInfos(); |
| | | }else{//其他服务器类型 |
| | | } else {// 其他服务器类型 |
| | | abstractServerInfos = new WindowsServerInfos(); |
| | | } |
| | | LicenseCheck serverInfos = abstractServerInfos.getServerInfos(); |
| | |
| | | param.setLicensePath(licensePath); |
| | | param.setPublicKeysStorePath(publicKeysStorePath); |
| | | |
| | | //验证许可证是否有效 |
| | | // 验证许可证是否有效 |
| | | LicenseVerify licenseVerify = new LicenseVerify(); |
| | | //安装证书 |
| | | // 安装证书 |
| | | LicenseContent install = licenseVerify.install(param, latestLicense.getLicense()); |
| | | |
| | | if (install != null) { |
| | |
| | | Date end = install.getNotAfter(); |
| | | Long starTime = start.getTime(); |
| | | Long endTime = end.getTime(); |
| | | long num = endTime - starTime;//时间戳相差的毫秒数 |
| | | long num = endTime - starTime;// 时间戳相差的毫秒数 |
| | | int day = (int) (num / 24 / 60 / 60 / 1000); |
| | | setLicenseDays(day); |
| | | setSystemSupport(true); |
| | | }else { |
| | | } else { |
| | | setLicenseDays(0); |
| | | setSystemSupport(false); |
| | | } |