网站如何做才能被360收录,哈尔滨教育云平台网站建设,怎么用wordpress做搜索网站,数据库与网站建设1、生成前准备
在生成授权文件前#xff0c;首先需要密钥对插入#xff1a;密钥对分为公钥与私钥#xff0c;私钥需要本地储存不泄露#xff0c;公钥需要对外提供#xff1b;私钥内部包含证书#xff0c;对于授权文件进行数字签名#xff0c;相当于加密的步骤#xff0…1、生成前准备
在生成授权文件前首先需要密钥对插入密钥对分为公钥与私钥私钥需要本地储存不泄露公钥需要对外提供私钥内部包含证书对于授权文件进行数字签名相当于加密的步骤公钥则是在验证步骤时使用。生成密钥对的工具有很多鉴于开发过程中团队使用的都是JAVA使用了JDK自带的KeyTool作为生成工具。在JDK中1创建私钥
打开CMD在系统环境变量已配置java相关后可以使用。语句示例keytool -genkey -alias privatekey -keystore privateKeys.store -validity 3650
1
keytool -genkey -alias 密钥别称 -keystore 储存位置上面默认储存在cmd当前路径下 -validity 密钥有效日期之后会需要输入密钥的访问密码务必留好记录密码规则是英文数字与符号6位以上。输入并重复密码后会输入相关信息可以比较随意目前没有发现问题。2导出证书
keytool -export -alias privatekey -file certfile.cer -keystore privateKeys.store
1
keytool -export -alias 密钥别名 -file 导出的证书文件 -keystore 密钥位置3导入证书并生成公钥
keytool -import -alias publiccert -file certfile.cer -keystore publicCerts.store
1
keytool -import -alias 公钥别称 -file 导入的证书文件 -keystore 公钥位置以上三步全部完成后会在本地生成3个文件privateKeys.keystore私钥不能泄露。
publicCerts.keystore公钥配合license进行授权信息的校验。
certfile.cer证书已导入公钥无用。记录好公钥别称私钥别称公钥私钥密码等所输入的信息
LicenseVerify类实现方法
package com.meslog.system.run.license;import de.schlichtherle.license.CipherParam;
import de.schlichtherle.license.DefaultCipherParam;
import de.schlichtherle.license.DefaultLicenseParam;
import de.schlichtherle.license.KeyStoreParam;
import de.schlichtherle.license.LicenseContent;
import de.schlichtherle.license.LicenseManager;
import de.schlichtherle.license.LicenseParam;
import java.io.File;
import java.text.DateFormat;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.prefs.Preferences;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.meslog.commin.core.utils.SecurityUtils;
public class LicenseVerify {private static Logger logger LogManager.getLogger(LicenseVerify.class);public synchronized LicenseContent install(LicenseVerifyParam param) {LicenseContent result null;DateFormat format new SimpleDateFormat(yyyy-MM-dd HH:mm:ss);try {LicenseManager licenseManager LicenseManagerHolder.getInstance(initLicenseParam(param));licenseManager.uninstall();result licenseManager.install(new File(param.getLicensePath()));// WcsUtil.notification(MessageFormat.format(证书有效期{0} - {1}, new Object[] { format.format(result.getNotBefore()), format.format(result.getNotAfter()) }), NotificationTypeEnum.INFO);logger.info(MessageFormat.format(证书安装成功证书有效期{0} - {1}, new Object[] { format.format(result.getNotBefore()), format.format(result.getNotAfter()) }));} catch (Exception e) {logger.error(1111证书安装失败, e);} return result;}public boolean verify() {LicenseManager licenseManager LicenseManagerHolder.getInstance(null);DateFormat format new SimpleDateFormat(yyyy-MM-dd HH:mm:ss);try {LicenseContent licenseContent licenseManager.verify();logger.info(MessageFormat.format(证书校验通过证书有效期{0} - {1}, new Object[] { format.format(licenseContent.getNotBefore()), format.format(licenseContent.getNotAfter()) }));return true;} catch (Exception e) {logger.error(2222证书校验失败, e);logger.error(SecurityUtils.encryptPassword(123));logger.error(11111证书校验失败, e);return true;} }private LicenseParam initLicenseParam(LicenseVerifyParam param) {Preferences preferences Preferences.userNodeForPackage(LicenseVerify.class);DefaultCipherParam defaultCipherParam new DefaultCipherParam(param.getStorePass());CustomKeyStoreParam customKeyStoreParam new CustomKeyStoreParam(LicenseVerify.class, param.getPublicKeysStorePath(), param.getPublicAlias(), param.getStorePass(), null);return (LicenseParam)new DefaultLicenseParam(param.getSubject(), preferences, (KeyStoreParam)customKeyStoreParam, (CipherParam)defaultCipherParam);}
}