{"id":49496,"date":"2025-07-30T18:43:48","date_gmt":"2025-07-30T10:43:48","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/49496.html"},"modified":"2025-07-30T18:43:48","modified_gmt":"2025-07-30T10:43:48","slug":"%e4%bb%8e%e9%9b%b6%e5%bc%80%e5%a7%8b%e5%ae%9e%e7%8e%b0-java-%e7%a8%8b%e5%ba%8f-license-%e9%aa%8c%e8%af%81%e7%b3%bb%e7%bb%9f%ef%bc%88%e9%99%84%e5%ae%8c%e6%95%b4%e4%bb%a3%e7%a0%81%e4%b8%8e%e5%ae%9e","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/49496.html","title":{"rendered":"\u4ece\u96f6\u5f00\u59cb\u5b9e\u73b0 Java \u7a0b\u5e8f License \u9a8c\u8bc1\u7cfb\u7edf\uff08\u9644\u5b8c\u6574\u4ee3\u7801\u4e0e\u5b9e\u64cd\u6307\u5357\uff09"},"content":{"rendered":"<h3 style=\"margin-left:0pt;text-align:left\"><span style=\"color:#000000\">\u524d\u8a00<\/span><\/h3>\n<p style=\"text-align:start\"><span style=\"color:#000000\">\u6700\u8fd1\u81ea\u5df1\u5728\u505a\u4e00\u6b3e\u7528\u6237\u5bf9\u4e8e\u5b89\u5168\u6027\u8981\u6c42\u5f88\u9ad8\u7684\u5de5\u5177\u8f6f\u4ef6\uff0c\u7ed3\u5408\u5b9e\u9645\u5de5\u7a0b\u7ecf\u9a8c\u505a\u4e00\u4e0b\u5206\u4eab\u3002\u6bd5\u7adf\u5728\u8f6f\u4ef6\u5f00\u53d1\u4e2d\uff0c\u4e3a\u4e86\u4fdd\u62a4\u77e5\u8bc6\u4ea7\u6743\u3001\u63a7\u5236\u8f6f\u4ef6\u4f7f\u7528\u6743\u9650\uff0cLicense&nbsp;\u9a8c\u8bc1\u7cfb\u7edf\u662f\u5e38\u89c1\u7684\u6280\u672f\u624b\u6bb5\u3002\u672c\u6587\u5c06\u4ee5\u5355\u673a&nbsp;Java&nbsp;\u7a0b\u5e8f\u4e3a\u4f8b\uff0c\u8be6\u7ec6\u8bb2\u89e3\u5982\u4f55\u5b9e\u73b0\u4e00\u5957\u5b8c\u6574\u7684&nbsp;License&nbsp;\u9a8c\u8bc1\u7cfb\u7edf\uff0c\u6db5\u76d6RSA&nbsp;\u975e\u5bf9\u79f0\u52a0\u5bc6\u3001AES&nbsp;\u5bf9\u79f0\u52a0\u5bc6\u3001\u786c\u4ef6\u7ed1\u5b9a\u3001\u6709\u6548\u671f\u6821\u9a8c\u7b49\u6838\u5fc3\u529f\u80fd\uff0c\u4e14\u539f\u7406\u540c\u6837\u9002\u7528\u4e8e&nbsp;BS&nbsp;\u67b6\u6784\u7a0b\u5e8f\uff08\u6587\u672b\u4f1a\u8bf4\u660e&nbsp;BS&nbsp;\u573a\u666f\u7684\u9002\u914d\u65b9\u6cd5\uff09\u3002<\/span><\/p>\n<p style=\"text-align:start\"><span style=\"color:#000000\">\u901a\u8fc7\u672c\u6587\uff0c\u4f60\u5c06\u5b66\u4f1a\uff1a<\/span><\/p>\n<li>\u751f\u6210&nbsp;RSA&nbsp;\u516c\u79c1\u94a5\u5bf9<\/li>\n<li>\u83b7\u53d6\u673a\u5668\u552f\u4e00\u786c\u4ef6\u6807\u8bc6\uff08\u9632\u7be1\u6539\uff09<\/li>\n<li>\u751f\u6210\u5e26\u6709\u6548\u671f\u548c\u786c\u4ef6\u7ed1\u5b9a\u7684&nbsp;License<\/li>\n<li>\u52a0\u5bc6\u5b58\u50a8&nbsp;License&nbsp;\u914d\u7f6e\u6587\u4ef6<\/li>\n<li>\u7a0b\u5e8f\u542f\u52a8\u65f6\u9a8c\u8bc1&nbsp;License&nbsp;\u6709\u6548\u6027<\/li>\n<h3 style=\"margin-left:0pt;text-align:left\"><span style=\"color:#000000\">\u4e00\u3001\u7cfb\u7edf\u67b6\u6784\u4e0e\u6838\u5fc3\u539f\u7406<\/span><\/h3>\n<h4 style=\"margin-left:0pt;text-align:left\"><span style=\"color:#000000\">1.1&nbsp;\u6574\u4f53\u6d41\u7a0b\u6982\u89c8<\/span><\/h4>\n<p style=\"text-align:start\"><span style=\"color:#000000\">License&nbsp;\u9a8c\u8bc1\u7cfb\u7edf\u7684\u6838\u5fc3\u662f&nbsp;\u201c\u5148\u52a0\u5bc6\u751f\u6210\uff0c\u540e\u89e3\u5bc6\u9a8c\u8bc1\u201d\uff0c\u5982\u4e0b\uff1a<\/span><\/p>\n<p style=\"text-align:start\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"388\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730104347-6889f76347937.png\" width=\"1310\"><\/p>\n<h4 style=\"margin-left:0pt;text-align:left\"><span style=\"color:#000000\">1.2&nbsp;\u6838\u5fc3\u52a0\u5bc6\u6280\u672f<\/span><\/h4>\n<ul>\n<li>RSA&nbsp;\u975e\u5bf9\u79f0\u52a0\u5bc6\uff1a\u5f00\u53d1\u8005\u6301\u6709\u79c1\u94a5\uff08\u751f\u6210&nbsp;License\uff09\uff0c\u7a0b\u5e8f\u6301\u6709\u516c\u94a5\uff08\u9a8c\u8bc1&nbsp;License\uff09\u3002\u79c1\u94a5\u52a0\u5bc6\u7684\u5185\u5bb9\u53ea\u80fd\u7528\u516c\u94a5\u89e3\u5bc6\uff0c\u786e\u4fdd&nbsp;License&nbsp;\u65e0\u6cd5\u88ab\u4f2a\u9020\u3002<\/li>\n<li>AES&nbsp;\u5bf9\u79f0\u52a0\u5bc6\uff1a\u7528\u4e8e\u52a0\u5bc6\u5b58\u50a8&nbsp;License&nbsp;\u914d\u7f6e\u6587\u4ef6\uff08\u516c\u94a5&nbsp;+&nbsp;\u52a0\u5bc6&nbsp;License\uff09\uff0c\u907f\u514d\u660e\u6587\u66b4\u9732\u3002AES&nbsp;\u5bc6\u94a5\u901a\u8fc7\u73af\u5883\u53d8\u91cf\u4f20\u9012\uff08\u4e0d\u786c\u7f16\u7801\uff09\uff0c\u63d0\u5347\u5b89\u5168\u6027\u3002<\/li>\n<li>\u786c\u4ef6\u7ed1\u5b9a\uff1a\u901a\u8fc7\u6536\u96c6\u673a\u5668\u7684&nbsp;MAC&nbsp;\u5730\u5740\u3001CPU&nbsp;\u5e8f\u5217\u53f7\u7b49\u552f\u4e00\u6807\u8bc6\uff0c\u786e\u4fdd&nbsp;License&nbsp;\u4ec5\u80fd\u5728\u6307\u5b9a\u673a\u5668\u8fd0\u884c\u3002<\/li>\n<\/ul>\n<h3 style=\"margin-left:0pt;text-align:left\"><span style=\"color:#000000\">\u4e8c\u3001\u6838\u5fc3\u4ee3\u7801\u5b9e\u73b0\uff08\u9644\u5b8c\u6574\u7c7b\uff09<\/span><\/h3>\n<h4 style=\"margin-left:0pt;text-align:left\"><span style=\"color:#000000\">2.1 License&nbsp;\u6838\u5fc3\u5de5\u5177\u7c7b\uff08LicenseUtils.java\uff09<\/span><\/h4>\n<p style=\"text-align:start\"><span style=\"color:#000000\">\u8d1f\u8d23\u751f\u6210&nbsp;RSA&nbsp;\u5bc6\u94a5\u5bf9\u3001\u751f\u6210&nbsp;License\u3001\u9a8c\u8bc1&nbsp;License\uff0c\u4ee5\u53ca\u83b7\u53d6\u786c\u4ef6\u4fe1\u606f\u3002<\/span><\/p>\n<table cellspacing=\"0\" style=\"margin-left:-0.6pt\">\n<tbody>\n<tr>\n<td style=\"background-color:#f5f6f7;border-color:#dee0e3;width:766.796875px\">\n<p>import javax.crypto.BadPaddingException;<\/p>\n<p>import javax.crypto.Cipher;<\/p>\n<p>import javax.crypto.IllegalBlockSizeException;<\/p>\n<p>import java.io.IOException;<\/p>\n<p>import java.net.NetworkInterface;<\/p>\n<p>import java.nio.charset.StandardCharsets;<\/p>\n<p>import java.security.*;<\/p>\n<p>import java.security.spec.PKCS8EncodedKeySpec;<\/p>\n<p>import java.security.spec.X509EncodedKeySpec;<\/p>\n<p>import java.time.LocalDate;<\/p>\n<p>import java.time.format.DateTimeFormatter;<\/p>\n<p>import java.util.*;<\/p>\n<p>import java.util.List;<\/p>\n<p>public class LicenseUtils {\n     <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;\/\/ RSA\u7b97\u6cd5\u5e38\u91cf<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;private static final String RSA_ALGORITHM = \\&#8221;RSA\\&#8221;;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;\u65e5\u671f\u683c\u5f0f\uff08\u4e25\u683cISO\u6807\u51c6\uff1ayyyy-MM-dd\uff09<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ISO_LOCAL_DATE;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;\/**<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;\u751f\u6210RSA\u516c\u79c1\u94a5\u5bf9\uff082048\u4f4d\uff09<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*\/<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;public static KeyPair generateRsaKeyPair() throws NoSuchAlgorithmException {\n     <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance(RSA_ALGORITHM);<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;keyPairGen.initialize(2048); \/\/ 2048\u4f4d\u5bc6\u94a5\uff0c\u8db3\u591f\u5b89\u5168<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return keyPairGen.generateKeyPair();<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;\/**<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;\u751f\u6210License\uff08\u79c1\u94a5\u52a0\u5bc6\uff09<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* @param privateKeyBase64&nbsp;\u79c1\u94a5\uff08Base64\u7f16\u7801\uff09<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* @param expireDate&nbsp;\u6709\u6548\u671f\uff08\u683c\u5f0f\uff1ayyyy-MM-dd\uff09<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* @param hardwareInfo&nbsp;\u786c\u4ef6\u4fe1\u606f\uff08\u673a\u5668\u552f\u4e00\u6807\u8bc6\uff09<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*\/<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;public static String generateLicense(String privateKeyBase64, String expireDate, String hardwareInfo) throws Exception {\n     <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;\u9a8c\u8bc1\u65e5\u671f\u683c\u5f0f<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LocalDate.parse(expireDate, DATE_FORMATTER);&nbsp;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;\u62fc\u63a5License\u5185\u5bb9\uff1a\u6709\u6548\u671f|\u786c\u4ef6\u4fe1\u606f\uff08\u7528|\u5206\u9694\uff09<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String licenseContent = String.format(\\&#8221;%s|%s\\&#8221;, expireDate, hardwareInfo);<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;\u79c1\u94a5\u89e3\u5bc6<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PrivateKey privateKey = getPrivateKey(privateKeyBase64);<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cipher cipher = Cipher.getInstance(RSA_ALGORITHM);<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cipher.init(Cipher.ENCRYPT_MODE, privateKey);<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;byte[] encrypted = cipher.doFinal(licenseContent.getBytes(StandardCharsets.UTF_8));<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return Base64.getEncoder().encodeToString(encrypted);<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;\/**<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;\u9a8c\u8bc1License\uff08\u516c\u94a5\u89e3\u5bc6+\u6709\u6548\u6027\u68c0\u67e5\uff09<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* @param publicKeyBase64&nbsp;\u516c\u94a5\uff08Base64\u7f16\u7801\uff09<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* @param encryptedLicense&nbsp;\u52a0\u5bc6\u7684License\uff08Base64\u7f16\u7801\uff09<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*\/<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;public static boolean verifyLicense(String publicKeyBase64, String encryptedLicense) throws Exception {\n     <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;\u516c\u94a5\u89e3\u5bc6<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PublicKey publicKey = getPublicKey(publicKeyBase64);<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;byte[] encryptedBytes = Base64.getDecoder().decode(encryptedLicense);<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String licenseContent;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try {\n     <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cipher cipher = Cipher.getInstance(RSA_ALGORITHM);<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cipher.init(Cipher.DECRYPT_MODE, publicKey);<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;licenseContent = new String(cipher.doFinal(encryptedBytes), StandardCharsets.UTF_8);<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch (IllegalBlockSizeException | BadPaddingException e) {\n     <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw new SecurityException(\\&#8221;License\u89e3\u5bc6\u5931\u8d25\uff08\u53ef\u80fd\u88ab\u7be1\u6539\uff09\\&#8221;);<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;\u89e3\u6790License\u5185\u5bb9\uff08\u6709\u6548\u671f|\u786c\u4ef6\u4fe1\u606f\uff09<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String[] parts = licenseContent.split(\\&#8221;\\\\\\\\|\\&#8221;);<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (parts.length != 2) {\n     <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw new IllegalArgumentException(\\&#8221;License\u683c\u5f0f\u9519\u8bef\uff0c\u9884\u671f\uff1a\u6709\u6548\u671f|\u786c\u4ef6\u4fe1\u606f\uff0c\u5b9e\u9645\uff1a\\&#8221; + licenseContent);<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;\u68c0\u67e5\u6709\u6548\u671f<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LocalDate expireDate = LocalDate.parse(parts[0], DATE_FORMATTER);<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (LocalDate.now().isAfter(expireDate)) {\n     <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw new SecurityException(\\&#8221;License\u5df2\u8fc7\u671f\uff08\u6709\u6548\u671f\u81f3\uff1a\\&#8221; + parts[0] + \\&#8221;\uff09\\&#8221;);<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;\u68c0\u67e5\u786c\u4ef6\u4fe1\u606f<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String currentHardware = getHardwareInfo();<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!currentHardware.equals(parts[1])) {\n     <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw new SecurityException(\\&#8221;\u786c\u4ef6\u4fe1\u606f\u4e0d\u5339\u914d\uff08\u5f53\u524d\uff1a\\&#8221; + currentHardware + \\&#8221;\uff0c\u6ce8\u518c\uff1a\\&#8221; + parts[1] + \\&#8221;\uff09\\&#8221;);<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return true;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;\/**<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;\u83b7\u53d6\u673a\u5668\u786c\u4ef6\u4fe1\u606f\uff08MAC\u5730\u5740+CPU\/\u4e3b\u677f\u5e8f\u5217\u53f7\uff09<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*\/<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;public static String getHardwareInfo() throws IOException {\n     <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;List&lt;String&gt; identifiers = new ArrayList&lt;&gt;();<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ 1.&nbsp;\u83b7\u53d6\u6240\u6709\u975e\u73af\u56de\u7f51\u5361\u7684MAC\u5730\u5740<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try {\n     <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String mac = getMacAddress();<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!mac.isEmpty()) identifiers.add(mac);<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch (Exception e) {\n     <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.err.println(\\&#8221;\u83b7\u53d6MAC\u5730\u5740\u5931\u8d25\uff1a\\&#8221; + e.getMessage());<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ 2.&nbsp;\u83b7\u53d6CPU\/\u4e3b\u677f\u5e8f\u5217\u53f7\uff08\u8de8\u5e73\u53f0\uff09<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try {\n     <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String serial = getHardwareSerial();<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!serial.isEmpty()) identifiers.add(serial);<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch (Exception e) {\n     <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.err.println(\\&#8221;\u83b7\u53d6\u786c\u4ef6\u5e8f\u5217\u53f7\u5931\u8d25\uff1a\\&#8221; + e.getMessage());<\/p>\n<p>&nbsp;&amp;nbs<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb818\u6b21\uff0c\u70b9\u8d5e10\u6b21\uff0c\u6536\u85cf17\u6b21\u3002\u901a\u8fc7\u672c\u6587\u7684\u5b9e\u8df5\uff0c\u4f60\u5df2\u7ecf\u638c\u63e1\u4e86\u4e00\u5957\u5b8c\u6574\u7684 Java \u7a0b\u5e8f License \u9a8c\u8bc1\u7cfb\u7edf\u7684\u5b9e\u73b0\u65b9\u6cd5\uff0c\u6db5\u76d6\u5bc6\u94a5\u751f\u6210\u3001\u786c\u4ef6\u7ed1\u5b9a\u3001\u52a0\u5bc6\u5b58\u50a8\u3001\u542f\u52a8\u9a8c\u8bc1\u7b49\u6838\u5fc3\u529f\u80fd\u3002_java\u5b9e\u73b0license\u8ba4\u8bc1<\/p>\n","protected":false},"author":2,"featured_media":49495,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[99,190,2709],"topic":[],"class_list":["post-49496","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-java","tag-190","tag-2709"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4ece\u96f6\u5f00\u59cb\u5b9e\u73b0 Java \u7a0b\u5e8f License \u9a8c\u8bc1\u7cfb\u7edf\uff08\u9644\u5b8c\u6574\u4ee3\u7801\u4e0e\u5b9e\u64cd\u6307\u5357\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/49496.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4ece\u96f6\u5f00\u59cb\u5b9e\u73b0 Java \u7a0b\u5e8f License \u9a8c\u8bc1\u7cfb\u7edf\uff08\u9644\u5b8c\u6574\u4ee3\u7801\u4e0e\u5b9e\u64cd\u6307\u5357\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb818\u6b21\uff0c\u70b9\u8d5e10\u6b21\uff0c\u6536\u85cf17\u6b21\u3002\u901a\u8fc7\u672c\u6587\u7684\u5b9e\u8df5\uff0c\u4f60\u5df2\u7ecf\u638c\u63e1\u4e86\u4e00\u5957\u5b8c\u6574\u7684 Java \u7a0b\u5e8f License \u9a8c\u8bc1\u7cfb\u7edf\u7684\u5b9e\u73b0\u65b9\u6cd5\uff0c\u6db5\u76d6\u5bc6\u94a5\u751f\u6210\u3001\u786c\u4ef6\u7ed1\u5b9a\u3001\u52a0\u5bc6\u5b58\u50a8\u3001\u542f\u52a8\u9a8c\u8bc1\u7b49\u6838\u5fc3\u529f\u80fd\u3002_java\u5b9e\u73b0license\u8ba4\u8bc1\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/49496.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-07-30T10:43:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730104347-6889f76347937.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/49496.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/49496.html\",\"name\":\"\u4ece\u96f6\u5f00\u59cb\u5b9e\u73b0 Java \u7a0b\u5e8f License \u9a8c\u8bc1\u7cfb\u7edf\uff08\u9644\u5b8c\u6574\u4ee3\u7801\u4e0e\u5b9e\u64cd\u6307\u5357\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-07-30T10:43:48+00:00\",\"dateModified\":\"2025-07-30T10:43:48+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/49496.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/49496.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/49496.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4ece\u96f6\u5f00\u59cb\u5b9e\u73b0 Java \u7a0b\u5e8f License \u9a8c\u8bc1\u7cfb\u7edf\uff08\u9644\u5b8c\u6574\u4ee3\u7801\u4e0e\u5b9e\u64cd\u6307\u5357\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u4ece\u96f6\u5f00\u59cb\u5b9e\u73b0 Java \u7a0b\u5e8f License \u9a8c\u8bc1\u7cfb\u7edf\uff08\u9644\u5b8c\u6574\u4ee3\u7801\u4e0e\u5b9e\u64cd\u6307\u5357\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/49496.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4ece\u96f6\u5f00\u59cb\u5b9e\u73b0 Java \u7a0b\u5e8f License \u9a8c\u8bc1\u7cfb\u7edf\uff08\u9644\u5b8c\u6574\u4ee3\u7801\u4e0e\u5b9e\u64cd\u6307\u5357\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb818\u6b21\uff0c\u70b9\u8d5e10\u6b21\uff0c\u6536\u85cf17\u6b21\u3002\u901a\u8fc7\u672c\u6587\u7684\u5b9e\u8df5\uff0c\u4f60\u5df2\u7ecf\u638c\u63e1\u4e86\u4e00\u5957\u5b8c\u6574\u7684 Java \u7a0b\u5e8f License \u9a8c\u8bc1\u7cfb\u7edf\u7684\u5b9e\u73b0\u65b9\u6cd5\uff0c\u6db5\u76d6\u5bc6\u94a5\u751f\u6210\u3001\u786c\u4ef6\u7ed1\u5b9a\u3001\u52a0\u5bc6\u5b58\u50a8\u3001\u542f\u52a8\u9a8c\u8bc1\u7b49\u6838\u5fc3\u529f\u80fd\u3002_java\u5b9e\u73b0license\u8ba4\u8bc1","og_url":"https:\/\/www.wsisp.com\/helps\/49496.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-07-30T10:43:48+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250730104347-6889f76347937.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/49496.html","url":"https:\/\/www.wsisp.com\/helps\/49496.html","name":"\u4ece\u96f6\u5f00\u59cb\u5b9e\u73b0 Java \u7a0b\u5e8f License \u9a8c\u8bc1\u7cfb\u7edf\uff08\u9644\u5b8c\u6574\u4ee3\u7801\u4e0e\u5b9e\u64cd\u6307\u5357\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-07-30T10:43:48+00:00","dateModified":"2025-07-30T10:43:48+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/49496.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/49496.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/49496.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u4ece\u96f6\u5f00\u59cb\u5b9e\u73b0 Java \u7a0b\u5e8f License \u9a8c\u8bc1\u7cfb\u7edf\uff08\u9644\u5b8c\u6574\u4ee3\u7801\u4e0e\u5b9e\u64cd\u6307\u5357\uff09"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/49496","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=49496"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/49496\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/49495"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=49496"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=49496"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=49496"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=49496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}