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

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

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

一,简介

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