@ -3,21 +3,106 @@
< meta charset = "UTF-8" >
< meta charset = "UTF-8" >
< title > XTXAppCOM异步调用方式< / title >
< title > XTXAppCOM异步调用方式< / title >
< style type = "text/css" >
< style type = "text/css" >
.TopDIV {position:absolute;left:10px;top:10px; height:70px;background-color:#BCCE98;text-align:center;}
.TopDIV {
.MenuDIV {position:absolute;left:10px;top:85px; background-color:#DAE9BC;width:250px;float:left;overflow:auto;}
position: absolute;
.MainTopDIV {position:absolute;left:265px;top:85px; background-color:#EEEEEE;height:130px;float:left;overflow:auto;}
left: 10px;
.MainContentDIV {position:absolute;bottom:30px;left:265px;top:240px; background-color:#EEEEEE;float:left;overflow:auto;}
top: 10px;
.BottomDIV {position:fixed;bottom:0px;left:10px;height:30px;background-color:#BCCE98;clear:both;text-align:center;overflow:auto;}
height: 70px;
h2 {margin-bottom:2;font-size:18px;}
background-color: #BCCE98;
li {font-size:15px;}
text-align: center;
.customers {font-family:"Trebuchet MS", Arial, Helvetica, sans-serif; width:100%; border-collapse:collapse;}
}
.customers td, .customers th {font-size:1em; border:1px solid #98bf21; padding:3px 7px 2px 7px;text-align: center;}
.customers th {font-size:1em; border:1px solid #98bf21; padding:3px 7px 2px 7px;text-align:center; background-color:#98bf21;color:#ffffff;}
.MenuDIV {
.customers td.right {text-align: right;width:20%}
position: absolute;
.customers td.left {text-align: left;width:80%}
left: 10px;
.StandardWidth {width:500px; box-sizing:border-box;}
top: 85px;
background-color: #DAE9BC;
width: 250px;
float: left;
overflow: auto;
}
.MainTopDIV {
position: absolute;
left: 265px;
top: 85px;
background-color: #EEEEEE;
height: 130px;
float: left;
overflow: auto;
}
.MainContentDIV {
position: absolute;
bottom: 30px;
left: 265px;
top: 240px;
background-color: #EEEEEE;
float: left;
overflow: auto;
}
.BottomDIV {
position: fixed;
bottom: 0px;
left: 10px;
height: 30px;
background-color: #BCCE98;
clear: both;
text-align: center;
overflow: auto;
}
h2 {
margin-bottom: 2;
font-size: 18px;
}
li {
font-size: 15px;
}
.customers {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
width: 100%;
border-collapse: collapse;
}
.customers td, .customers th {
font-size: 1em;
border: 1px solid #98bf21;
padding: 3px 7px 2px 7px;
text-align: center;
}
.customers th {
font-size: 1em;
border: 1px solid #98bf21;
padding: 3px 7px 2px 7px;
text-align: center;
background-color: #98bf21;
color: #ffffff;
}
.customers td.right {
text-align: right;
width: 20%
}
.customers td.left {
text-align: left;
width: 80%
}
.StandardWidth {
width: 500px;
box-sizing: border-box;
}
< / style >
< / style >
< script src = "/js/CA/xtxasyn.js" > < / script > "
< link rel = "stylesheet" href = "/lib/layui/css/layui.css" >
< script src = "/lib/layui/layui.js" > < / script >
< script src = "/js/CA/xtxasyn.js" > < / script >
"
< / head >
< / head >
< script >
< script >
////////////////////////////////////// 页面布局本身的JS脚本开始 ///////////////////////////////////
////////////////////////////////////// 页面布局本身的JS脚本开始 ///////////////////////////////////
@ -72,6 +157,7 @@
}
}
return;
return;
}
}
function SetDIVPostion() {
function SetDIVPostion() {
//Top的宽度是整个页面的宽度
//Top的宽度是整个页面的宽度
var objTopDiv = document.getElementById("Top");
var objTopDiv = document.getElementById("Top");
@ -102,29 +188,34 @@
objBottomDiv.style.width = document.body.clientWidth - 10;
objBottomDiv.style.width = document.body.clientWidth - 10;
}
}
}
}
function select_cert(value) {
function select_cert(value) {
form_xtx.id_selected_cert_id.value = value;
form_xtx.id_selected_cert_id.value = value;
}
}
function select_device(value) {
function select_device(value) {
form_xtx.id_selected_device_sn.value = value;
form_xtx.id_selected_device_sn.value = value;
}
}
< / script >
< / script >
< body onresize = "SetDIVPostion();" onLoad = "SetDIVPostion(); showSelectDiv('div_app_setuserconfig');" >
< body onresize = "SetDIVPostion();" onLoad = "SetDIVPostion(); showSelectDiv('div_app_setuserconfig');" >
< form id = "form_xtx" name = "form_xtx" >
< form id = "form_xtx" name = "form_xtx" >
<!-- 页头部 -->
<!-- 页头部 -->
< div id = "Top" class = "TopDIV" >
< div id = "Top" class = "TopDIV" >
< br / >
< br / >
< b > < font size = "6" color = "#0000FF" > ukey登录< / font > < / b >
< b > < font size = "6" color = "#0000FF" > ukey登录< / font > < / b >
< br / > < br / >
< br / > < br / >
< / div >
< / div >
<!-- 菜单 -->
<!-- 菜单 -->
< div id = "Menu" class = "MenuDIV" >
< div id = "Menu" class = "MenuDIV" >
<!-- <h4>应用接口测试</h4> -->
<!-- <h4>应用接口测试</h4> -->
< ul >
< ul >
< li > < A href = "javascript:onClick=showSelectDiv('div_app_setuserconfig')" id = 'id_div_app_setuserconfig' > 证书参数< / A > < / li >
< li > < A href = "javascript:onClick=showSelectDiv('div_app_setuserconfig')"
< li > < A href = "javascript:onClick=showSelectDiv('div_app_export_cert')" id = 'id_div_app_export_cert' > 导出证书< / A > < / li >
id='id_div_app_setuserconfig'>证书参数< / A > < / li >
< li > < A href = "javascript:onClick=showSelectDiv('div_app_export_cert')" id = 'id_div_app_export_cert' > 导出证书< / A >
< / li >
< li > < A href = "javascript:onClick=showSelectDiv('div_app_login_out')" id = 'id_div_app_login_out' > 登录登出< / A > < / li >
< li > < A href = "javascript:onClick=showSelectDiv('div_app_login_out')" id = 'id_div_app_login_out' > 登录登出< / A > < / li >
< li > < A href = "javascript:onClick=showSelectDiv('div_app_change_pin')" id = 'id_div_app_change_pin' > 修改密码< / A > < / li >
< li > < A href = "javascript:onClick=showSelectDiv('div_app_change_pin')" id = 'id_div_app_change_pin' > 修改密码< / A >
< / li >
< li > < A href = "/login.jsp" id = 'id_div_app_change_pin2' > 返回登录< / A > < / li >
< li > < A href = "/login.jsp" id = 'id_div_app_change_pin2' > 返回登录< / A > < / li >
< / ul >
< / ul >
< / div >
< / div >
@ -132,46 +223,48 @@
< div id = "MainTop" class = "MainTopDIV" >
< div id = "MainTop" class = "MainTopDIV" >
< table class = "customers" >
< table class = "customers" >
< tr >
< tr >
< td class = "right" > 组件版本号: < / td >
< td class = "right" > 组件版本号:< / td >
< td class = "left" >
< td class = "left" >
< input type = "text" class = "StandardWidth" id = "id_xtx_version" readonly = "readonly" >
< input type = "text" class = "StandardWidth" id = "id_xtx_version" readonly = "readonly" >
< / td >
< / td >
< / tr >
< / tr >
< tr >
< tr >
< td class = "right" > 请选择证书: < / td >
< td class = "right" > 请选择证书:< / td >
< td class = "left" >
< td class = "left" >
< select class = "StandardWidth" id = "id_cert_list" method = "post" onchange = "select_cert(this.value)" enctype = "multipart/form-data" action = "submit" >
< select class = "StandardWidth" id = "id_cert_list" method = "post" onchange = "select_cert(this.value)"
enctype="multipart/form-data" action="submit">
< / select >
< / select >
< / td >
< / td >
< / tr >
< / tr >
< tr >
< tr >
< td class = "right" > 选择的证书ID: < / td >
< td class = "right" > 选择的证书ID:< / td >
< td class = "left" >
< td class = "left" >
< input type = "text" class = "StandardWidth" method = "post" id = "id_selected_cert_id" name = "certid" enctype = "multipart/form-data" >
< input type = "text" class = "StandardWidth layui-input" method = "post" id = "id_selected_cert_id"
name="certid" enctype="multipart/form-data">
< / td >
< / td >
< / tr >
< / tr >
< tr >
< tr >
< td class = "right" > 选择设备序列号: < / td >
< td class = "right" > 选择设备序列号:< / td >
< td class = "left" >
< td class = "left" >
< select class = "StandardWidth" id = "id_device_list" onchange = "select_device(this.value)" >
< select class = "StandardWidth" id = "id_device_list" onchange = "select_device(this.value)" >
< / select >
< / select >
< / td >
< / td >
< / tr >
< / tr >
< tr >
< tr >
< td class = "right" > 设备序列号: < / td >
< td class = "right" > 设备序列号:< / td >
< td class = "left" >
< td class = "left" >
< input type = "text" class = "StandardWidth" id = "id_selected_device_sn" >
< input type = "text" class = "StandardWidth" id = "id_selected_device_sn" >
< / td >
< / td >
< / tr >
< / tr >
< button type = "button" id = "key_login" > 选择完毕< / button >
< button type = "button" id = "key_login" > 选择完毕< / button >
< script >
< script >
document.addEventListener("DOMContentLoaded", function() {
document.addEventListener("DOMContentLoaded", function () {
// 获取按钮元素
// 获取按钮元素
const button = document.getElementById("key_login"); // 替换成你实际的按钮ID
const button = document.getElementById("key_login"); // 替换成你实际的按钮ID
// 监听按钮的点击事件
// 监听按钮的点击事件
button.addEventListener("click", function() {
button.addEventListener("click", function () {
// 获取两个input框的值
// 获取两个input框的值
//var certListValue = document.getElementById("id_cert_list").value;
//var certListValue = document.getElementById("id_cert_list").value;
var selectedCertIdValue = document.getElementById("id_selected_cert_id").value;
var selectedCertIdValue = document.getElementById("id_selected_cert_id").value;
@ -202,15 +295,17 @@
form_xtx.id_set_userconfig_param.value = '';
form_xtx.id_set_userconfig_param.value = '';
return;
return;
}
}
function test_SOF_GetSignMethod() {
function test_SOF_GetSignMethod() {
SOF_GetSignMethod(function(retObj) {
SOF_GetSignMethod(function (retObj) {
var algor = Number(retObj.retVal);
var algor = Number(retObj.retVal);
form_xtx.id_get_sign_method_res.value = "0x" + algor.toString(16);
form_xtx.id_get_sign_method_res.value = "0x" + algor.toString(16);
});
});
}
}
function test_SOF_SetSignMethod() {
function test_SOF_SetSignMethod() {
var algor = parseInt(form_xtx.id_set_sign_method_algor.value);
var algor = parseInt(form_xtx.id_set_sign_method_algor.value);
SOF_SetSignMethod(algor, function(retObj) {
SOF_SetSignMethod(algor, function (retObj) {
if (retObj.retVal == 0) {
if (retObj.retVal == 0) {
alert("设置签名算法成功");
alert("设置签名算法成功");
} else {
} else {
@ -218,16 +313,18 @@
}
}
});
});
}
}
function test_SOF_GetEncryptMethod() {
function test_SOF_GetEncryptMethod() {
SOF_GetEncryptMethod(function(retObj) {
SOF_GetEncryptMethod(function (retObj) {
var algor = Number(retObj.retVal);
var algor = Number(retObj.retVal);
form_xtx.id_get_encrypt_method_res.value = "0x" + algor.toString(16);
form_xtx.id_get_encrypt_method_res.value = "0x" + algor.toString(16);
//form_xtx.id_get_encrypt_method_res.value = retObj.retVal;
//form_xtx.id_get_encrypt_method_res.value = retObj.retVal;
});
});
}
}
function test_SOF_SetEncryptMethod() {
function test_SOF_SetEncryptMethod() {
var algor = parseInt(form_xtx.id_set_encrypt_method_algor.value);
var algor = parseInt(form_xtx.id_set_encrypt_method_algor.value);
SOF_SetEncryptMethod(algor, function(retObj) {
SOF_SetEncryptMethod(algor, function (retObj) {
if (retObj.retVal == 0) {
if (retObj.retVal == 0) {
alert("设置加密算法成功");
alert("设置加密算法成功");
} else {
} else {
@ -235,10 +332,11 @@
}
}
});
});
}
}
function test_SetUserConfig() {
function test_SetUserConfig() {
var type = parseInt(form_xtx.id_set_userconfig_type.value);
var type = parseInt(form_xtx.id_set_userconfig_type.value);
var value = form_xtx.id_set_userconfig_param.value;
var value = form_xtx.id_set_userconfig_param.value;
SetUserConfig(type, value, function(retObj) {
SetUserConfig(type, value, function (retObj) {
if (retObj.retVal) {
if (retObj.retVal) {
alert("SetUserConfig成功");
alert("SetUserConfig成功");
} else {
} else {
@ -259,11 +357,13 @@
form_xtx.id_export_exchange_user_cert_res.value = '';
form_xtx.id_export_exchange_user_cert_res.value = '';
return;
return;
}
}
function test_SOF_GetUserList() {
function test_SOF_GetUserList() {
SOF_GetUserList(function(retObj){
SOF_GetUserList(function (retObj) {
form_xtx.id_get_user_list_res.value = retObj.retVal;
form_xtx.id_get_user_list_res.value = retObj.retVal;
});
});
}
}
function getSelectCertID() {
function getSelectCertID() {
if (form_xtx.id_selected_cert_id.value == "") {
if (form_xtx.id_selected_cert_id.value == "") {
alert("请选择证书");
alert("请选择证书");
@ -273,21 +373,23 @@
return form_xtx.id_selected_cert_id.value;
return form_xtx.id_selected_cert_id.value;
}
}
function test_SOF_ExportUserCert() {
function test_SOF_ExportUserCert() {
var certId = getSelectCertID();
var certId = getSelectCertID();
if (certId == "") {
if (certId == "") {
return;
return;
}
}
SOF_ExportUserCert(certId, function(retObj) {
SOF_ExportUserCert(certId, function (retObj) {
form_xtx.id_export_user_cert_res.value = retObj.retVal;
form_xtx.id_export_user_cert_res.value = retObj.retVal;
});
});
}
}
function test_SOF_ExportExChangeUserCert() {
function test_SOF_ExportExChangeUserCert() {
var certId = getSelectCertID();
var certId = getSelectCertID();
if (certId == "") {
if (certId == "") {
return;
return;
}
}
SOF_ExportExChangeUserCert(certId, function(retObj) {
SOF_ExportExChangeUserCert(certId, function (retObj) {
form_xtx.id_export_exchange_user_cert_res.value = retObj.retVal;
form_xtx.id_export_exchange_user_cert_res.value = retObj.retVal;
});
});
}
}
@ -299,21 +401,21 @@
< / th >
< / th >
< / tr >
< / tr >
< tr >
< tr >
< td class = "right" > 证书ID列表: < / td >
< td class = "right" > 证书ID列表:< / td >
< td class = "left" >
< td class = "left" >
< textarea class = "StandardWidth" id = "id_get_user_list_res" rows = "3" > < / textarea >
< textarea class = "StandardWidth" id = "id_get_user_list_res" rows = "3" > < / textarea >
< input type = "button" value = "获取证书列表" onclick = "return test_SOF_GetUserList()" >
< input type = "button" value = "获取证书列表" onclick = "return test_SOF_GetUserList()" >
< / td >
< / td >
< / tr >
< / tr >
< tr >
< tr >
< td class = "right" > 签名证书: < / td >
< td class = "right" > 签名证书:< / td >
< td class = "left" >
< td class = "left" >
< textarea class = "StandardWidth" id = "id_export_user_cert_res" rows = "5" > < / textarea >
< textarea class = "StandardWidth" id = "id_export_user_cert_res" rows = "5" > < / textarea >
< input type = "button" value = "导出签名证书" onclick = "return test_SOF_ExportUserCert()" >
< input type = "button" value = "导出签名证书" onclick = "return test_SOF_ExportUserCert()" >
< / td >
< / td >
< / tr >
< / tr >
< tr >
< tr >
< td class = "right" > 加密证书: < / td >
< td class = "right" > 加密证书:< / td >
< td class = "left" >
< td class = "left" >
< textarea class = "StandardWidth" id = "id_export_exchange_user_cert_res" rows = "5" > < / textarea >
< textarea class = "StandardWidth" id = "id_export_exchange_user_cert_res" rows = "5" > < / textarea >
< input type = "button" value = "导出加密证书" onclick = "return test_SOF_ExportExChangeUserCert()" >
< input type = "button" value = "导出加密证书" onclick = "return test_SOF_ExportExChangeUserCert()" >
@ -332,13 +434,14 @@
form_xtx.id_form_login_passwd.value = '';
form_xtx.id_form_login_passwd.value = '';
form_xtx.id_form_login_res.value = '';
form_xtx.id_form_login_res.value = '';
}
}
//异步调用sof_login回调函数
//异步调用sof_login回调函数
function test_login_callback(retObj) {
function test_login_callback(retObj) {
var certId = retObj.ctx.certId;
var certId = retObj.ctx.certId;
if (retObj.retVal) { //retObj.retVal表示sof_login结果true或false
if (retObj.retVal) { //retObj.retVal表示sof_login结果true或false
//form_xtx.id_login_out_res.value = "证书登录成功";
//form_xtx.id_login_out_res.value = "证书登录成功";
form_xtx.id_login_out_res.value = "证书[" + certId + "]登录成功";
form_xtx.id_login_out_res.value = "证书[" + certId + "]登录成功";
window.location.href = "/index.jsp";
// window.location.href = "/index.jsp";
// let value = document.getElementById("id_login_out_res").value;
// let value = document.getElementById("id_login_out_res").value;
// // 将值传到后端(这里假设使用Ajax发送请求)
// // 将值传到后端(这里假设使用Ajax发送请求)
@ -347,11 +450,10 @@
// xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
// xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
// xhr.send("value=" + encodeURIComponent(value));
// xhr.send("value=" + encodeURIComponent(value));
// 获取按钮元素
// 获取按钮元素
}
} else {
else {
form_xtx.id_login_out_res.value = "证书[" + certId + "]登录失败";
form_xtx.id_login_out_res.value = "证书[" + certId + "]登录失败";
//当登录失败时, 调用SOF_GetLastError取错误码, errcode为79时表示pin码复杂度不符合
//当登录失败时, 调用SOF_GetLastError取错误码, errcode为79时表示pin码复杂度不符合
SOF_GetLastError(function(retObj) {
SOF_GetLastError(function (retObj) {
var err = retObj.retVal;
var err = retObj.retVal;
if (err == 79) {
if (err == 79) {
alert("请核对pin码复杂度是否符合要求!");
alert("请核对pin码复杂度是否符合要求!");
@ -362,13 +464,50 @@
alert(str_waring);
alert(str_waring);
// 此处无论登录成功失败都调用了获取重试次数
// 此处无论登录成功失败都调用了获取重试次数
// 实际情况可能仅在登录失败时获取一下重试次数做个提醒
// 实际情况可能仅在登录失败时获取一下重试次数做个提醒
SOF_GetPinRetryCount(certId, function(retObj) {
SOF_GetPinRetryCount(certId, function (retObj) {
var certId = retObj.ctx.certId;
var certId = retObj.ctx.certId;
form_xtx.id_login_out_retry.value = "证书[" + certId + "]重试次数剩余:" + retObj.retVal + "次...";
form_xtx.id_login_out_retry.value = "证书[" + certId + "]重试次数剩余:" + retObj.retVal + "次...";
}, retObj.ctx);
}, retObj.ctx);
}
}
// xhr模拟请求工具
function makePostRequest(url, data, callback) {
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
callback(null, xhr.responseText);
} else {
callback(new Error('Post request failed'));
}
}
};
xhr.send(data);
}
function test_SOF_IsLogin() {
const certId = getSelectCertID();
if (certId == "") {
return;
}
SOF_IsLogin(certId, function (retObj) {
const certId = retObj.ctx.certId;
if (retObj.retVal) {
form_xtx.id_islogin_res.value = "证书[" + certId + "]已登录...";
} else {
form_xtx.id_islogin_res.value = "证书[" + certId + "]未登录!!!";
}
}, {certId: certId});
}
// 登录
function test_SOF_Login() {
function test_SOF_Login() {
var certId = getSelectCertID();
const certId = getSelectCertID();
if (certId == "") {
if (certId == "") {
return;
return;
}
}
@ -380,21 +519,56 @@
}
}
var time_begin = new Date();
var time_begin = new Date();
if (form_xtx.id_login_with_cssupdate.checked) { //当勾选时进行证书更新
if (form_xtx.id_login_with_cssupdate.checked) { //当勾选时进行证书更新
SOF_Login(certId, passwd, test_login_callback, {begin:time_begin, certId:certId});
SOF_Login(certId, passwd, test_login_callback, {begin: time_begin, certId: certId});
alert("证书正在更新");
//默认进行证书更新
//默认进行证书更新
} else {
} else {
var platform = navigator.platform.toLowerCase();
if (platform.indexOf("win") != -1){
const platform = navigator.platform.toLowerCase();
if (platform.indexOf("win") != -1) {
//SOF_LoginEx第3个参数:登录成功后是否通过CSS控件进行证书更新操作, 1表示进行证书更新, 0表示不进行证书更新。
//SOF_LoginEx第3个参数:登录成功后是否通过CSS控件进行证书更新操作, 1表示进行证书更新, 0表示不进行证书更新。
SOF_LoginEx(certId, passwd, 0, test_login_callback, {begin:time_begin, certId:certId});
SOF_LoginEx(certId, passwd, 0, test_login_callback, {begin: time_begin, certId: certId});
}
} else {
else {
SOF_Login(certId, passwd, test_login_callback, {begin: time_begin, certId: certId});
SOF_Login(certId, passwd, test_login_callback, {begin:time_begin, certId:certId});
}
}
}
}
function testAndMakePostRequest() {
const certId = getSelectCertID();
if (certId == "") {
return;
}
}
// SOF_IsLogin(certId, function(retObj) {
// if (retObj.retVal) {
// makePostRequest('/keylogin', certId, function(err, response) {
// if (err) {
// console.error('Error:', err);
// } else {
// console.log('Response:', response);
// // 处理响应数据
// }
// });
// } else {
// // 进行其他处理,如重新登录等
// alert('User is not logged in');
// }
// }, {certId: certId});
}
}
document.addEventListener("DOMContentLoaded", function() {
const loginButton = document.getElementById('loginButton');
if (loginButton) {
loginButton.addEventListener('click', testAndMakePostRequest);
}
});
// 注销登录
function test_SOF_Logout() {
function test_SOF_Logout() {
var certId = form_xtx.id_selected_cert_id.value;
var certId = form_xtx.id_selected_cert_id.value;
if (form_xtx.id_logout_certid_all.checked) {
if (form_xtx.id_logout_certid_all.checked) {
@ -406,14 +580,16 @@
} else {
} else {
strMsg = "全部";
strMsg = "全部";
}
}
SOF_Logout(certId, function(retObj) {
SOF_Logout(certId, function (retObj) {
if (retObj.retVal) {
if (retObj.retVal) {
form_xtx.id_login_out_res.value = "证书[" + retObj.ctx.msgCertId + "]登出成功...";
form_xtx.id_login_out_res.value = "证书[" + retObj.ctx.msgCertId + "]登出成功...";
} else {
} else {
form_xtx.id_login_out_res.value = "证书[" + retObj.ctx.msgCertId + "]登出失败!!!";
form_xtx.id_login_out_res.value = "证书[" + retObj.ctx.msgCertId + "]登出失败!!!";
}
}
}, {msgCertId:strMsg});
}, {msgCertId: strMsg});
}
}
function logout_all_click(id) {
function logout_all_click(id) {
if (id == 'id_logout_certid_cur') {
if (id == 'id_logout_certid_cur') {
form_xtx.id_logout_certid_cur.checked = true;
form_xtx.id_logout_certid_cur.checked = true;
@ -423,39 +599,32 @@
form_xtx.id_logout_certid_all.checked = true;
form_xtx.id_logout_certid_all.checked = true;
}
}
}
}
function test_SOF_IsLogin() {
var certId = getSelectCertID();
if (certId == "") {
return;
}
SOF_IsLogin(certId, function(retObj) {
var certId = retObj.ctx.certId;
if (retObj.retVal) {
form_xtx.id_islogin_res.value = "证书[" + certId + "]已登录...";
} else {
form_xtx.id_islogin_res.value = "证书[" + certId + "]未登录!!!";
}
}, {certId:certId});
}
function test_SOF_GetPinRetryCount() {
function test_SOF_GetPinRetryCount() {
var certId = getSelectCertID();
var certId = getSelectCertID();
if (certId == "") {
if (certId == "") {
return;
return;
}
}
SOF_GetPinRetryCount(certId, function(retObj) {
SOF_GetPinRetryCount(certId, function (retObj) {
form_xtx.id_login_out_retry.value = "证书[" + certId + "]重试次数剩余:" + retObj.retVal + "次...";
form_xtx.id_login_out_retry.value = "证书[" + certId + "]重试次数剩余:" + retObj.retVal + "次...";
});
});
}
}
var strServerSignedData = "FUy74vw8FOnzJl4MEKheNqPrOv2U/8/Wgrs2hxsV8AawIu7eKEboBNhLY+uzuYPKRhItrY+UkbRaUB2CVoi87owFn3FhitlTp4YbpBpqxdeddtvC/pMGVND4NQcbEw+qqIRq6L3kI5/ZGicz+DhehQC1oWNMWMe/h1hAPjzZXDE=";
var strServerSignedData = "FUy74vw8FOnzJl4MEKheNqPrOv2U/8/Wgrs2hxsV8AawIu7eKEboBNhLY+uzuYPKRhItrY+UkbRaUB2CVoi87owFn3FhitlTp4YbpBpqxdeddtvC/pMGVND4NQcbEw+qqIRq6L3kI5/ZGicz+DhehQC1oWNMWMe/h1hAPjzZXDE=";
var strServerRan = "CV3w40tGbz/E6xdEy4h2+gjcLXONfBWM";
var strServerRan = "CV3w40tGbz/E6xdEy4h2+gjcLXONfBWM";
var strServerCert = "MIIE+DCCA+CgAwIBAgIKGzAAAAAAAFlKWzANBgkqhkiG9w0BAQUFADBSMQswCQYDVQQGEwJDTjENMAsGA1UECgwEQkpDQ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yWnP8pvbPNOvs6xZZzyXMPaHvQK8vV1kSm1VIqazQNvPWRNoE0CETS3g2jwmW4O34/jzrMbG0sXQToDEOkYZVSLCT70RnGrKzJ/F3hsy4G2yPY7B0jRkCzVO1+tSzN7iMDUC/SM7B9Jhl9jCzVQ==";
function test_FormLogin() {
function test_FormLogin() {
var certId = getSelectCertID();
var certId = getSelectCertID();
if (certId == "") {
if (certId == "") {
return;
return;
}
}
var passwd = form_xtx.id_form_login_passwd.value;
var passwd = form_xtx.id_form_login_passwd.value;
Login("form_xtx", certId, passwd, "", function(ret) {
Login("form_xtx", certId, passwd, "", function (ret) {
if (ret) {
if (ret) {
form_xtx.id_form_login_res.value = "表单登录成功...";
form_xtx.id_form_login_res.value = "表单登录成功...";
} else {
} else {
@ -472,32 +641,36 @@
< / th >
< / th >
< / tr >
< / tr >
< tr >
< tr >
< td class = "right" > 密码: < / td >
< td class = "right" > 密码:< / td >
< td class = "left" >
< td class = "left" >
< input type = "password" class = "StandardWidth" id = "id_login_passwd" >
< input type = "password" class = "StandardWidth" id = "id_login_passwd" >
<!-- <input type="button" value="登录" onclick="sendResultToBackend()"> -->
<!-- <input type="button" value="登录" onclick="sendResultToBackend()"> -->
< input type = "button" value = "登录" onclick = "return test_SOF_Login()" >
< input type = "button" value = "登录" onclick = "return test_SOF_Login()" >
< button id = "loginButton" > 登录并发送请求< / button >
< input type = "checkbox" id = "id_login_with_cssupdate" > 是否通过CSS更新证书
< input type = "checkbox" id = "id_login_with_cssupdate" > 是否通过CSS更新证书
< / td >
< / td >
< / tr >
< / tr >
< tr >
< tr >
< td class = "right" > 登录结果: < / td >
< td class = "right" > 登录结果:< / td >
< td class = "left" >
< td class = "left" >
< input type = "text" class = "StandardWidth" name = "id_login_out_res" >
< input type = "text" class = "StandardWidth" name = "id_login_out_res" >
< input type = "button" value = "登出" onclick = "return test_SOF_Logout()" >
< input type = "button" value = "登出" onclick = "return test_SOF_Logout()" >
< input type = "checkbox" name = "name_logout_all" id = "id_logout_certid_cur" onclick = "logout_all_click('id_logout_certid_cur');" checked = true / > 登出当前证书
< input type = "checkbox" name = "name_logout_all" id = "id_logout_certid_cur"
< input type = "checkbox" name = "name_logout_all" id = "id_logout_certid_all" onclick = "logout_all_click('id_logout_certid_all');" / > 登出全部证书
onclick="logout_all_click('id_logout_certid_cur');" checked=true/>登出当前证书
< input type = "checkbox" name = "name_logout_all" id = "id_logout_certid_all"
onclick="logout_all_click('id_logout_certid_all');"/>登出全部证书
< / td >
< / td >
< / tr >
< / tr >
< tr >
< tr >
< td class = "right" > 检查是否登录的结果: < / td >
< td class = "right" > 检查是否登录的结果:< / td >
< td class = "left" >
< td class = "left" >
< input type = "text" class = "StandardWidth" name = "id_islogin_res" >
< input type = "text" class = "StandardWidth" name = "id_islogin_res" >
< input type = "button" value = "检查是否登录" onclick = "return test_SOF_IsLogin()" >
< input type = "button" value = "检查是否登录" onclick = "return test_SOF_IsLogin()" >
< / td >
< / td >
< / tr >
< / tr >
< tr >
< tr >
< td class = "right" > 密码重试次数: < / td >
< td class = "right" > 密码重试次数:< / td >
< td class = "left" >
< td class = "left" >
< input type = "text" class = "StandardWidth" name = "id_login_out_retry" >
< input type = "text" class = "StandardWidth" name = "id_login_out_retry" >
< input type = "button" value = "获取密码重试次数" onclick = "return test_SOF_GetPinRetryCount()" >
< input type = "button" value = "获取密码重试次数" onclick = "return test_SOF_GetPinRetryCount()" >
@ -515,8 +688,8 @@
form_xtx.id_change_user_passwd_res.value = '';
form_xtx.id_change_user_passwd_res.value = '';
form_xtx.id_change_user_passwd_retry.value = '';
form_xtx.id_change_user_passwd_retry.value = '';
}
}
function test_SOF_ChangePassWd()
{
function test_SOF_ChangePassWd() {
var certId = getSelectCertID();
var certId = getSelectCertID();
if (certId == "") {
if (certId == "") {
return;
return;
@ -544,7 +717,7 @@
form_xtx.id_change_user_passwd_new_2.focus();
form_xtx.id_change_user_passwd_new_2.focus();
return;
return;
}
}
SOF_ChangePassWd(certId, oldpin, newpin1, function(retObj) {
SOF_ChangePassWd(certId, oldpin, newpin1, function (retObj) {
if (retObj.retVal) {
if (retObj.retVal) {
form_xtx.id_change_user_passwd_res.value = "修改证书密码成功";
form_xtx.id_change_user_passwd_res.value = "修改证书密码成功";
} else {
} else {
@ -554,17 +727,17 @@
// 此处无论修改密码成功失败都调用了获取重试次数
// 此处无论修改密码成功失败都调用了获取重试次数
// 实际情况可能仅在修改失败时获取一下重试次数做个提醒
// 实际情况可能仅在修改失败时获取一下重试次数做个提醒
SOF_GetPinRetryCount(certId, function(retObj) {
SOF_GetPinRetryCount(certId, function (retObj) {
form_xtx.id_change_user_passwd_retry.value = "证书[" + certId + "]重试次数剩余:" + retObj.retVal + "次...";
form_xtx.id_change_user_passwd_retry.value = "证书[" + certId + "]重试次数剩余:" + retObj.retVal + "次...";
});
});
}
}
function test_SOF_GetRetryCount()
{
function test_SOF_GetRetryCount() {
var certId = getSelectCertID();
var certId = getSelectCertID();
if (certId == "") {
if (certId == "") {
return;
return;
}
}
SOF_GetPinRetryCount(certId, function(retObj) {
SOF_GetPinRetryCount(certId, function (retObj) {
form_xtx.id_change_user_passwd_retry.value = "证书[" + certId + "]重试次数剩余:" + retObj.retVal + "次...";
form_xtx.id_change_user_passwd_retry.value = "证书[" + certId + "]重试次数剩余:" + retObj.retVal + "次...";
});
});
}
}
@ -576,32 +749,32 @@
< / th >
< / th >
< / tr >
< / tr >
< tr >
< tr >
< td class = "right" > 原密码: < / td >
< td class = "right" > 原密码:< / td >
< td class = "left" >
< td class = "left" >
< input type = "password" class = "StandardWidth" id = "id_change_user_passwd_old" >
< input type = "password" class = "StandardWidth" id = "id_change_user_passwd_old" >
< / td >
< / td >
< / tr >
< / tr >
< tr >
< tr >
< td class = "right" > 新密码: < / td >
< td class = "right" > 新密码:< / td >
< td class = "left" >
< td class = "left" >
< input type = "password" class = "StandardWidth" id = "id_change_user_passwd_new_1" >
< input type = "password" class = "StandardWidth" id = "id_change_user_passwd_new_1" >
< / td >
< / td >
< / tr >
< / tr >
< tr >
< tr >
< td class = "right" > 新密码确认: < / td >
< td class = "right" > 新密码确认:< / td >
< td class = "left" >
< td class = "left" >
< input type = "password" class = "StandardWidth" id = "id_change_user_passwd_new_2" >
< input type = "password" class = "StandardWidth" id = "id_change_user_passwd_new_2" >
< input type = "button" value = "修改密码" onclick = "return test_SOF_ChangePassWd()" >
< input type = "button" value = "修改密码" onclick = "return test_SOF_ChangePassWd()" >
< / td >
< / td >
< / tr >
< / tr >
< tr >
< tr >
< td class = "right" > 修改结果: < / td >
< td class = "right" > 修改结果:< / td >
< td class = "left" >
< td class = "left" >
< input type = "text" class = "StandardWidth" id = "id_change_user_passwd_res" >
< input type = "text" class = "StandardWidth" id = "id_change_user_passwd_res" >
< / td >
< / td >
< / tr >
< / tr >
< tr >
< tr >
< td class = "right" > 密码重试次数: < / td >
< td class = "right" > 密码重试次数:< / td >
< td class = "left" >
< td class = "left" >
< input type = "text" class = "StandardWidth" id = "id_change_user_passwd_retry" >
< input type = "text" class = "StandardWidth" id = "id_change_user_passwd_retry" >
< input type = "button" value = "获取密码重试次数" onclick = "return test_SOF_GetRetryCount()" >
< input type = "button" value = "获取密码重试次数" onclick = "return test_SOF_GetRetryCount()" >
@ -627,7 +800,7 @@
}
}
function FillDeviceList() {
function FillDeviceList() {
GetAllDeviceSN(function(retObj){
GetAllDeviceSN(function (retObj) {
var obj = document.getElementById("id_device_list");
var obj = document.getElementById("id_device_list");
if (obj == undefined) {
if (obj == undefined) {
return;
return;
@ -640,7 +813,7 @@
var strDeviceList = retObj.retVal;
var strDeviceList = retObj.retVal;
while (true) {
while (true) {
var pos = strDeviceList.indexOf(";");
var pos = strDeviceList.indexOf(";");
if (pos < = 0 ) {
if (pos < = 0) {
break;
break;
}
}
var strOneDevice = strDeviceList.substring(0, pos);
var strOneDevice = strDeviceList.substring(0, pos);
@ -655,10 +828,11 @@
}
}
function test_SOF_GetVersion() {
function test_SOF_GetVersion() {
SOF_GetVersion(function(retObj) {
SOF_GetVersion(function (retObj) {
form_xtx.id_xtx_version.value = retObj.retVal;
form_xtx.id_xtx_version.value = retObj.retVal;
});
});
}
}
test_SOF_GetVersion();
test_SOF_GetVersion();
SetUserCertList("id_cert_list");
SetUserCertList("id_cert_list");
FillDeviceList();
FillDeviceList();