< html lang = "zh_CN.utf8" xmlns:th = "http://www.thymeleaf.org" >
< head >
< meta charset = "UTF-8" >
< title > XTXAppCOM异步调用方式< / title >
< style type = "text/css" >
.TopDIV {position:absolute;left:10px;top:10px; height:70px;background-color:#BCCE98;text-align:center;}
.MenuDIV {position:absolute;left:10px;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 >
< script src = "/js/CA/xtxasyn.js" > < / script > "
< / head >
< script >
////////////////////////////////////// 页面布局本身的JS脚本开始 ///////////////////////////////////
// 存放所有测试的DIV ID
// 每个DIV对应一个左侧菜单
var kDivArray = new Array();
var divArrayIndex = 0;
// 应用接口测试菜单对应的div名称列表
kDivArray[divArrayIndex++] = "div_app_setuserconfig";
kDivArray[divArrayIndex++] = "div_app_export_cert";
kDivArray[divArrayIndex++] = "div_app_login_out";
kDivArray[divArrayIndex++] = "div_app_change_pin";
kDivArray[divArrayIndex++] = "div_app_pv_cert"; // Parse and Validate
kDivArray[divArrayIndex++] = "div_app_plain_sign_vfy";
kDivArray[divArrayIndex++] = "div_app_hash_sign_vfy";
kDivArray[divArrayIndex++] = "div_app_pkcs7_sign_vfy";
kDivArray[divArrayIndex++] = "div_app_pkcs7_sign_hash_vfy";
kDivArray[divArrayIndex++] = "div_app_xml_sign_vfy";
kDivArray[divArrayIndex++] = "div_app_asym_enc_dec";
kDivArray[divArrayIndex++] = "div_app_symm_enc_dec";
kDivArray[divArrayIndex++] = "div_app_pkcs7_envlope";
kDivArray[divArrayIndex++] = "div_app_pkcs7_sign_envlope";
kDivArray[divArrayIndex++] = "div_app_crypto";
kDivArray[divArrayIndex++] = "div_app_base64";
kDivArray[divArrayIndex++] = "div_app_secret_seg";
kDivArray[divArrayIndex++] = "div_app_file_enc_dec";
// 其他接口
function showSelectDiv(id) {
for (var i = 0; i < kDivArray.length ; i + + ) {
var objDiv = document.getElementById(kDivArray[i]);
if (objDiv == undefined) {
continue;
}
var objHref = document.getElementById("id_" + kDivArray[i]);
var pos = -1;
if (objHref) {
pos = objHref.innerText.indexOf('-->');
}
if (pos != -1) {
objHref.innerText = objHref.innerText.substring(0, pos);
}
objHref.style.backgroundColor = '#DAE9BC';
if (id == kDivArray[i]) {
objDiv.style.display = 'block';
objHref.innerText = objHref.innerText + "-->";
objHref.style.backgroundColor = 'yellow'
} else {
objDiv.style.display = 'none';
}
}
return;
}
function SetDIVPostion() {
//Top的宽度是整个页面的宽度
var objTopDiv = document.getElementById("Top");
if (objTopDiv != undefined) {
objTopDiv.style.width = document.body.clientWidth - 10;
}
//Menu的宽度是固定宽度 250 + 15(滚动条的宽度)
var objMenu = document.getElementById("Menu");
if (objMenu != undefined) {
objMenu.style.height = document.body.clientHeight - 100;
}
//Content DIV的宽度
var objContentTopDiv = document.getElementById("MainTop");
if (objContentTopDiv != undefined) {
objContentTopDiv.style.width = document.body.clientWidth - 265;
objContentTopDiv.style.height = document.body.clientHeight - 100;
}
var i;
for (i = 0; i < kDivArray.length ; i + + ) {
var objDiv = document.getElementById(kDivArray[i]);
if (objDiv != undefined) {
objDiv.style.width = document.body.clientWidth - 265;
}
}
//Bottom DIV的宽度
var objBottomDiv = document.getElementById("Bottom");
if (objBottomDiv != undefined) {
objBottomDiv.style.width = document.body.clientWidth - 10;
}
}
function select_cert(value) {
form_xtx.id_selected_cert_id.value = value;
}
function select_device(value) {
form_xtx.id_selected_device_sn.value = value;
}
< / script >
< body onresize = "SetDIVPostion();" onLoad = "SetDIVPostion(); showSelectDiv('div_app_setuserconfig');" >
< form id = "form_xtx" name = "form_xtx" >
<!-- 页头部 -->
< div id = "Top" class = "TopDIV" >
< br / >
< b > < font size = "6" color = "#0000FF" > ukey登录< / font > < / b >
< br / > < br / >
< / div >
<!-- 菜单 -->
< div id = "Menu" class = "MenuDIV" >
<!-- <h4>应用接口测试</h4> -->
< 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_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_change_pin')" id = 'id_div_app_change_pin' > 修改密码< / A > < / li >
< li > < A href = "/login.jsp" id = 'id_div_app_change_pin2' > 返回登录< / A > < / li >
< / ul >
< / div >
<!-- 测试内容头部 显示证书列表 设备列表 -->
< div id = "MainTop" class = "MainTopDIV" >
< table class = "customers" >
< tr >
< td class = "right" > 组件版本号: < / td >
< td class = "left" >
< input type = "text" class = "StandardWidth" id = "id_xtx_version" readonly = "readonly" >
< / td >
< / tr >
< tr >
< td class = "right" > 请选择证书: < / td >
< td class = "left" >
< select class = "StandardWidth" id = "id_cert_list" method = "post" onchange = "select_cert(this.value)" enctype = "multipart/form-data" action = "submit" >
< / select >
< / td >
< / tr >
< tr >
< td class = "right" > 选择的证书ID: < / td >
< td class = "left" >
< input type = "text" class = "StandardWidth" method = "post" id = "id_selected_cert_id" name = "certid" enctype = "multipart/form-data" >
< / td >
< / tr >
< tr >
< td class = "right" > 选择设备序列号: < / td >
< td class = "left" >
< select class = "StandardWidth" id = "id_device_list" onchange = "select_device(this.value)" >
< / select >
< / td >
< / tr >
< tr >
< td class = "right" > 设备序列号: < / td >
< td class = "left" >
< input type = "text" class = "StandardWidth" id = "id_selected_device_sn" >
< / td >
< / tr >
< button type = "button" id = "key_login" > 选择完毕< / button >
< script >
document.addEventListener("DOMContentLoaded", function() {
// 获取按钮元素
const button = document.getElementById("key_login"); // 替换成你实际的按钮ID
// 监听按钮的点击事件
button.addEventListener("click", function() {
// 获取两个input框的值
//var certListValue = document.getElementById("id_cert_list").value;
var selectedCertIdValue = document.getElementById("id_selected_cert_id").value;
alert("选择成功,点击返回登陆");
// 创建一个新的XMLHttpRequest对象
var xhr = new XMLHttpRequest();
// 设置POST请求的目标路径为login
const url = "/keylogin"; // 替换成实际的路径
// 设置POST请求
xhr.open("POST", url, true);
// 设置POST请求的Content-Type头部
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(JSON.stringify(selectedCertIdValue))
// xhr.send(selectedCertIdValue(value))
});
});
< / script >
< / table >
< / div >
<!-- //////////////////////////////////////////////////////////////////////////////////////////////////////// -->
< div id = "div_app_setuserconfig" class = "MainContentDIV" style = "display:none" >
< script >
function clear_div_app_setuserconfig_res() {
form_xtx.id_get_sign_method_res.value = '';
form_xtx.id_get_encrypt_method_res.value = '';
form_xtx.id_set_userconfig_param.value = '';
return;
}
function test_SOF_GetSignMethod() {
SOF_GetSignMethod(function(retObj) {
var algor = Number(retObj.retVal);
form_xtx.id_get_sign_method_res.value = "0x" + algor.toString(16);
});
}
function test_SOF_SetSignMethod() {
var algor = parseInt(form_xtx.id_set_sign_method_algor.value);
SOF_SetSignMethod(algor, function(retObj) {
if (retObj.retVal == 0) {
alert("设置签名算法成功");
} else {
alert("设置签名算法失败,返回值[" + retObj.retVal + "]!!!");
}
});
}
function test_SOF_GetEncryptMethod() {
SOF_GetEncryptMethod(function(retObj) {
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 = retObj.retVal;
});
}
function test_SOF_SetEncryptMethod() {
var algor = parseInt(form_xtx.id_set_encrypt_method_algor.value);
SOF_SetEncryptMethod(algor, function(retObj) {
if (retObj.retVal == 0) {
alert("设置加密算法成功");
} else {
alert("设置加密算法失败,返回值[" + retObj.retVal + "]!!!");
}
});
}
function test_SetUserConfig() {
var type = parseInt(form_xtx.id_set_userconfig_type.value);
var value = form_xtx.id_set_userconfig_param.value;
SetUserConfig(type, value, function(retObj) {
if (retObj.retVal) {
alert("SetUserConfig成功");
} else {
alert("SetUserConfig失败, 返回值[" + retObj.retVal + "]!!!");
}
});
}
< / script >
< table class = "customers" >
< / table >
< / div >
<!-- //////////////////////////////////////////////////////////////////////////////////////////////////////// -->
< div id = "div_app_export_cert" class = "MainContentDIV" style = "display:none" >
< script >
function clear_div_app_export_cert_res() {
form_xtx.id_get_user_list_res.value = '';
form_xtx.id_export_user_cert_res.value = '';
form_xtx.id_export_exchange_user_cert_res.value = '';
return;
}
function test_SOF_GetUserList() {
SOF_GetUserList(function(retObj){
form_xtx.id_get_user_list_res.value = retObj.retVal;
});
}
function getSelectCertID() {
if (form_xtx.id_selected_cert_id.value == "") {
alert("请选择证书");
form_xtx.id_selected_cert_id.focus();
return "";
}
return form_xtx.id_selected_cert_id.value;
}
function test_SOF_ExportUserCert() {
var certId = getSelectCertID();
if (certId == "") {
return;
}
SOF_ExportUserCert(certId, function(retObj) {
form_xtx.id_export_user_cert_res.value = retObj.retVal;
});
}
function test_SOF_ExportExChangeUserCert() {
var certId = getSelectCertID();
if (certId == "") {
return;
}
SOF_ExportExChangeUserCert(certId, function(retObj) {
form_xtx.id_export_exchange_user_cert_res.value = retObj.retVal;
});
}
< / script >
< table class = "customers" >
< tr >
< th colspan = "2" > 导出证书
< input type = "button" value = "清空数据" onclick = "return clear_div_app_export_cert_res()" >
< / th >
< / tr >
< tr >
< td class = "right" > 证书ID列表: < / td >
< td class = "left" >
< textarea class = "StandardWidth" id = "id_get_user_list_res" rows = "3" > < / textarea >
< input type = "button" value = "获取证书列表" onclick = "return test_SOF_GetUserList()" >
< / td >
< / tr >
< tr >
< td class = "right" > 签名证书: < / td >
< td class = "left" >
< textarea class = "StandardWidth" id = "id_export_user_cert_res" rows = "5" > < / textarea >
< input type = "button" value = "导出签名证书" onclick = "return test_SOF_ExportUserCert()" >
< / td >
< / tr >
< tr >
< td class = "right" > 加密证书: < / td >
< td class = "left" >
< textarea class = "StandardWidth" id = "id_export_exchange_user_cert_res" rows = "5" > < / textarea >
< input type = "button" value = "导出加密证书" onclick = "return test_SOF_ExportExChangeUserCert()" >
< / td >
< / tr >
< / table >
< / div >
<!-- //////////////////////////////////////////////////////////////////////////////////////////////////////// -->
< div id = "div_app_login_out" class = "MainContentDIV" style = "display:none" >
< script type = "text/javascript" >
function clear_div_app_login_out_res() {
form_xtx.id_login_passwd.value = '';
form_xtx.id_login_out_res.value = '';
form_xtx.id_islogin_res.value = '';
form_xtx.id_login_out_retry.value = '';
form_xtx.id_form_login_passwd.value = '';
form_xtx.id_form_login_res.value = '';
}
//异步调用sof_login回调函数
function test_login_callback(retObj) {
var certId = retObj.ctx.certId;
if (retObj.retVal) { //retObj.retVal表示sof_login结果true或false
//form_xtx.id_login_out_res.value = "证书登录成功";
form_xtx.id_login_out_res.value = "证书[" + certId + "]登录成功";
window.location.href = "/index.jsp";
// let value = document.getElementById("id_login_out_res").value;
// // 将值传到后端(这里假设使用Ajax发送请求)
// let xhr = new XMLHttpRequest();
// xhr.open("POST", "/login", true);
// xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
// xhr.send("value=" + encodeURIComponent(value));
// 获取按钮元素
}
else {
form_xtx.id_login_out_res.value = "证书[" + certId + "]登录失败";
//当登录失败时, 调用SOF_GetLastError取错误码, errcode为79时表示pin码复杂度不符合
SOF_GetLastError(function(retObj) {
var err = retObj.retVal;
if (err == 79) {
alert("请核对pin码复杂度是否符合要求!");
}
}, retObj.ctx);
}
var str_waring = "消耗时间" + (new Date() - retObj.ctx.begin) / 1000 + "秒";
alert(str_waring);
// 此处无论登录成功失败都调用了获取重试次数
// 实际情况可能仅在登录失败时获取一下重试次数做个提醒
SOF_GetPinRetryCount(certId, function(retObj) {
var certId = retObj.ctx.certId;
form_xtx.id_login_out_retry.value = "证书[" + certId + "]重试次数剩余:" + retObj.retVal + "次...";
}, retObj.ctx);
}
function test_SOF_Login() {
var certId = getSelectCertID();
if (certId == "") {
return;
}
var passwd = form_xtx.id_login_passwd.value;
if (passwd == "") {
alert("请输入用户密码");
form_xtx.id_login_passwd.focus();
return;
}
var time_begin = new Date();
if (form_xtx.id_login_with_cssupdate.checked) { //当勾选时进行证书更新
SOF_Login(certId, passwd, test_login_callback, {begin:time_begin, certId:certId});
//默认进行证书更新
} else {
var platform = navigator.platform.toLowerCase();
if (platform.indexOf("win") != -1){
//SOF_LoginEx第3个参数:登录成功后是否通过CSS控件进行证书更新操作, 1表示进行证书更新, 0表示不进行证书更新。
SOF_LoginEx(certId, passwd, 0, test_login_callback, {begin:time_begin, certId:certId});
}
else {
SOF_Login(certId, passwd, test_login_callback, {begin:time_begin, certId:certId});
}
}
}
function test_SOF_Logout() {
var certId = form_xtx.id_selected_cert_id.value;
if (form_xtx.id_logout_certid_all.checked) {
certId = "";
}
var strMsg;
if (certId != "") {
strMsg = certId;
} else {
strMsg = "全部";
}
SOF_Logout(certId, function(retObj) {
if (retObj.retVal) {
form_xtx.id_login_out_res.value = "证书[" + retObj.ctx.msgCertId + "]登出成功...";
} else {
form_xtx.id_login_out_res.value = "证书[" + retObj.ctx.msgCertId + "]登出失败!!!";
}
}, {msgCertId:strMsg});
}
function logout_all_click(id) {
if (id == 'id_logout_certid_cur') {
form_xtx.id_logout_certid_cur.checked = true;
form_xtx.id_logout_certid_all.checked = false;
} else if (id == 'id_logout_certid_all') {
form_xtx.id_logout_certid_cur.checked = false;
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() {
var certId = getSelectCertID();
if (certId == "") {
return;
}
SOF_GetPinRetryCount(certId, function(retObj) {
form_xtx.id_login_out_retry.value = "证书[" + certId + "]重试次数剩余:" + retObj.retVal + "次...";
});
}
var strServerSignedData = "FUy74vw8FOnzJl4MEKheNqPrOv2U/8/Wgrs2hxsV8AawIu7eKEboBNhLY+uzuYPKRhItrY+UkbRaUB2CVoi87owFn3FhitlTp4YbpBpqxdeddtvC/pMGVND4NQcbEw+qqIRq6L3kI5/ZGicz+DhehQC1oWNMWMe/h1hAPjzZXDE=";
var strServerRan = "CV3w40tGbz/E6xdEy4h2+gjcLXONfBWM";
var strServerCert = "MIIE+DCCA+CgAwIBAgIKGzAAAAAAAFlKWzANBgkqhkiG9w0BAQUFADBSMQswCQYDVQQGEwJDTjENMAsGA1UECgwEQkpDQTEYMBYGA1UECwwPUHVibGljIFRydXN0IENBMRowGAYDVQQDDBFQdWJsaWMgVHJ1c3QgQ0EtMTAeFw0yMDA1MjUxNjAwMDBaFw0yMTA2MjUxNTU5NTlaMEsxCzAJBgNVBAYTAkNOMRIwEAYDVQQDDAnotbXmsLjnnIExKDAmBgkqhkiG9w0BCQEWGXpoYW95b25nc2hlbmdAYmpjYS5vcmcuY24wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALgaT9lsB6duKSsmVbhotgAB2nsTZMKPLPBdLO+Nchvcj7C0ZrePd/m0KzbXWpwk0ZOTa6XsUmGZhHo4FUZr5i9a1GblX3UAY/cu1cIk02IvvoCL/Dh7GAH9eCZAlyXLKhUB1wspBpPkGwIiB5l0f2/ds6C8sR3NOojG3Sx2i9xrAgMBAAGjggJZMIICVTAfBgNVHSMEGDAWgBSsO+yvDKNQDu+vr7RPbDvb0VfSiTAdBgNVHQ4EFgQUWsU79eTB2d2qdLouBzQn7WbBNdowCwYDVR0PBAQDAgbAMIGvBgNVHR8EgacwgaQwbaBroGmkZzBlMQswCQYDVQQGEwJDTjENMAsGA1UECgwEQkpDQTEYMBYGA1UECwwPUHVibGljIFRydXN0IENBMRowGAYDVQQDDBFQdWJsaWMgVHJ1c3QgQ0EtMTERMA8GA1UEAxMIY2EzY3JsMzAwM6AxoC+GLWh0dHA6Ly9sZGFwLmJqY2Eub3JnLmNuL2NybC9wdGNhL2NhM2NybDMwLmNybDAJBgNVHRMEAjAAMBEGCWCGSAGG+EIBAQQEAwIA/zAdBgUqVgsHAQQUU0YzNzI1MjYxOTgyMTIwMjY2NzkwHQYFKlYLBwgEFFNGMzcyNTI2MTk4MjEyMDI2Njc5MCAGCGCGSAGG+EQCBBRTRjM3MjUyNjE5ODIxMjAyNjY3OTAbBggqVoZIAYEwAQQPMTAyMDgwMDA2OTAzMzAwMCUGCiqBHIbvMgIBBAEEFzhDQFNGMzcyNTI2MTk4MjEyMDI2Njc5MCoGC2CGSAFlAwIBMAkKBBtodHRwOi8vYmpjYS5vcmcuY24vYmpjYS5jcnQwDwYFKlYVAQEEBjEwMDA4MDBABgNVHSAEOTA3MDUGCSqBHIbvMgICATAoMCYGCCsGAQUFBwIBFhpodHRwOi8vd3d3LmJqY2Eub3JnLmNuL2NwczATBgoqgRyG7zICAQEeBAUMAzUyMDANBgkqhkiG9w0BAQUFAAOCAQEAaFIE1vKWRqZudqnTPuY/QRYo8R1itRg5OIDcQ51AKBtaxqcMCzXqZwP/zMU36fOT96tCbeIte6jFeJaM3J3Zp5gFZcP4TKxLnQ/FGRMQaKyrJ0Lvi7zNfk48iQzKjKmRAn8XOajA195kX5tJ2YMNamAYVmMgtRrK5YcHg7P9SZC9bqT3IYxAoebQcv666l8nyNQyWnP8pvbPNOvs6xZZzyXMPaHvQK8vV1kSm1VIqazQNvPWRNoE0CETS3g2jwmW4O34/jzrMbG0sXQToDEOkYZVSLCT70RnGrKzJ/F3hsy4G2yPY7B0jRkCzVO1+tSzN7iMDUC/SM7B9Jhl9jCzVQ==";
function test_FormLogin() {
var certId = getSelectCertID();
if (certId == "") {
return;
}
var passwd = form_xtx.id_form_login_passwd.value;
Login("form_xtx", certId, passwd, "", function(ret) {
if (ret) {
form_xtx.id_form_login_res.value = "表单登录成功...";
} else {
form_xtx.id_form_login_res.value = "表单登录失败!";
}
});
}
< / script >
< table class = "customers" >
< tr >
< th colspan = "2" > 登录登出
< input type = "button" value = "清空数据" onclick = "return clear_div_app_login_out_res()" >
< / th >
< / tr >
< tr >
< td class = "right" > 密码: < / td >
< td class = "left" >
< input type = "password" class = "StandardWidth" id = "id_login_passwd" >
<!-- <input type="button" value="登录" onclick="sendResultToBackend()"> -->
< input type = "button" value = "登录" onclick = "return test_SOF_Login()" >
< input type = "checkbox" id = "id_login_with_cssupdate" > 是否通过CSS更新证书
< / td >
< / tr >
< tr >
< td class = "right" > 登录结果: < / td >
< td class = "left" >
< input type = "text" class = "StandardWidth" name = "id_login_out_res" >
< 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_all" onclick = "logout_all_click('id_logout_certid_all');" / > 登出全部证书
< / td >
< / tr >
< tr >
< td class = "right" > 检查是否登录的结果: < / td >
< td class = "left" >
< input type = "text" class = "StandardWidth" name = "id_islogin_res" >
< input type = "button" value = "检查是否登录" onclick = "return test_SOF_IsLogin()" >
< / td >
< / tr >
< tr >
< td class = "right" > 密码重试次数: < / td >
< td class = "left" >
< input type = "text" class = "StandardWidth" name = "id_login_out_retry" >
< input type = "button" value = "获取密码重试次数" onclick = "return test_SOF_GetPinRetryCount()" >
< / td >
< / tr >
< / table >
< / div >
<!-- //////////////////////////////////////////////////////////////////////////////////////////////////////// -->
< div id = "div_app_change_pin" class = "MainContentDIV" style = "display:none" >
< script >
function clear_div_app_change_pin_res() {
form_xtx.id_change_user_passwd_old.value = '';
form_xtx.id_change_user_passwd_new_1.value = '';
form_xtx.id_change_user_passwd_new_2.value = '';
form_xtx.id_change_user_passwd_res.value = '';
form_xtx.id_change_user_passwd_retry.value = '';
}
function test_SOF_ChangePassWd()
{
var certId = getSelectCertID();
if (certId == "") {
return;
}
var oldpin = form_xtx.id_change_user_passwd_old.value;
var newpin1 = form_xtx.id_change_user_passwd_new_1.value;
var newpin2 = form_xtx.id_change_user_passwd_new_2.value;
if (oldpin == "") {
alert("请输入原密码");
form_xtx.id_change_user_passwd_old.focus();
return;
}
if (newpin1 == "") {
alert("请输入新密码");
form_xtx.id_change_user_passwd_new_1.focus();
return;
}
if (newpin2 == "") {
alert("请输入新密码");
form_xtx.id_change_user_passwd_new_2.focus();
return;
}
if (newpin1 != newpin2) {
alert("两次输入的新密码不一致");
form_xtx.id_change_user_passwd_new_2.focus();
return;
}
SOF_ChangePassWd(certId, oldpin, newpin1, function(retObj) {
if (retObj.retVal) {
form_xtx.id_change_user_passwd_res.value = "修改证书密码成功";
} else {
form_xtx.id_change_user_passwd_res.value = "修改证书密码失败";
}
});
// 此处无论修改密码成功失败都调用了获取重试次数
// 实际情况可能仅在修改失败时获取一下重试次数做个提醒
SOF_GetPinRetryCount(certId, function(retObj) {
form_xtx.id_change_user_passwd_retry.value = "证书[" + certId + "]重试次数剩余:" + retObj.retVal + "次...";
});
}
function test_SOF_GetRetryCount()
{
var certId = getSelectCertID();
if (certId == "") {
return;
}
SOF_GetPinRetryCount(certId, function(retObj) {
form_xtx.id_change_user_passwd_retry.value = "证书[" + certId + "]重试次数剩余:" + retObj.retVal + "次...";
});
}
< / script >
< table class = "customers" >
< tr >
< th colspan = "2" > 修改密码
< input type = "button" value = "清空数据" onclick = "return clear_div_app_change_pin_res()" >
< / th >
< / tr >
< tr >
< td class = "right" > 原密码: < / td >
< td class = "left" >
< input type = "password" class = "StandardWidth" id = "id_change_user_passwd_old" >
< / td >
< / tr >
< tr >
< td class = "right" > 新密码: < / td >
< td class = "left" >
< input type = "password" class = "StandardWidth" id = "id_change_user_passwd_new_1" >
< / td >
< / tr >
< tr >
< td class = "right" > 新密码确认: < / td >
< td class = "left" >
< input type = "password" class = "StandardWidth" id = "id_change_user_passwd_new_2" >
< input type = "button" value = "修改密码" onclick = "return test_SOF_ChangePassWd()" >
< / td >
< / tr >
< tr >
< td class = "right" > 修改结果: < / td >
< td class = "left" >
< input type = "text" class = "StandardWidth" id = "id_change_user_passwd_res" >
< / td >
< / tr >
< tr >
< td class = "right" > 密码重试次数: < / td >
< td class = "left" >
< input type = "text" class = "StandardWidth" id = "id_change_user_passwd_retry" >
< input type = "button" value = "获取密码重试次数" onclick = "return test_SOF_GetRetryCount()" >
< / td >
< / tr >
< / table >
< / div >
< / form >
< / body >
< script >
function customFireEvent(objId, eventName) {
var obj = document.getElementById(objId);
if (obj == undefined) {
return;
}
if (obj.fireEvent) {
obj.fireEvent("on" + eventName);
} else if (obj.dispatchEvent) {
var e = document.createEvent('HTMLEvents');
e.initEvent(eventName, false, false);
obj.dispatchEvent(e);
}
}
function FillDeviceList() {
GetAllDeviceSN(function(retObj){
var obj = document.getElementById("id_device_list");
if (obj == undefined) {
return;
}
var i, n = obj.length;
for (i = 0; i < n ; i + + ) {
obj.remove(0);
}
var strDeviceList = retObj.retVal;
while (true) {
var pos = strDeviceList.indexOf(";");
if (pos < = 0 ) {
break;
}
var strOneDevice = strDeviceList.substring(0, pos);
var objItem = new Option(strOneDevice, strOneDevice);
obj.options.add(objItem);
var len = strDeviceList.length;
strDeviceList = strDeviceList.substring(pos + 1, len);
}
customFireEvent('id_cert_list', 'change');
customFireEvent('id_device_list', 'change');
});
}
function test_SOF_GetVersion() {
SOF_GetVersion(function(retObj) {
form_xtx.id_xtx_version.value = retObj.retVal;
});
}
test_SOF_GetVersion();
SetUserCertList("id_cert_list");
FillDeviceList();
SetOnUsbKeyChangeCallBack(FillDeviceList);
< / script >
< / html >