package cn.melina.license; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.Properties; import java.util.prefs.Preferences; import de.schlichtherle.license.CipherParam; import de.schlichtherle.license.DefaultCipherParam; import de.schlichtherle.license.DefaultKeyStoreParam; import de.schlichtherle.license.DefaultLicenseParam; import de.schlichtherle.license.KeyStoreParam; import de.schlichtherle.license.LicenseParam; import de.schlichtherle.license.LicenseManager; /** * VerifyLicense * @author melina */ public class VerifyLicense { //common param private static String PUBLICALIAS = ""; private static String STOREPWD = ""; private static String SUBJECT = ""; private static String licPath = ""; private static String pubPath = ""; public void setParam(String propertiesPath) { // 获取参数 Properties prop = new Properties(); InputStream in = getClass().getResourceAsStream(propertiesPath); try { prop.load(in); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } PUBLICALIAS = prop.getProperty("PUBLICALIAS"); STOREPWD = prop.getProperty("STOREPWD"); SUBJECT = prop.getProperty("SUBJECT"); licPath = prop.getProperty("licPath"); pubPath = prop.getProperty("pubPath"); } public boolean verify() { /************** 证书使用者端执行 ******************/ LicenseManager licenseManager = LicenseManagerHolder .getLicenseManager(initLicenseParams()); // 安装证书 try { licenseManager.install(new File(licPath)); System.out.println("客户端安装证书成功!"); } catch (Exception e) { e.printStackTrace(); System.out.println("客户端证书安装失败!"); return false; } // 验证证书 try { licenseManager.verify(); System.out.println("客户端验证证书成功!"); } catch (Exception e) { e.printStackTrace(); System.out.println("客户端证书验证失效!"); return false; } return true; } // 返回验证证书需要的参数 private static LicenseParam initLicenseParams() { Preferences preference = Preferences .userNodeForPackage(VerifyLicense.class); CipherParam cipherParam = new DefaultCipherParam(STOREPWD); KeyStoreParam privateStoreParam = new DefaultKeyStoreParam( VerifyLicense.class, pubPath, PUBLICALIAS, STOREPWD, null); LicenseParam licenseParams = new DefaultLicenseParam(SUBJECT, preference, privateStoreParam, cipherParam); return licenseParams; } }

微信网友_6174112425660416 LV1
2022年10月15日
yufadashen LV3
2020年11月16日
huweinan03 LV1
2020年10月20日
ycr202008 LV1
2020年5月24日
123456781qaz LV2
2019年12月24日
Lee240603372 LV1
2019年10月25日
rongxinhui LV8
2019年8月31日
zzyyyyyy LV1
2019年7月8日
alang94 LV5
2019年5月22日
ftlgood LV1
2019年1月18日

kenhomeliu LV29
2024年4月30日
80730176 LV7
2023年3月9日
青梅论酒 LV9
2023年2月14日
微信网友_6174112425660416 LV1
2022年10月13日
wwwbl123 LV2
2022年3月18日
陈箫goddess LV16
2021年12月28日
maixiaomai LV6
2021年3月26日
bfh365
2021年3月18日
暂无贡献等级
张洪燕
2021年3月17日
暂无贡献等级
xhmpmail LV17
2021年2月24日