当前位置: 首页 > news >正文

将license验证加入到系统中

1.将ClientDemo下的cn文件夹的内容导入项目对应的java目录下。

2.将license-config.properties文件导入resources目录下。

在这里插入图片描述

3.在项目的pom.xml中添加如下依赖。

    <properties><!-- Apache HttpClient --><httpclient>4.5.5</httpclient><!-- License --><truelicense>1.33</truelicense></properties></dependencies>下:<!-- Apache HttpClient --><dependency><groupId>org.apache.httpcomponents</groupId><artifactId>httpclient</artifactId><version>${httpclient}</version></dependency><!-- Jackson对自动解析JSON和XML格式的支持 --><dependency><groupId>com.fasterxml.jackson.jaxrs</groupId><artifactId>jackson-jaxrs-json-provider</artifactId></dependency><dependency><groupId>com.fasterxml.jackson.dataformat</groupId><artifactId>jackson-dataformat-xml</artifactId></dependency><!-- License --><dependency><groupId>de.schlichtherle.truelicense</groupId><artifactId>truelicense-core</artifactId><version>${truelicense}</version></dependency><dependency><groupId>net.sourceforge.nekohtml</groupId><artifactId>nekohtml</artifactId><version>1.9.22</version></dependency>最后:<resources><resource><directory>src/main/resources</directory></resource><resource><directory>src/main/java</directory><includes><include>**/*.properties</include><include>**/*.xml</include><include>**/*.tld</include></includes><filtering>false</filtering></resource></resources>

4.在BcdFlightApplication.java启动项中添加:

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.PropertySource;@ServletComponentScan
@ComponentScan(basePackageClasses = {BcdFlightApplication.class, LicenseCheckListener.class})
@PropertySource({"license-config.properties"}) //加载额外的配置
public class BcdFlightApplication extends SpringBootServletInitializer {  ...  }

5.在WebMvcConfig.java中添加需要校验的接口。

    /*** 添加拦截器*/@Overridepublic void addInterceptors(InterceptorRegistry registry) {registry.addInterceptor(new LicenseCheckInterceptor()).addPathPatterns("/flight/hlFlyPlan/**");registry.addInterceptor(new LicenseCheckInterceptor()).addPathPatterns("/flight/hlFlyDemand/**");}

6.linux执行license.sh文件,获取认证所需相关信息;

windows执行(获取IP,mac,CPU,主板信息.bat)文件,获取认证所需相关信息。

7.使用JDK自带的 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"

windows:将privateKeys.keystore,publicCerts.keystore导入C:/layman/目录下
Linux:将privateKeys.keystore,publicCerts.keystore导入/layman/目录下

8.本地启动ServerDemo服务,在postman中执行http://127.0.0.1:7000/license/generateLicense,生成license.lic文件。

windows:将license.lic导入C:/layman/目录下
Linux:将license.lic导入/layman/目录下

9.运行程序,查看证书安装情况。

在这里插入图片描述

http://www.lryc.cn/news/194441.html

相关文章:

  • 中断机制-interrupt和isInterrupted源码分析、中断协商案例
  • 我与COSCon的故事【时光的故事】
  • 【科学文献计量】利用pybibx分析Scopus文献数据集(EDA,N-Grams,Cluster,Network analysis,NLP)
  • -带你看懂11种API类型及应用-
  • 集成友盟qq互联分享,导出风险问题处理
  • 探索数字安全的卓越之选 - Digicert证书
  • 第五章 流程控制 Pro
  • CSS之实现线性渐变背景
  • 软考 系统架构设计师系列知识点之特定领域软件体系结构DSSA(7)
  • CentOS-7网卡重启后关闭的解决方法
  • Linux CentOS7 用户组管理
  • C++算法:前缀和基础
  • vue和react的区别
  • STM32 之 HAL 库串口 USART 丢数据及ORE卡死的解决方案
  • 递归最小二乘法RLS
  • Apache Doris (三十九):Doris数据导出 - MySQL dump导出
  • 【Nginx32】Nginx学习:随机索引、真实IP处理与来源处理模块
  • vue3后台管理框架之集成sass
  • 无需付费开会员,一个Python程序实现PDF转高清图片
  • 为分布式系统设计数据库
  • Programming abstractions in C阅读笔记:p179-p180
  • 在 VSCode 中使用 PlantUML
  • css3过渡属性属性名:transition
  • 关于数据链路层(初步)
  • 诊断DLL——CAPL_DLL集成安全访问算法
  • 集合元素处理(传统方式和Stream方式)
  • 亲测好用,这3款免费高清录屏软件,效果惊人!
  • 超声波清洗机洗眼镜真的可以洗干净吗?眼镜超声波清洗机推荐
  • centos7安装部署ElasticSearch
  • websocket+node+vite(vue)实现一个简单的聊天