使用truelicense进行Java程序license控制 经过扩张可以验证license 开始结束日期,验证绑定给定mac地址

使用truelicense进行Java程序license控制

经过扩张可以验证license 开始结束日期,验证绑定给定mac地址。

 

Truelicense 是一个开源的java license 验证项目。

使用truelicense实现用于JAVA工程license机制(包括license生成和验证)请参考http://www.it165.net/pro/html/201404/11540.html

其中包括license授权机制的原理和制作license的具体步骤

 

本文主要是在此文基础上增加了mac 地址验证:

在createparam.properties

中增加 ip地址和 mac 地址的配置

##########common parameters###########
#alias
PRIVATEALIAS=privateKeys
#key(important!)
KEYPWD=iptv1234
#STOREPWD
STOREPWD=iptv1234
#SUBJECT
SUBJECT=bigdata
#licPath
licPath=C:/9exce/license/license.lic
#priPath
priPath=C:/9exce/license/PrivateKeys.keystore
##########license content###########
#issuedTime
issuedTime=2015-03-09
#notBeforeTime
notBefore=2015-03-09
#notAfterTime
notAfter=2016-03-20
#ip address
ipAddress=150.236.220.200
#mac address
macAddress=80-00-0B-56-3B-32
#consumerType
consumerType=user
#ConsumerAmount
consumerAmount=1
#info
info=this is a license


 

因为增加了mac地址,需要改变LicenseManager中的validate函数增加create_validate 用于create时的verify, 因为创建证书的时候 不能验证mac地址。

	protected synchronized void create_validate(LicenseContent paramLicenseContent)
			throws LicenseContentException {
		LicenseParam localLicenseParam = getLicenseParam();
		if (!localLicenseParam.getSubject().equals(
				paramLicenseContent.getSubject())) {
			throw new LicenseContentException(EXC_INVALID_SUBJECT);
		}
		if (paramLicenseContent.getHolder() == null) {
			throw new LicenseContentException(EXC_HOLDER_IS_NULL);
		}
		if (paramLicenseContent.getIssuer() == null) {
			throw new LicenseContentException(EXC_ISSUER_IS_NULL);
		}
		if (paramLicenseContent.getIssued() == null) {
			throw new LicenseContentException(EXC_ISSUED_IS_NULL);
		}
		Date localDate1 = new Date();
		Date localDate2 = paramLicenseContent.getNotBefore();
		if ((localDate2 != null) && (local
  • 3
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 20
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 20
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值