certmanage.js 65 KB

1
  1. var __certmanage=function(a){var X=function(n){function y(){if(!a.certsList)return null;for(var b=a.certsList,c=b.list.length,d=[],h=[],e=0;e<c;e++){a.usWebToolkit.x509Certificate.parser(b.list[e].cert,"Base64");var g=a.usWebToolkit.x509Certificate.getCertificatePoliciesOid(),r=a.usWebToolkit.x509Certificate.getSubjectName(),f=a.usWebToolkit.x509Certificate.getNotAfter(),k=a.usWebToolkit.x509Certificate.getNotAfter(),v=b.list[e].index,t=a.certUtil().getIssuerName(g);"undefined"==t&&(t=a.certUtil().getO(r));var q=[""];q[1]=a.certUtil().getCertType(g);q[2]=a.certUtil().getCN(r);q[3]=t;q[4]=a.certUtil().getLocalDate(f);q[5]=v;q[6]=a.certUtil().getExpirationStateValue(k);"crosscert"==a.certUtil().getO(r).toLowerCase()?d.push(q):h.push(q)}return{list:d.concat(h)}}function w(b,c,d,h,e){if(a.CONST.__USFB_M_DISK.device>b||0>c||!d)return-1;var g=0,r=0;u=c;a.certsList&&(a.certsList=null);k=!0;if(a.CONST.__PF_M_LS.device===b){a.PFSH||e(-1);try{a.PFSH.SelectStorage(1)}catch(x){e(-1)}try{a.PFSH.LoadAllCerts(document.domain)}catch(x){301E5===x.code&&(a.PFSH.InstallCACerts(document.domain),a.PFSH.LoadAllCerts(document.domain))}c=null;try{c=a.PFSH.GetUserCerts(document.domain),a.PFUC=c}catch(x){a.uiUtil().errMsgBox(x.message,x.code)}null!=c&&void 0!=c&&void 0!=c.length&&(g=c.length-1);if(0<g){h=[];for(var f=0;f<g;f++){var m=f+1,v={};v.index=m;v.cert=c[m].signcert;v.path="LocalStorage";h[f]=v}a.certsList={list:h}}else a.certsList=null,r=0;e(r)}else if(b==a.CONST.__PF_M_SS.device&&a.CCPFSH())k=!1,a.CCPFSH().GetCCStorageHandler(a.ESVS.EncAlgo,a.ESVS.HashAlgo,a.ESVS.BSPKI,function(b,c){0==b&&a.CCPFSH().GetCertificateList(function(b,c){if(0==b){var d=0;(a.PFUC=c)&&(d=c.length-1);if(0<d){for(var f=[],g=0;g<d;g++){var h=g+1,q={};q.index=h;q.cert=c[h].signcert;q.path="BrowserSign";f[g]=q}a.certsList={list:f}}}e(b)})});else if(b==a.CONST.__PF_M_CLOUDSIGN.device){k=!1;if(n.CS_phoneNumber)q(n.CS_phoneNumber);else{var t=a.loadUI("phoneNumber")({type:"phoneNumber",args:null,onConfirm:function(a){__PhoneNumber=a;q(a);t.dispose()},onCancel:function(){t.dispose()}});t.show()}var q=function(b){a.uiUtil().loadingBox(!0,"us-div-list-load",0);a.PFCS().reqMemberInfo(b,function(c,d,f){if(0!=c)return a.uiUtil().loadingBox(!1,"us-div-list-load",0),alert(d+"\n\nError Code [ "+c+" ]"),e(c),!1;c=parseInt(f.split("|")[0]);if(0<c)A(b);else{if(-1==c){c=a.loadUI("cloudservice");var g=c({type:"double",args:{pNumber:b},onCancel:function(){g.dispose(!0);a.uiUtil().loadingBox(!1,"us-div-list-load",0)}})}else c=a.loadUI("cloudservice"),g=c({type:"joinus",args:{pNumber:b},onCancel:function(){g.dispose(!0);a.uiUtil().loadingBox(!1,"us-div-list-load",0)}});g.show()}})},A=function(c){a.PFCS().reqGetCert(c,"MANAGEMENT",function(c,b,d){if(0!=c)return a.uiUtil().loadingBox(!1,"us-div-list-load",0),a.uiUtil().errMsgBox(b,c),e(c),!1;if(0<d.length){b=[];for(var f=0;f<d.length;f++){var g={};g.index=f+1;g.cert=d[f];g.path="CloudSign";b[f]=g}a.certsList={list:b}}e(c);a.uiUtil().loadingBox(!1,"us-div-list-load",0);return!0})}}else!a.uiUtil().isItPFDevice(b)&&4&a.ESVS.Mode?a.nimservice()?a.nimservice().GetAllUserCertListNum(b,c,h,function(c,f,q){if(l!=b)return k=!1;g=q;if(0==c)0<g?a.nimservice().GetAllUserCert(q,function(c,b){0==c?a.certsList={list:b}:a.uiUtil().errMsgBox(a.nimservice().GetLastErrorMessage(),c);a.uiUtil().loadingBox(!1,"us-div-list-load");e(c)}):(a.certsList=null,a.uiUtil().loadingBox(!1,"us-div-list-load"),e(0));else{if(b==a.CONST.__USFB_M_MOBILE.device&&61E6==c)return a.ERROR.Code=11003,a.ERROR.Message=d.IDS_MSGBOX_NOT_INSTALL_MOBILE,confirm(d.IDS_MSGBOX_NOT_INSTALL_MOBILE_CFM)?(document.getElementById("us-cert-manage-cls-btn").click(),c="firefox"==a.browserName?window.open(a.ubiKeyEnv.downloadURL,"ubikey_url","scrollbars=1, op=100px, left=100px, height=500px, width=500px"):window.open(a.ubiKeyEnv.downloadURL,"ubikey_url","top=100px, left=100px, height=500px, width=500px"),null==c&&a.uiUtil().msgBox(d.IDS_MSGBOX_BLOCK_POPUP_WINDOW),a.certsList=null,e(-1)):(a.certsList=null,a.uiUtil().loadingBox(!1,"us-div-list-load"),e(0)),!1;if(b==a.CONST.__USFB_M_SECUREDISK.device&&8005E4==c)return a.ERROR.Code=31001,a.ERROR.Message=d.IDS_MSGBOX_NOT_INSTALL_SD,confirm(d.IDS_CONFIRMBOX_NOT_INSTALL_SD)&&(c="firefox"==a.browserName?window.open(a.ESVS.SDInstallURL,"securedisk_url","scrollbars=1, op=100px, left=100px, height=500px, width=380px"):window.open(a.ESVS.SDInstallURL,"securedisk_url","top=100px, left=100px, height=500px, width=380px"),null==c&&a.uiUtil().msgBox(d.IDS_MSGBOX_BLOCK_POPUP_WINDOW)),a.uiUtil().loadingBox(!1,"us-div-list-load"),a.certsList=null,e(-1),!1;-1!==g&&(a.nimservice().GetLastErrorCode(),a.nimservice().GetLastErrorMessage());e(-1);a.certsList=null;a.uiUtil().loadingBox(!1,"us-div-list-load")}}):(a.uiUtil().msgBox(d.IDS_MSGBOX_NIM_ERROR_UNLOAD),e(-1)):e(r)}function F(b,c){if(!b||!c)return!1;if(!a.certsList)return a.uiUtil().msgBox(c.IDS_MSGBOX_COMMON_ERROR_NO_SELECTED_CERT),!1;var d=a.loadUI("certview")({type:null,args:{type:"Base64",idx:parseInt(m.selectedIndex()),cert:a.certsList.list[parseInt(m.selectedIndex())-1].cert},onConfirm:function(){d.dispose();b.focus()},onCancel:function(){d.dispose();b.focus()}});d.show();a.uiUtil().loadingBox(!1,"us-div-list-load");return!0}function S(b,c){4&a.ESVS.Mode&&(SSDialog=a.loadUI("storageselect")({type:"CERT_COPY",args:{drivetype:"BACKUP_DRIVE"},onConfirm:function(d,h){SSDialog.dispose();certlistDialog=a.loadUI("certlistui")({type:"BACKUPED_CERT",args:{device:l,dn:""},onConfirm:function(d){if(0>=d)return a.uiUtil().loadingBox(!1,"us-div-list-load"),a.uiUtil().msgBox(c.IDS_MSGBOX_CERT_RECOVER_ERROR),!1;PWDialog=a.loadUI("password")({type:null,args:null,onConfirm:function(b){PWDialog.dispose();a.nimservice().RecoverFromUSB(1,d,b,function(d,f,e){certlistDialog.dispose();0==d?w(l,1,c,"",function(d){(d=y())?m.redrawList(d.list,d.list.length):m.redrawList(null,0);k=!1;b="";a.uiUtil().loadingBox(!1,"us-div-list-load");a.uiUtil().msgBox(c.IDS_MSGBOX_CERT_RECOVER_SUCCESS)}):(a.uiUtil().loadingBox(!1,"us-div-list-load"),a.uiUtil().msgBox(c.IDS_MSGBOX_CERT_RECOVER_ERROR))})},onCancel:function(){PWDialog.dispose();a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){b.dispose()},10)}});PWDialog.show()},onCancel:function(){certlistDialog.dispose();a.uiUtil().getUserCancelErrCodeNMsg()}});certlistDialog.show();a.uiUtil().loadingBox(!1,"us-div-cert-list-load")},onCancel:function(){a.uiUtil().loadingBox(!1,"us-div-list-load");SSDialog.dispose()}}),SSDialog.show())}function ja(b,c){function d(c,b,d){a.nimservice().BackupToUSB(c,b,d,function(c,b){0===c?a.uiUtil().msgBox(e.IDS_MSGBOX_CERT_BACKUP_SUCCESS):a.uiUtil().errMsgBox(e.IDS_MSGBOX_CERT_BACKUP_ERROR,c);d="";a.uiUtil().loadingBox(!1,"us-div-list-load")})}function h(c,b,e){PWDialog=a.loadUI("password")({type:null,args:null,onConfirm:function(c){PWDialog.dispose();var f=parseInt(m.selectedIndex());a.nimservice().CheckPassword(l,u,f,c,!0,function(g,h){0==g?(SSDialog=a.loadUI("storageselect")({type:"CERT_COPY",args:{drivetype:"BACKUP_DRIVE"},onConfirm:function(a,b){SSDialog.dispose();d(f,b,c)},onCancel:function(){a.uiUtil().loadingBox(!1,"us-div-list-load");SSDialog.dispose();b.focus()}}),SSDialog.show()):(c="",a.uiUtil().msgBox(""==h?e.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_PASSWORD:h),a.uiUtil().loadingBox(!1,"us-div-list-load"),setTimeout(function(){b.dispose()},10))})},onCancel:function(){PWDialog.dispose();a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){b.dispose()},10)}});PWDialog.show()}var e=c,g=null;if(!a.certsList||0>=parseInt(m.selectedIndex()))return a.uiUtil().msgBox(e.IDS_MSGBOX_COMMON_ERROR_NO_SELECTED_CERT),!1;if(4&a.ESVS.Mode)if(a.nimservice())a.nimservice().GetBackupedDriveList(function(c,d,k){var f=k.length;if(0==c)if(0<f){c=[];for(d=0;d<f;d++){var r={};r.index=d+1;r.name=k[d];c[d]=r}g={list:c}}else return a.uiUtil().loadingBox(!1,"us-div-list-load"),a.uiUtil().msgBox(e.IDS_MSGBOX_NO_BACKDRIVE),!1;else return a.uiUtil().loadingBox(!1,"us-div-list-load"),a.uiUtil().errMsgBox(d,c),!1;h(g,b,e)});else return a.uiUtil().loadingBox(!1,"us-div-list-load"),a.uiUtil().msgBox(e.IDS_MSGBOX_NIM_ERROR_UNLOAD),!1}function Z(b,c,d){function h(c,b,d,g,h){if(a.CONST.__USFB_M_DISK.device===b||a.CONST.__USFB_M_HDD.device===b||a.CONST.__USFB_M_MOBILE.device===b||a.CONST.__USFB_M_SECUREDISK.device===b||a.CONST.__USFB_M_MOBILETOKEN.device===b)e(c,g,b,d,0),g="";else if(a.CONST.__USFB_M_HSMKEY.device===b||a.CONST.__USFB_M_SMARTCARD.device===b){var f=null;f=a.CONST.__USFB_M_SMARTCARD.device===b?"PIN_SAVE_TOKEN":"PIN_SECURITY_TOKEN";PINDialog=a.loadUI("pin")({type:f,args:null,onConfirm:function(a){e(c,g,b,d,a,h);g="";PINDialog.dispose()},onCancel:function(){g="";PINDialog.dispose();a.uiUtil().loadingBox(!1,"us-div-list-load")}});PINDialog.show()}else g="",a.uiUtil().loadingBox(!1,"us-div-list-load")}function e(c,b,e,h,k,q){1>c||a.CONST.__USFB_M_DISK.device>e||0>h||null==b||0>=b.length?a.uiUtil().loadingBox(!1,"us-div-list-load"):e==a.CONST.__USFB_M_HSMKEY.device?a.nimservice().EnvelopData("kmcert",c,b,null,"abcdefghijklmnopqrstuvwxyz1234567890",1,function(f,r,m){4503E4==f&&a.uiUtil().msgBox(g.IDS_MSGBOX_HSM_INFO_NO_KMCERT);a.nimservice().CopyCert(c,b,e,h,k,function(e,f){if(0===e)a.uiUtil().msgBox(g.IDS_MSGBOX_CERT_COPY_SUCCESS),d&&d(0,q,a.certUtil().getTheCertAttributes(a.certsList.list[c-1].cert,"Base64"));else switch(e){case 4823E4:a.uiUtil().msgBox(g.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_SEC_TOKEN_PIN);break;case 4825E4:a.uiUtil().msgBox(g.IDS_MSGBOX_PW_ERROR_SEC_TOKEN_PIN_LOCKED);break;case 4013E4:a.uiUtil().msgBox(g.IDS_MSGBOX_HSM_ERROR_UNSUPPORT_LOW_PERFORM_MEDIA);break;case 4844E4:a.uiUtil().msgBox(g.IDS_MSGBOX_HSM_ERROR_MEMORY_TOO_SMALL);break;case 4846E4:a.uiUtil().msgBox(g.IDS_MSGBOX_HSM_ERROR_UNSUPPORT_KEY_LENGTH);break;case 4904E4:a.uiUtil().msgBox(g.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_SAVE_TOKEN_PIN);break;case 4905E4:a.uiUtil().msgBox(g.IDS_MSGBOX_PW_ERROR_SAVE_TOKEN_PIN_LOCKED);break;case 4843E4:case 4123E4:f=a.nimservice().GetLastErrorMessage();f=g.IDS_MSGBOX_CERT_COPY_ERROR_NEWEST_CERT+"\n\n"+f;a.uiUtil().msgBox(f);break;default:e=a.nimservice().GetLastErrorCode(),a.uiUtil().errMsgBox(f?f:g.IDS_MSGBOX_CERT_COPY_ERROR,e)}b="";a.uiUtil().loadingBox(!1,"us-div-list-load")})}):a.nimservice().CopyCert(c,b,e,h,k,function(c,e){if(0===c)a.uiUtil().msgBox(g.IDS_MSGBOX_CERT_COPY_SUCCESS),d&&d(0);else switch(c){case 4823E4:a.uiUtil().msgBox(g.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_SEC_TOKEN_PIN);break;case 4825E4:a.uiUtil().msgBox(g.IDS_MSGBOX_PW_ERROR_SEC_TOKEN_PIN_LOCKED);break;case 4013E4:a.uiUtil().msgBox(g.IDS_MSGBOX_HSM_ERROR_UNSUPPORT_LOW_PERFORM_MEDIA);break;case 4844E4:a.uiUtil().msgBox(g.IDS_MSGBOX_HSM_ERROR_MEMORY_TOO_SMALL);break;case 4846E4:a.uiUtil().msgBox(g.IDS_MSGBOX_HSM_ERROR_UNSUPPORT_KEY_LENGTH);break;case 4904E4:a.uiUtil().msgBox(g.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_SAVE_TOKEN_PIN);break;case 4905E4:a.uiUtil().msgBox(g.IDS_MSGBOX_PW_ERROR_SAVE_TOKEN_PIN_LOCKED);break;case 4843E4:case 4123E4:e=a.nimservice().GetLastErrorMessage();e=g.IDS_MSGBOX_CERT_COPY_ERROR_NEWEST_CERT+"\n\n"+e;a.uiUtil().msgBox(e);break;default:c=a.nimservice().GetLastErrorCode(),a.uiUtil().errMsgBox(e?e:g.IDS_MSGBOX_CERT_COPY_ERROR,c)}b="";a.uiUtil().loadingBox(!1,"us-div-list-load")})}if(!b||!c)return!1;var g=c;if(!a.certsList)return a.uiUtil().msgBox(g.IDS_MSGBOX_COMMON_ERROR_NO_SELECTED_CERT),!1;a.uiUtil().loadingBox(!0,"us-div-list-load",5);Dialog=a.loadUI("storageselect")({type:"CERT_COPY",args:{sourceDevice:l,sourceDrive:u},onConfirm:function(c,b,d){Dialog.dispose();PWDialog=a.loadUI("password")({type:null,args:null,onConfirm:function(e){PWDialog.dispose();if(a.nimservice()){var f=parseInt(m.selectedIndex());a.CONST.__USFB_M_SMARTCARD.device!=l?a.nimservice().CheckPassword(l,u,f,e,!0,function(q,k){0==q?h(f,c,b,e,d):(e="",a.uiUtil().msgBox(""==k?g.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_PASSWORD:k),a.uiUtil().loadingBox(!1,"us-div-list-load"))}):h(f,c,b,e)}else e="",a.uiUtil().msgBox(g.IDS_MSGBOX_NIM_ERROR_UNLOAD),PWDialog.dispose(),a.uiUtil().loadingBox(!1,"us-div-list-load")},onCancel:function(){PWDialog.dispose();a.uiUtil().loadingBox(!1,"us-div-list-load")}});PWDialog.show()},onCancel:function(){Dialog.dispose();a.uiUtil().loadingBox(!1,"us-div-list-load");b.focus()}});Dialog.show();return!0}function aa(b,c,d){if(!b||!c)return!1;if(!a.certsList)return a.uiUtil().msgBox(c.IDS_MSGBOX_COMMON_ERROR_NO_SELECTED_CERT),!1;var h=document.getElementById("us-cert-manage-pw-change-btn");Dialog=a.loadUI("changepassword")({type:null,args:null,onConfirm:function(b,g){Dialog.dispose();if(null==b||0>=b.length||null==g||0>=g.length)return a.uiUtil().msgBox(c.IDS_MSGBOX_PW_ERROR_PLEASE_INPUT_PASSWORD),setTimeout(function(){h.focus()},10),!1;var e=parseInt(m.selectedIndex());if(1>e)return a.uiUtil().msgBox(c.IDS_MSGBOX_COMMON_ERROR_NO_SELECTED_CERT),setTimeout(function(){h.focus()},10),!1;if(a.uiUtil().isItPFDevice(l))try{var f=a.PFUC[e],n;var v=n=null;var t=a.usWebToolkit.pkcs8.encryptedPrivateKeyFromBase64(f.signpri),q=a.usWebToolkit.pkcs8.checkUserCertPassword(t,b);if(!1===q){t=null;var A={code:-1,message:c.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_PASSWORD};throw A;}v=a.usWebToolkit.pkcs8.changePassword(t,b,g,"Base64");t=null;if("undefined"!==typeof f.kmcert){t=a.usWebToolkit.pkcs8.encryptedPrivateKeyFromBase64(f.kmpri);q=a.usWebToolkit.pkcs8.checkUserCertPassword(t,b);if(!1===q)throw t=null,A={code:-1,message:c.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_PASSWORD},A;n=a.usWebToolkit.pkcs8.changePassword(t,b,g,"Base64")}t=null;try{var x={};x.signcert=f.signcert;x.signpri=v;null!==n&&(x.kmcert=f.kmcert,x.kmpri=n);a.CONST.__PF_M_LS.device===l?(a.PFSH.SaveUserCert(f.ca,x,document.domain,!1),f=x=null,w(l,u,c,"",function(b){(b=y())?m.redrawList(b.list,b.list.length):m.redrawList(null,0);k=!1;a.uiUtil().msgBox(c.IDS_MSGBOX_CERT_CHANGE_PW_SUCCESS);setTimeout(function(){h.focus()},10)})):a.CCPFSH().SaveUserCert(f.ca,x,!1,function(b){0==b?(f=x=null,w(l,u,c,"",function(b){(b=y())?m.redrawList(b.list,b.list.length):m.redrawList(null,0);k=!1;a.uiUtil().msgBox(c.IDS_MSGBOX_CERT_CHANGE_PW_SUCCESS);setTimeout(function(){h.focus()},10)})):(a.uiUtil().errMsgBox(c.IDS_MSGBOX_CERT_CHANGE_PW_ERROR,b),setTimeout(function(){h.focus()},10))})}catch(E){switch(E.code){case 1E7:0<=E.detail.indexOf("115010")?a.uiUtil().msgBox(c.IDS_MSGBOX_PW_ERROR_PASSWORD_IS_NOT_MATCHED):a.uiUtil().errMsgBox(c.IDS_MSGBOX_CERT_CHANGE_PW_ERROR,E.code);break;default:a.uiUtil().errMsgBox(c.IDS_MSGBOX_CERT_CHANGE_PW_ERROR,E.code)}setTimeout(function(){h.focus()},10)}finally{}}catch(E){a.uiUtil().errMsgBox(E.message,E.code),setTimeout(function(){h.focus()},10)}finally{}else a.nimservice()?(e=parseInt(m.selectedIndex()),a.nimservice().CheckPassword(l,u,e,b,!0,function(f,q){0===f?a.nimservice().ChangePassword(e,b,g,function(b,e){0===b?(a.uiUtil().msgBox(c.IDS_MSGBOX_CERT_CHANGE_PW_SUCCESS),d&&d(0)):(b=a.nimservice().GetLastErrorCode(),a.uiUtil().errMsgBox(""==e?c.IDS_MSGBOX_CERT_CHANGE_PW_ERROR:e,b));a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){h.focus()},10)}):(a.uiUtil().loadingBox(!1,"us-div-list-load"),a.uiUtil().msgBox(""==q?c.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_PASSWORD:q),setTimeout(function(){h.focus()},10))})):(a.uiUtil().loadingBox(!1,"us-div-list-load"),a.uiUtil().msgBox(c.IDS_MSGBOX_NIM_ERROR_UNLOAD),setTimeout(function(){h.focus()},10))},onCancel:function(){a.uiUtil().loadingBox(!1,"us-div-list-load");a.uiUtil().msgBox(c.IDS_MSGBOX_CERT_CHANGE_PW_CANCEL);Dialog.dispose();setTimeout(function(){h.focus()},10)}});Dialog.show()}function ba(b,c,d){function h(b){a.certsList&&(a.certsList=null);w(l,u,r,"",function(b){(b=y())?m.redrawList(b.list,b.list.length):m.redrawList(null,0);k=!1;a.uiUtil().msgBox(r.IDS_MSGBOX_CERT_DELETE_SUCCESS);d&&d(0)})}function e(b){var c=parseInt(m.selectedIndex());if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(l))a.nimservice()?a.CONST.__USFB_M_HSMKEY.device!=l?a.nimservice().CheckPassword(l,u,c,b,!1,function(d,e){0===d?g(c,b,null):(a.uiUtil().loadingBox(!1,"us-div-list-load"),a.uiUtil().msgBox(""==e?r.IDS_MSGBOX_PW_ERROR_PASSWORD_IS_NOT_MATCHED:e))}):g(c,b,null):(a.uiUtil().loadingBox(!1,"us-div-list-load"),a.uiUtil().msgBox(r.IDS_MSGBOX_NIM_ERROR_UNLOAD));else{if(a.CONST.__PF_M_LS.device===l&&!a.PFUC||a.CONST.__PF_M_SS.device===l&&!a.CCPFSH())return b="",!1;try{var d=a.usWebToolkit.pkcs8.encryptedPrivateKeyFromBase64(a.PFUC[c].signpri),e=a.usWebToolkit.pkcs8.checkUserCertPassword(d,b);d="";!1===e?a.uiUtil().msgBox(r.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_PASSWORD):g(c,b,null)}catch(A){a.uiUtil().errMsgBox(A.message,A.code)}finally{}a.uiUtil().loadingBox(!1,"us-div-list-load")}}function g(b,c,d){if("MPKI"==a.ESVS.PKI){if(1>b)return a.uiUtil().loadingBox(!1,"us-div-list-load"),!1}else if(1>b||null==c||0>=c.length)return a.uiUtil().loadingBox(!1,"us-div-list-load"),d&&d.dispose(),!1;if(a.CONST.__PF_M_LS.device===l){try{a.PFSH.DeleteUserCertByIndex(b,document.domain),h(c),d&&d.dispose(),c=""}catch(q){return a.uiUtil().errMsgBox(r.IDS_MSGBOX_CERT_DELETE_ERROR,q.code),c="",d&&d.dispose(),!1}finally{}a.uiUtil().loadingBox(!1,"us-div-list-load")}else a.CONST.__PF_M_SS.device===l?a.CCPFSH().DeleteUserCertByIndex(b,function(b,e){0==b?h(c):a.uiUtil().msgBox(r.IDS_MSGBOX_CERT_DELETE_ERROR,b);d&&d.dispose();a.uiUtil().loadingBox(!1,"us-div-list-load")}):a.nimservice().DeleteCert(b,c,function(b,e){a.uiUtil().loadingBox(!1,"us-div-list-load");d&&d.dispose();if(0===b)h(c);else{c="";switch(b){case 4823E4:a.uiUtil().msgBox(r.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_SEC_TOKEN_PIN);break;case 4825E4:a.uiUtil().msgBox(r.IDS_MSGBOX_PW_ERROR_SEC_TOKEN_PIN_LOCKED);break;case 4904E4:a.uiUtil().msgBox(r.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_SAVE_TOKEN_PIN);break;case 4905E4:a.uiUtil().msgBox(r.IDS_MSGBOX_PW_ERROR_SAVE_TOKEN_PIN_LOCKED);break;default:b=a.nimservice().GetLastErrorCode(),a.uiUtil().errMsgBox(r.IDS_MSGBOX_CERT_DELETE_ERROR,b)}return!1}});return!0}if(!b||!c)return!1;var r=c;if(!a.certsList)return a.uiUtil().msgBox(r.IDS_MSGBOX_COMMON_ERROR_NO_SELECTED_CERT),!1;if(confirm(r.IDS_CONFIRMBOX_WARNING_DELETE_CERT))if("MPKI"==a.ESVS.PKI)b=parseInt(m.selectedIndex()),g(b,"",null);else{b=null;b=a.CONST.__USFB_M_HSMKEY.device===l?a.loadUI("pin"):a.loadUI("password");var f=b({type:null,args:null,onConfirm:function(a){f.dispose();e(a)},onCancel:function(){f.dispose();a.uiUtil().loadingBox(!1,"us-div-list-load")}});f.show()}return!0}function ca(b,c){if(null==b||0>=b.length||null==c)return!1;if(0<b.length&&-1<b.indexOf(".")){if(b=b.split("."),b=b[b.length-1].toLowerCase(),"pfx"!=b&&"p12"!=b)return a.uiUtil().msgBox(c.IDS_MSGBOX_FILE_ERROR_NOT_PFX),!1}else return a.uiUtil().msgBox(c.IDS_MSGBOX_FILE_ERROR_READ),!1;return!0}function da(b,c,d){function h(b,c){a.nimservice().ExportCert(b,c,function(b,c,f){if(0==b&&f&&0<f.length)a.uiUtil().msgBox(e.IDS_MSGBOX_CERT_EXPORT_SUCCESS+"\n\n"+f),d&&d(0);else switch(b=a.nimservice().GetLastErrorCode(),a.nimservice().GetLastErrorMessage(),b){case 4301E4:case 4302E4:case 4303E4:a.uiUtil().msgBox(e.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_PASSWORD);break;case 4013E4:a.uiUtil().msgBox(e.IDS_MSGBOX_HSM_ERROR_UNSUPPORT_LOW_PERFORM_MEDIA);break;default:a.uiUtil().errMsgBox(e.IDS_MSGBOX_CERT_EXPORT_ERROR,b)}a.uiUtil().loadingBox(!1,"us-div-list-load")})}if(!b||!c)return!1;var e=c;if(!a.certsList)return a.uiUtil().msgBox(e.IDS_MSGBOX_COMMON_ERROR_NO_SELECTED_CERT),!1;var g=document.getElementById("us-cert-manage-put-cert-out-btn");if(4==a.ESVS.Mode||6==a.ESVS.Mode&&!a.uiUtil().isItPFDevice(l))if(a.nimservice()&&null!=a.nimservice()){var k=parseInt(m.selectedIndex());b=a.loadUI("password");Dialog=b({type:null,args:null,onConfirm:function(b){l!=a.CONST.__USFB_M_DISK.device&&l!=a.CONST.__USFB_M_SMARTCARD.device&&l!=a.CONST.__USFB_M_MOBILE.device&&l!=a.CONST.__USFB_M_HDD.device&&l!=a.CONST.__USFB_M_SECUREDISK.device&&l!=a.CONST.__USFB_M_ETC.device?(h(k,b),Dialog.dispose()):a.nimservice().CheckPassword(l,u,k,b,!0,function(c,d){0==c?h(k,b):(a.uiUtil().msgBox(""==d?e.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_PASSWORD:d),a.uiUtil().loadingBox(!1,"us-div-list-load"));b="";Dialog.dispose();setTimeout(function(){g.focus()},10)})},onCancel:function(){Dialog.dispose();setTimeout(function(){g.focus()},10)}});Dialog.show()}else a.uiUtil().loadingBox(!1,"us-div-list-load"),a.uiUtil().msgBox(e.IDS_MSGBOX_NIM_ERROR_UNLOAD);else l==a.CONST.__PF_M_SS.device?(b=a.loadUI("password"),Dialog=b({type:null,args:null,onConfirm:function(b){var c=parseInt(m.selectedIndex());if(!a.PFUC)return b="",!1;l==a.CONST.__PF_M_SS.device&&a.CCPFSH();try{var d=a.usWebToolkit.pkcs8.encryptedPrivateKeyFromBase64(a.PFUC[c].signpri),f=a.usWebToolkit.pkcs8.checkUserCertPassword(d,b);d="";!1===f?a.uiUtil().msgBox(e.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_PASSWORD):a.uiUtil().isItPortableDevice()?a.CCPFSH().GetP12ForBuToMo(c,"hex",function(b,c,d,e){0!=b?a.uiUtil().errMsgBox(c,b):a.uiUtil().ExportToBackupStore(e,d);Dialog.dispose();a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){g.focus()},10)}):a.CCPFSH().GetP12ForBuToPc(c,b,"base64",function(b,c,d,e){if(0!=b)a.uiUtil().errMsgBox(c,b);else{b=a.usWebToolkit.util.decode64(e);c=Array(b.length);for(e=0;e<b.length;e++)c[e]=b.charCodeAt(e);b=new Uint8Array(c);d=a.certUtil().getCN(d)+".p12";a.fileUtil().save(d,b)}Dialog.dispose();a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){g.focus()},10)})}catch(q){a.uiUtil().errMsgBox(q.message,q.code)}finally{}},onCancel:function(){Dialog.dispose();a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){g.focus()},10)}})):(b=a.loadUI("password"),Dialog=b({type:null,args:null,onConfirm:function(b){var c=parseInt(m.selectedIndex());if(!a.PFUC)return b="",!1;try{var d=a.usWebToolkit.pkcs8.encryptedPrivateKeyFromBase64(a.PFUC[c].signpri),f=a.usWebToolkit.pkcs8.checkUserCertPassword(d,b);d="";if(!1===f)a.uiUtil().msgBox(e.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_PASSWORD);else if(a.uiUtil().isItPortableDevice()){var h=a.PFSH.GetP12ForBuToMo(c,"hex");a.uiUtil().ExportToBackupStore(h.p12,h.key);h=null}else{h=a.PFSH.GetP12ForBuToPc(c,b);var k=h.p12,l=h.dn,r=a.certUtil().getCN(l)+".p12";a.fileUtil().save(r,k);k=l=h=null}}catch(Y){a.uiUtil().errMsgBox(Y.message,Y.code)}finally{}b="";Dialog.dispose();a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){g.focus()},10)},onCancel:function(){Dialog.dispose();a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){g.focus()},10)}})),Dialog.show();return!0}function X(b){if(!b)return!1;var c=a.loadUI("swinfo")({type:null,args:null,onConfirm:function(){c.dispose();setTimeout(function(){b.focus()},10)},onCancel:function(){c.dispose();setTimeout(function(){b.focus()},10)}});c.show();return!0}function N(){var a=document.getElementById("us-cert-manage-cert-copy-btn");a.readOnly=!1;a.disabled=!1}function T(){var a=document.getElementById("us-cert-manage-cert-copy-btn");a.readOnly=!0;a.disabled=!0}function K(){var a=document.getElementById("us-cert-manage-pw-change-btn");a.readOnly=!1;a.disabled=!1}function V(){var a=document.getElementById("us-cert-manage-pw-change-btn");a.readOnly=!0;a.disabled=!0}function L(){var a=document.getElementById("us-cert-manage-put-cert-out-btn");a.readOnly=!1;a.disabled=!1}function P(){var a=document.getElementById("us-cert-manage-put-cert-out-btn");a.readOnly=!0;a.disabled=!0}function O(){var a=document.getElementById("us-cert-manage-cert-delete-btn");a.readOnly=!1;a.disabled=!1}function ea(){var a=document.getElementById("us-cert-manage-cert-delete-btn");a.readOnly=!0;a.disabled=!0}function J(){var a=document.getElementById("us-cert-manage-get-cert-btn");a.readOnly=!1;a.disabled=!1}function G(b){b==a.CONST.__PF_M_LS.device?(T(),K(),a.uiUtil().isItSupportingPFCertBackUp()?L():P(),J()):b==a.CONST.__PF_M_SS.device?(T(),K(),a.uiUtil().isItSupportingPFCertBackUp()?L():P(),J()):b==a.CONST.__USFB_M_HDD.device?(N(),K(),L(),O(),J()):b==a.CONST.__USFB_M_DISK.device?(N(),K(),L(),O(),J()):b==a.CONST.__USFB_M_HSMKEY.device?(T(),V(),P(),O(),J()):b==a.CONST.__USFB_M_SMARTCARD.device?(N(),K(),L(),O(),J()):b==a.CONST.__USFB_M_MOBILE.device?(N(),V(),L(),ea()):b==a.CONST.__USFB_M_SECUREDISK.device?(N(),K(),P(),O(),J()):b==a.CONST.__PF_M_CLOUDSIGN.device?(T(),V(),P(),ea(),b=document.getElementById("us-cert-manage-get-cert-btn"),b.readOnly=!0,b.disabled=!0):(N(),K(),L(),O(),J())}function ka(b,c,d,h){if(a.CONST.__USFB_M_DISK.device>b||!c||!d||!h)return!1;var e=a.loadUI("driveselect")({type:"DEVICE_REMOVABLE_DISK",args:c,onConfirm:function(g){g=c.list[g-1].index;0<g&&w(b,g,h,"",function(b){0!=b?(a.uiUtil().errMsgBox(h.IDS_MSGBOX_COMMON_ERROR_GET_CERT,b),m.redrawList(null,0)):(b=y())?m.redrawList(b.list,b.list.length):m.redrawList(null,0);k=!1;a.ESVS.Embedded?setTimeout(function(){e.focus()},10):e.dispose();d.focus();a.uiUtil().loadingBox(!1,"us-div-list-load")})},onCancel:function(){a.uiUtil().loadingBox(!1,"us-div-list-load");e.dispose();d.focus()}});e.show()}function la(b,c,d,h){if(a.CONST.__USFB_M_DISK.device>b||!d||!h)return k=!1;var e=a.loadUI("sectokenselect")({type:b,args:c,onConfirm:function(c){0<c?(a.ESVS.Embedded?setTimeout(function(){e.dispose()},10):e.dispose(),w(b,c,h,"",function(b){if(0!=b){switch(b){case 4812E4:case 4813E4:a.uiUtil().msgBox(h.IDS_MSGBOX_HSM_ERROR_CONNECTION);break;default:a.uiUtil().errMsgBox(h.IDS_MSGBOX_COMMON_ERROR_GET_CERT,b)}m.redrawList(null,0)}else(b=y())?m.redrawList(b.list,b.list.length):m.redrawList(null,0);k=!1;d.focus()})):k=!1},onCancel:function(){k=!1;e.dispose();d.focus()}});e.show()}function ma(b,c,d,h){if(a.CONST.__USFB_M_DISK.device>b||!c||!d||!h)return k=!1;a.uiUtil().loadingBox(!0,"us-div-list-load",0);var e=a.loadUI("driveselect")({type:"DEVICE_SAVE_TOKEN",args:c,onConfirm:function(c){e.dispose();a.nimservice()?a.nimservice().CheckSCardConnected(function(c,e){0===c?(PINDialog=a.loadUI("pin")({type:"PIN_SAVE_TOKEN",args:null,onConfirm:function(c){a.ESVS.Embedded?setTimeout(function(){PINDialog.dispose()},10):PINDialog.dispose();a.nimservice().CheckSCardPin(c,function(e,f){if(0!=e){switch(e){case 4904E4:a.uiUtil().msgBox(h.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_SAVE_TOKEN_PIN);break;case 4905E4:a.uiUtil().msgBox(h.IDS_MSGBOX_PW_ERROR_SAVE_TOKEN_PIN_LOCKED);break;default:a.uiUtil().errMsgBox(h.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_SAVE_TOKEN_PIN,e)}m.redrawList(null,0);k=!1;setTimeout(function(){d.dispose()},10)}else w(b,1,h,c,function(a){0!=a?m.redrawList(null,0):(a=y())?m.redrawList(a.list,a.list.length):m.redrawList(null,0);k=!1;setTimeout(function(){d.dispose()},10)})})},onCancel:function(){k=!1;PINDialog.dispose();a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){d.dispose()},10)}}),PINDialog.show()):(k=!1,a.uiUtil().msgBox(h.IDS_MSGBOX_SMART_CARD_UNCONNECTED),a.uiUtil().loadingBox(!1,"us-div-list-load"),setTimeout(function(){d.dispose()},10))}):(k=!1,a.uiUtil().msgBox(h.IDS_MSGBOX_NIM_ERROR_UNLOAD),a.uiUtil().loadingBox(!1,"us-div-list-load"),setTimeout(function(){d.dispose()},10))},onCancel:function(){k=!1;e.dispose();a.uiUtil().loadingBox(!1,"us-div-list-load");setTimeout(function(){d.dispose()},10)}});e.show()}function na(b,c){if(!b||!c)return k=!1;l=a.CONST.__PF_M_SS.device;u=0;G(l);a.certsList&&(a.certsList=null);m.redrawList(null,-1);w(a.CONST.__PF_M_SS.device,0,c,"",function(b){if(0!=b)return win&&"none"!=win.style.display&&a.uiUtil().errMsgBox(c.IDS_MSGBOX_COMMON_ERROR_GET_CERT,b),m.redrawList(null,0),k=!1;(b=y())?m.redrawList(b.list,b.list.length):m.redrawList(null,0);k=!1})}function oa(b,c){if(!b||!c)return k=!1;l=a.CONST.__PF_M_LS.device;u=0;G(l);a.certsList&&(a.certsList=null);m.redrawList(null,-1);a.uiUtil().loadingBox(!0,"us-div-list-load",0);setTimeout(function(){w(a.CONST.__PF_M_LS.device,0,c,"",function(b){a.uiUtil().loadingBox(!1,"us-div-list-load",0);if(0!=b)return a.uiUtil().errMsgBox(c.IDS_MSGBOX_COMMON_ERROR_GET_CERT,b),m.redrawList(null,0),k=!1;(b=y())?m.redrawList(b.list,b.list.length):m.redrawList(null,0);k=!1})},10);return!0}function pa(b,c){if(!b||!c)return k=!1;l=a.CONST.__USFB_M_HDD.device;u=0;G(l);a.certsList&&(a.certsList=null);m.redrawList(null,-1);w(a.CONST.__USFB_M_HDD.device,0,c,"",function(b){if(0!=b)return a.uiUtil().errMsgBox(c.IDS_MSGBOX_COMMON_ERROR_GET_CERT,b),m.redrawList(null,0),k=!1;(b=y())?m.redrawList(b.list,b.list.length):m.redrawList(null,0);k=!1;return!0})}function qa(b,c){if(!b||!c)return k=!1;k=!0;var d=null;l=a.CONST.__USFB_M_DISK.device;u=0;G(l);a.certsList&&(a.certsList=null);m.redrawList(null,-1);if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(l))if(a.nimservice())a.nimservice().GetDiskList(function(h,e,g){e=0;g&&(e=g.length);if(0==h&&0<e){h=[];for(var l=0,f=0;l<e;l++)if("MacIntel"!=navigator.platform||"Macintosh HD"!=g[l]){var m={};m.index=l+1;m.name=g[l];h[f++]=m}d={list:h}}else return a.uiUtil().loadingBox(!1,"us-div-list-load"),a.certsList=null,k=!1;k=!1;ka(a.CONST.__USFB_M_DISK.device,d,b,c)});else return k=!1,a.uiUtil().loadingBox(!1,"us-div-list-load"),a.uiUtil().msgBox(c.IDS_MSGBOX_NIM_ERROR_UNLOAD),!1;else k=!1;return!0}function ra(b,c){if(!b||!c)return k=!1;k=!0;var d=null;l=a.CONST.__USFB_M_HSMKEY.device;u=0;G(l);a.certsList&&(a.certsList=null);m.redrawList(null,-1);if(4&a.ESVS.Mode)if(a.nimservice())a.nimservice().GetHSMList(1,function(h,e,g){e=0;g&&(e=g.length);if(0==h&&0<e){h=0;for(var l=[],f=0;f<e;f++){var m=f+1,n={},t=g[f].split("|");n.index=m;n.name=t[0];n.driver=t[1];n.passage=t[2];n.validity=t[3];l[h++]=n}d={list:l}}else a.uiUtil().loadingBox(!1,"us-div-list-load"),a.nimservice().GetLastErrorCode();k=!1;la(a.CONST.__USFB_M_HSMKEY.device,d,b,c)});else return k=!1,a.uiUtil().msgBox(c.IDS_MSGBOX_NIM_ERROR_UNLOAD),!1;else k=!1;return!0}function sa(b,c){if(!b||!c)return k=!1;k=!0;l=a.CONST.__USFB_M_SECUREDISK.device;u=1;G(l);a.certsList&&(a.certsList=null);m.redrawList(null,-1);a.nimservice().IsSDInstalled(function(b,h){a.uiUtil().loadingBox(!1,"us-div-list-load");0!=b?(a.ERROR.Code=31001,a.ERROR.Message=c.IDS_MSGBOX_NOT_INSTALL_SD,confirm(c.IDS_CONFIRMBOX_NOT_INSTALL_SD)&&(document.getElementById("us-cert-manage-cls-btn").click(),null==("firefox"==a.browserName?window.open(a.ESVS.SDInstallURL,"securedisk_url","scrollbars=1, op=100px, left=100px, height=500px, width=380px"):window.open(a.ESVS.SDInstallURL,"securedisk_url","top=100px, left=100px, height=500px, width=380px"))&&a.uiUtil().msgBox(c.IDS_MSGBOX_BLOCK_POPUP_WINDOW)),k=!1):w(a.CONST.__USFB_M_SECUREDISK.device,1,c,"",function(b){if(0!=b)return a.uiUtil().errMsgBox(c.IDS_MSGBOX_COMMON_ERROR_GET_CERT,b),m.redrawList(null,0),k=!1;(b=y())?m.redrawList(b.list,b.list.length):m.redrawList(null,0);k=!1;return!0})})}function ta(b,c){if(!b||!c)return k=!1;k=!0;l=a.CONST.__USFB_M_MOBILEOTKEN.device;u=0;a.certsList&&(a.certsList=null);m.redrawList(null,-1);if(4&a.ESVS.Mode)if(a.nimservice())a.nimservice().IsInstalledUSIMModule(2,!1,function(b,h){a.uiUtil().loadingBox(!1,"us-div-list-load");0==b?(k=!0,a.nimservice().SetUSIMOptions(a.usimEnv.sitecode,a.usimEnv.modecode,a.usimEnv.siteURL,a.usimEnv.serviceIP,a.usimEnv.servicePort,a.usimEnv.downloadURL,function(a){document.getElementById("us-confirm-btn").click()})):(k=!0,4847E4==b||4117E4==b?(a.ERROR.Code=21002,a.ERROR.Message=c.IDS_MSGBOX_NOT_INSTALL_SMARTCERT,b=document.getElementById("us-cert-manage-cls-btn"),b.click(),null==("firefox"==a.browserName?window.open(a.usimEnv.downloadURL,"usim_url","scrollbars=1, op=100px, left=100px, height=500px, width=380px"):window.open(a.usimEnv.downloadURL,"usim_url","top=100px, left=100px, height=500px, width=380px"))&&a.uiUtil().msgBox(c.IDS_MSGBOX_BLOCK_POPUP_WINDOW)):(a.ERROR.Code=a.nimservice().GetLastErrorCode(),a.ERROR.Message=a.nimservice().GetLastErrorMessage(),a.uiUtil().errMsgBox(a.ERROR.Message,a.ERROR.Code),b=document.getElementById("us-cert-manage-cls-btn"),b.click()));k=!1});else return k=!1,a.uiUtil().msgBox(c.IDS_MSGBOX_NIM_ERROR_UNLOAD),!1;else k=!1;return!0}function ua(b,c){if(!b||!c)return k=!1;l=a.CONST.__USFB_M_MOBILE.device;u=0;G(l);a.certsList&&(a.certsList=null);m.redrawList(null,-1);if(4&a.ESVS.Mode&&!a.uiUtil().isItPFDevice(l))if(a.nimservice())w(l,u,c,"",function(b){if(0!=b){switch(b){case 61E6:case 6101E4:a.ERROR.Code=11003;confirm(c.IDS_MSGBOX_NOT_INSTALL_MOBILE_CFM)&&(k=!1,document.getElementById("us-cert-manage-cls-btn").click(),null==("firefox"==a.browserName?window.open(a.ubiKeyEnv.downloadURL,"ubikey_url","scrollbars=1, op=100px, left=100px, height=500px, width=500px"):window.open(a.ubiKeyEnv.downloadURL,"ubikey_url","top=100px, left=100px, height=500px, width=500px"))&&a.uiUtil().msgBox(c.IDS_MSGBOX_BLOCK_POPUP_WINDOW));break;case 6102E4:a.uiUtil().errMsgBox(c.IDS_MSGBOX_UBIKEY_LOAD_LIBRARY,b);break;case 6107E4:a.uiUtil().errMsgBox(c.IDS_MSGBOX_UBIKEY_SET_ENV,b)}m.redrawList(null,0)}else(b=y())?m.redrawList(b.list,b.list.length):m.redrawList(null,0);k=!1});else return k=!1,a.uiUtil().msgBox(c.IDS_MSGBOX_NIM_ERROR_UNLOAD),!1;else k=!1;return!0}function Q(b,c){if(!b||!c)return k=!1;k=!0;a.uiUtil().MsgBox(c.IDS_MSGBOX_NOT_SUPPORTED_MEDIA);return!0}function z(b){var c="browsersign";if(b==a.CONST.__PF_M_LS.device||b==a.CONST.__PF_M_SS.device)c="browsersign";else if(b==a.CONST.__PF_M_CLOUDSIGN.device)c="cloudsign";else{null!=H&&(H.dispose(),H=null);return}null!=H?H.changeMedia(c):setTimeout(function(){H=a.loadUI("guide")({type:c,onCancel:function(){H.dispose();H=null}});H.show()},10)}function va(b,c){if(!b||!c)return!1;G(l);fa=a.loadUI("gridlist");m=fa({type:"certslist",tblid:"us-cert-manage-tbl-list",tbltitleid:"us-cert-manage-tbl-list-th",titlelistid:"us-cert-manage-grid-head-div",titlerowid:"us-cert-manage-list-title-row",titleelementid:"us-cert-manage-list-title-element",titledividerid:"us-cert-manage-list-title-divider",titlelistcn:"us-layout-grid-head-div",titlerowcn:"us-layout-grid-head-row",titleelementcn:"us-layout-grid-row-title-element",titledividercn:"us-layout-grid-row-title-divider",tblbodyid:"us-cert-manage-tbl-list-td",datalistid:"us-cert-manage-grid-body-div",datarowid:"us-cert-manage-list-body-row",dataelementid:"us-cert-manage-list-data-element",datalistcn:"us-layout-grid-body-div",datarowcn:"us-layout-grid-body-row",dataelementcn:"us-layout-grid-row-data-element",dataselectcn:"us-layout-grid-row-data-selected-element",textObj:c});var d=!0;"opera"==a.browserName&&(d=!1);m.drawList(b,b.length,null,0,ha,d);for(var h in a.CONST)if(a.CONST[h].device==l&&1==a.CONST[h].disabled)return;w(l,u,c,"",function(b){0!=b?a.uiUtil().errMsgBox(c.IDS_MSGBOX_COMMON_ERROR_GET_CERT,b):(b=y())?m.redrawList(b.list,b.list.length):m.redrawList(null,0);k=!1})}function I(b){if(!b)return!1;R(b,p,"close");for(var c=a.ESVS.Media.list.split("|"),d=0;d<c.length;d++){var h=a.CONST.medias[c[d]];void 0!=h&&null!=h&&(h=document.getElementById("us-cert-manage-btn-"+h.name),void 0!=h&&null!=h&&"us-layout-storage-btn-none"!=h.className&&(h.className=b===h?"us-layout-storage-btn-on":"us-layout-storage-btn-off"))}return!0}function wa(b){if(null==b||void 0==b)return!1;var c=!a.uiUtil().isItSupportingThisStorage(b);0==c&&null!=a.ESVS.Media&&null!=a.ESVS.Media.list&&0>a.ESVS.Media.list.indexOf(b.name)&&(c=!0);if(c)return!1;c=document.getElementById("us-cert-manage-storage-btn-list");var d=document.createElement("li");d.setAttribute("id","us-cert-manage-storage-btn-li-"+b.name,0);d.setAttribute("mediaIndex",b.mediaIndex,0);7==b.mediaIndex&&(d.className="line-first");"hidden"===b.visibility?(d.style.display="none",d.style.visibility="hidden"):(d.style.display="block",d.style.visibility="visible");var h=document.createElement("button");h.setAttribute("type","button",0);h.setAttribute("id","us-cert-manage-btn-"+b.name,0);h.setAttribute("title",b.label,0);h.setAttribute("tabindex",b.tabIndex,0);b.disabled?(h.onclick=function(){a.uiUtil().msgBox(p.IDS_MSGBOX_NOT_SUPPORTED_MEDIA)},h.className="us-layout-storage-btn-none"):(h.onclick=b.onclick,h.className=b.device===l?"us-layout-storage-btn-on":"us-layout-storage-btn-off");d.appendChild(h);if(!a.ESVS.chkEXESetup&&"cloudsign"!==b.name&&"webstorage"!==b.name&&"browsersign"!==b.name&&"qrcode"!==b.name){var e=document.createElement("span");e.className="us-download-select";h.appendChild(e)}e=document.createElement("span");e.className="us-img-storage";var g=document.createElement("img");g.setAttribute("id","us-cert-manage-img-"+b.name,0);g.setAttribute("alt",b.label,0);"browsersign"==b.name?"unknown"==a.browserName?b.disabled?g.setAttribute("src",a.ESVS.SRCPath+"unisignweb/rsrc/img/media_"+b.name+"_d.png",0):g.setAttribute("src",a.ESVS.SRCPath+"unisignweb/rsrc/img/media_"+b.name+".png",0):b.disabled?g.setAttribute("src",a.ESVS.SRCPath+"unisignweb/rsrc/img/browser/"+a.browserName+"_d.png",0):g.setAttribute("src",a.ESVS.SRCPath+"unisignweb/rsrc/img/browser/"+a.browserName+".png",0):b.disabled?g.setAttribute("src",a.ESVS.SRCPath+"unisignweb/rsrc/img/media_"+b.name+"_d.png",0):g.setAttribute("src",a.ESVS.SRCPath+"unisignweb/rsrc/img/media_"+b.name+".png",0);e.appendChild(g);h.appendChild(e);e=document.createElement("span");e.setAttribute("id","us-cert-manage-lbl-"+b.name,0);e.className="us-layout-lbl-storage";e.appendChild(document.createTextNode(b.label));h.appendChild(e);d.appendChild(h);c.appendChild(d);return!0}function R(b,c,d){if("no_more"==d)a.uiUtil().msgBox(c.IDS_MSGBOX_NOT_MORE_MEDIA);else{document.getElementById("us-cert-manage-storage-wrap");"open"==d?(b=document.getElementById("us-cert-manage-div-storage"),b.style.height="186px",b=document.getElementById("us-cert-manage-storage-more-btn"),b.setAttribute("title",c.IDS_STORAGE_MORE_VIEW+c.IDS_STORAGE_MORE_VIEW_HIDDEN+c.IDS_BUTTON,0),b.onclick=function(){R(this,c,"close")},b=document.getElementById("us-cert-manage-storage-more-btn-img"),b.setAttribute("alt",c.IDS_STORAGE_MORE_VIEW+c.IDS_STORAGE_MORE_VIEW_HIDDEN,0),b.setAttribute("src",a.ESVS.SRCPath+"unisignweb/rsrc/img/media_more_btn_close.png",0)):(b=document.getElementById("us-cert-manage-div-storage"),b.style.height="96px",b=document.getElementById("us-cert-manage-storage-more-btn"),b.setAttribute("title",c.IDS_STORAGE_MORE_VIEW+c.IDS_STORAGE_MORE_VIEW_SHOW+c.IDS_BUTTON,0),b.onclick=function(){R(this,c,"open")},b=document.getElementById("us-cert-manage-storage-more-btn-img"),b.setAttribute("alt",c.IDS_STORAGE_MORE_VIEW+c.IDS_STORAGE_MORE_VIEW_SHOW,0),b.setAttribute("src",a.ESVS.SRCPath+"unisignweb/rsrc/img/media_more_btn_open.png",0));b=a.ESVS.Media.list.split("|");for(var h=0;h<b.length;h++){var e=a.CONST.medias[b[h]];if(void 0!=e&&null!=e){var g=document.getElementById("us-cert-manage-storage-btn-li-"+e.name);if(void 0!=g&&null!=g){var k=g.getAttribute("mediaIndex");"open"==d?(g.style.display="block",g.style.visibility="visible"):6<k?(g.style.display="none",g.style.visibility="hidden"):(g.style.display="block",g.style.visibility="visible");1==k&&document.getElementById("us-cert-manage-btn-"+e.name)}}}}return!0}function M(){m.restoreOnMouseEvent();l==a.CONST.__PF_M_CLOUDSIGN.device&&a.PFCS().reqCloseSession();a.ESVS._chkEXESetupCancel=!0;if(1<=arguments.length)n.onConfirm(arguments[0],arguments[1]);else n.onCancel()}function B(a){try{var b=document.querySelector(".us-layout-storage-btn-on span img").alt,d=document.querySelector(".us-layout-storage-btn-on span img").src,h=document.getElementById("us-cert-manage-img-current-storage");h.setAttribute("alt",b,0);h.setAttribute("src",d,0);h=document.getElementById("us-cert-manage-lbl-current-storage");h.innerHTML=b;m&&0>m.selectedIndex()&&(document.getElementById("us-layout-cert-manage-detail-box-subject").innerHTML="<b style='color: red;'>"+a.IDS_DETAIL_BOX_NOT_SELECTED+"</b>",document.getElementById("us-layout-cert-manage-detail-box-expire-data").innerHTML="")}catch(e){xa.log("getCurrDevice error")}}function ya(a,c,d){switch(n.args.type){case 1:Z(a,c,d);break;case 2:aa(a,c,d);break;case 3:U(c,d);break;case 4:da(a,c,d);break;case 5:ba(a,c,d);break;case 6:ja(a,c,d);break;case 7:S(a,c)}}var za=function(){var b=window.XMLHttpRequest?new window.XMLHttpRequest:new ActiveXObject("MSXML2.XMLHTTP.3.0");b.open("GET",a.ESVS.SRCPath+"unisignweb/rsrc/layout/certmanage.html?version="+a.ver,!1);b.send(null);return b.responseText},ia=function(){var b=window.XMLHttpRequest?new window.XMLHttpRequest:new ActiveXObject("MSXML2.XMLHTTP.3.0");b.open("GET",a.ESVS.SRCPath+"unisignweb/rsrc/lang/"+a.ESVS.Language+"/certmanage_"+a.ESVS.Language+".js?version="+a.ver,!1);b.send(null);return b.responseText},p=a.CustomEval(ia,!0),fa=null,m=null,C=a.ESVS.TabIndex+1,ha=0,l=a.CONST.__USFB_M_HDD.device,u=0,k=!1,H=null;if(null!=a.ESVS.Media&&null!=a.ESVS.Media.defaultdevice){l=a.uiUtil().getMediaDevice(a.ESVS.Media.defaultdevice);a.uiUtil().isItPFDevice(l)&&4==a.ESVS.Mode&&(a.SELECTINFO.curdevice=l=a.CONST.__USFB_M_HDD.device);if(l==a.CONST.__USFB_M_SECUREDISK.device||l==a.CONST.__USFB_M_SMARTCARD.device)u=1;a.SELECTINFO.curdevice=l}else 2==a.ESVS.Mode&&(l=a.CONST.__PF_M_LS.device,a.SELECTINFO.curdevice=l);!n.args||6!=n.args.type&&7!=n.args.type||(l=a.CONST.__USFB_M_SECUREDISK.device,u=1,a.SELECTINFO.curdevice=l);var xa=window.console||{log:function(){}},U=null,W=null;window.FileReader?(U=function(b,c){if(null==b)return!1;a.uiUtil().loadingBox(!0,"us-div-list-load");if(a.uiUtil().isItPortableDevice())a.uiUtil().ImportFromBackupStore();else if(a.uiUtil().isItPortableDevice())a.uiUtil().ImportFromBackupStore();else{var d=a.loadUI("importcert")({type:"importcert",args:null,onConfirm:function(b,c){var e=document.getElementById("us-cert-manage-get-cert-btn");"MPKI"==a.ESVS.PKI?(W(a.CONST.__USFB_M_HDD.device,0,b,c),setTimeout(function(){e.focus()},10)):(SSDialog=a.loadUI("storageselect")({type:"CERT_IMPORT",args:{possibleWhale:!1},onConfirm:function(g,f){SSDialog.dispose();a.uiUtil().loadingBox(!1,"us-div-list-load");d.dispose();W(g,f,b,c);setTimeout(function(){e.focus()},10)},onCancel:function(){pw="";SSDialog.dispose();setTimeout(function(){e.focus()},10)}}),SSDialog.show())},onCancel:function(){a.uiUtil().loadingBox(!1,"us-div-list-load");a.uiUtil().msgBox(b.IDS_MSGBOX_CERT_IMPORT_CANCEL);d.dispose();var c=document.getElementById("us-cert-manage-get-cert-btn");setTimeout(function(){c.focus()},10)}});d.show()}return!0},W=function(b,c,d,h){function e(){var a=y();a?m.redrawList(a.list,a.list.length):m.redrawList(null,0)}function g(b,c,d,e){0===b&&(a.uiUtil().msgBox(p.IDS_MSGBOX_CERT_IMPORT_SUCCESS),l===c&&u===d&&(a.CONST.__USFB_M_SMARTCARD.device===l&&0===u&&w(l,u,p,e,function(a){(a=y())?m.redrawList(a.list,a.list.length):m.redrawList(null,0);k=!1}),w(l,u,p,"",function(a){(a=y())?m.redrawList(a.list,a.list.length):m.redrawList(null,0);k=!1})))}var r=h;document.getElementById("us-cert-get-btn");if(b==a.CONST.__PF_M_LS.device){var f=0;try{a.PFSH.LoadAllCerts(document.domain)}catch(x){301E5===x.code&&(a.PFSH.InstallCACerts(document.domain),a.PFSH.LoadAllCerts(document.domain))}try{var z=a.PFSH.SetP12OnMemory(d,r),v=z.aluc[z.index];a.usWebToolkit.x509Certificate.parser(v.signcert,"Base64");var t=a.usWebToolkit.x509Certificate.getCertificatePoliciesOid(),q=a.certUtil().getIssuerEnName(t);a.PFSH.SaveUserCert(q,v,document.domain,!0)}catch(x){switch(f=x.code,x.code){case 1E7:0<=x.detail.indexOf("115010")?a.uiUtil().msgBox(p.IDS_MSGBOX_PW_ERROR_PASSWORD_IS_NOT_MATCHED):a.uiUtil().errMsgBox(p.IDS_MSGBOX_CERT_IMPORT_ERROR,x.code);break;default:a.uiUtil().errMsgBox(p.IDS_MSGBOX_CERT_IMPORT_ERROR,x.code)}}g(f,b,c,"")}else if(b==a.CONST.__PF_M_SS.device){var A=function(d,e){a.CCPFSH().SetP12OnMemory(d,e,function(d,f,h){if(0==d)d=h.aluc[h.index],a.usWebToolkit.x509Certificate.parser(d.signcert,"Base64"),f=a.usWebToolkit.x509Certificate.getCertificatePoliciesOid(),f=a.certUtil().getIssuerEnName(f),a.CCPFSH().SaveUserCert(f,d,!0,function(d){e="";0==d?g(d,b,c,""):a.uiUtil().errMsgBox(p.IDS_MSGBOX_CERT_IMPORT_ERROR,d)});else{switch(d){case 1E7:0<=f.indexOf("115010")?a.uiUtil().msgBox(p.IDS_MSGBOX_PW_ERROR_PASSWORD_IS_NOT_MATCHED):a.uiUtil().errMsgBox(p.IDS_MSGBOX_CERT_IMPORT_ERROR,d);break;default:a.uiUtil().errMsgBox(p.IDS_MSGBOX_CERT_IMPORT_ERROR,d)}e=""}})};a.CCPFSH().IsCCPFSHAvailable(function(b){0==b?A(d,r):a.CCPFSH().GetCCStorageHandler(a.ESVS.EncAlgo,a.ESVS.HashAlgo,a.ESVS.BSPKI,function(a,b){0==a&&A(d,r)})})}else a.CONST.__USFB_M_HSMKEY.device===b||a.CONST.__USFB_M_SMARTCARD.device===b?(f=null,f=a.CONST.__USFB_M_SMARTCARD.device===b?"PIN_SAVE_TOKEN":"PIN_SECURITY_TOKEN",PINDialog=a.loadUI("pin")({type:f,args:null,onConfirm:function(f){a.nimservice().ImportCert(0,d,h,b,c,f,function(d,h){if(0==d)l==b&&u==c&&b!=a.CONST.__USFB_M_MOBILE.device?g(d,b,c,f):(e(),a.uiUtil().msgBox(p.IDS_MSGBOX_CERT_IMPORT_SUCCESS)),n.args&&3==n.args.type&&M();else switch(a.uiUtil().loadingBox(!1,"us-div-list-load"),d){case 4823E4:a.uiUtil().msgBox(p.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_SEC_TOKEN_PIN);break;case 4825E4:a.uiUtil().msgBox(p.IDS_MSGBOX_PW_ERROR_SEC_TOKEN_PIN_LOCKED);break;case 4844E4:a.uiUtil().msgBox(p.IDS_MSGBOX_HSM_ERROR_MEMORY_TOO_SMALL);break;case 4846E4:a.uiUtil().msgBox(p.IDS_MSGBOX_HSM_ERROR_UNSUPPORT_KEY_LENGTH);break;case 4904E4:a.uiUtil().msgBox(p.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_SAVE_TOKEN_PIN);break;case 4905E4:a.uiUtil().msgBox(p.IDS_MSGBOX_PW_ERROR_SAVE_TOKEN_PIN_LOCKED);break;case 4843E4:case 4123E4:h=a.nimservice().GetLastErrorMessage();h=p.IDS_MSGBOX_CERT_COPY_ERROR_NEWEST_CERT+"\n\n"+h;a.uiUtil().msgBox(h);break;case 4019E4:a.uiUtil().errMsgBox(h,d);break;case 4301E4:0<=h.indexOf("3509")?a.uiUtil().msgBox(p.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_PASSWORD):a.uiUtil().errMsgBox(p.IDS_MSGBOX_CERT_IMPORT_ERROR,d);break;default:switch(d=a.nimservice().GetLastErrorCode(),a.nimservice().GetLastErrorMessage(),d){case 3509:a.uiUtil().msgBox(p.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_PASSWORD);break;default:a.uiUtil().errMsgBox(h?h:p.IDS_MSGBOX_CERT_IMPORT_ERROR,d)}}});PINDialog.dispose()},onCancel:function(){r="";PINDialog.dispose()}}),PINDialog.show()):a.nimservice().ImportCert(0,d,h,b,c,"",function(d,f){if(0==d)l==b&&u==c&&b!=a.CONST.__USFB_M_MOBILE.device?g(d,b,c,""):(e(),a.uiUtil().msgBox(p.IDS_MSGBOX_CERT_IMPORT_SUCCESS)),n.args&&3==n.args.type&&M();else switch(a.uiUtil().loadingBox(!1,"us-div-list-load"),d){case 4823E4:a.uiUtil().msgBox(p.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_SEC_TOKEN_PIN);break;case 4825E4:a.uiUtil().msgBox(p.IDS_MSGBOX_PW_ERROR_SEC_TOKEN_PIN_LOCKED);break;case 4844E4:a.uiUtil().msgBox(p.IDS_MSGBOX_HSM_ERROR_MEMORY_TOO_SMALL);break;case 4846E4:a.uiUtil().msgBox(p.IDS_MSGBOX_HSM_ERROR_UNSUPPORT_KEY_LENGTH);break;case 4904E4:a.uiUtil().msgBox(p.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_SAVE_TOKEN_PIN);break;case 4905E4:a.uiUtil().msgBox(p.IDS_MSGBOX_PW_ERROR_SAVE_TOKEN_PIN_LOCKED);break;case 4843E4:case 4123E4:f=a.nimservice().GetLastErrorMessage();f=p.IDS_MSGBOX_CERT_COPY_ERROR_NEWEST_CERT+"\n\n"+f;a.uiUtil().msgBox(f);break;case 4019E4:a.uiUtil().errMsgBox(f,d);break;case 4301E4:0<=f.indexOf("3509")?a.uiUtil().msgBox(p.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_PASSWORD):a.uiUtil().errMsgBox(p.IDS_MSGBOX_CERT_IMPORT_ERROR,d);break;default:switch(d=a.nimservice().GetLastErrorCode(),a.nimservice().GetLastErrorMessage(),d){case 3509:a.uiUtil().msgBox(p.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_PASSWORD);break;default:a.uiUtil().errMsgBox(f?f:p.IDS_MSGBOX_CERT_IMPORT_ERROR,d)}}})}):(U=function(b,c){if(null==b)return!1;if(a.uiUtil().isItPortableDevice())a.uiUtil().ImportFromBackupStore();else{c=document.getElementById("us-cert-manage-file-search-hidden");if("safari"==a.browserName&&6>parseFloat(a.browserVersion))return a.uiUtil().msgBox(b.IDS_MSGBOX_SEARCH_CERT_GUIDE_FOR_SAFARI),!1;if("opera"==a.browserName||"safari"==a.browserName||"msie"==a.browserName&&8===parseInt(a.browserVersion))c.style.display="block";"safari"==a.browserName&&c.setAttribute("accept","",0);c.value="";if(""!=c.value){b=c.onchange;var d=c.parentNode;d.removeChild(c);c=document.createElement("input");c.setAttribute("type","file",0);"safari"==a.browserName?c.setAttribute("accept","",0):c.setAttribute("accept","application/x-pkcs12",0);c.setAttribute("id","us-cert-manage-file-search-hidden",0);c.className="us-layout-cert-manage-file-search-hidden";c.onchange=b;d.appendChild(c)}c.click()}return!0},ImportPFX=function(b,c){function d(b,c,d,f){a.uiUtil().msgBox(e.IDS_MSGBOX_CERT_IMPORT_SUCCESS);a.CONST.__USFB_M_SMARTCARD.device===l&&1===u?w(l,u,e,f,function(a){(a=y())?m.redrawList(a.list,a.list.length):m.redrawList(null,0);k=!1}):w(l,u,e,"",function(a){(a=y())?m.redrawList(a.list,a.list.length):m.redrawList(null,0);k=!1})}function h(b,c,f,h,k){function q(f){var k=0,q=r;null!=g&&(k=1,q=g);a.nimservice().ImportCert(k,q,h,b,c,f,function(g,k){if(0==g)l==b&&u==c&&b!=a.CONST.__USFB_M_MOBILE.device?d(g,b,c,f):((g=y())?m.redrawList(g.list,g.list.length):m.redrawList(null,0),a.uiUtil().msgBox(e.IDS_MSGBOX_CERT_IMPORT_SUCCESS)),n.args&&3==n.args.type&&M(),h=f="";else switch(a.uiUtil().loadingBox(!1,"us-div-list-load"),g){case 4823E4:a.uiUtil().msgBox(e.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_SEC_TOKEN_PIN);break;case 4825E4:a.uiUtil().msgBox(e.IDS_MSGBOX_PW_ERROR_SEC_TOKEN_PIN_LOCKED);break;case 4844E4:a.uiUtil().msgBox(e.IDS_MSGBOX_HSM_ERROR_MEMORY_TOO_SMALL);break;case 4846E4:a.uiUtil().msgBox(e.IDS_MSGBOX_HSM_ERROR_UNSUPPORT_KEY_LENGTH);break;case 4904E4:a.uiUtil().msgBox(e.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_SAVE_TOKEN_PIN);break;case 4905E4:a.uiUtil().msgBox(e.IDS_MSGBOX_PW_ERROR_SAVE_TOKEN_PIN_LOCKED);break;case 4843E4:case 4123E4:g=a.nimservice().GetLastErrorMessage();g=e.IDS_MSGBOX_CERT_COPY_ERROR_NEWEST_CERT+"\n\n"+g;a.uiUtil().msgBox(g);break;case 4019E4:a.uiUtil().errMsgBox(k,g);break;default:switch(g=a.CONST.__PF_M_LS.device===b?g:a.nimservice().GetLastErrorCode(),g){case 3509:a.uiUtil().msgBox(e.IDS_MSGBOX_PW_ERROR_INPUT_WRONG_PASSWORD);break;default:a.uiUtil().errMsgBox(e.IDS_MSGBOX_CERT_IMPORT_ERROR,g)}}})}var p=document.getElementById("us-cert-manage-get-cert-btn");if(4<=a.ESVS.Mode)if(a.CONST.__PF_M_LS.device==b||a.CONST.__PF_M_SS.device==b){if(!a.PFSH)return a.uiUtil().msgBox("unsupport html5 storage"),!1;f=0;try{var t=a.PFSH.SetP12OnMemory(r,h),v=t.index,x=t.aluc[v];a.usWebToolkit.x509Certificate.parser(x.signcert,"Base64");var A=a.usWebToolkit.x509Certificate.getCertificatePoliciesOid(),w=a.certUtil().getIssuerEnName(A);a.PFSH.SaveUserCert(w,x,document.domain,!0)}catch(D){switch(f=D.code,D.code){case 1E7:0<=D.detail.indexOf("115010")?a.uiUtil().msgBox(e.IDS_MSGBOX_PW_ERROR_PASSWORD_IS_NOT_MATCHED):a.uiUtil().errMsgBox(e.IDS_MSGBOX_CERT_IMPORT_ERROR,D.code);break;default:a.uiUtil().errMsgBox(e.IDS_MSGBOX_CERT_IMPORT_ERROR,D.code)}}0==f&&d(f,b,c,"");h="";k&&k.dispose();setTimeout(function(){p.focus()},10)}else a.nimservice()?a.CONST.__USFB_M_HSMKEY.device===b||a.CONST.__USFB_M_SMARTCARD.device===b?(k&&k.dispose(),k=null,k=a.CONST.__USFB_M_SMARTCARD.device===b?"PIN_SAVE_TOKEN":"PIN_SECURITY_TOKEN",PINDialog=a.loadUI("pin")({type:k,args:null,onConfirm:function(a){q(a);PINDialog.dispose();setTimeout(function(){p.focus()},10)},onCancel:function(){h="";PINDialog.dispose();setTimeout(function(){p.focus()},10)}}),PINDialog.show()):(k&&k.dispose(),q("")):a.uiUtil().msgBox(e.IDS_MSGBOX_NIM_ERROR_UNLOAD);else{if(!a.PFSH)return a.uiUtil().msgBox("unsupport html5 storage"),!1;f=0;try{t=a.PFSH.SetP12OnMemory(r,h),v=t.index,x=t.aluc[v],a.usWebToolkit.x509Certificate.parser(x.signcert,"Base64"),A=a.usWebToolkit.x509Certificate.getCertificatePoliciesOid(),w=a.certUtil().getIssuerEnName(A),a.PFSH.SaveUserCert(w,x,document.domain,!0)}catch(D){switch(f=D.code,D.code){case 1E7:0<=D.detail.indexOf("115010")?a.uiUtil().msgBox(e.IDS_MSGBOX_PW_ERROR_PASSWORD_IS_NOT_MATCHED):a.uiUtil().errMsgBox(e.IDS_MSGBOX_CERT_IMPORT_ERROR,D.code);break;default:a.uiUtil().errMsgBox(e.IDS_MSGBOX_CERT_IMPORT_ERROR,D.code)}}0==f&&d(f,b,c,"");h="";k&&k.dispose();setTimeout(function(){p.focus()},10)}}if(!b||!c)return!1;var e=c,g=null,r=null,f=document.getElementById("us-cert-manage-get-cert-btn");if("opera"==a.browserName||"safari"==a.browserName)b.style.display="none";if(window.FileReader)if(b=b.files,0<b.length){var p=b[0];if(1==ca(p.name,e)){var v=new FileReader;v.readAsBinaryString?(v.readAsBinaryString(p),v.addEventListener("load",function(){var b=v.result,c=b.length;if(p.size===c)r=a.usWebToolkit.util.encode64(b,c);else return a.uiUtil().msgBox(e.IDS_MSGBOX_FILE_ERROR_READ),!1})):(v.readAsArrayBuffer(p),v.addEventListener("load",function(){var b=v.result,c=null;try{var d=String.fromCharCode.apply(null,Array.prototype.slice.apply(new Uint8Array(b)));try{c=decodeURIComponent(escape(d))}catch(E){var f=E;if("URIError"==f.name)c=d;else throw f;}}catch(E){return a.uiUtil().msgBox(e.IDS_MSGBOX_FILE_ERROR_READ),!1}b=c.length;if(p.size===b)r=a.usWebToolkit.util.encode64(c,b);else return a.uiUtil().msgBox(e.IDS_MSGBOX_FILE_ERROR_READ),!1}))}else return setTimeout(function(){f.focus()},10),!1}else return setTimeout(function(){f.focus()},10),!1;else{if("msie"==a.browserName&&8===parseInt(a.browserVersion))c=document.getElementById("us-div-cert-manage"),c.onselectstart=function(){return!0},b.select(),g=b.value,b.style.display="none",c.onselectstart=function(){return!1};else if("msie"==a.browserName&&9===parseInt(a.browserVersion)){if(g=b.value,-1<g.indexOf("fakepath"))return a.uiUtil().msgBox(e.IDS_MSGBOX_SEARCH_CERT_GUIDE_FOR_IE9),setTimeout(function(){f.focus()},10),!1}else g=b.value;if(0==ca(g,e))return setTimeout(function(){f.focus()},10),!1}Dialog=a.loadUI("password")({type:null,args:null,onConfirm:function(b){Dialog.dispose();"MPKI"==a.ESVS.PKI?h(a.CONST.__USFB_M_HDD.device,0,g,b,null):(SSDialog=a.loadUI("storageselect")({type:"CERT_IMPORT",args:{possibleWhale:!1},onConfirm:function(a,c){h(a,c,g,b,SSDialog)},onCancel:function(){b="";SSDialog.dispose();setTimeout(function(){f.focus()},10)}}),SSDialog.show())},onCancel:function(){Dialog.dispose();setTimeout(function(){f.focus()},10)}});Dialog.show();return!0});return function(){var b=a.CustomEval(za),c=a.CustomEval(ia,!0);if(n.args&&n.args.style&&"child"==n.args.style){var d=document.createElement("div");document.body.insertBefore(d,document.body.firstChild);d.innerHTML=b()}else a.ESVS.TargetObj.innerHTML=b();var h=document.getElementById("us-cert-manage-lbl-title");h.appendChild(document.createTextNode(c.IDS_CERT_MANAGEMENT));h.setAttribute("tabindex",C++,0);b=document.getElementById("us-cert-manage-cls-img-btn");b.setAttribute("title",c.IDS_CLOSE_CERT_MANAGEMENT_CLOSE,0);b.onclick=function(){k&&a.ESVS.chkEXESetup||M()};document.getElementById("us-cert-manage-cls-btn-img").setAttribute("src",a.ESVS.SRCPath+"unisignweb/rsrc/img/cert_close_btn.png",0);document.getElementById("us-cursor-disabled").setAttribute("title",c.IDS_SENSE_READER_INTRO,0);b=document.getElementById("us-cert-manage-logo-img");b.setAttribute("alt",c.IDS_LOGO,0);b.setAttribute("src",a.ESVS.SRCPath+"unisignweb/rsrc/img/main_cert_logo.png",0);document.getElementById("us-cert-manage-legend-storage").appendChild(document.createTextNode(c.IDS_STORAGE_SELECT));b=0;d=a.ESVS.Media.list.split("|");for(var e=null,g=0;g<d.length;g++){var p=d[g],f=a.CONST.medias[p];if(void 0!=f&&null!=f){switch(f.device){case a.CONST.__USFB_M_DISK.device:f.label=c.IDS_STORAGE_REMOVABLE;f.disabled=2==a.ESVS.Mode||n.args&&(6==n.args.type||7==n.args.type)||"MPKI"==a.ESVS.PKI;f.onclick=function(){k&&a.ESVS.chkEXESetup||(z(a.CONST.__USFB_M_DISK.device),a.ESVS._chkEXESetupCancel=!1,qa(this,c),I(this),B(c),a.SELECTINFO.curdevice=a.CONST.__USFB_M_DISK.device)};break;case a.CONST.__USFB_M_HSMKEY.device:f.label=c.IDS_STORAGE_SECTOKEN;f.disabled=!n.args||1!=n.args.type&&2!=n.args.type&&4!=n.args.type&&6!=n.args.type&&7!=n.args.type?"win"!=a.osName||"MPKI"==a.ESVS.PKI:!0;f.onclick=function(){k&&a.ESVS.chkEXESetup||(z(a.CONST.__USFB_M_HSMKEY.device),a.ESVS._chkEXESetupCancel=!1,ra(this,c),I(this),B(c),a.SELECTINFO.curdevice=a.CONST.__USFB_M_HSMKEY.device)};break;case a.CONST.__USFB_M_SMARTCARD.device:f.label=c.IDS_STORAGE_SAVETOKEN;f.disabled="win"!=a.osName||n.args&&(6==n.args.type||7==n.args.type)||"MPKI"==a.ESVS.PKI;f.onclick=function(){if(!k||!a.ESVS.chkEXESetup){z(a.CONST.__USFB_M_SMARTCARD.device);a.ESVS._chkEXESetupCancel=!1;if(this&&c){k=!0;l=a.CONST.__USFB_M_SMARTCARD.device;u=1;G(l);a.certsList&&(a.certsList=null);m.redrawList(null,-1);var b=[],d={};d.index=a.CONST.__USFB_M_SMARTCARD.device;d.name=c.IDS_SAVETOKEN_SMART_CARD;b[0]=d;ma(a.CONST.__USFB_M_SMARTCARD.device,{list:b},this,c)}else k=!1;I(this);B(c);a.SELECTINFO.curdevice=a.CONST.__USFB_M_SMARTCARD.device}};break;case a.CONST.__USFB_M_MOBILE.device:f.label=c.IDS_STORAGE_MOBILEPHONE;f.disabled=!n.args||2!=n.args.type&&5!=n.args.type&&6!=n.args.type&&7!=n.args.type?"win"!=a.osName||2==a.ESVS.Mode||"MPKI"==a.ESVS.PKI:!0;f.onclick=function(){k&&a.ESVS.chkEXESetup||(z(a.CONST.__USFB_M_MOBILE.device),a.ESVS._chkEXESetupCancel=!1,ua(this,c),I(this),B(c),a.SELECTINFO.curdevice=a.CONST.__USFB_M_MOBILE.device)};break;case a.CONST.__USFB_M_HDD.device:f.label=c.IDS_STORAGE_HARDDISK;f.disabled=2==a.ESVS.Mode||n.args&&(6==n.args.type||7==n.args.type);f.onclick=function(){k&&a.ESVS.chkEXESetup||(z(a.CONST.__USFB_M_HDD.device),a.ESVS._chkEXESetupCancel=!1,pa(this,c),I(this),B(c),a.SELECTINFO.curdevice=a.CONST.__USFB_M_HDD.device)};break;case a.CONST.__USFB_M_MOBILETOKEN.device:f.label=c.IDS_STORAGE_MOBILETOKEN;f.disabled=!0;f.readOnly=!0;f.onclick=function(){k&&a.ESVS.chkEXESetup||(z(a.CONST.__USFB_M_MOBILETOKEN.device),a.ESVS._chkEXESetupCancel=!1,document.getElementById("us-div-cert-manage").style.display="none",ta(this,c),I(this),B(c),a.SELECTINFO.curdevice=a.CONST.__USFB_M_MOBILETOKEN.device)};break;case a.CONST.__USFB_M_SECUREDISK.device:f.label=c.IDS_STORAGE_SECUREDISK;f.disabled=!n.args||1!=n.args.type&&4!=n.args.type?"win"!=a.osName||"MPKI"==a.ESVS.PKI:!0;f.readOnly=!0;f.onclick=function(){k&&a.ESVS.chkEXESetup||(z(a.CONST.__USFB_M_SECUREDISK.device),a.ESVS._chkEXESetupCancel=!1,sa(this,c),I(this),B(c),a.SELECTINFO.curdevice=a.CONST.__USFB_M_SECUREDISK.device)};break;case a.CONST.__PF_M_SS.device:f.label=c.IDS_STORAGE_SS;f.disabled=n.args&&1==n.args.type?!0:4==a.ESVS.Mode;if(1==f.disabled)break;f.onclick=function(){k&&a.ESVS.chkEXESetup||(z(a.CONST.__PF_M_SS.device),a.ESVS._chkEXESetupCancel=!0,na(this,c),I(this),B(c),a.SELECTINFO.curdevice=a.CONST.__PF_M_SS.device)};break;case a.CONST.__PF_M_LS.device:f.label=c.IDS_STORAGE_LS;f.disabled=n.args&&1==n.args.type?!0:4==a.ESVS.Mode;if(1==f.disabled)break;f.onclick=function(){k&&a.ESVS.chkEXESetup||(z(a.CONST.__PF_M_LS.device),a.ESVS._chkEXESetupCancel=!0,oa(this,c),I(this),B(c),a.SELECTINFO.curdevice=a.CONST.__PF_M_LS.device)};break;case a.CONST.__PF_M_TOUCHSIGN.device:f.label=c.IDS_STORAGE_TOUCHSIGN;f.disabled=!0;f.onclick=function(){k&&a.ESVS.chkEXESetup||(z(a.CONST.__PF_M_TOUCHSIGN.device),a.ESVS._chkEXESetupCancel=!1,Q(this,c),B(c),a.SELECTINFO.curdevice=a.CONST.__PF_M_TOUCHSIGN.device)};break;case a.CONST.__PF_M_SMARTSIGN.device:f.label=c.IDS_STORAGE_SMARTSIGN;f.disabled=!0;f.onclick=function(){k&&a.ESVS.chkEXESetup||(z(a.CONST.__PF_M_SMARTSIGN.device),a.ESVS._chkEXESetupCancel=!1,Q(this,c),B(c),a.SELECTINFO.curdevice=a.CONST.__PF_M_SMARTSIGN.device)};break;case a.CONST.__PF_M_WEBSECTOKEN.device:f.label=c.IDS_STORAGE_WEBSECTOKEN;f.disabled=!0;f.onclick=function(){k&&a.ESVS.chkEXESetup||(z(a.CONST.__PF_M_WEBSECTOKEN.device),a.ESVS._chkEXESetupCancel=!1,Q(this,c),B(c),a.SELECTINFO.curdevice=a.CONST.__PF_M_WEBSECTOKEN.device)};break;case a.CONST.__PF_M_WEBSOFTTOKEN.device:f.label=c.IDS_STORAGE_WEBSOFTTOKEN;f.disabled=!0;f.onclick=function(){k&&a.ESVS.chkEXESetup||(z(a.CONST.__PF_M_WEBSOFTTOKEN.device),a.ESVS._chkEXESetupCancel=!1,Q(this,c),B(c),a.SELECTINFO.curdevice=a.CONST.__PF_M_WEBSOFTTOKEN.device)};break;case a.CONST.__PF_M_CLOUDSIGN.device:f.label=c.IDS_STORAGE_CLOUDSIGN;f.disabled=!0;break;default:f.label=c.IDS_STORAGE_ETC,f.disabled=!0,f.onclick=function(){k&&a.ESVS.chkEXESetup||(z(0),a.ESVS._chkEXESetupCancel=!1,Q(this,c),B(c),a.SELECTINFO.curdevice=0)}}a.ESVS.Media.option&&0>=a.ESVS.Media.option&&-1*a.ESVS.Media.option&Math.pow(2,g)&&a.ESVS.Media.defaultdevice!=p&&(f.disabled=!0);f.tabIndex=C;f.mediaIndex=b+1;f.visibility=6<f.mediaIndex?"hidden":"visible";wa(f)&&(C++,b++);null==e&&(e=f)}}d=document.getElementById("us-cert-manage-storage-more-btn");null!=d&&void 0!=d&&(d.setAttribute("title",c.IDS_STORAGE_MORE_VIEW+c.IDS_STORAGE_MORE_VIEW_SHOW+c.IDS_BUTTON,0),6<b?(d.style.display="block",d.style.visibility="visible",d.setAttribute("tabindex",C++,0),d.onclick=function(){R(this,c,"open")}):(d.setAttribute("disabled","disabled",0),d.style.display="none",d.style.visibility="hidden",d.onclick=function(){R(this,c,"no_more")}),b=document.getElementById("us-cert-manage-storage-more-btn-img"),b.setAttribute("alt",c.IDS_STORAGE_MORE_VIEW+c.IDS_STORAGE_MORE_VIEW_SHOW,0),b.setAttribute("src",a.ESVS.SRCPath+"unisignweb/rsrc/img/media_more_btn_open.png",0));document.getElementById("us-h5-storage").innerText=c.IDS_H5_STORAGE;document.getElementById("us-h5-list").innerText=c.IDS_H5_LIST;b=document.getElementById("us-cert-manage-tbl-list");b.style.summary=c.IDS_CERT_LIST_TABLE_SUMMARY;b.setAttribute("title",c.IDS_CERT_LIST_CAPTION);a.ESVS.Mode&2&&a.uiUtil().loadingBox(!0,"us-div-list-load",0);var w=[{title:c.IDS_CERT_STATUS},{title:c.IDS_CERT_CLASSIFY},{title:c.IDS_CERT_USER},{title:c.IDS_CERT_ISSUER},{title:c.IDS_CERT_EXPIRATION_DAY}];ha=C++;setTimeout(function(){va(w,c)},100);window.FileReader||(document.getElementById("us-cert-manage-file-search-hidden").onchange=function(){ImportPFX(this,c)});null!=n.args&&null!=n.args.type?(document.getElementById("us-div-cert-manage-btns").style.display="none",document.getElementById("us-fieldset-cert-manage-title").appendChild(document.createTextNode(c.IDS_DETAIL_BOX_TITLE)),m&&-1<m.selectedIndex()?(b=parseInt(m.selectedIndex()),d=a.certsList.list[b-1].path,a.usWebToolkit.x509Certificate.parser(a.certsList.list[b-1].cert,"Base64"),document.getElementById("us-layout-cert-manage-detail-box-subject").innerHTML="<b>"+a.certUtil().getCN(a.usWebToolkit.x509Certificate.getSubjectName())+"</b>",document.getElementById("us-layout-cert-manage-detail-box-expire-data").innerHTML=a.certUtil().getLocalDate(a.usWebToolkit.x509Certificate.getNotBefore())+" ~ "+a.certUtil().getLocalDate(a.usWebToolkit.x509Certificate.getNotAfter()),document.getElementById("us-layout-cert-manage-detail-box-savepath-data").innerHTML=d,document.getElementById("us-layout-cert-manage-detail-box-savepath-data").setAttribute("title",d)):document.getElementById("us-layout-cert-manage-detail-box-subject").innerHTML="<b style='color: red;'>"+c.IDS_DETAIL_BOX_NOT_SELECTED+"</b>",document.getElementById("us-layout-cert-manage-detail-box-expire-lbl").innerHTML=c.IDS_DETAIL_BOX_EXPIRE_DATE+" : ",document.getElementById("us-layout-cert-manage-detail-box-savepath-lbl").innerHTML=c.IDS_DETAIL_BOX_SAVE_PATH+" : ",b=document.getElementById("us-cert-manage-detail-view-btn"),b.setAttribute("tabindex",C++,0),b.value=c.IDS_DETAIL_BOX_BTN_VIEW,b.title=c.IDS_DETAIL_BOX_BTN_VIEW,b.onclick=function(){k||F(this,c)},b=document.getElementById("us-cert-manage-sw-info-btn"),b.setAttribute("tabindex",C++,0),b.setAttribute("class","btn-action"),b.value=c.IDS_DETAIL_BOX_BTN_ACTIONS[n.args.type],b.title=c.IDS_DETAIL_BOX_BTN_ACTIONS[n.args.type],b.onclick=function(){k||ya(this,c,function(a,b,c){0==a&&(b&&c?M(b,c):M())})},B(c)):(document.getElementById("us-div-cert-manage-detail").style.display="none",b=document.getElementById("us-cert-manage-cert-view-btn"),b.setAttribute("value",c.IDS_CERT_VIEW,0),b.setAttribute("title",c.IDS_CERT_VIEW+c.IDS_BUTTON,0),b.setAttribute("tabindex",C++,0),b.onclick=function(){k||F(this,c)},b=document.getElementById("us-cert-manage-pw-change-btn"),b.setAttribute("value",c.IDS_PW_CHANGE,0),b.setAttribute("title",c.IDS_PW_CHANGE+c.IDS_BUTTON,0),b.setAttribute("tabindex",C++,0),b.onclick=function(){k||aa(this,c)},d=document.getElementById("us-cert-manage-cert-delete-btn"),d.setAttribute("value",c.IDS_CERT_DELETE,0),d.setAttribute("title",c.IDS_CERT_DELETE+c.IDS_BUTTON,0),d.setAttribute("tabindex",C++,0),d.onclick=function(){k||ba(this,c)},d=document.getElementById("us-cert-manage-cert-copy-btn"),d.setAttribute("value",c.IDS_CERT_COPY,0),d.setAttribute("title",c.IDS_CERT_COPY+c.IDS_BUTTON,0),d.setAttribute("tabindex",C++,0),d.onclick=function(){k||Z(this,c)},"MPKI"==a.ESVS.PKI&&(d.readOnly=!0,d.disabled=!0,b.readOnly=!0,b.disabled=!0),a.uiUtil().isIraq()&&(d.readOnly=!0,d.disabled=!0),b=document.getElementById("us-cert-manage-get-cert-btn"),b.setAttribute("value",c.IDS_CERT_GET,0),b.setAttribute("title",c.IDS_CERT_GET+c.IDS_BUTTON,0),b.setAttribute("tabindex",C++,0),b.onclick=function(){k||U(c)},b=document.getElementById("us-cert-manage-put-cert-out-btn"),b.setAttribute("value",c.IDS_CERT_PUT_OUT,0),b.setAttribute("title",c.IDS_CERT_PUT_OUT+c.IDS_BUTTON,0),b.setAttribute("tabindex",C++,0),b.onclick=function(){k||da(this,c)},b=document.getElementById("us-cert-manage-sw-info-btn"),b.setAttribute("value",c.IDS_SW_INFO,0),b.setAttribute("title",c.IDS_SW_INFO+c.IDS_BUTTON,0),b.setAttribute("tabindex",C++,0),b.onclick=function(){k||X(this)});b=document.getElementById("us-cert-manage-lbl-notice");b.appendChild(document.createTextNode(c.IDS_NOTICE));if("MPKI"==a.ESVS.PKI||a.uiUtil().isIraq())b.style.visibility="hidden";var v=document.getElementById("us-cert-manage-cls-btn");v.setAttribute("value",c.IDS_CLOSE,0);v.setAttribute("title",c.IDS_CLOSE+c.IDS_BUTTON,0);v.setAttribute("tabindex",C++,0);v.onclick=function(){k&&a.ESVS.chkEXESetup||M()};v.onkeydown=function(a){a=a||window.event;var b=a.which||a.keyCode;9==b&&a.shiftKey&&(v.onblur=function(){setTimeout(function(){document.getElementById("us-cert-manage-sw-info-btn").focus()},10)});9!=b||a.shiftKey||(v.onblur=function(){setTimeout(function(){h.focus()},10)})};var t=!1;h.onkeyup=function(a){a=a||window.event;9==(a.which||a.keyCode)&&a.shiftKey&&t&&(t=!1,setTimeout(function(){v.focus()},10))};h.onkeydown=function(a){a=a||window.event;if(9==(a.which||a.keyCode)&&a.shiftKey)return a.cancelBubble=!0,t=a.returnValue=!0,!1};a.ESVS.ShowGuide&&z(l);return document.getElementById("us-div-cert-manage")}()};return function(n){var y=a.uiLayerLevel,w=a.uiUtil().getOverlay(y),F=X({type:n.type,args:n.args,onConfirm:n.onConfirm,onCancel:n.onCancel});F.style.zIndex=y+1;document.body.insertBefore(w,document.body.firstChild);var S=window.onresize;return{show:function(){draggable(F,document.getElementById("us-div-cert-manage-title"));w.style.display="block";a.uiUtil().offsetResize(F);window.onresize=function(){a.uiUtil().offsetResize(F)};a.uiLayerLevel+=10;a.ESVS.TabIndex+=30;setTimeout(function(){a.uiUtil().setFirstFocus("us-cert-manage-lbl-title")},10)},hide:function(){w.style.display="none";F.style.display="none"},dispose:function(n){1==n&&4&a.ESVS.Mode&&a.ESVS.chkEXESetup&&a.nimservice().ClearAllUserCertList(function(a,n){});window.onresize=function(){S&&S()};F.parentNode.removeChild(F);w.parentNode.removeChild(w);a.uiLayerLevel-=10;a.ESVS.TabIndex-=30}}}};