|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 校验License证书 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public boolean verify(){ | 
|---|
|  |  |  | public boolean verify() { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | LicenseManager licenseManager = LicenseManagerHolder.getInstance(null); | 
|---|
|  |  |  | DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LicenseContent licenseContent = licenseManager.verify(); | 
|---|
|  |  |  | logger.info(MessageFormat.format("许可证校验通过,许可证有效期:{0} - {1}",format.format(licenseContent.getNotBefore()),format.format(licenseContent.getNotAfter()))); | 
|---|
|  |  |  | logger.info(MessageFormat.format("许可证校验通过,许可证有效期:{0} - {1}", format.format(licenseContent.getNotBefore()), format.format(licenseContent.getNotAfter()))); | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | logger.error("许可证校验失败!",e); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | logger.error("许可证校验失败!", e); | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 校验License证书并获取证书信息 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public LicenseContent getVerifyInfo(){ | 
|---|
|  |  |  | public LicenseContent getVerifyInfo() { | 
|---|
|  |  |  | LicenseManager licenseManager = LicenseManagerHolder.getInstance(null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //校验证书 | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | LicenseContent licenseContent = licenseManager.verify(); | 
|---|
|  |  |  | return licenseContent; | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | logger.error("许可证校验失败!",e); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | logger.error("许可证校验失败!", e); | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 初始化证书生成参数 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param param License校验类需要的参数 | 
|---|
|  |  |  | * @return de.schlichtherle.license.LicenseParam | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private LicenseParam initLicenseParam(LicenseVerifyParam param){ | 
|---|
|  |  |  | private LicenseParam initLicenseParam(LicenseVerifyParam param) { | 
|---|
|  |  |  | Preferences preferences = Preferences.userNodeForPackage(LicenseVerify.class); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | CipherParam cipherParam = new DefaultCipherParam(param.getStorePass()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | KeyStoreParam publicStoreParam = new CustomKeyStoreParam(LicenseVerify.class | 
|---|
|  |  |  | ,param.getPublicKeysStorePath() | 
|---|
|  |  |  | ,param.getPublicAlias() | 
|---|
|  |  |  | ,param.getStorePass() | 
|---|
|  |  |  | ,null); | 
|---|
|  |  |  | , param.getPublicKeysStorePath() | 
|---|
|  |  |  | , param.getPublicAlias() | 
|---|
|  |  |  | , param.getStorePass() | 
|---|
|  |  |  | , null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new DefaultLicenseParam(param.getSubject() | 
|---|
|  |  |  | ,preferences | 
|---|
|  |  |  | ,publicStoreParam | 
|---|
|  |  |  | ,cipherParam); | 
|---|
|  |  |  | , preferences | 
|---|
|  |  |  | , publicStoreParam | 
|---|
|  |  |  | , cipherParam); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 将Base64字符串转换为临时文件 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param base64String Base64编码的字符串 | 
|---|
|  |  |  | * @param filePrefix 文件名前缀(例如 "license_") | 
|---|
|  |  |  | * @param fileSuffix 文件后缀(例如 ".lic") | 
|---|
|  |  |  | * @param filePrefix   文件名前缀(例如 "license_") | 
|---|
|  |  |  | * @param fileSuffix   文件后缀(例如 ".lic") | 
|---|
|  |  |  | * @return 生成的临时File对象(自动在JVM退出时删除) | 
|---|
|  |  |  | * @throws IOException | 
|---|
|  |  |  | */ | 
|---|