调整生成c2v方式getInfo
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package com.sentinel.license.utils;
|
||||
import Aladdin.Hasp;
|
||||
import Aladdin.HaspStatus;
|
||||
import cn.hutool.core.util.XmlUtil;
|
||||
import cn.hutool.log.Log;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
|
||||
public class HaspUtil {
|
||||
@@ -31,6 +33,13 @@ public class HaspUtil {
|
||||
|
||||
protected final static String KEY_C2V_FORMAT = "<haspformat format=\"updateinfo\"/>";
|
||||
|
||||
protected final static String KEY_ID_FORMAT = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
|
||||
"<haspformat root=\"haspscope\">\n" +
|
||||
" <hasp>\n" +
|
||||
" <attribute name=\"id\" />\n" +
|
||||
" </hasp>\n" +
|
||||
"</haspformat>";
|
||||
|
||||
public final static String ALL_FORMAT = "<haspformat>\n" +
|
||||
" <hasp>\n" +
|
||||
" <element name=\"id\"/>\n" +
|
||||
@@ -154,8 +163,17 @@ public class HaspUtil {
|
||||
// log.info("license status: {}", status);
|
||||
if(status == HaspStatus.HASP_STATUS_OK) {
|
||||
//如果已经安装过license ,读取指纹和 hasp id
|
||||
// String licenseInfo = hasp.getSessionInfo(KEY_C2V_FORMAT);
|
||||
String licenseInfo = hasp.getInfo(KEY_SCOPE,KEY_C2V_FORMAT,vendorCode);
|
||||
String info = hasp.getSessionInfo(KEY_ID_FORMAT);
|
||||
Document document = XmlUtil.parseXml(info);
|
||||
Element rootEle = document.getDocumentElement();
|
||||
Element haspElement=XmlUtil.getElement(rootEle,"hasp");
|
||||
String id = haspElement.getAttribute("id");
|
||||
String licenseInfo = hasp.getInfo("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
|
||||
"<haspscope>\n" +
|
||||
" <hasp " +
|
||||
"id= \"" + id +"\""+
|
||||
"/>\n" +
|
||||
"</haspscope>",KEY_C2V_FORMAT,vendorCode);
|
||||
status = hasp.getLastError();
|
||||
log.info("getLicense c2v license status: {}", status);
|
||||
if (status != HaspStatus.HASP_STATUS_OK) {
|
||||
|
||||
Reference in New Issue
Block a user