License3j做web项目部署授权认证功能

本文介绍了如何利用License3j进行Web项目的部署授权认证。首先通过gpg生成密钥对,然后将公钥和私钥导出。接着在项目中引入License3j库,并使用密钥对加密授权文件。在用户登录时,使用公钥解密文件进行授权校验。在实践中遇到的ASN1Integer签名信息不匹配问题,通过调整依赖版本和顺序得以解决。
摘要由CSDN通过智能技术生成

一、功能流程

  • 密钥生成(gpg  --full-gen-key)

生成密钥:gpg --full-gen-key

    创建时需要留意的地方:RAS加密、userId

导出公钥:gpg   --output public-key  --export [userId]

 导出私钥:gpg  --output public-key --export-secret-key [userId]

  • 项目中引入License3j

<dependency>
           <groupId>com.verhas</groupId>
           <artifactId>license3j</artifactId>
           <version>2.0.0-JVM8</version>
       </dependency>

  • 使用密钥对员文件进行加密
OutputStream out;
try {
	out = new FileOutputStream(licenseFile);
	out.write(new License().setLicense(new File(originFile))
			  .loadKey(new File(privateKeyFile), userId)
			  .encodeLicense(privateProtectedPassword).getBytes("utf-8&#
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值