• Spring Boot项目中使用 TrueLicense 生成和验证License(服务器许可)

Spring Boot项目中使用 TrueLicense 生成和验证License(服务器许可)

2025-04-28 18:00:21 1 阅读

一,简介

License,即版权许可证,一般用于收费软件给付费用户提供的访问许可证明。根据应用部署位置的不同,一般可以分为以下两种情况讨论:

  • 应用部署在开发者自己的云服务器上。这种情况下用户通过账号登录的形式远程访问,因此只需要在账号登录的时候校验目标账号的有效期、访问权限等信息即可。
  • 应用部署在客户的内网环境。因为这种情况开发者无法控制客户的网络环境,也不能保证应用所在服务器可以访问外网,因此通常的做法是使用服务器许可文件,在应用启动的时候加载证书,然后在登录或者其他关键操作的地方校验证书的有效性。

二, 使用 TrueLicense 生成License

1,在pom.xml中添加关键依赖

<dependency>
    <groupId>de.schlichtherle.truelicensegroupId>
    <artifactId>truelicense-coreartifactId>
    <version>1.33version>
    <scope>providedscope>
dependency>

2,校验自定义的License参数

TrueLicensede.schlichtherle.license.LicenseManager 类自带的verify方法只校验了我们后面颁发的许可文件的生效和过期时间,然而在实际项目中我们可能需要额外校验应用部署的服务器的IP地址、MAC地址、CPU序列号、主板序列号等信息,因此我们需要复写框架的部分方法以实现校验自定义参数的目的。

首先需要添加一个自定义的可被允许的服务器硬件信息的实体类(如果校验其他参数,可自行补充):

package cn.zifangsky.license;

import java.io.Serializable;
import java.util.List;

/**
 * 自定义需要校验的License参数
 *
 * @author zifangsky
 * @date 2018/4/23
 * @since 1.0.0
 */
public class LicenseCheckModel implements Serializable{

    private static final long serialVersionUID = 8600137500316662317L;
    /**
     * 可被允许的IP地址
     */
    private List<String> ipAddress;

    /**
     * 可被允许的MAC地址
     */
    private List<String> macAddress;

    /**
     * 可被允许的CPU序列号
     */
    private String cpuSerial;

    /**
     * 可被允许的主板序列号
     */
    private String mainBoardSerial;

    //省略setter和getter方法

    @Override
    public String toString() {
        return "LicenseCheckModel{" +
                "ipAddress=" + ipAddress +
                ", macAddress=" + macAddress +
                ", cpuSerial='" + cpuSerial + ''' +
                ", mainBoardSerial='" + mainBoardSerial + ''' +
                '}';
    }
}

其次,添加一个License生成类需要的参数:

package cn.zifangsky.license;

import com.fasterxml.jackson.annotation.JsonFormat;

import java.io.Serializable;
import java.util.Date;

/**
 * License生成类需要的参数
 *
 * @author zifangsky
 * @date 2018/4/19
 * @since 1.0.0
 */
public class LicenseCreatorParam implements Serializable {

    private static final long serialVersionUID = -7793154252684580872L;
    /**
     * 证书subject
     */
    private String subject;

    /**
     * 密钥别称
     */
    private String privateAlias;

    /**
     * 密钥密码(需要妥善保管,不能让使用者知道)
     */
    private String keyPass;

    /**
     * 访问秘钥库的密码
     */
    private String storePass;

    /**
     * 证书生成路径
     */
    private String licensePath;

    /**
     * 密钥库存储路径
     */
    private String privateKeysStorePath;

    /**
     * 证书生效时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date issuedTime = new Date();

    /**
     * 证书失效时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date expiryTime;

    /**
     * 用户类型
     */
    private String consumerType = "user";

    /**
     * 用户数量
     */
    private Integer consumerAmount = 1;

    /**
     * 描述信息
     */
    private String description = "";

    /**
     * 额外的服务器硬件校验信息
     */
    private LicenseCheckModel licenseCheckModel;

    //省略setter和getter方法

    @Override
    public String toString() {
        return "LicenseCreatorParam{" +
                "subject='" + subject + ''' +
                ", privateAlias='" + privateAlias + ''' +
                ", keyPass='" + keyPass + ''' +
                ", storePass='" + storePass + ''' +
                ", licensePath='" + licensePath + ''' +
                ", privateKeysStorePath='" + privateKeysStorePath + ''' +
                ", issuedTime=" + issuedTime +
                ", expiryTime=" + expiryTime +
                ", consumerType='" + consumerType + ''' +
                ", consumerAmount=" + consumerAmount +
                ", description='" + description + ''' +
                ", licenseCheckModel=" + licenseCheckModel +
                '}';
    }
}

添加抽象类AbstractServerInfos,用户获取服务器的硬件信息:

package cn.zifangsky.license;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;

/**
 * 用于获取客户服务器的基本信息,如:IP、Mac地址、CPU序列号、主板序列号等
 *
 * @author zifangsky
 * @date 2018/4/23
 * @since 1.0.0
 */
public abstract class AbstractServerInfos {
    private static Logger logger = LogManager.getLogger(AbstractServerInfos.class);

    /**
     * 组装需要额外校验的License参数
     * @author zifangsky
     * @date 2018/4/23 14:23
     * @since 1.0.0
     * @return demo.LicenseCheckModel
     */
    public LicenseCheckModel getServerInfos(){
        LicenseCheckModel result = new LicenseCheckModel();

        try {
            result.setIpAddress(this.getIpAddress());
            result.setMacAddress(this.getMacAddress());
            result.setCpuSerial(this.getCPUSerial());
            result.setMainBoardSerial(this.getMainBoardSerial());
        }catch (Exception e){
            logger.error("获取服务器硬件信息失败",e);
        }

        return result;
    }

    /**
     * 获取IP地址
     * @author zifangsky
     * @date 2018/4/23 11:32
     * @since 1.0.0
     * @return java.util.List
     */
    protected abstract List<String> getIpAddress() throws Exception;

    /**
     * 获取Mac地址
     * @author zifangsky
     * @date 2018/4/23 11:32
     * @since 1.0.0
     * @return java.util.List
     */
    protected abstract List<String> getMacAddress() throws Exception;

    /**
     * 获取CPU序列号
     * @author zifangsky
     * @date 2018/4/23 11:35
     * @since 1.0.0
     * @return java.lang.String
     */
    protected abstract String getCPUSerial() throws Exception;

    /**
     * 获取主板序列号
     * @author zifangsky
     * @date 2018/4/23 11:35
     * @since 1.0.0
     * @return java.lang.String
     */
    protected abstract String getMainBoardSerial() throws Exception;

    /**
     * 获取当前服务器所有符合条件的InetAddress
     * @author zifangsky
     * @date 2018/4/23 17:38
     * @since 1.0.0
     * @return java.util.List
     */
    protected List<InetAddress> getLocalAllInetAddress() throws Exception {
        List<InetAddress> result = new ArrayList<>(4);

        // 遍历所有的网络接口
        for (Enumeration networkInterfaces = NetworkInterface.getNetworkInterfaces(); networkInterfaces.hasMoreElements(); ) {
            NetworkInterface iface = (NetworkInterface) networkInterfaces.nextElement();
            // 在所有的接口下再遍历IP
            for (Enumeration inetAddresses = iface.getInetAddresses(); inetAddresses.hasMoreElements(); ) {
                InetAddress inetAddr = (InetAddress) inetAddresses.nextElement();

                //排除LoopbackAddress、SiteLocalAddress、LinkLocalAddress、MulticastAddress类型的IP地址
                if(!inetAddr.isLoopbackAddress() /*&& !inetAddr.isSiteLocalAddress()*/
                        && !inetAddr.isLinkLocalAddress() && !inetAddr.isMulticastAddress()){
                    result.add(inetAddr);
                }
            }
        }

        return result;
    }

    /**
     * 获取某个网络接口的Mac地址
     * @author zifangsky
     * @date 2018/4/23 18:08
     * @since 1.0.0
     * @param
     * @return void
     */
    protected String getMacByInetAddress(InetAddress inetAddr){
        try {
            byte[] mac = NetworkInterface.getByInetAddress(inetAddr).getHardwareAddress();
            StringBuffer stringBuffer = new StringBuffer();

            for(int i=0;i<mac.length;i++){
                if(i != 0) {
                    stringBuffer.append("-");
                }

                //将十六进制byte转化为字符串
                String temp = Integer.toHexString(mac[i] & 0xff);
                if(temp.length() == 1){
                    stringBuffer.append("0" + temp);
                }else{
                    stringBuffer.append(temp);
                }
            }

            return stringBuffer.toString().toUpperCase();
        } catch (SocketException e) {
            e.printStackTrace();
        }

        return null;
    }

}

获取客户Linux服务器的基本信息:

package cn.zifangsky.license;

import org.apache.commons.lang3.StringUtils;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 用于获取客户Linux服务器的基本信息
 *
 * @author zifangsky
 * @date 2018/4/23
 * @since 1.0.0
 */
public class LinuxServerInfos extends AbstractServerInfos {

    @Override
    protected List<String> getIpAddress() throws Exception {
        List<String> result = null;

        //获取所有网络接口
        List<InetAddress> inetAddresses = getLocalAllInetAddress();

        if(inetAddresses != null && inetAddresses.size() > 0){
            result = inetAddresses.stream().map(InetAddress::getHostAddress).distinct().map(String::toLowerCase).collect(Collectors.toList());
        }

        return result;
    }

    @Override
    protected List<String> getMacAddress() throws Exception {
        List<String> result = null;

        //1. 获取所有网络接口
        List<InetAddress> inetAddresses = getLocalAllInetAddress();

        if(inetAddresses != null && inetAddresses.size() > 0){
            //2. 获取所有网络接口的Mac地址
            result = inetAddresses.stream().map(this::getMacByInetAddress).distinct().collect(Collectors.toList());
        }

        return result;
    }

    @Override
    protected String getCPUSerial() throws Exception {
        //序列号
        String serialNumber = "";

        //使用dmidecode命令获取CPU序列号
        String[] shell = {"/bin/bash","-c","dmidecode -t processor | grep 'ID' | awk -F ':' '{print $2}' | head -n 1"};
        Process process = Runtime.getRuntime().exec(shell);
        process.getOutputStream().close();

        BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));

        String line = reader.readLine().trim();
        if(StringUtils.isNotBlank(line)){
            serialNumber = line;
        }

        reader.close();
        return serialNumber;
    }

    @Override
    protected String getMainBoardSerial() throws Exception {
        //序列号
        String serialNumber = "";

        //使用dmidecode命令获取主板序列号
        String[] shell = {"/bin/bash","-c","dmidecode | grep 'Serial Number' | awk -F ':' '{print $2}' | head -n 1"};
        Process process = Runtime.getRuntime().exec(shell);
        process.getOutputStream().close();

        BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));

        String line = reader.readLine().trim();
        if(StringUtils.isNotBlank(line)){
            serialNumber = line;
        }

        reader.close();
        return serialNumber;
    }
}

获取客户Windows服务器的基本信息:

package cn.zifangsky.license;

import java.net.InetAddress;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

/**
 * 用于获取客户Windows服务器的基本信息
 *
 * @author zifangsky
 * @date 2018/4/23
 * @since 1.0.0
 */
public class WindowsServerInfos extends AbstractServerInfos {

    @Override
    protected List<String> getIpAddress() throws Exception {
        List<String> result = null;

        //获取所有网络接口
        List<InetAddress> inetAddresses = getLocalAllInetAddress();

        if(inetAddresses != null && inetAddresses.size() > 0){
            result = inetAddresses.stream().map(InetAddress::getHostAddress).distinct().map(String::toLowerCase).collect(Collectors.toList());
        }

        return result;
    }

    @Override
    protected List<String> getMacAddress() throws Exception {
        List<String> result = null;

        //1. 获取所有网络接口
        List<InetAddress> inetAddresses = getLocalAllInetAddress();

        if(inetAddresses != null && inetAddresses.size() > 0){
            //2. 获取所有网络接口的Mac地址
            result = inetAddresses.stream().map(this::getMacByInetAddress).distinct().collect(Collectors.toList());
        }

        return result;
    }

    @Override
    protected String getCPUSerial() throws Exception {
        //序列号
        String serialNumber = "";

        //使用WMIC获取CPU序列号
        Process process = Runtime.getRuntime().exec("wmic cpu get processorid");
        process.getOutputStream().close();
        Scanner scanner = new Scanner(process.getInputStream());

        if(scanner.hasNext()){
            scanner.next();
        }

        if(scanner.hasNext()){
            serialNumber = scanner.next().trim();
        }

        scanner.close();
        return serialNumber;
    }

    @Override
    protected String getMainBoardSerial() throws Exception {
        //序列号
        String serialNumber = "";

        //使用WMIC获取主板序列号
        Process process = Runtime.getRuntime().exec("wmic baseboard get serialnumber");
        process.getOutputStream().close();
        Scanner scanner = new Scanner(process.getInputStream());

        if(scanner.hasNext()){
            scanner.next();
        }

        if(scanner.hasNext()){
            serialNumber = scanner.next().trim();
        }

        scanner.close();
        return serialNumber;
    }
}

自定义LicenseManager,用于增加额外的服务器硬件信息校验:

package cn.zifangsky.license;

import de.schlichtherle.license.LicenseContent;
import de.schlichtherle.license.LicenseContentException;
import de.schlichtherle.license.LicenseManager;
import de.schlichtherle.license.LicenseNotary;
import de.schlichtherle.license.LicenseParam;
import de.schlichtherle.license.NoLicenseInstalledException;
import de.schlichtherle.xml.GenericCertificate;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.beans.XMLDecoder;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.List;

/**
 * 自定义LicenseManager,用于增加额外的服务器硬件信息校验
 *
 * @author zifangsky
 * @date 2018/4/23
 * @since 1.0.0
 */
public class CustomLicenseManager extends LicenseManager{
    private static Logger logger = LogManager.getLogger(CustomLicenseManager.class);

    //XML编码
    private static final String XML_CHARSET = "UTF-8";
    //默认BUFSIZE
    private static final int DEFAULT_BUFSIZE = 8 * 1024;

    public CustomLicenseManager() {

    }

    public CustomLicenseManager(LicenseParam param) {
        super(param);
    }

    /**
     * 复写create方法
     * @author zifangsky
     * @date 2018/4/23 10:36
     * @since 1.0.0
     * @param
     * @return byte[]
     */
    @Override
    protected synchronized byte[] create(
            LicenseContent content,
            LicenseNotary notary)
            throws Exception {
        initialize(content);
        this.validateCreate(content);
        final GenericCertificate certificate = notary.sign(content);
        return getPrivacyGuard().cert2key(certificate);
    }

    /**
     * 复写install方法,其中validate方法调用本类中的validate方法,校验IP地址、Mac地址等其他信息
     * @author zifangsky
     * @date 2018/4/23 10:40
     * @since 1.0.0
     * @param
     * @return de.schlichtherle.license.LicenseContent
     */
    @Override
    protected synchronized LicenseContent install(
            final byte[] key,
            final LicenseNotary notary)
            throws Exception {
        final GenericCertificate certificate = getPrivacyGuard().key2cert(key);

        notary.verify(certificate);
        final LicenseContent content = (LicenseContent)this.load(certificate.getEncoded());
        this.validate(content);
        setLicenseKey(key);
        setCertificate(certificate);

        return content;
    }

    /**
     * 复写verify方法,调用本类中的validate方法,校验IP地址、Mac地址等其他信息
     * @author zifangsky
     * @date 2018/4/23 10:40
     * @since 1.0.0
     * @param
     * @return de.schlichtherle.license.LicenseContent
     */
    @Override
    protected synchronized LicenseContent verify(final LicenseNotary notary)
            throws Exception {
        GenericCertificate certificate = getCertificate();

        // Load license key from preferences,
        final byte[] key = getLicenseKey();
        if (null == key){
            throw new NoLicenseInstalledException(getLicenseParam().getSubject());
        }

        certificate = getPrivacyGuard().key2cert(key);
        notary.verify(certificate);
        final LicenseContent content = (LicenseContent)this.load(certificate.getEncoded());
        this.validate(content);
        setCertificate(certificate);

        return content;
    }

    /**
     * 校验生成证书的参数信息
     * @author zifangsky
     * @date 2018/5/2 15:43
     * @since 1.0.0
     * @param content 证书正文
     */
    protected synchronized void validateCreate(final LicenseContent content)
            throws LicenseContentException {
        final LicenseParam param = getLicenseParam();

        final Date now = new Date();
        final Date notBefore = content.getNotBefore();
        final Date notAfter = content.getNotAfter();
        if (null != notAfter && now.after(notAfter)){
            throw new LicenseContentException("证书失效时间不能早于当前时间");
        }
        if (null != notBefore && null != notAfter && notAfter.before(notBefore)){
            throw new LicenseContentException("证书生效时间不能晚于证书失效时间");
        }
        final String consumerType = content.getConsumerType();
        if (null == consumerType){
            throw new LicenseContentException("用户类型不能为空");
        }
    }


    /**
     * 复写validate方法,增加IP地址、Mac地址等其他信息校验
     * @author zifangsky
     * @date 2018/4/23 10:40
     * @since 1.0.0
     * @param content LicenseContent
     */
    @Override
    protected synchronized void validate(final LicenseContent content)
            throws LicenseContentException {
        //1. 首先调用父类的validate方法
        super.validate(content);

        //2. 然后校验自定义的License参数
        //License中可被允许的参数信息
        LicenseCheckModel expectedCheckModel = (LicenseCheckModel) content.getExtra();
        //当前服务器真实的参数信息
        LicenseCheckModel serverCheckModel = getServerInfos();

        if(expectedCheckModel != null && serverCheckModel != null){
            //校验IP地址
            if(!checkIpAddress(expectedCheckModel.getIpAddress(),serverCheckModel.getIpAddress())){
                throw new LicenseContentException("当前服务器的IP没在授权范围内");
            }

            //校验Mac地址
            if(!checkIpAddress(expectedCheckModel.getMacAddress(),serverCheckModel.getMacAddress())){
                throw new LicenseContentException("当前服务器的Mac地址没在授权范围内");
            }

            //校验主板序列号
            if(!checkSerial(expectedCheckModel.getMainBoardSerial(),serverCheckModel.getMainBoardSerial())){
                throw new LicenseContentException("当前服务器的主板序列号没在授权范围内");
            }

            //校验CPU序列号
            if(!checkSerial(expectedCheckModel.getCpuSerial(),serverCheckModel.getCpuSerial())){
                throw new LicenseContentException("当前服务器的CPU序列号没在授权范围内");
            }
        }else{
            throw new LicenseContentException("不能获取服务器硬件信息");
        }
    }


    /**
     * 重写XMLDecoder解析XML
     * @author zifangsky
     * @date 2018/4/25 14:02
     * @since 1.0.0
     * @param encoded XML类型字符串
     * @return java.lang.Object
     */
    private Object load(String encoded){
        BufferedInputStream inputStream = null;
        XMLDecoder decoder = null;
        try {
            inputStream = new BufferedInputStream(new ByteArrayInputStream(encoded.getBytes(XML_CHARSET)));

            decoder = new XMLDecoder(new BufferedInputStream(inputStream, DEFAULT_BUFSIZE),null,null);

            return decoder.readObject();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } finally {
            try {
                if(decoder != null){
                    decoder.close();
                }
                if(inputStream != null){
                    inputStream.close();
                }
            } catch (Exception e) {
                logger.error("XMLDecoder解析XML失败",e);
            }
        }

        return null;
    }

    /**
     * 获取当前服务器需要额外校验的License参数
     * @author zifangsky
     * @date 2018/4/23 14:33
     * @since 1.0.0
     * @return demo.LicenseCheckModel
     */
    private LicenseCheckModel getServerInfos(){
        //操作系统类型
        String osName = System.getProperty("os.name").toLowerCase();
        AbstractServerInfos abstractServerInfos = null;

        //根据不同操作系统类型选择不同的数据获取方法
        if (osName.startsWith("windows")) {
            abstractServerInfos = new WindowsServerInfos();
        } else if (osName.startsWith("linux")) {
            abstractServerInfos = new LinuxServerInfos();
        }else{//其他服务器类型
            abstractServerInfos = new LinuxServerInfos();
        }

        return abstractServerInfos.getServerInfos();
    }

    /**
     * 校验当前服务器的IP/Mac地址是否在可被允许的IP范围内
* 如果存在IP在可被允许的IP/Mac地址范围内,则返回true * @author zifangsky * @date 2018/4/24 11:44 * @since 1.0.0 * @return boolean */
private boolean checkIpAddress(List<String> expectedList,List<String> serverList){ if(expectedList != null && expectedList.size() > 0){ if(serverList != null && serverList.size() > 0){ for(String expected : expectedList){ if(serverList.contains(expected.trim())){ return true; } } } return false; }else { return true; } } /** * 校验当前服务器硬件(主板、CPU等)序列号是否在可允许范围内 * @author zifangsky * @date 2018/4/24 14:38 * @since 1.0.0 * @return boolean */ private boolean checkSerial(String expectedSerial,String serverSerial){ if(StringUtils.isNotBlank(expectedSerial)){ if(StringUtils.isNotBlank(serverSerial)){ if(expectedSerial.equals(serverSerial)){ return true; } } return false; }else{ return true; } } }

最后是License生成类,用于生成License证书:

package cn.zifangsky.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 org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import javax.security.auth.x500.X500Principal;
import java.io.File;
import java.text.MessageFormat;
import java.util.prefs.Preferences;

/**
 * License生成类
 *
 * @author zifangsky
 * @date 2018/4/19
 * @since 1.0.0
 */
public class LicenseCreator {
    private static Logger logger = LogManager.getLogger(LicenseCreator.class);
    private final static X500Principal DEFAULT_HOLDER_AND_ISSUER = new X500Principal("CN=localhost, OU=localhost, O=localhost, L=SH, ST=SH, C=CN");
    private LicenseCreatorParam param;

    public LicenseCreator(LicenseCreatorParam param) {
        this.param = param;
    }

    /**
     * 生成License证书
     * @author zifangsky
     * @date 2018/4/20 10:58
     * @since 1.0.0
     * @return boolean
     */
    public boolean generateLicense(){
        try {
            LicenseManager licenseManager = new CustomLicenseManager(initLicenseParam());
            LicenseContent licenseContent = initLicenseContent();

            licenseManager.store(licenseContent,new File(param.getLicensePath()));

            return true;
        }catch (Exception e){
            logger.error(MessageFormat.format("证书生成失败:{0}",param),e);
            return false;
        }
    }

    /**
     * 初始化证书生成参数
     * @author zifangsky
     * @date 2018/4/20 10:56
     * @since 1.0.0
     * @return de.schlichtherle.license.LicenseParam
     */
    private LicenseParam initLicenseParam(){
        Preferences preferences = Preferences.userNodeForPackage(LicenseCreator.class);

        //设置对证书内容加密的秘钥
        CipherParam cipherParam = new DefaultCipherParam(param.getStorePass());

        KeyStoreParam privateStoreParam = new CustomKeyStoreParam(LicenseCreator.class
                ,param.getPrivateKeysStorePath()
                ,param.getPrivateAlias()
                ,param.getStorePass()
                ,param.getKeyPass());

        LicenseParam licenseParam = new DefaultLicenseParam(param.getSubject()
                ,preferences
                ,privateStoreParam
                ,cipherParam);

        return licenseParam;
    }

    /**
     * 设置证书生成正文信息
     * @author zifangsky
     * @date 2018/4/20 10:57
     * @since 1.0.0
     * @return de.schlichtherle.license.LicenseContent
     */
    private LicenseContent initLicenseContent(){
        LicenseContent licenseContent = new LicenseContent();
        licenseContent.setHolder(DEFAULT_HOLDER_AND_ISSUER);
        licenseContent.setIssuer(DEFAULT_HOLDER_AND_ISSUER);

        licenseContent.setSubject(param.getSubject());
        licenseContent.setIssued(param.getIssuedTime());
        licenseContent.setNotBefore(param.getIssuedTime());
        licenseContent.setNotAfter(param.getExpiryTime());
        licenseContent.setConsumerType(param.getConsumerType());
        licenseContent.setConsumerAmount(param.getConsumerAmount());
        licenseContent.setInfo(param.getDescription());

        //扩展校验服务器硬件信息
        licenseContent.setExtra(param.getLicenseCheckModel());

        return licenseContent;
    }

}

3,添加一个生成证书的Controller:

这个Controller对外提供了两个RESTful接口,分别是「获取服务器硬件信息」和「生成证书」,示例代码如下:

package cn.zifangsky.controller;

import cn.zifangsky.license.AbstractServerInfos;
import cn.zifangsky.license.LicenseCheckModel;
import cn.zifangsky.license.LicenseCreator;
import cn.zifangsky.license.LicenseCreatorParam;
import cn.zifangsky.license.LinuxServerInfos;
import cn.zifangsky.license.WindowsServerInfos;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 *
 * 用于生成证书文件,不能放在给客户部署的代码里
 * @author zifangsky
 * @date 2018/4/26
 * @since 1.0.0
 */
@RestController
@RequestMapping("/license")
public class LicenseCreatorController {

    /**
     * 证书生成路径
     */
    @Value("${license.licensePath}")
    private String licensePath;

    /**
     * 获取服务器硬件信息
     * @author zifangsky
     * @date 2018/4/26 13:13
     * @since 1.0.0
     * @param osName 操作系统类型,如果为空则自动判断
     * @return com.ccx.models.license.LicenseCheckModel
     */
    @RequestMapping(value = "/getServerInfos",produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
    public LicenseCheckModel getServerInfos(@RequestParam(value = "osName",required = false) String osName) {
        //操作系统类型
        if(StringUtils.isBlank(osName)){
            osName = System.getProperty("os.name");
        }
        osName = osName.toLowerCase();

        AbstractServerInfos abstractServerInfos = null;

        //根据不同操作系统类型选择不同的数据获取方法
        if (osName.startsWith("windows")) {
            abstractServerInfos = new WindowsServerInfos();
        } else if (osName.startsWith("linux")) {
            abstractServerInfos = new LinuxServerInfos();
        }else{//其他服务器类型
            abstractServerInfos = new LinuxServerInfos();
        }

        return abstractServerInfos.getServerInfos();
    }

    /**
     * 生成证书
     * @author zifangsky
     * @date 2018/4/26 13:13
     * @since 1.0.0
     * @param param 生成证书需要的参数,如:{"subject":"ccx-models","privateAlias":"privateKey","keyPass":"5T7Zz5Y0dJFcqTxvzkH5LDGJJSGMzQ","storePass":"3538cef8e7","licensePath":"C:/Users/zifangsky/Desktop/license.lic","privateKeysStorePath":"C:/Users/zifangsky/Desktop/privateKeys.keystore","issuedTime":"2018-04-26 14:48:12","expiryTime":"2018-12-31 00:00:00","consumerType":"User","consumerAmount":1,"description":"这是证书描述信息","licenseCheckModel":{"ipAddress":["192.168.245.1","10.0.5.22"],"macAddress":["00-50-56-C0-00-01","50-7B-9D-F9-18-41"],"cpuSerial":"BFEBFBFF000406E3","mainBoardSerial":"L1HF65E00X9"}}
     * @return java.util.Map
     */
    @RequestMapping(value = "/generateLicense",produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
    public Map<String,Object> generateLicense(@RequestBody(required = true) LicenseCreatorParam param) {
        Map<String,Object> resultMap = new HashMap<>(2);

        if(StringUtils.isBlank(param.getLicensePath())){
            param.setLicensePath(licensePath);
        }

        LicenseCreator licenseCreator = new LicenseCreator(param);
        boolean result = licenseCreator.generateLicense();

        if(result){
            resultMap.put("result","ok");
            resultMap.put("msg",param);
        }else{
            resultMap.put("result","error");
            resultMap.put("msg","证书文件生成失败!");
        }
        return resultMap;
    }
}

三,使用JDK自带的 keytool 工具生成公私钥证书库

假如我们设置公钥库密码为:public_password1234,私钥库密码为:private_password1234,则生成命令如下:

#生成命令
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"

上述命令执行完成之后,会在当前路径下生成三个文件,分别是:privateKeys.keystorepublicCerts.keystorecertfile.cer其中文件certfile.cer不再需要可以删除,文件privateKeys.keystore用于当前的 ServerDemo 项目给客户生成license文件,而文件publicCerts.keystore则随应用代码部署到客户服务器,用户解密license文件并校验其许可信息。

四,为客户生成license文件

将 ServerDemo 项目部署到客户服务器,通过以下接口获取服务器的硬件信息(等license文件生成后需要删除这个项目。当然也可以通过命令手动获取客户服务器的硬件信息,然后在开发者自己的电脑上生成license文件):

然后生成license文件:

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

{
	"subject": "license_demo",
	"privateAlias": "privateKey",
	"keyPass": "private_password1234",
	"storePass": "public_password1234",
	"licensePath": "C:/Users/zifangsky/Desktop/license_demo/license.lic",
	"privateKeysStorePath": "C:/Users/zifangsky/Desktop/license_demo/privateKeys.keystore",
	"issuedTime": "2018-07-10 00:00:01",
	"expiryTime": "2019-12-31 23:59:59",
	"consumerType": "User",
	"consumerAmount": 1,
	"description": "这是证书描述信息",
	"licenseCheckModel": {
		"ipAddress": ["192.168.245.1", "10.0.5.22"],
		"macAddress": ["00-50-56-C0-00-01", "50-7B-9D-F9-18-41"],
		"cpuSerial": "BFEBFBFF000406E3",
		"mainBoardSerial": "L1HF65E00X9"
	}
}

如果请求成功,那么最后会在 licensePath 参数设置的路径生成一个license.lic的文件,这个文件就是给客户部署代码的服务器许可文件。

五,给客户部署的应用中添加License校验

1,添加License校验类需要的参数

package cn.zifangsky.license;

/**
 * License校验类需要的参数
 *
 * @author zifangsky
 * @date 2018/4/20
 * @since 1.0.0
 */
public class LicenseVerifyParam {

    /**
     * 证书subject
     */
    private String subject;

    /**
     * 公钥别称
     */
    private String publicAlias;

    /**
     * 访问公钥库的密码
     */
    private String storePass;

    /**
     * 证书生成路径
     */
    private String licensePath;

    /**
     * 密钥库存储路径
     */
    private String publicKeysStorePath;

    public LicenseVerifyParam() {

    }

    public LicenseVerifyParam(String subject, String publicAlias, String storePass, String licensePath, String publicKeysStorePath) {
        this.subject = subject;
        this.publicAlias = publicAlias;
        this.storePass = storePass;
        this.licensePath = licensePath;
        this.publicKeysStorePath = publicKeysStorePath;
    }

    //省略setter和getter方法

    @Override
    public String toString() {
        return "LicenseVerifyParam{" +
                "subject='" + subject + ''' +
                ", publicAlias='" + publicAlias + ''' +
                ", storePass='" + storePass + ''' +
                ", licensePath='" + licensePath + ''' +
                ", publicKeysStorePath='" + publicKeysStorePath + ''' +
                '}';
    }
}

然后再添加License校验类:

package cn.zifangsky.license;

import de.schlichtherle.license.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.File;
import java.text.DateFormat;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.prefs.Preferences;

/**
 * License校验类
 *
 * @author zifangsky
 * @date 2018/4/20
 * @since 1.0.0
 */
public class LicenseVerify {
    private static Logger logger = LogManager.getLogger(LicenseVerify.class);

    /**
     * 安装License证书
     * @author zifangsky
     * @date 2018/4/20 16:26
     * @since 1.0.0
     */
    public synchronized LicenseContent install(LicenseVerifyParam param){
        LicenseContent result = null;
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        //1. 安装证书
        try{
            LicenseManager licenseManager = LicenseManagerHolder.getInstance(initLicenseParam(param));
            licenseManager.uninstall();

            result = licenseManager.install(new File(param.getLicensePath()));
            logger.info(MessageFormat.format("证书安装成功,证书有效期:{0} - {1}",format.format(result.getNotBefore()),format.format(result.getNotAfter())));
        }catch (Exception e){
            logger.error("证书安装失败!",e);
        }

        return result;
    }

    /**
     * 校验License证书
     * @author zifangsky
     * @date 2018/4/20 16:26
     * @since 1.0.0
     * @return boolean
     */
    public boolean verify(){
        LicenseManager licenseManager = LicenseManagerHolder.getInstance(null);
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        //2. 校验证书
        try {
            LicenseContent licenseContent = licenseManager.verify();
//            System.out.println(licenseContent.getSubject());

            logger.info(MessageFormat.format("证书校验通过,证书有效期:{0} - {1}",format.format(licenseContent.getNotBefore()),format.format(licenseContent.getNotAfter())));
            return true;
        }catch (Exception e){
            logger.error("证书校验失败!",e);
            return false;
        }
    }

    /**
     * 初始化证书生成参数
     * @author zifangsky
     * @date 2018/4/20 10:56
     * @since 1.0.0
     * @param param License校验类需要的参数
     * @return de.schlichtherle.license.LicenseParam
     */
    private LicenseParam initLicenseParam(LicenseVerifyParam param){
        Preferences preferences = Preferences.userNodeForPackage(LicenseVerify.class);

        CipherParam cipherParam = new DefaultCipherParam(param.getStorePass());

        KeyStoreParam publicStoreParam = new CustomKeyStoreParam(LicenseVerify.class
                ,param.getPublicKeysStorePath()
                ,param.getPublicAlias()
                ,param.getStorePass()
                ,null);

        return new DefaultLicenseParam(param.getSubject()
                ,preferences
                ,publicStoreParam
                ,cipherParam);
    }

}

2,添加Listener,用于在项目启动的时候安装License证书

package cn.zifangsky.license;

import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

/**
 * 在项目启动时安装证书
 *
 * @author zifangsky
 * @date 2018/4/24
 * @since 1.0.0
 */
@Component
public class LicenseCheckListener implements ApplicationListener<ContextRefreshedEvent> {
    private static Logger logger = LogManager.getLogger(LicenseCheckListener.class);

    /**
     * 证书subject
     */
    @Value("${license.subject}")
    private String subject;

    /**
     * 公钥别称
     */
    @Value("${license.publicAlias}")
    private String publicAlias;

    /**
     * 访问公钥库的密码
     */
    @Value("${license.storePass}")
    private String storePass;

    /**
     * 证书生成路径
     */
    @Value("${license.licensePath}")
    private String licensePath;

    /**
     * 密钥库存储路径
     */
    @Value("${license.publicKeysStorePath}")
    private String publicKeysStorePath;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        //root application context 没有parent
        ApplicationContext context = event.getApplicationContext().getParent();
        if(context == null){
            if(StringUtils.isNotBlank(licensePath)){
                logger.info("++++++++ 开始安装证书 ++++++++");

                LicenseVerifyParam param = new LicenseVerifyParam();
                param.setSubject(subject);
                param.setPublicAlias(publicAlias);
                param.setStorePass(storePass);
                param.setLicensePath(licensePath);
                param.setPublicKeysStorePath(publicKeysStorePath);

                LicenseVerify licenseVerify = new LicenseVerify();
                //安装证书
                licenseVerify.install(param);

                logger.info("++++++++ 证书安装结束 ++++++++");
            }
        }
    }
}

注:上面代码使用参数信息如下所示:

#License相关配置
license.subject=license_demo
license.publicAlias=publicCert
license.storePass=public_password1234
license.licensePath=C:/Users/zifangsky/Desktop/license_demo/license.lic
license.publicKeysStorePath=C:/Users/zifangsky/Desktop/license_demo/publicCerts.keystore

3,添加拦截器,用于在登录的时候校验License证书

package cn.zifangsky.license;

import com.alibaba.fastjson.JSON;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

/**
 * LicenseCheckInterceptor
 *
 * @author zifangsky
 * @date 2018/4/25
 * @since 1.0.0
 */
public class LicenseCheckInterceptor extends HandlerInterceptorAdapter{
    private static Logger logger = LogManager.getLogger(LicenseCheckInterceptor.class);

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        LicenseVerify licenseVerify = new LicenseVerify();

        //校验证书是否有效
        boolean verifyResult = licenseVerify.verify();

        if(verifyResult){
            return true;
        }else{
            response.setCharacterEncoding("utf-8");
            Map<String,String> result = new HashMap<>(1);
            result.put("result","您的证书无效,请核查服务器是否取得授权或重新申请证书!");

            response.getWriter().write(JSON.toJSONString(result));

            return false;
        }
    }

}

4,添加登录页面并测试

<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta content="text/html;charset=UTF-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <title>登录页面title>
    <script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js">script>
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js">script>
    <link rel="stylesheet" th:href="@{/css/style.css}"/>

    <script>
        //回车登录
        function enterlogin(e) {
            var key = window.event ? e.keyCode : e.which;
            if (key === 13) {
                userLogin();
            }
        }

        //用户密码登录
        function userLogin() {
            //获取用户名、密码
            var username = $("#username").val();
            var password = $("#password").val();

            if (username == null || username === "") {
                $("#errMsg").text("请输入登陆用户名!");
                $("#errMsg").attr("style", "display:block");
                return;
            }
            if (password == null || password === "") {
                $("#errMsg").text("请输入登陆密码!");
                $("#errMsg").attr("style", "display:block");
                return;
            }

            $.ajax({
                url: "/check",
                type: "POST",
                dataType: "json",
                async: false,
                data: {
                    "username": username,
                    "password": password
                },
                success: function (data) {
                    if (data.code == "200") {
                        $("#errMsg").attr("style", "display:none");
                        window.location.href = '/userIndex';
                    } else if (data.result != null) {
                        $("#errMsg").text(data.result);
                        $("#errMsg").attr("style", "display:block");
                    } else {
                        $("#errMsg").text(data.msg);
                        $("#errMsg").attr("style", "display:block");
                    }
                }
            });
        }
    script>
head>
<body onkeydown="enterlogin(event);">
<div class="container">
    <div class="form row">
        <div class="form-horizontal col-md-offset-3" id="login_form">
            <h3 class="form-title">LOGINh3>
            <div class="col-md-9">
                <div class="form-group">
                    <i class="fa fa-user fa-lg">i>
                    <input class="form-control required" type="text" placeholder="Username" id="username"
                           name="username" autofocus="autofocus" maxlength="20"/>
                div>
                <div class="form-group">
                    <i class="fa fa-lock fa-lg">i>
                    <input class="form-control required" type="password" placeholder="Password" id="password"
                           name="password" maxlength="8"/>
                div>
                <div class="form-group">
                    <span class="errMsg" id="errMsg" style="display: none">错误提示span>
                div>
                <div class="form-group col-md-offset-9">
                    <button type="submit" class="btn btn-success pull-right" name="submit" onclick="userLogin()">登录
                    button>
                div>
            div>
        div>
    div>
div>
body>
html>

启动项目,可以发现之前生成的license证书可以正常使用:

这时访问 http://127.0.0.1:7080/login ,可以正常登录:

重新生成license证书,并设置很短的有效期。
重新启动ClientDemo,并再次登录,可以发现爆以下提示信息:


至此,关于使用 TrueLicense 生成和验证License就结束了
转自大佬:Spring Boot项目中使用 TrueLicense 生成和验证License(服务器许可)

本文地址:https://www.vps345.com/4855.html

搜索文章

Tags

PV计算 带宽计算 流量带宽 服务器带宽 上行带宽 上行速率 什么是上行带宽? CC攻击 攻击怎么办 流量攻击 DDOS攻击 服务器被攻击怎么办 源IP 服务器 linux 运维 游戏 云计算 javascript 前端 chrome edge python MCP ssh llama 算法 opencv 自然语言处理 神经网络 语言模型 进程 操作系统 进程控制 Ubuntu harmonyos 华为 开发语言 typescript 计算机网络 ubuntu 数据库 centos oracle 关系型 安全 分布式 阿里云 网络 网络安全 网络协议 deepseek Ollama 模型联网 API CherryStudio RTSP xop RTP RTSPServer 推流 视频 udp unity php android 宝塔面板访问不了 宝塔面板网站访问不了 宝塔面板怎么配置网站能访问 宝塔面板配置ip访问 宝塔面板配置域名访问教程 宝塔面板配置教程 Dell R750XS vue.js audio vue音乐播放器 vue播放音频文件 Audio音频播放器自定义样式 播放暂停进度条音量调节快进快退 自定义audio覆盖默认样式 rust http java ssl 深度学习 YOLO 目标检测 计算机视觉 人工智能 fastapi mcp mcp-proxy mcp-inspector fastapi-mcp agent sse HCIE 数通 filezilla 无法连接服务器 连接被服务器拒绝 vsftpd 331/530 GaN HEMT 氮化镓 单粒子烧毁 辐射损伤 辐照效应 numpy macos adb 鸿蒙 c# Flask FastAPI Waitress Gunicorn uWSGI Uvicorn flutter Hyper-V WinRM TrustedHosts tcp/ip 面试 性能优化 jdk intellij-idea 架构 ide ai AI编程 物联网 iot golang 后端 pycharm windows websocket react.js 前端面试题 node.js 持续部署 redis mybatis oceanbase rc.local 开机自启 systemd 麒麟 Qwen2.5-coder 离线部署 chatgpt 大模型 llama3 Chatglm 开源大模型 计算机外设 电脑 mac 软件需求 ping++ 运维开发 conda 机器学习 c++ 深度优先 图论 并集查找 换根法 树上倍增 ollama llm 科技 个人开发 YOLOv12 docker 容器 ffmpeg 音视频 pip 嵌入式硬件 单片机 温湿度数据上传到服务器 Arduino HTTP WSL2 pytorch 开源 银河麒麟服务器操作系统 系统激活 微信 微信分享 Image wxopensdk 学习 负载均衡 uni-app 安装教程 GPU环境配置 Ubuntu22 CUDA PyTorch Anaconda安装 ESP32 豆瓣 追剧助手 迅雷 nas spring boot tomcat LDAP mysql aws googlecloud vscode 笔记 maven intellij idea Windsurf 实时音视频 经验分享 学习方法 nginx dubbo 监控 自动化运维 .netcore ollama下载加速 智能路由器 外网访问 内网穿透 端口映射 word图片自动上传 word一键转存 复制word图片 复制word图文 复制word公式 粘贴word图文 粘贴word公式 pillow jenkins gitee 大数据 大数据平台 .net github AI Agent django flask web3.py C 环境变量 进程地址空间 自动化 蓝耘科技 元生代平台工作流 ComfyUI 前端框架 jmeter 软件测试 DeepSeek-R1 API接口 僵尸进程 sqlserver live555 rtsp rtp json html5 firefox vim WSL win11 无法解析服务器的名称或地址 https apache 小程序 微信小程序域名配置 微信小程序服务器域名 微信小程序合法域名 小程序配置业务域名 微信小程序需要域名吗 微信小程序添加域名 web安全 Kali Linux 黑客 渗透测试 信息收集 vue3 HTML audio 控件组件 vue3 audio音乐播放器 Audio标签自定义样式默认 vue3播放音频文件音效音乐 自定义audio播放器样式 播放暂停调整声音大小下载文件 产品经理 agi microsoft cuda cudnn anaconda 微服务 springcloud 代码调试 ipdb asm 嵌入式 linux驱动开发 arm开发 创意 社区 cpu 内存 实时 使用 C语言 YOLOv8 NPU Atlas800 A300I pro asi_bench DigitalOcean GPU服务器购买 GPU服务器哪里有 GPU服务器 transformer c语言 qt stm32项目 stm32 debian PVE 指令 mq rabbitmq rocketmq kafka safari Mac 系统 系统架构 shell 磁盘监控 netty 部署 服务器配置 华为云 数据挖掘 r语言 数据可视化 ip命令 新增网卡 新增IP 启动网卡 dell服务器 go 代理模式 硬件架构 docker compose ceph docker命令大全 Trae AI代码编辑器 IIS .net core Hosting Bundle .NET Framework vs2022 5G 3GPP 卫星通信 XFS xfs文件系统损坏 I_O error es jvm 大语言模型 html file server http server web server 状态管理的 UDP 服务器 Arduino RTOS X11 Xming 集成学习 集成测试 驱动开发 mcu 生物信息学 openEuler dify 深度求索 私域 知识库 远程工作 Linux DNS minio zabbix ESXi 腾讯云 腾讯云大模型知识引擎 Deepseek mariadb Docker Hub docker pull 镜像源 daemon.json Ubuntu 24 常用命令 Ubuntu 24 Ubuntu vi 异常处理 职场和发展 gpu算力 交换机 硬件 设备 GPU PCI-Express 微信小程序 jetty undertow UOS 统信操作系统 yum LLM 大模型面经 大模型学习 报错 HarmonyOS Next DevEco Studio fpga开发 kubernetes k8s 编辑器 鸿蒙系统 WebUI DeepSeek V3 DeepSeek AI大模型 缓存 灵办AI kvm 图形化界面 信息与通信 ip 音乐服务器 Navidrome 音流 JAVA Java spring cloud threejs 3D kylin 智能手机 NAS Termux Samba efficientVIT YOLOv8替换主干网络 TOLOv8 Erlang OTP gen_server 热代码交换 事务语义 Dify jupyter 1024程序员节 wsl2 wsl 系统安全 hugo 远程桌面 GCC crosstool-ng 并查集 leetcode ruoyi Dell HPE 联想 浪潮 MQTT协议 消息服务器 代码 DeepSeek行业应用 Heroku 网站部署 java-ee 压力测试 测试工具 测试用例 功能测试 AIGC gpt linux上传下载 kind AI写作 AI作画 react next.js 部署next.js QQ 聊天室 webrtc prometheus 监控k8s集群 集群内prometheus VMware安装Ubuntu Ubuntu安装k8s 思科模拟器 思科 Cisco nuxt3 asp.net大文件上传 asp.net大文件上传源码 ASP.NET断点续传 asp.net上传文件夹 asp.net上传大文件 .net core断点续传 .net mvc断点续传 多层架构 解耦 virtualenv bash muduo 云原生 k8s集群资源管理 云原生开发 hadoop 其他 分析解读 服务器管理 宝塔面板 配置教程 服务器安装 网站管理 ansible playbook 剧本 eureka sql KingBase 博客 selete 高级IO 弹性计算 虚拟化 KVM 计算虚拟化 弹性裸金属 游戏程序 ros2 moveit 机器人运动 网站搭建 serv00 安全威胁分析 微信开放平台 微信公众平台 微信公众号配置 远程登录 telnet vscode 1.86 selenium MacMini 迷你主机 mini Apple grafana mongodb IPMI okhttp unix 小艺 Pura X wireshark 显示过滤器 安装 ICMP Wireshark安装 gitlab excel pygame 漏洞 unity3d 银河麒麟 kylin v10 麒麟 v10 网络穿透 云服务器 Nuxt.js spring SSH Xterminal 远程连接 低代码 ci/cd devops 裸金属服务器 弹性裸金属服务器 数据结构 express p2p Linux awk awk函数 awk结构 awk内置变量 awk参数 awk脚本 awk详解 postman mock mock server 模拟服务器 mock服务器 Postman内置变量 Postman随机数据 CORS 跨域 CPU 主板 电源 网卡 visual studio code Netty 即时通信 NIO VR手套 数据手套 动捕手套 动捕数据手套 机器人 半虚拟化 硬件虚拟化 Hypervisor 边缘计算 智能硬件 命名管道 客户端与服务端通信 IIS服务器 IIS性能 日志监控 micropython esp32 mqtt 能力提升 面试宝典 技术 IT信息化 av1 电视盒子 机顶盒ROM 魔百盒刷机 3d 数学建模 matlab git RAID RAID技术 磁盘 存储 华为od sqlite 田俊楠 MS Materials openssl 密码学 gateway Clion Nova ResharperC++引擎 Centos7 远程开发 业界资讯 模拟退火算法 code-server MQTT mosquitto 消息队列 远程 命令 执行 sshpass 操作 数据分析 计算机 程序员 postgresql pgpool 数据库系统 chrome devtools chromedriver C# MQTTS 双向认证 emqx Ubuntu DeepSeek DeepSeek Ubuntu DeepSeek 本地部署 DeepSeek 知识库 DeepSeek 私有化知识库 本地部署 DeepSeek DeepSeek 私有化部署 hibernate 课程设计 kamailio sip VoIP ArcTS 登录 ArcUI GridItem arkUI 政务 分布式系统 监控运维 Prometheus Grafana echarts 信息可视化 网页设计 jar gradle 框架搭建 tcpdump Cursor SSH 服务 SSH Server OpenSSH Server W5500 OLED u8g2 TCP服务器 remote-ssh chfs ubuntu 16.04 rust腐蚀 统信 国产操作系统 虚拟机安装 web 火绒安全 etcd 数据安全 RBAC 企业微信 Linux24.04 deepin 金融 爬虫 网络用户购物行为分析可视化平台 大数据毕业设计 程序人生 vSphere vCenter 软件定义数据中心 sddc RTMP 应用层 雨云 NPS protobuf 序列化和反序列化 孤岛惊魂4 小游戏 五子棋 恒源云 webstorm OD机试真题 华为OD机试真题 服务器能耗统计 传统数据库升级 银行 LLMs 强制清理 强制删除 mac废纸篓 软件工程 IPMITOOL BMC 硬件管理 opcua opcda KEPServer安装 oneapi 大模型微调 open webui docker搭建nacos详解 docker部署nacos docker安装nacos 腾讯云搭建nacos centos7搭建nacos ios nvidia springboot远程调试 java项目远程debug docker远程debug java项目远程调试 springboot远程 服务器数据恢复 数据恢复 存储数据恢复 北亚数据恢复 oracle数据恢复 pdf dba Ark-TS语言 VSCode 华为认证 网络工程师 多线程服务器 Linux网络编程 移动云 android studio mysql离线安装 ubuntu22.04 mysql8.0 springsecurity6 oauth2 授权服务器 token sas FTP 服务器 XCC Lenovo 混合开发 环境安装 JDK 虚拟机 VMware 繁忙 服务器繁忙 解决办法 替代网站 汇总推荐 AI推理 SSL 域名 rsyslog Anolis nginx安装 linux插件下载 elasticsearch 多进程 命令行 基础入门 编程 raid5数据恢复 磁盘阵列数据恢复 visualstudio list skynet centos-root /dev/mapper yum clean all df -h / du -sh 服务器部署ai模型 ecmascript VMware安装mocOS macOS系统安装 firewalld IDE AI 原生集成开发环境 Trae AI 数据集 硬件工程 嵌入式实习 nextjs reactjs RustDesk自建服务器 rustdesk服务器 docker rustdesk 黑客技术 流式接口 本地部署 api pyqt Kylin-Server EasyConnect gcc Cline open Euler dde 统信UOS Google pay Apple pay 目标跟踪 OpenVINO 推理应用 服务器主板 AI芯片 Ubuntu Server Ubuntu 22.04.5 交互 网工 opensearch helm 开机自启动 系统开发 binder 车载系统 framework 源码环境 搜索引擎 ssrf 失效的访问控制 WebRTC openwrt 飞牛NAS 飞牛OS MacBook Pro Portainer搭建 Portainer使用 Portainer使用详解 Portainer详解 Portainer portainer ux 多线程 cnn ue4 着色器 ue5 虚幻 adobe elk Python 网络编程 聊天服务器 套接字 TCP 客户端 Socket bot Docker xrdp Linux PID Reactor 设计模式 C++ string模拟实现 深拷贝 浅拷贝 经典的string类问题 三个swap 游戏服务器 TrinityCore 魔兽世界 群晖 文件分享 WebDAV NFS 雨云服务器 环境迁移 崖山数据库 YashanDB 源码剖析 rtsp实现步骤 流媒体开发 Ubuntu 24.04.1 轻量级服务器 redhat 毕设 进程信号 CLion 相差8小时 UTC 时间 iftop 网络流量监控 远程控制 远程看看 远程协助 银河麒麟操作系统 国产化 sqlite3 rpc 远程过程调用 Windows环境 make命令 makefile文件 图像处理 直播推流 技能大赛 ipython curl wget eNSP 网络规划 VLAN 企业网络 svn 串口服务器 linux环境变量 蓝桥杯 无桌面 安卓 gitea 媒体 risc-v 文件系统 路径解析 RoboVLM 通用机器人策略 VLA设计哲学 vlm fot robot 视觉语言动作模型 具身智能 springboot css 设置代理 实用教程 Invalid Host allowedHosts vue k8s资源监控 annotations自动化 自动化监控 监控service 监控jvm linux 命令 sed 命令 bootstrap ragflow bonding 链路聚合 mount挂载磁盘 wrong fs type LVM挂载磁盘 Centos7.9 Docker Compose docker-compose ecm bpm 压测 ECS 宕机切换 服务器宕机 Redis Desktop minicom 串口调试工具 TRAE Playwright 自动化测试 RAGFLOW RAG 检索增强生成 文档解析 大模型垂直应用 向日葵 数据库架构 数据管理 数据治理 数据编织 数据虚拟化 Minecraft ddos idm iDRAC R720xd freebsd zotero 同步失败 医疗APP开发 app开发 thingsboard 安全架构 历史版本 下载 网络结构图 yaml Ultralytics 可视化 前后端分离 etl 免费域名 域名解析 服务器无法访问 ip地址无法访问 无法访问宝塔面板 宝塔面板打不开 Linux环境 midjourney DocFlow FunASR ASR bug 佛山戴尔服务器维修 佛山三水服务器维修 嵌入式Linux IPC TrueLicense EMUI 回退 降级 升级 linux安装配置 arm Linux的权限 kali 共享文件夹 怎么卸载MySQL MySQL怎么卸载干净 MySQL卸载重新安装教程 MySQL5.7卸载 Linux卸载MySQL8.0 如何卸载MySQL教程 MySQL卸载与安装 Jellyfin 超融合 frp Spring Security 我的世界 我的世界联机 数码 监控k8s 监控kubernetes apt rdp 实验 我的世界服务器搭建 技术共享 王者荣耀 匿名管道 Wi-Fi c/c++ 串口 vpn SysBench 基准测试 用户缓冲区 模拟实现 Claude Linux的基础指令 支付 微信支付 开放平台 ArkTs ArkUI 单元测试 鲲鹏 昇腾 npu AnythingLLM AnythingLLM安装 eclipse ISO镜像作为本地源 游戏开发 composer 云电竞 云电脑 todesk 执法记录仪 智能安全帽 smarteye 链表 MNN Qwen 反向代理 DenseNet Mac内存不够用怎么办 ui 备份SQL Server数据库 数据库备份 傲梅企业备份网络版 CrewAI qemu libvirt edge浏览器 WebVM SenseVoice 流水线 脚本式流水线 can 线程池 中间件 pppoe radius tensorflow Kali 渗透 trae gaussdb dns是什么 如何设置电脑dns dns应该如何设置 版本 xss 在线预览 xlsx xls文件 在浏览器直接打开解析xls表格 前端实现vue3打开excel 文件地址url或接口文档流二进 USB网络共享 ocr IO模型 AI agent IM即时通讯 剪切板对通 HTML FORMAT 无人机 云服务 saltstack trea idea Radius npm ssh漏洞 ssh9.9p2 CVE-2025-23419 qt项目 qt项目实战 qt教程 uni-file-picker 拍摄从相册选择 uni.uploadFile H5上传图片 微信小程序上传图片 Cookie 国标28181 视频监控 监控接入 语音广播 流程 SIP SDP 矩阵 vmware 卡死 n8n 工作流 workflow 自动化编程 Ubuntu22.04 开发人员主页 算力 社交电子 高效远程协作 TrustViewer体验 跨设备操作便利 智能远程控制 ai小智 语音助手 ai小智配网 ai小智教程 esp32语音助手 diy语音助手 EMQX 通信协议 lsb_release /etc/issue /proc/version uname -r 查看ubuntu版本 VS Code 工业4.0 windwos防火墙 defender防火墙 win防火墙白名单 防火墙白名单效果 防火墙只允许指定应用上网 防火墙允许指定上网其它禁止 clickhouse 同步 备份 建站 阻塞队列 生产者消费者模型 服务器崩坏原因 laravel Linux无人智慧超市 LInux多线程服务器 QT项目 LInux项目 单片机项目 less 键盘 宠物 毕业设计 免费学习 宠物领养 宠物平台 直流充电桩 充电桩 IMX317 MIPI H265 VCU junit 小智AI服务端 xiaozhi TTS 小番茄C盘清理 便捷易用C盘清理工具 小番茄C盘清理的优势尽显何处? 教你深度体验小番茄C盘清理 C盘变红?!不知所措? C盘瘦身后电脑会发生什么变化? 显示管理器 lightdm gdm AD 域管理 线程 实战案例 perf rime hive DBeaver 数据仓库 kerberos AD域 camera Arduino 电子信息 minecraft 致远OA OA服务器 服务器磁盘扩容 tcp 产测工具框架 IMX6ULL 管理框架 SWAT 配置文件 服务管理 网络共享 游戏机 程序员创富 openstack Xen HTTP 服务器控制 ESP32 DeepSeek 毕昇JDK cfssl 备选 网站 调用 示例 银河麒麟桌面操作系统 Kylin OS vasp安装 查询数据库服务IP地址 SQL Server Typore 语音识别 7z AutoDL 输入法 策略模式 单例模式 Logstash 日志采集 远程服务 分布式训练 稳定性 看门狗 EtherNet/IP串口网关 EIP转RS485 EIP转Modbus EtherNet/IP网关协议 EIP转RS485网关 EIP串口服务器 keepalived ROS 自动驾驶 sonoma 自动更新 聚类 xshell termius iterm2 neo4j 数据库开发 database 华为机试 实时互动 mamba 虚拟局域网 AISphereButler xcode 服务网格 istio 银河麒麟高级服务器 外接硬盘 Kylin outlook prompt flink 根服务器 OpenSSH 交叉编译 回显服务器 UDP的API使用 gpt-3 文心一言 做raid 装系统 Java Applet URL操作 服务器建立 Socket编程 网络文件读取 大模型入门 大模型教程 可信计算技术 网络攻击模型 ukui 麒麟kylinos openeuler 显卡驱动 大模型应用 语法 序列化反序列化 IPv4 子网掩码 公网IP 私有IP ftp 主从复制 CVE-2024-7347 fd 文件描述符 VPS 内网服务器 内网代理 内网通信 人工智能生成内容 VM搭建win2012 win2012应急响应靶机搭建 攻击者获取服务器权限 上传wakaung病毒 应急响应并溯源 挖矿病毒处置 应急响应综合性靶场 rustdesk 需求分析 规格说明书 dns big data 图形渲染 飞书 Ubuntu共享文件夹 共享目录 Linux共享文件夹 黑苹果 uniapp ruby web3 sdkman P2P HDLC 单一职责原则 alias unalias 别名 双系统 GRUB引导 Linux技巧 飞牛 asp.net大文件上传下载 iis uv glibc 源码 spark HistoryServer Spark YARN jobhistory Headless Linux regedit 开机启动 xml CDN 京东云 embedding 软负载 AI-native Docker Desktop 软件构建 自定义客户端 SAS 影刀 #影刀RPA# Hive环境搭建 hive3环境 Hive远程模式 僵尸世界大战 游戏服务器搭建 虚拟显示器 webgl cmos zookeeper AP配网 AK配网 小程序AP配网和AK配网教程 WIFI设备配网小程序UDP开 nfs 阿里云ECS 重启 排查 系统重启 日志 原因 LORA NLP flash-attention v10 软件 ldap armbian u-boot 实习 rnn c ros arcgis URL 项目部署到linux服务器 项目部署过程 banner seatunnel g++ g++13 epoll 迁移指南 pyautogui LLM Web APP Streamlit cpp-httplib rag ragflow 源码启动 移动魔百盒 运维监控 MI300x GoogLeNet USB转串口 CH340 vscode1.86 1.86版本 ssh远程连接 SSE 邮件APP 免费软件 代理 Vmamba SRS 流媒体 直播 本地部署AI大模型 开发环境 SSL证书 LInux sysctl.conf vm.nr_hugepages 视觉检测 docker run 数据卷挂载 交互模式 性能测试 DeepSeek r1 Open WebUI odoo 服务器动作 Server action cd 目录切换 VMware创建虚拟机 OpenManus python3.11 tidb GLIBC 视频编解码 宝塔 自学笔记 小米 澎湃OS Android 高效日志打印 串口通信日志 服务器日志 系统状态监控日志 异常记录日志 iphone miniapp 真机调试 调试 debug 断点 网络API请求调试方法 国内源 DIFY 代码托管服务 RAGFlow 本地知识库部署 DeepSeek R1 模型 sentinel 游戏引擎 wordpress 无法访问wordpess后台 打开网站页面错乱 linux宝塔面板 wordpress更换服务器 bat swoole 三级等保 服务器审计日志备份 FTP服务器 软考 架构与原理 联想开天P90Z装win10 多个客户端访问 IO多路复用 TCP相关API 干货分享 黑客工具 密码爆破 信号处理 权限 MacOS录屏软件 tailscale derp derper 中转 triton 模型分析 线性代数 电商平台 大文件分片上传断点续传及进度条 如何批量上传超大文件并显示进度 axios大文件切片上传详细教 node服务器合并切片 vue3大文件上传报错提示错误 大文件秒传跨域报错cors 自动化任务管理 互信 C++软件实战问题排查经验分享 0xfeeefeee 0xcdcdcdcd 动态库加载失败 程序启动失败 程序运行权限 标准用户权限与管理员权限 easyui langchain IDEA 上传视频至服务器代码 vue3批量上传多个视频并预览 如何实现将本地视频上传到网页 element plu视频上传 ant design vue vue3本地上传视频及预览移除 iBMC UltraISO 串口驱动 CH341 uart 485 rclone AList webdav fnOS lua 飞牛nas fnos vue-i18n 国际化多语言 vue2中英文切换详细教程 如何动态加载i18n语言包 把语言json放到服务器调用 前端调用api获取语言配置文件 log4j cursor MCP server C/S windows日志 yum源切换 更换国内yum源 nac 802.1 portal DOIT 四博智联 EtherCAT转Modbus ECT转Modbus协议 EtherCAT转485网关 ECT转Modbus串口网关 EtherCAT转485协议 ECT转Modbus网关 Unity Dedicated Server Host Client 无头主机 端口测试 音乐库 matplotlib H3C vr bcompare Beyond Compare 模拟器 教程 常用命令 文本命令 目录命令 安防软件 Unity插件 iventoy VmWare OpenEuler css3 云桌面 微软 AD域控 证书服务器 perl gnu 李心怡 浏览器自动化 多端开发 智慧分发 应用生态 鸿蒙OS UDP 加解密 Yakit yaklang Python基础 Python教程 Python技巧 中兴光猫 换光猫 网络桥接 自己换光猫 WLAN jina 带外管理 流量运营 服务器时间 PX4 zip unzip 软链接 硬链接 MacOS 换源 Debian 大模型推理 cocoapods 基础环境 网络爬虫 开发 元服务 应用上架 yolov8 llama.cpp word 问题解决 ubuntu24 vivado24 deekseek 网络药理学 生信 gromacs 分子动力学模拟 MD 动力学模拟 ubuntu24.04.1 kotlin ssh远程登录 虚幻引擎 virtualbox kernel 浏览器开发 AI浏览器 个人博客 su sudo 状态模式 fast 烟花代码 烟花 元旦 rtsp服务器 rtsp server android rtsp服务 安卓rtsp服务器 移动端rtsp服务 大牛直播SDK 性能调优 安全代理 信号 嵌入式系统开发 云耀服务器 HAProxy wps 物联网开发 grub 版本升级 扩容 磁盘清理 powerpoint hexo dity make ShenTong SEO 代理服务器 searxng PPI String Cytoscape CytoHubba Docker引擎已经停止 Docker无法使用 WSL进度一直是0 镜像加速地址 磁盘镜像 服务器镜像 服务器实时复制 实时文件备份 抗锯齿 极限编程 拓扑图 知识图谱 firewall TCP协议 milvus QT 5.12.12 QT开发环境 Ubuntu18.04 MVS 海康威视相机 x64 SIGSEGV xmm0 SVN Server tortoise svn 大模型部署 程序 性能分析 proxy模式 查看显卡进程 fuser ArtTS ABAP Windows 强化学习 MDK 嵌入式开发工具 论文笔记 sublime text onlyoffice 在线office 存储维护 NetApp存储 EMC存储 企业网络规划 华为eNSP 合成模型 扩散模型 图像生成 nvm whistle CentOS 容器技术 SSH 密钥生成 SSH 公钥 私钥 生成 HarmonyOS OpenHarmony 镜像 鸿蒙开发 移动开发 捆绑 链接 谷歌浏览器 youtube google gmail docker搭建pg docker搭建pgsql pg授权 postgresql使用 postgresql搭建 iperf3 带宽测试 sequoiaDB autodl seleium 对比 工具 meld DiffMerge IMM prometheus数据采集 prometheus数据模型 prometheus特点 相机 智能音箱 智能家居 wpf lio-sam SLAM hosts 项目部署 推荐算法 Qwen2.5-VL vllm Node-Red 编程工具 流编程 wsgiref Web 服务器网关接口 本地化部署 考研 玩机技巧 软件分享 软件图标 大大通 第三代半导体 碳化硅 端口 查看 ss ardunio BLE 沙盒 deployment daemonset statefulset cronjob ai工具 java-rocketmq chrome 浏览器下载 chrome 下载安装 谷歌浏览器下载 读写锁 私有化 AI Agent 字节智能运维 办公自动化 自动化生成 pdf教程 GIS 遥感 WebGIS h.264 HarmonyOS NEXT 原生鸿蒙 MySql 计算生物学 生物信息 基因组 内网环境 figma 网卡的名称修改 eth0 ens33 fstab harmonyOS面试题 win服务器架设 windows server 端口聚合 windows11 top Linux top top命令详解 top命令重点 top常用参数 ubuntu20.04 ros1 Noetic 20.04 apt 安装 Linux find grep 钉钉 react native deepseek r1 db 抓包工具 System V共享内存 进程通信 dash 正则表达式 NLP模型 UOS1070e HiCar CarLife+ CarPlay QT RK3588 信创 信创终端 中科方德 docker desktop image 粘包问题 网络建设与运维 xpath定位元素 环境配置 navicat deep learning docker部署翻译组件 docker部署deepl docker搭建deepl java对接deepl 翻译组件使用 visual studio ranger MySQL8.0 KylinV10 麒麟操作系统 Vmware nlp Attention aarch64 编译安装 HPC Deepseek-R1 私有化部署 推理模型 健康医疗 互联网医院 防火墙 NAT转发 NAT Server Xinference 树莓派 VNC 软件卸载 系统清理 金仓数据库 2025 征文 数据库平替用金仓 域名服务 DHCP 符号链接 配置 Linux权限 权限命令 特殊权限 docker部署Python WSL2 上安装 Ubuntu yum换源 开机黑屏 vu大文件秒传跨域报错cors 增强现实 沉浸式体验 应用场景 技术实现 案例分析 AR Sealos 论文阅读 MAVROS 四旋翼无人机 风扇控制软件 rancher 网络搭建 神州数码 神州数码云平台 云平台 上传视频文件到服务器 uniApp本地上传视频并预览 uniapp移动端h5网页 uniapp微信小程序上传视频 uniapp app端视频上传 uniapp uview组件库 ip协议 安装MySQL 通信工程 毕业 conda配置 conda镜像源 数字证书 签署证书 热榜 智能电视 离线部署dify dock 加速 js macOS AI员工 服务器正确解析请求体 IO 西门子PLC 通讯 mm-wiki搭建 linux搭建mm-wiki mm-wiki搭建与使用 mm-wiki使用 mm-wiki详解 nosql 英语 MobaXterm k8s二次开发 集群管理 rpa 搜狗输入法 中文输入法 达梦 DM8 CentOS Stream 搭建个人相关服务器 接口优化 yolov5 多路转接 欧标 OCPP 解决方案