|
|
|
|
@ -22,6 +22,8 @@ public class LPLicense {
|
|
|
|
|
|
|
|
|
|
private static String CPU_INFO = null;
|
|
|
|
|
|
|
|
|
|
private static String DISK_INFO = null;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 初始的时候创建
|
|
|
|
|
*/
|
|
|
|
|
@ -30,7 +32,9 @@ public class LPLicense {
|
|
|
|
|
if(!file.exists()){
|
|
|
|
|
String cpu = getCpuInfo();
|
|
|
|
|
CPU_INFO = cpu;
|
|
|
|
|
FileUtil.save(cpu,key_path);
|
|
|
|
|
String disk = getDiskInfo();
|
|
|
|
|
DISK_INFO = disk;
|
|
|
|
|
FileUtil.save(cpu+disk,key_path);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -44,7 +48,22 @@ public class LPLicense {
|
|
|
|
|
String cpu = sc.next();
|
|
|
|
|
return cpu;
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
log.error("createLicKeyIfNotExist error:{}",e);
|
|
|
|
|
log.error("GET CPU error:{}",e);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static String getDiskInfo(){
|
|
|
|
|
try {
|
|
|
|
|
Process process = Runtime.getRuntime().exec(
|
|
|
|
|
new String[] { "wmic","diskdrive","where","index=0", "get", "serialnumber"});
|
|
|
|
|
process.getOutputStream().close();
|
|
|
|
|
Scanner sc = new Scanner(process.getInputStream());
|
|
|
|
|
String property = sc.next();
|
|
|
|
|
String disk = sc.next();
|
|
|
|
|
return disk;
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
log.error("Get DISK error:{}",e);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -55,12 +74,13 @@ public class LPLicense {
|
|
|
|
|
lastUpdate = LocalDateTime.now();
|
|
|
|
|
lic_str = FileUtil.getText(lic_path);
|
|
|
|
|
CPU_INFO = getCpuInfo();
|
|
|
|
|
DISK_INFO = getDiskInfo();
|
|
|
|
|
}
|
|
|
|
|
return lic_str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean checkLic(String licStr){
|
|
|
|
|
return CPU_INFO != null && licStr.equals(encryptor.Encryptor.encryptStr(CPU_INFO));
|
|
|
|
|
return CPU_INFO != null && DISK_INFO != null && licStr.equals(encryptor.Encryptor.encryptStr(CPU_INFO+DISK_INFO));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean checkLic(){
|
|
|
|
|
|