Giter Club home page Giter Club logo

licensedemo's Introduction

LicenseDemo

项目介绍

在基于Spring的项目中使用 TrueLicense 生成和验证License证书(服务器许可)的示例代码

技术依赖:

  • Spring Boot:项目基础架构
  • TrueLicense :基于Java实现的生成和验证服务器许可的简单框架

环境依赖:

  • JDK8+

两个子项目说明:

  • ServerDemo:用于开发者给客户生成License证书的示例代码
  • ClientDemo模拟需要给客户部署的业务项目

ServerDemo项目:

首先的利用keytool生成秘钥 #生成命令 keytool -genkeypair -keysize 1024 -validity 3650 -alias "privateKey" -keystore "privateKeys.keystore" -storepass "public_password1234" -keypass "private_password1234" -dname "CN=localhost, OU=localhost, O=localhost, L=SH, ST=SH, C=CN"

#导出命令 keytool -exportcert -alias "privateKey" -keystore "privateKeys.keystore" -storepass "public_password1234" -file "certfile.cer"

#导入命令 keytool -import -alias "publicCert" -file "certfile.cer" -keystore "publicCerts.keystore" -storepass "public_password1234"

对外发布了两个RESTful接口:

(1)获取服务器硬件信息 :

请求地址:http://127.0.0.1:7000/license/getServerInfos

获取服务器硬件信息

(2)生成证书 :

请求地址:http://127.0.0.1:7000/license/generateLicense

请求时需要在Header中添加一个 Content-Type ,其值为:application/json;charset=UTF-8。请求参数如下:

{
	"subject": "license_demo",
	"privateAlias": "privateKey",
	"keyPass": "private_password1234",
	"storePass": "public_password1234",
	"licensePath": "D:/license.lic",
	"privateKeysStorePath": "D:/privateKeys.keystore",
	"issuedTime": "2020-07-10 00:00:01",
	"expiryTime": "2021-12-31 23:59:59",
	"consumerType": "User",
	"consumerAmount": 1,
	"description": "这是证书描述信息",
	"licenseCheckModel": {
		"ipAddress": ["192.168.0.43", "192.168.154.1", "192.168.136.1"],
		"macAddress": ["94-C6-91-BD-BF-93", "00-50-56-C0-00-01", "00-50-56-C0-00-08"],
		"cpuSerial": "BFEBFBFF000906EA",
		"mainBoardSerial": ""
	}
}

(4)验证客户端登陆 POST请求 http://localhost:7080/check?username=admin&password=123

生成证书

ClientDemo项目:

项目启动时安装证书,通过cn/zifangsky/license/LicenseCheckListener.java类实现。用户登录时校验证书的可用性,通过cn/zifangsky/license/LicenseCheckInterceptor.java类实现。

特别说明:

详细开发思路可以参考我写的这篇文章:https://www.zifangsky.cn/1277.html

服务器许可证

licensedemo's People

Contributors

joe192168 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.