appPackage.js 91 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970
  1. function utf8_to_b64(str) {
  2. return window.btoa(unescape(encodeURIComponent(str)));
  3. }
  4. function b64_to_utf8(str) {
  5. return decodeURIComponent(escape(window.atob(str)));
  6. }
  7. //////////////工具函数///////////////////
  8. function JsonToTable(json) {
  9. for (var key in json) {
  10. }
  11. }
  12. function toggleVisible(dom) {
  13. toggleClassName(dom.parentElement.getElementsByTagName('table')[0], 'hide');
  14. }
  15. //移除类名
  16. function removeClass(dom, className) {
  17. var temp = dom.className.split(' ');
  18. dom.className = ""
  19. for (var index in temp) {
  20. if (temp[index] != className) {
  21. dom.className += (temp[index] + ' ');
  22. }
  23. }
  24. }
  25. //添加类名
  26. function addClass(dom, className) {
  27. if (dom.className != "") {
  28. if (!hasClass(dom, className)) {
  29. dom.className += (' ' + className);
  30. }
  31. } else {
  32. dom.className = className;
  33. }
  34. }
  35. //是否含有此类名
  36. function hasClass(dom, className) {
  37. var classNames = dom.className.split(' ');
  38. for (var index in classNames) {
  39. if (classNames[index] == className) {
  40. return true;
  41. }
  42. }
  43. return false;
  44. }
  45. function toggleClassName(dom, className) {
  46. if (hasClass(dom, className)) {
  47. removeClass(dom, className);
  48. } else {
  49. addClass(dom, className);
  50. }
  51. }
  52. function toggleBlock(className, showElementId) {
  53. var collection = document.getElementsByTagName('*');
  54. for (var index = 0; index < collection.length; index++) {
  55. if (hasClass(collection[index], className)) {
  56. addClass(collection[index], 'hide');
  57. }
  58. }
  59. var showElement = document.getElementById(showElementId);
  60. removeClass(showElement, 'hide');
  61. }
  62. function formatPrint(outValue){
  63. if(outValue == null || outValue == undefined || outValue.length == 0)
  64. return "null";
  65. else
  66. return outValue;
  67. }
  68. function checkServiceOK()
  69. {
  70. var NETCA_ERROR_WEBSOCKETCONNECTFAIL=-11000;
  71. var params ={};
  72. NetcaPKI.checkPKIInstall(params)
  73. .Then(function(res)
  74. {
  75. SuccessService(res);
  76. })
  77. .Catch(function (res)
  78. {
  79. //连接失败 返回错误
  80. FailedService(res);
  81. });
  82. }
  83. function SuccessService(res)
  84. {
  85. checkVersion();
  86. }
  87. function FailedService(res)
  88. {
  89. alert(res.msg);
  90. }
  91. function getNetcaKeyId(certObj) {
  92. //绑定值顺序 2019-8-1
  93. //证书客户服务号(23)->证书实体唯一标识(36)->绑定姆印(1);*/
  94. if (certObj.userCertServiceId != null && certObj.userCertServiceId.length != 0) {
  95. return certObj.userCertServiceId;
  96. }
  97. else if (certObj.netcaSubjectUniqueId != null && certObj.netcaSubjectUniqueId.length != 0) {
  98. return certObj.netcaSubjectUniqueId;
  99. }
  100. else {
  101. return certObj.Thumbprint;
  102. }
  103. }
  104. function getCertListSuccess(res)
  105. {
  106. if (res && res.deviceCount === 0) {
  107. toastr.error('请插入UKey获取证书');
  108. return;
  109. } else if (res.deviceCount === 1) {
  110. toastr.success('获取证书信息成功');
  111. const cert = res.certInfo[0];
  112. const tip = "证书主题:"+cert.subjectCN+",keyId:"+getNetcaKeyId(cert)+"\n";
  113. // for( s = 0; s < res.certCount; ++s)
  114. // {
  115. // const cert = res.certInfo[s];
  116. // tip += "证书主题:"+cert.subjectCN+",keyId:"+getNetcaKeyId(cert)+"\n";
  117. // }
  118. DeviceOutputId.value = tip;
  119. $('#name').val(cert.subjectCN);
  120. $('#keyId').val(getNetcaKeyId(cert));
  121. } else if (res.deviceCount === 2) {
  122. toastr.error('请拔出多个UKey,保留一个并设置绑定');
  123. return;
  124. } else {
  125. toastr.error('获取证书失败');
  126. }
  127. }
  128. function getCertListFail(res)
  129. {
  130. alert("获取证书列表成功\n" + res.msg);
  131. }
  132. function getCertList()
  133. {
  134. var params={};
  135. NetcaPKI.GetCertList(params)
  136. .Then(function(res){
  137. getCertListSuccess(res);
  138. })
  139. .Catch(function (res) {
  140. getCertListFail(res);
  141. });
  142. }
  143. function DoClearPwdCache() {
  144. var params = {};
  145. NetcaPKI.clearPwdCache(params)
  146. .Then(function (res) {
  147. alert("清除密码缓存成功");
  148. })
  149. .Catch(function (res) {
  150. alert(res.msg);
  151. });
  152. }
  153. function publicKeyEncrypt()
  154. {
  155. var selectType = "Device";
  156. var selectCondition = "CertType='Encrypt'";
  157. switch (publicKeyEncSelectOp.value)
  158. {
  159. case 'pubkeyEnc_op1':
  160. var params = {
  161. cert: { //证书(CertificateParams)
  162. type: selectType,
  163. condition: selectCondition
  164. },
  165. data: { //数据(DataParams)
  166. fileName: publicKeyEncFile.value
  167. }
  168. }
  169. NetcaPKI.publicKeyEncrypt(params)
  170. .Then(function (res) {
  171. SuccessPublicKeyEncryptFileCallBack(res);
  172. })
  173. .Catch(function (res) {
  174. FailedPublicKeyEncryptFileCallBack(res);
  175. })
  176. break;
  177. case 'pubkeyEnc_op2':
  178. var params = {
  179. cert: { //证书(CertificateParams)
  180. type: selectType,
  181. condition: selectCondition
  182. },
  183. data: { //数据(DataParams)
  184. text: utf8_to_b64(publicKeyEncClearText.value)
  185. }};
  186. NetcaPKI.publicKeyEncrypt(params)
  187. .Then(function (res) {
  188. SuccessPublicKeyEncryptFileCallBack(res);
  189. })
  190. .Catch(function (res) {
  191. FailedPublicKeyEncryptFileCallBack(res);
  192. })
  193. break;
  194. }
  195. }
  196. function SuccessPublicKeyEncryptFileCallBack(res)
  197. {
  198. publicKeyEncResult.value =res.encryptValue;
  199. lastPublicKeyEncResult.value = res.encryptValue;
  200. }
  201. function FailedPublicKeyEncryptFileCallBack(res)
  202. {
  203. alert("公钥加密失败\n" + res.msg);
  204. }
  205. function privateKeyDecrypt()
  206. {
  207. var selectType = "Device";
  208. var selectCondition = "CertType='Encrypt'";
  209. var cipherData=lastPublicKeyEncResult.value;
  210. savefile=null;
  211. if(publicKeyDecryptFile.value.length > 0)
  212. {
  213. savefile=publicKeyDecryptFile.value;
  214. }
  215. var params = {
  216. cert: {
  217. type: selectType,
  218. condition: selectCondition
  219. },
  220. // algo: 0, //非对称加密算法
  221. encData: cipherData,
  222. savefileName:savefile
  223. };
  224. NetcaPKI.privateKeyDecrypt(params)
  225. .Then(function (res) {
  226. SuccessPrivateKeyDecryptCallBack(res);
  227. })
  228. .Catch(function (res) {
  229. FailedPrivateKeyDecryptCallBack(res);
  230. })
  231. }
  232. function SuccessPrivateKeyDecryptCallBack(res)
  233. {
  234. if( res.clearEncodeType == "base64" )
  235. {
  236. privateKeyDecResult.value = b64_to_utf8(res.clearValue);
  237. }
  238. else if( res.clearEncodeType == "file" )
  239. {
  240. privateKeyDecResult.value = "文件解密成功,明文文件路径:\n " + savefile;
  241. }
  242. }
  243. function FailedPrivateKeyDecryptCallBack(res)
  244. {
  245. alert("解密失败\n" + res.msg);
  246. }
  247. //PKCS#1 签名
  248. function SuccessSignCallBack(res)
  249. {
  250. p1SignResult.value = "P1签名成功,签名值:\n" + res.signValue;
  251. lastP1SignResult.value = res.signValue;
  252. }
  253. function FailedSignCallBack(res)
  254. {
  255. if (res.netcaCryptoCode != null && res.netcaCryptoCode == -54)
  256. {
  257. alert("P1签名失败\n" + res.msg + ":请确认签名算法和密钥是否匹配!");
  258. return;
  259. }
  260. alert("P1签名失败\n" + res.msg);
  261. }
  262. function signSample()
  263. {
  264. var certEncode = "";
  265. var selectType = "Device";
  266. var selectCondition = "InValidity='True' && CertType='Signature'";
  267. var origindata= utf8_to_b64(p1SignClearText.value);
  268. var signAlgo = parseInt(P1SignAlgo.value);
  269. var params = {
  270. cert: {
  271. "encode": certEncode,
  272. "type": selectType,
  273. "condition": selectCondition
  274. },
  275. data: {
  276. text: origindata
  277. },
  278. algo: signAlgo
  279. };
  280. NetcaPKI.sign(params)
  281. .Then(function (res) {
  282. SuccessSignCallBack(res);
  283. })
  284. .Catch(function (res) {
  285. FailedSignCallBack(res);
  286. });
  287. }
  288. function SuccessSignVerifyCallBack(res) {
  289. alert("p1验证签名成功\n" + res.certObject.certCode);
  290. }
  291. function FailedSignVerifyCallBack(res) {
  292. if (res.netcaCryptoCode != null && res.netcaCryptoCode == -54) {
  293. alert("P1验证签名失败\n" + res.msg + ":请确认签名算法和密钥是否匹配!");
  294. return;
  295. }
  296. alert("P1验证签名失败\n" + res.msg);
  297. }
  298. function signVerifyTest()
  299. {
  300. var certEncode = "";
  301. var selectType = "Device";
  302. var selectCondition = "InValidity='True' && CertType='Signature'";
  303. var origindata = utf8_to_b64(lastP1SignClearText.value);
  304. var signAlgo = parseInt(P1VerifySignAlgo.value);
  305. var signValue = lastP1SignResult.value;
  306. var params = {
  307. cert: {
  308. "encode": certEncode,
  309. "type": selectType,
  310. "condition": selectCondition
  311. },
  312. data: {
  313. text: origindata
  314. },
  315. signature:signValue,
  316. algo: signAlgo
  317. };
  318. NetcaPKI.verifySignature(params)
  319. .Then(function (res) {
  320. SuccessSignVerifyCallBack(res);
  321. })
  322. .Catch(function (res) {
  323. FailedSignVerifyCallBack(res);
  324. });
  325. }
  326. function signedDataSign() {
  327. var certEncode = "";
  328. var selectType = "Device";
  329. var selectCondition = "InValidity='True' && CertType='Signature'";
  330. var _certPwd = CertPwd.value;
  331. var tbs = utf8_to_b64(SignedDataTBS.value);
  332. var _useSubjectKeyId = signedDataUseSubjectKeyId.value;
  333. var _useQ7 = false;
  334. var _detached = signedDataDetach.value;
  335. var _tsaURL = "http://tsa.cnca.net/NETCATimeStampServer/TSAServer.jsp";
  336. var _includeCertOption = 2;
  337. var params={};
  338. if(_certPwd=="")
  339. {
  340. params = {
  341. cert: { //证书(CertificateParams)
  342. encode: certEncode, //可选字段但不能为空
  343. type: selectType,
  344. condition: selectCondition
  345. },
  346. data: { //数据(DataParams)
  347. text: tbs
  348. },
  349. useSubjectKeyId: _useSubjectKeyId, //是否使用主体密钥标识符来标识证书,默认为true
  350. useQ7:_useQ7, //布尔值 是否使用国密Q7的方式,默认为false
  351. detached: parseInt(_detached),
  352. tsaURL: _tsaURL,
  353. includeCertOption: _includeCertOption//整数 包含证书的标识
  354. };
  355. }else
  356. {
  357. params = {
  358. cert: { //证书(CertificateParams)
  359. encode: certEncode, //可选字段但不能为空
  360. type: selectType,
  361. condition: selectCondition
  362. },
  363. data: { //数据(DataParams)
  364. text: tbs
  365. },
  366. useSubjectKeyId: _useSubjectKeyId, //是否使用主体密钥标识符来标识证书,默认为true
  367. useQ7:_useQ7, //布尔值 是否使用国密Q7的方式,默认为false
  368. detached: parseInt(_detached),
  369. tsaURL: _tsaURL,
  370. includeCertOption: _includeCertOption,//整数 包含证书的标识
  371. certPwd:_certPwd
  372. };
  373. }
  374. NetcaPKI.signedDataSign(params)
  375. .Then(function (res) {
  376. SuccessSignedDataSignCallBack(res);
  377. })
  378. .Catch(function (res) {
  379. FailedSignedDataSignCallBack(res);
  380. })
  381. }
  382. function SuccessSignedDataSignCallBack(res)
  383. {
  384. var retSignValue = res.signValue;
  385. //处理base填充问题,这里去掉Base64的填充内容
  386. if(retSignValue!=null&&retSignValue.length>2)
  387. {
  388. var paddingCount=0;
  389. if(retSignValue[retSignValue.length-1]=="=")
  390. {
  391. paddingCount++;
  392. }
  393. if(retSignValue[retSignValue.length-2]=="=")
  394. {
  395. paddingCount++;
  396. }
  397. if(paddingCount>0)
  398. {
  399. //裁剪后面的=号
  400. retSignValue=retSignValue.substring(0,retSignValue.length-paddingCount);
  401. }
  402. }
  403. if(res.result==-5||res.result==-81)
  404. {
  405. retSignValue = "失败\n密码错误,密码重试次数为:"+res.retrynum;
  406. }
  407. SignedDataPVAL.value = "SignedData签名成功,签名值为:\n"+retSignValue;
  408. SignedDataSignature.value = retSignValue;
  409. SignedDataGetInfoSignature.value = retSignValue;
  410. }
  411. function FailedSignedDataSignCallBack(res)
  412. {
  413. alert("SignedData签名失败\n" + res.msg);
  414. }
  415. function signedDataVerify()
  416. {
  417. var _verifyLevel=1;//默认为1
  418. var _signedData = SignedDataSignature.value;
  419. var tbs=null;
  420. if (SignedDataVerifyTBS.value.length > 0 && signedDataDetach.value == "1")
  421. {
  422. tbs=utf8_to_b64(SignedDataVerifyTBS.value);
  423. }
  424. var params = {
  425. verifyLevel: _verifyLevel, //验证级别,默认为验证签名本身,不验证证书,默认为1
  426. signedData: _signedData //signedData的编码值
  427. };
  428. if (tbs != null) {
  429. params.originData = {
  430. text: tbs
  431. };
  432. }
  433. NetcaPKI.signedDataVerify(params)
  434. .Then(function (res) {
  435. SuccessSignedDataVerifyCallBack(res);
  436. })
  437. .Catch(function (res) {
  438. FailedSignedDataVerifyCallBack(res);
  439. })
  440. }
  441. function SuccessSignedDataVerifyCallBack(res)
  442. {
  443. alert("验证签名成功" + JSON.stringify(res));
  444. }
  445. function FailedSignedDataVerifyCallBack(res)
  446. {
  447. alert("验证签名失败"+res.msg);
  448. }
  449. function envelopedDataEncrypt() {
  450. var certCode = "";
  451. var selectType = "Device";
  452. var selectCondition = "CertType='Encrypt'";
  453. var _algo = 0;
  454. var _useSubjectKeyId = (envelopedDataUseSubjectKeyId.value == 1) ? true : false;
  455. switch (EnvelopedDataEncryptSelectOp.value) {
  456. case 'EnvelopedDataEncrypt_op1':
  457. var params = {
  458. cert: { //证书(CertificateParams)
  459. encode: certCode,
  460. type: selectType,
  461. condition: selectCondition
  462. },
  463. algo : _algo, //对称加密算法,默认为128位的AES CBC模式
  464. data: {
  465. fileName: EnvelopedDataEncryptFile.value
  466. },
  467. useSubjectKeyId : _useSubjectKeyId
  468. };
  469. NetcaPKI.envelopedDataEncrypt(params)
  470. .Then(function (res) {
  471. SuccessEnvelopedDataEncryptCallBack(res);
  472. })
  473. .Catch(function (res) {
  474. FailedEnvelopedDataEncryptCallBack(res);
  475. })
  476. break;
  477. case 'EnvelopedDataEncrypt_op2':
  478. var params = {
  479. cert: { //证书(CertificateParams)
  480. encode: certCode,
  481. type: selectType,
  482. condition: selectCondition
  483. },
  484. algo : _algo, //对称加密算法,默认为128位的AES CBC模式
  485. data: {
  486. text: utf8_to_b64(EnvelopedDataEncryptClearText.value)
  487. }
  488. };
  489. NetcaPKI.envelopedDataEncrypt(params)
  490. .Then(function (res) {
  491. SuccessEnvelopedDataEncryptCallBack(res);
  492. })
  493. .Catch(function (res) {
  494. FailedEnvelopedDataEncryptCallBack(res);
  495. })
  496. break;
  497. }
  498. }
  499. function SuccessEnvelopedDataEncryptCallBack(res){
  500. EnvelopedDataEncryptPVAL.value = "数字信封加密成功,密文为:\n"+res.encryptValue;
  501. EnvelopedDataDecryptCipher.value = res.encryptValue;
  502. }
  503. function FailedEnvelopedDataEncryptCallBack(res)
  504. {
  505. alert("数字信封加密失败\n" + res.msg);
  506. }
  507. function envelopedDataDecrypt() {
  508. var _encData = EnvelopedDataDecryptCipher.value;
  509. var _saveFile=null;//解密后如果需要使用文件保存,传入的文件路径
  510. if(EnvelopedDataDecryptFile.value.length > 0)
  511. {
  512. _saveFile=EnvelopedDataDecryptFile.value;
  513. }
  514. var params = {
  515. encData: _encData, //要解密的数据
  516. savefileName:_saveFile
  517. };
  518. NetcaPKI.envelopedDataDecrypt(params)
  519. .Then(function (res) {
  520. SuccessEnvDecryptCallBack(res);
  521. })
  522. .Catch(function (res) {
  523. FailedEnvDecryptCallBack(res);
  524. })
  525. }
  526. function SuccessEnvDecryptCallBack(res)
  527. {
  528. if( res.clearEncodeType == "base64" )
  529. {
  530. EnvelopedDataDecryptClearText.value = b64_to_utf8(res.clearValue);
  531. }
  532. else if( res.clearEncodeType == "file" )
  533. {
  534. EnvelopedDataDecryptClearText.value = "文件解密成功,明文文件路径为 " + EnvelopedDataDecryptFile.value;
  535. }
  536. }
  537. function FailedEnvDecryptCallBack(res)
  538. {
  539. alert("解密失败 " + res.msg);
  540. }
  541. function AutoSignField() {
  542. var _hashAlgo = "SHA-256";//例如:“sha-1”,“sha-256”
  543. var _srcFile = src_path_for_field.value; //源pdf文件
  544. var _destFile = des_path_for_field.value;
  545. var _revInfoIncludeFlag=false; //签名时是否包含签名证书状态信息,true包含
  546. var _tsaURL= "";//时间戳地址
  547. var _tsaUsr= ""; //时间戳服务对应用户名
  548. var _tsaPwd= ""; //时间戳服务对应用户的密码
  549. var _tsaHashAlgo= ""; //时间戳使用的hash算法,例如”sha-1”,”sha-256”等
  550. var _allowCertType="";
  551. /**
  552. * allowCertType为NULL或者ANY表示不进行限制。
  553. * RSA为RSA类型,SM2为SM2类型,ECC为ECC类型包括SM2,ECC!SM2为不包括SM2的ECC类型。
  554. * RSA:SM2为既包括RSA也包括SM2。
  555. * 默认支持RSA,SM2类型的证书。
  556. * 中间件 5.2版本新增的
  557. */
  558. var _selMode= select_mode.value == "0" ? 0 : 1; //选择模式,有两种:按证书选择(0)和按印章选择(1)
  559. var _fieldName = pdfsign_field.value;//要进行签名的签名域名称
  560. var params = {
  561. hashAlgo: _hashAlgo, //例如:“sha-1”,“sha-256”
  562. srcFile: _srcFile, //源pdf文件
  563. destFile: _destFile, //源pdf文件
  564. revInfoIncludeFlag: _revInfoIncludeFlag, //签名时是否包含签名证书状态信息,true包含
  565. selMode: _selMode, //选择模式,有两种:按证书选择(0)和按印章选择(1)
  566. tsaURL: _tsaURL, //时间戳地址
  567. tsaUsr: _tsaUsr, //时间戳服务对应用户名
  568. tsaPwd:_tsaPwd, //时间戳服务对应用户的密码
  569. tsaHashAlgo: _tsaHashAlgo, //时间戳使用的hash算法,例如”sha-1”,”sha-256”等
  570. allowCertType: _allowCertType,
  571. /**
  572. * allowCertType为NULL或者ANY表示不进行限制。
  573. * RSA为RSA类型,SM2为SM2类型,ECC为ECC类型包括SM2,ECC!SM2为不包括SM2的ECC类型。
  574. * RSA:SM2为既包括RSA也包括SM2。
  575. * 默认支持RSA,SM2类型的证书。
  576. * 中间件 5.2版本新增的
  577. */
  578. signField: {
  579. fieldName: _fieldName //要进行签名的签名域名称
  580. }
  581. };
  582. NetcaPKI.pdfAutoSign(params)
  583. .Then(function (res) {
  584. SignSuccessCallBack();
  585. })
  586. .Catch(function (res) {
  587. SignFailedCallBack(res);
  588. });
  589. }
  590. function AutoSignPosition() {
  591. var _hashAlgo = "SHA-256";//例如:“sha-1”,“sha-256”
  592. var _srcFile = src_path_for_position.value; //源pdf文件
  593. var _destFile = des_path_for_position.value;
  594. var _revInfoIncludeFlag=false; //签名时是否包含签名证书状态信息,true包含
  595. var _tsaURL= "";//时间戳地址
  596. var _tsaUsr= ""; //时间戳服务对应用户名
  597. var _tsaPwd= ""; //时间戳服务对应用户的密码
  598. var _tsaHashAlgo= ""; //时间戳使用的hash算法,例如”sha-1”,”sha-256”等
  599. var _allowCertType="";
  600. /**
  601. * allowCertType为NULL或者ANY表示不进行限制。
  602. * RSA为RSA类型,SM2为SM2类型,ECC为ECC类型包括SM2,ECC!SM2为不包括SM2的ECC类型。
  603. * RSA:SM2为既包括RSA也包括SM2。
  604. * 默认支持RSA,SM2类型的证书。
  605. * 中间件 5.2版本新增的
  606. */
  607. var _selMode= select_mode.value == "0" ? 0 : 1; //选择模式,有两种:按证书选择(0)和按印章选择(1)
  608. var _pageNum= parseInt(pdfSign_pageNumber.value); //输入参数,整型,PDF文档的页码,页码从1开始计算。
  609. var _xPos= parseInt(pdfSign_xpos.value); //输入参数,整型,签章左下角的水平向右方向坐标。
  610. var _yPos=parseInt(pdfSign_ypos.value); //输入参数,整型,签章左下角的垂直向上方向坐标。
  611. var _width= parseInt(pdfSign_seal_width.value); //输入参数,整型,签章的宽度。
  612. var _height=parseInt(pdfSign_seal_height.value) ;//输入参数,整型,签章的高度。
  613. var params = {
  614. hashAlgo: _hashAlgo, //例如:“sha-1”,“sha-256”
  615. srcFile: _srcFile, //源pdf文件
  616. destFile: _destFile, //源pdf文件
  617. revInfoIncludeFlag: _revInfoIncludeFlag, //签名时是否包含签名证书状态信息,true包含
  618. selMode: _selMode, //选择模式,有两种:按证书选择(0)和按印章选择(1)
  619. tsaURL: _tsaURL, //时间戳地址
  620. tsaUsr: _tsaUsr, //时间戳服务对应用户名
  621. tsaPwd:_tsaPwd, //时间戳服务对应用户的密码
  622. tsaHashAlgo: _tsaHashAlgo, //时间戳使用的hash算法,例如”sha-1”,”sha-256”等
  623. allowCertType: _allowCertType,
  624. /**
  625. * allowCertType为NULL或者ANY表示不进行限制。
  626. * RSA为RSA类型,SM2为SM2类型,ECC为ECC类型包括SM2,ECC!SM2为不包括SM2的ECC类型。
  627. * RSA:SM2为既包括RSA也包括SM2。
  628. * 默认支持RSA,SM2类型的证书。
  629. * 中间件 5.2版本新增的
  630. */
  631. signPosition: {
  632. pageNum: _pageNum, //输入参数,整型,PDF文档的页码,页码从1开始计算。
  633. xPos: _xPos, //输入参数,整型,签章左下角的水平向右方向坐标。
  634. yPos: _yPos, //输入参数,整型,签章左下角的垂直向上方向坐标。
  635. width: _width, //输入参数,整型,签章的宽度。
  636. height: _height //输入参数,整型,签章的高度。
  637. }
  638. };
  639. NetcaPKI.pdfAutoSign(params)
  640. .Then(function (res) {
  641. SignSuccessCallBack();
  642. })
  643. .Catch(function (res) {
  644. SignFailedCallBack(res);
  645. });
  646. }
  647. function SignSuccessCallBack()
  648. {
  649. alert("签章成功");
  650. }
  651. function SignFailedCallBack(res)
  652. {
  653. alert("签章失败 " + res.msg);
  654. }
  655. function getCertStringAttribute()
  656. {
  657. /* 从USBKey中选择NETCA 颁发的签名证书 */
  658. var certEncode = CertCodeText.value;
  659. var selectType = "";
  660. var selectCondition = "";
  661. var attId = parseInt(CertAttributeIdText.value);
  662. if( CertCodeText.value.length == 0 )
  663. {
  664. selectType = "Device";
  665. selectCondition = "IssuerCN~'NETCA' && InValidity='True' && CertType='Signature'";
  666. }
  667. var params = {
  668. cert: {
  669. "encode":certEncode,
  670. "type":selectType,
  671. "condition":selectCondition
  672. },
  673. id:attId
  674. };
  675. NetcaPKI.getCertStringAttribute(params)
  676. .Then(function(res){
  677. successGetCertStringAttributeCallBack(res);
  678. })
  679. .Catch(function (res) {
  680. failedGetCertStringAttributeCallBack(res);
  681. });
  682. }
  683. function successGetCertStringAttributeCallBack(res)
  684. {
  685. var idvalue="";
  686. if(CertAttributeIdText.value > 0 )
  687. idvalue = "id " + CertAttributeIdText.value + "对应的属性值为 " + formatPrint(res.value);
  688. CertCodeText.value = res.certCode;
  689. var tip = "证书解析成功\n" + idvalue +
  690. "\n公钥算法(1-RSA,2-DSA,3-DH,4-ECC)为 " + res.publicKeyAlgorithm +
  691. " 公钥类型(1-RSA,2-SM2,3-ECC)为 " + res.publicKeyType +
  692. " 公钥长度为 " + res.publicKeyBits +
  693. "\n颁发者为 " + formatPrint(res.issuer) +
  694. "\n颁发者C为 " + formatPrint(res.issuerC) +
  695. "\n颁发者ST为 " + formatPrint(res.issuerST) +
  696. "\n颁发者L为 " + formatPrint(res.issuerL) +
  697. "\n颁发者O为 " + formatPrint(res.issuerO) +
  698. "\n颁发者OU为 " + formatPrint(res.issuerOU) +
  699. "\n颁发者CN为 " + formatPrint(res.issuerCN) +
  700. "\n主体者C为 " + formatPrint(res.subjectC) +
  701. "\n主体ST为 " + formatPrint(res.subjectST) +
  702. "\n主体L为 " + formatPrint(res.subjectL) +
  703. "\n主体O为 " + formatPrint(res.subjectO) +
  704. "\n主体OU为 " + formatPrint(res.subjectOU) +
  705. "\n主体EMAIL为 " + formatPrint(res.subjectEmail) +
  706. "\n主体CN为 " + formatPrint(res.subjectCN) +
  707. "\n有效期开始时间为 " + formatPrint(res.validFromDate) +
  708. "\n有效期结束时间为 " + formatPrint(res.validToDate) +
  709. "\nHex编码的证书序列号为 " + formatPrint(res.serialNumber) +
  710. "\n密钥用法为 " + formatPrint(res.keyUsage) +
  711. "\n用户证书服务号为 " + formatPrint(res.userCertServiceId) +
  712. "\n证书类别为 " + formatPrint( res.certClassExtValue) +
  713. "\n深圳地标唯一标识为 " + formatPrint(res.shenzhenSubjectUniqueId) +
  714. "\nNETCA唯一标识为 " + formatPrint(res.netcaSubjectUniqueId)+
  715. "\n实施证书唯一标识 " + formatPrint(res.AppUsrCertNO);
  716. if(res.netcaIdentifyItemsCount==null||res.netcaIdentifyItemsCount==0)
  717. {
  718. tip+="\n个人身份标识扩展不存在";
  719. }
  720. else
  721. {
  722. tip+="\n个人身份标识编码个数: " + res.netcaIdentifyItemsCount;
  723. var i=0;
  724. for(i=0;i<res.netcaIdentifyItemsCount;++i)
  725. {
  726. tip+="\n个人身份标识编码值:"+res.netcaIdentifyItems[i];
  727. }
  728. }
  729. if(res.netcaEnterpriseidItemsCount==null||res.netcaEnterpriseidItemsCount==0)
  730. {
  731. tip+="\n企业机构身份标识扩展不存在";
  732. }
  733. else
  734. {
  735. tip+="\n企业机构身份标识编码个数: " + res.netcaEnterpriseidItemsCount;
  736. var i=0;
  737. for(i=0;i<res.netcaEnterpriseidItemsCount;++i)
  738. {
  739. tip+="\n企业机构身份标识编码值:"+res.netcaEnterpriseidItems[i];
  740. }
  741. }
  742. CertAttributeValue.value = tip;
  743. }
  744. function failedGetCertStringAttributeCallBack(res)
  745. {
  746. alert("失败\n" + res.msg);
  747. }
  748. function isInsertKey()
  749. {
  750. var _cert = CertCodeText.value;
  751. var _sn = keySN.value;
  752. var _type = parseInt(keyType.value);
  753. var params = {
  754. cert: {
  755. "encode":_cert
  756. },//可选,指定证书所在的Key是否插入
  757. sn:_sn, //可选
  758. type:_type //可选
  759. };
  760. NetcaPKI.isInsertKey(params)
  761. .Then(function(res){
  762. if (res.insertCount > 0)
  763. {
  764. InsertCallBack(res);
  765. }
  766. else
  767. {
  768. UnInsertCallBack(res);
  769. }
  770. })
  771. .Catch(function (res) {
  772. UnInsertCallBack(res);
  773. });
  774. }
  775. function InsertCallBack(res)
  776. {
  777. var tip = "检测是否插入key接口调用成功\n设备数量为 " + res.insertCount;
  778. for( s = 1; s <= res.insertCount; ++s)
  779. {
  780. var temp = "type" + s;
  781. tip += "\n设备" + s +"的类型为" + res[temp];
  782. var temp2 = "sn" + s;
  783. tip += " 序列号为 " + res[temp2];
  784. var temp3="retrynum"+s;
  785. tip += "密码重试次数为 " + res[temp3];
  786. if(s == 1 && keySN.value == "" && keyType.value == "")
  787. {
  788. keySN.value = res[temp2];
  789. keyType.value = res[temp];
  790. }
  791. }
  792. DeviceOutputId.value = tip;
  793. }
  794. function UnInsertCallBack(res)
  795. {
  796. if (res.insertCount == 0)
  797. DeviceOutputId.value = "检测是否插入key接口调用成功,没有发现符合条件的Key";
  798. else
  799. DeviceOutputId.value = res.msg;
  800. }
  801. function monitorDevice()
  802. {
  803. var _delayTime=0;//延迟时间,单位是毫秒,默认是0毫秒
  804. var params = {
  805. delayTime: _delayTime //延迟时间,默认为0毫秒
  806. };
  807. NetcaPKI.monitorDevice(params)
  808. .Then(function(res)
  809. {
  810. SuccessMonitorDeviceCallBack(res);
  811. })
  812. .Catch(function (res)
  813. {
  814. FailedMonitorDeviceCallBack(res);
  815. });
  816. }
  817. function SuccessMonitorDeviceCallBack(res)
  818. {
  819. if(res !=null)
  820. {
  821. var deviceType=res.type;
  822. var deviceStatus;
  823. var isPullOut=res.pullOut;
  824. deviceSn=res.sn;
  825. if(isPullOut==1)
  826. {
  827. deviceStatus="拔出";
  828. alert("设备序列号为:"+deviceSn+"\n设备类型为:"+deviceType+"\n设备状态为:"+deviceStatus);
  829. }
  830. else{
  831. deviceStatus="插入";
  832. alert("设备序列号为:"+deviceSn+"\n设备类型为:"+deviceType+"\n设备状态为:"+deviceStatus);
  833. }
  834. }
  835. }
  836. function FailedMonitorDeviceCallBack(res)
  837. {
  838. alert("失败\n"+res.msg);
  839. }
  840. function checkVersion()
  841. {
  842. var params ={};
  843. NetcaPKI.getVersionInfo(params)
  844. .Then(function(res)
  845. {
  846. SuccessGetVersionInfoCallBack(res);
  847. })
  848. .Catch(function (res)
  849. {
  850. FailedGetVersionInfoCallBack(res);
  851. });
  852. }
  853. function SuccessGetVersionInfoCallBack(res)
  854. {
  855. var versionInfo=res.VersionInfo;
  856. var version =res.Version;
  857. alert("网证通相关驱动已经成功安装\n版本号为:"+version+"\n版本号信息为:"+versionInfo+"\n版本UID为:"+res.UID);
  858. }
  859. function FailedGetVersionInfoCallBack(res)
  860. {
  861. alert("多浏览器应用插件相关文件回调失败\n" + res.msg);
  862. }
  863. function FailedGetCertOidCallBack(res) {
  864. alert("获取证书扩展项失败\n" + res.msg);
  865. }
  866. function SuccessGetCertOidCallBack(res) {
  867. if(res.isExist==0)
  868. {
  869. alert("获取证书扩展项成功,但证书没有对应的扩展项");
  870. return;
  871. }
  872. alert("获取证书扩展项成功\n"+ res.extensionValue);
  873. }
  874. function getCertOid() {
  875. var _encode = CertCodeText.value;
  876. var _selectType = "Device";
  877. var _condition = "CertType='Signature'&& InValidity='True'";
  878. var _oidstr = certOid.value;
  879. var _oidType = parseInt(certOidType.value);
  880. var params = {
  881. cert: {
  882. "encode":_encode,
  883. "type":_selectType,
  884. "condition":_condition
  885. },
  886. oidstr:_oidstr,
  887. type: _oidType
  888. };
  889. NetcaPKI.getCertStringExtensionValue(params)
  890. .Then(function (res) {
  891. SuccessGetCertOidCallBack(res);
  892. })
  893. .Catch(function (res) {
  894. FailedGetCertOidCallBack(res);
  895. });
  896. }
  897. function verifyPwd()
  898. {
  899. var _pwd = pwdId.value;
  900. var _encode = CertCodeText.value;
  901. var _sn = keySN.value;
  902. var _type = parseInt(keyType.value);
  903. var params = {
  904. pwd:_pwd,
  905. cert: {
  906. "encode":_encode
  907. },//可选,指定证书所在的Key是否插入
  908. sn:_sn, //可选
  909. type:_type //可选
  910. };
  911. NetcaPKI.verifyKeyPwd(params)
  912. .Then(function(res){
  913. if (res.result == 1)
  914. {
  915. verifySuccess(res);
  916. }
  917. else
  918. {
  919. verifyFailed(res);
  920. }
  921. })
  922. .Catch(function (res) {
  923. alert(res.msg);
  924. });
  925. }
  926. function verifySuccess(res)
  927. {
  928. var tip = "密码验证成功,验证的设备类型为 " + res.type +
  929. "; 验证的设备序列号为 " + res.sn
  930. + "; 密码剩余重试次数为 " + res.retrynum;
  931. DeviceOutputId.value = tip;
  932. }
  933. function verifyFailed(res)
  934. {
  935. var tip = "密码验证失败,错误码为" + res.result +
  936. "; 验证的设备类型为 " + res.type +
  937. "; 验证的设备序列号为 " + res.sn
  938. + "; 密码剩余重试次数为 " + res.retrynum;
  939. DeviceOutputId.value = tip;
  940. }
  941. function formatPrint(outValue){
  942. if(outValue == null || outValue == undefined || outValue.length == 0)
  943. return "null";
  944. else
  945. return outValue;
  946. }
  947. function getHardDeviceInformation()
  948. {
  949. var params ={};
  950. NetcaPKI.getHardDeviceInformation(params)
  951. .Then(function(res)
  952. {
  953. SuccessGetHardDeviceCallBack(res);
  954. })
  955. .Catch(function (res)
  956. {
  957. FailedGetHardDeviceCallBack(res);
  958. });
  959. }
  960. function SuccessGetHardDeviceCallBack(res)
  961. {
  962. var tip = "当前时间为 " + res.time +
  963. ", mac 为 " + res.mac +
  964. ", 硬盘序列号为 " + res.diskSN +
  965. ", CPUID为 " + res.cpuid +
  966. ", 主板序列号为 " + res.boardsn +
  967. ", 主板类型为 " + res.boardtype;
  968. alert(tip);
  969. }
  970. function FailedGetHardDeviceCallBack(res)
  971. {
  972. alert("获取硬件信息失败 " + res.msg);
  973. }
  974. function getNetworkInformation()
  975. {
  976. var params = {};
  977. NetcaPKI.getNetworkInformation(params)
  978. .Then(function(res)
  979. {
  980. SuccessGetNetworkCallBack(res);
  981. })
  982. .Catch(function(res)
  983. {
  984. FailedGetNetworkCallBack(res);
  985. });
  986. }
  987. function SuccessGetNetworkCallBack(res)
  988. {
  989. var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=Base64._utf8_encode(e);while(f<e.length){n=e.charCodeAt(f++);r=e.charCodeAt(f++);i=e.charCodeAt(f++);s=n>>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)}return t},decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za-z0-9+/=]/g,"");while(f<e.length){s=this._keyStr.indexOf(e.charAt(f++));o=this._keyStr.indexOf(e.charAt(f++));u=this._keyStr.indexOf(e.charAt(f++));a=this._keyStr.indexOf(e.charAt(f++));n=s<<2|o>>4;r=(o&15)<<4|u>>2;i=(u&3)<<6|a;t=t+String.fromCharCode(n);if(u!=64){t=t+String.fromCharCode(r)}if(a!=64){t=t+String.fromCharCode(i)}}t=Base64._utf8_decode(t);return t},_utf8_encode:function(e){e=e.replace(/rn/g,"n");var t="";for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r)}else if(r>127&&r<2048){t+=String.fromCharCode(r>>6|192);t+=String.fromCharCode(r&63|128)}else{t+=String.fromCharCode(r>>12|224);t+=String.fromCharCode(r>>6&63|128);t+=String.fromCharCode(r&63|128)}}return t},_utf8_decode:function(e){var t="";var n=0;var r=c1=c2=0;while(n<e.length){r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r);n++}else if(r>191&&r<224){c2=e.charCodeAt(n+1);t+=String.fromCharCode((r&31)<<6|c2&63);n+=2}else{c2=e.charCodeAt(n+1);c3=e.charCodeAt(n+2);t+=String.fromCharCode((r&15)<<12|(c2&63)<<6|c3&63);n+=3}}return t}};
  990. var tip = "所有网卡信息:\n";
  991. for(i in res.AdaptorInfo)
  992. {
  993. var adapterInfo = "{" +
  994. "\"Name\"=" + Base64.decode(res.AdaptorInfo[i]["Name"]) +
  995. ", \"Mac\"=" + res.AdaptorInfo[i]["Mac"] +
  996. ", \"IPV4\"=" + res.AdaptorInfo[i]["IPV4"] +
  997. ", \"GateWay\"=" + res.AdaptorInfo[i]["GateWay"] +
  998. ", DNS信息= [";
  999. var dnsInfo = "";
  1000. for(j in res.AdaptorInfo[i]["DNS"])
  1001. {
  1002. dnsInfo += "\"DNS" + j + "\"=" + res.AdaptorInfo[i]["DNS"][j] + " ";
  1003. }
  1004. dnsInfo += "]}\n"
  1005. tip = tip + adapterInfo + dnsInfo;
  1006. }
  1007. // "网络IP地址:" + res.InuseAdaptor.IPV4 +
  1008. // "\n网关地址:" + res.InuseAdaptor.GateWay +
  1009. // "\nDNS地址:" + res.InuseAdaptor.DNS;
  1010. tip += "\n当前用户登录名:" + Base64.decode(res.LoginName) +
  1011. "\n操作系统版本号:" + res.OSVersion;
  1012. tip += "\n已连接wifi:{" +
  1013. "\"Name\"=" + Base64.decode(res.ConnectedWifi["Name"]) +
  1014. ", \"Mac\"=" + res.ConnectedWifi["Mac"] + "}";
  1015. tip += "\n可连接的所有潜在wifi:\n";
  1016. for(i in res.AttachableWifis)
  1017. {
  1018. var wifiStr = "{" +
  1019. "\"Name\"=" + Base64.decode(res.AttachableWifis[i]["Name"]) +
  1020. ", \"Mac\"=" + res.AttachableWifis[i]["Mac"] +
  1021. "}\n";
  1022. tip += wifiStr;
  1023. }
  1024. alert(tip);
  1025. console.log(tip);
  1026. }
  1027. function FailedGetNetworkCallBack(res)
  1028. {
  1029. alert("获取网络信息失败:" + res.msg);
  1030. }
  1031. function seal_SignSealField(_selMode)
  1032. {
  1033. var _srcFile = signatureCreator_src_path.value; //源Pdf文件路径
  1034. var _srcBytes = signatureCreator_srcBytes.value; //源Pdf文件字节流
  1035. var _destFile = signatureCreator_des_path.value; //目标pdf文件
  1036. var _certEncode = signatureCreator_certEncode.value; //签名证书Base64编码
  1037. var _selMode = parseInt(_selMode.name); //操作模式
  1038. var _signFieldText = signatureCreator_signFieldText.value; //签名域显示的文字
  1039. var _sealImageEncode = signatureCreator_sealImageEncode.value;//签章图片Base64编码
  1040. var _fieldName = signatureCreator_field.value; //签名域名称
  1041. var _revInfoIncludeFlag = (signatureCreator_revInfoIncludeFlag.value == 1) ? true : false; //是否包含吊销信息
  1042. var _tsaUrl= ""; //时间戳地址
  1043. var _tsaUsr= ""; //时间戳服务对应用户名
  1044. var _tsaPwd= ""; //时间戳服务对应用户的密码
  1045. var _tsaHashAlgo= ""; //时间戳使用的hash算法,例如”sha-1”,”sha-256”等
  1046. var params = {
  1047. srcFile: _srcFile, //源pdf文件
  1048. srcBytes: _srcBytes, //源Pdf文件的Base64编码
  1049. destFile: _destFile, //目标pdf文件
  1050. certEncode: _certEncode, //签名证书Base64编码
  1051. selMode: _selMode, //操作模式
  1052. signFieldText: _signFieldText, //签名域显示的文字
  1053. sealImageEncode: _sealImageEncode, //签章图片Base64编码
  1054. revInfoIncludeFlag: _revInfoIncludeFlag,//是否包含吊销信息
  1055. SignField: //签名域对象
  1056. {
  1057. fieldName: _fieldName //签名域名称
  1058. },
  1059. Tsa: //时间戳对象
  1060. {
  1061. tsaUrl: _tsaUrl, //时间戳地址
  1062. tsaUsr: _tsaUsr, //时间戳服务对应用户名
  1063. tsaPwd: _tsaPwd, //时间戳服务对应用户的密码
  1064. tsaHashAlgo: _tsaHashAlgo //时间戳使用的hash算法,例如”sha-1”,”sha-256”等
  1065. }
  1066. };
  1067. NetcaPKI.signatureCreatorSignSeal(params)
  1068. .Then(function (res)
  1069. {
  1070. SignatureCreatorSuccessCallBack(res);
  1071. })
  1072. .Catch(function (res)
  1073. {
  1074. SignatureCreatorFailedCallBack(res);
  1075. });
  1076. }
  1077. function seal_SignSealPosition(_selMode)
  1078. {
  1079. var _srcFile = signatureCreator_src_path.value; //源Pdf文件
  1080. var _srcBytes = signatureCreator_srcBytes.value; //源Pdf文件字节流
  1081. var _destFile = signatureCreator_des_path.value; //目标pdf文件
  1082. var _certEncode = signatureCreator_certEncode.value; //签名证书Base64编码
  1083. var _selMode = parseInt(_selMode.name); //操作模式
  1084. var _signFieldText = signatureCreator_signFieldText.value; //签名域显示的文字
  1085. var _sealImageEncode = signatureCreator_sealImageEncode.value;//签章图片Base64编码
  1086. var _revInfoIncludeFlag = (signatureCreator_revInfoIncludeFlag.value == 1) ? true : false; //是否包含吊销信息
  1087. var _pageNum = parseInt(signatureCreator_pageNumber.value); //PDF文档的页码
  1088. var _xPos = parseInt(signatureCreator_xpos.value); //签名域/签章左下角的水平向右方向坐标
  1089. var _yPos = parseInt(signatureCreator_ypos.value); //签名域/签章左下角的垂直向上方向坐标
  1090. var _width = parseInt(signatureCreator_width.value); //签名域/签章的宽度
  1091. var _height = parseInt(signatureCreator_height.value); //签名域/签章的高度
  1092. var _tsaUrl= "http://tsa.cnca.net/NETCATimeStampServer/TSAServer.jsp"; //时间戳地址
  1093. var _tsaUsr= ""; //时间戳服务对应用户名
  1094. var _tsaPwd= ""; //时间戳服务对应用户的密码
  1095. var _tsaHashAlgo= ""; //时间戳使用的hash算法,例如”sha-1”,”sha-256”等
  1096. var params = {
  1097. srcFile: _srcFile, //源pdf文件
  1098. srcBytes: _srcBytes, //源Pdf文件的Base64编码
  1099. destFile: _destFile, //目标pdf文件
  1100. certEncode: _certEncode, //签名证书Base64编码
  1101. selMode: _selMode, //操作模式
  1102. signFieldText: _signFieldText, //签名域显示的文字
  1103. sealImageEncode: _sealImageEncode, //签章图片Base64编码
  1104. revInfoIncludeFlag: _revInfoIncludeFlag,//是否包含吊销信息
  1105. SignPosition: //签名位置对象
  1106. {
  1107. pageNum: _pageNum, //PDF文档的页码
  1108. xPos: _xPos, //签名域/签章左下角的水平向右方向坐标
  1109. yPos: _yPos, //签名域/签章左下角的垂直向上方向坐标
  1110. width: _width, //签名域/签章的宽度
  1111. height: _height //签名域/签章的高度
  1112. },
  1113. Tsa: //时间戳对象
  1114. {
  1115. tsaUrl: _tsaUrl, //时间戳地址
  1116. tsaUsr: _tsaUsr, //时间戳服务对应用户名
  1117. tsaPwd: _tsaPwd, //时间戳服务对应用户的密码
  1118. tsaHashAlgo: _tsaHashAlgo //时间戳使用的hash算法,例如”sha-1”,”sha-256”等
  1119. }
  1120. };
  1121. NetcaPKI.signatureCreatorSignSeal(params)
  1122. .Then(function (res)
  1123. {
  1124. SignatureCreatorSuccessCallBack(res);
  1125. })
  1126. .Catch(function (res)
  1127. {
  1128. SignatureCreatorFailedCallBack(res);
  1129. });
  1130. }
  1131. function SignatureCreatorSuccessCallBack(res)
  1132. {
  1133. var result = "签名/章成功, 目标文件的Base64编码:\n" + res.destFileEncode;
  1134. alert(result);
  1135. console.log(res.destFileEncode);
  1136. if(res.destFileEncode.length >= 20*1024*1024)
  1137. {
  1138. alert("注意:目标文件大于20M,会造成浏览器卡顿");
  1139. }
  1140. NetcaPDFSeal.preViewPDF(1, res.destFileEncode);
  1141. }
  1142. function SignatureCreatorFailedCallBack(res)
  1143. {
  1144. alert("签名/章失败 " + res.msg);
  1145. }
  1146. function seal_SignSealFieldEx(selMode)
  1147. {
  1148. var _srcFile = signatureCreator_src_pathEx.value; //源Pdf文件路径
  1149. var _srcBytes = signatureCreator_srcBytesEx.value; //源Pdf文件字节流
  1150. var _destFile = signatureCreator_des_pathEx.value; //目标pdf文件
  1151. var _certEncode = signatureCreator_certEncodeEx.value; //签名证书Base64编码
  1152. var _selMode = parseInt(selMode.name); //操作模式
  1153. var _signFieldText = signatureCreator_signFieldTextEx.value; //签名域显示的文字
  1154. var _sealImageEncode = signatureCreator_sealImageEncodeEx.value;//签章图片Base64编码
  1155. var _fieldName = signatureCreator_fieldEx.value; //签名域名称
  1156. var _revInfoIncludeFlag = (signatureCreator_revInfoIncludeFlagEx.value == 1) ? true : false; //是否包含吊销信息
  1157. var _tsaUrl= ""; //时间戳地址
  1158. var _tsaUsr= ""; //时间戳服务对应用户名
  1159. var _tsaPwd= ""; //时间戳服务对应用户的密码
  1160. var _tsaHashAlgo= ""; //时间戳使用的hash算法,例如”sha-1”,”sha-256”等
  1161. var _text=signatureCreator_textEx.value; //自定义文本信息
  1162. var _timeFormat=signatureCreator_timeFormatEx.value; //日期格式
  1163. var _widthPercentage=parseFloat(signatureCreator_widthPercentageEx.value); //宽偏移百分比
  1164. var _heightPercentage=parseFloat(signatureCreator_heightPercentageEx.value); //高偏移百分比
  1165. var _fontName=signatureCreator_fontNameEx.value; //字体
  1166. var _fontSize=parseInt(signatureCreator_fontSizeEx.value); //字体大小
  1167. var _A=parseInt(signatureCreator_fontColorAEx.value); //透明度
  1168. var _R=parseInt(signatureCreator_fontColorREx.value); //红色
  1169. var _G=parseInt(signatureCreator_fontColorGEx.value); //绿色
  1170. var _B=parseInt(signatureCreator_fontColorBEx.value); //蓝色
  1171. var params = {
  1172. srcFile: _srcFile, //源pdf文件
  1173. srcBytes: _srcBytes, //源Pdf文件的Base64编码
  1174. destFile: _destFile, //目标pdf文件
  1175. certEncode: _certEncode, //签名证书Base64编码
  1176. selMode: _selMode, //操作模式
  1177. signFieldText: _signFieldText, //签名域显示的文字
  1178. sealImageEncode: _sealImageEncode, //签章图片Base64编码
  1179. revInfoIncludeFlag: _revInfoIncludeFlag,//是否包含吊销信息
  1180. SignField: //签名域对象
  1181. {
  1182. fieldName: _fieldName //签名域名称
  1183. },
  1184. Tsa: //时间戳对象
  1185. {
  1186. tsaUrl: _tsaUrl, //时间戳地址
  1187. tsaUsr: _tsaUsr, //时间戳服务对应用户名
  1188. tsaPwd: _tsaPwd, //时间戳服务对应用户的密码
  1189. tsaHashAlgo: _tsaHashAlgo //时间戳使用的hash算法,例如”sha-1”,”sha-256”等
  1190. },
  1191. TimeObj:
  1192. {
  1193. text: _text, //自定义文本信息
  1194. timeFormat: _timeFormat, //日期格式
  1195. widthPercentage: _widthPercentage, //宽偏移百分比
  1196. heightPercentage: _heightPercentage,//高偏移百分比
  1197. fontName: _fontName, //字体
  1198. fontSize: _fontSize, //字体大小
  1199. FontColor:
  1200. {
  1201. A: _A,
  1202. R: _R,
  1203. G: _G,
  1204. B: _B
  1205. }
  1206. },
  1207. AppearanceObj:
  1208. {
  1209. appearanceType:parseInt(signatureCreator_appearanceType.value), //外观类型
  1210. width:parseInt(signatureCreator_appearanceWidth.value), //外观宽度
  1211. height:parseInt(signatureCreator_appearanceHeight.value), //外观高度
  1212. textSpirits:g_textSpirits //文本信息
  1213. }
  1214. };
  1215. NetcaPKI.SignatureCreatorSignSealEx(params)
  1216. .Then(function (res)
  1217. {
  1218. SignatureCreatorSuccessCallBackEx(res);
  1219. })
  1220. .Catch(function (res)
  1221. {
  1222. SignatureCreatorFailedCallBackEx(res);
  1223. });
  1224. }
  1225. function seal_SignSealPositionEx(selMode)
  1226. {
  1227. var _srcFile = signatureCreator_src_pathEx.value; //源Pdf文件
  1228. var _srcBytes = signatureCreator_srcBytesEx.value; //源Pdf文件字节流
  1229. var _destFile = signatureCreator_des_pathEx.value; //目标pdf文件
  1230. var _certEncode = signatureCreator_certEncodeEx.value; //签名证书Base64编码
  1231. var _selMode = parseInt(selMode.name); //操作模式
  1232. var _signFieldText = signatureCreator_signFieldTextEx.value; //签名域显示的文字
  1233. var _sealImageEncode = signatureCreator_sealImageEncodeEx.value;//签章图片Base64编码
  1234. var _revInfoIncludeFlag = (signatureCreator_revInfoIncludeFlagEx.value == 1) ? true : false; //是否包含吊销信息
  1235. var _positionStartPage = parseInt(signatureCreator_position_startPageEx.value); //PDF文档的开始页码
  1236. var _positionEndPage = parseInt(signatureCreator_position_endPageEx.value); //PDF文档的结束页码
  1237. var _xPos = parseInt(signatureCreator_xposEx.value); //签名域/签章左下角的水平向右方向坐标
  1238. var _yPos = parseInt(signatureCreator_yposEx.value); //签名域/签章左下角的垂直向上方向坐标
  1239. var _positioinWidth = parseInt(signatureCreator_position_widthEx.value); //签名域/签章的宽度
  1240. var _positionHeight = parseInt(signatureCreator_position_heightEx.value); //签名域/签章的高度
  1241. var _tsaUrl= ""; //时间戳地址
  1242. var _tsaUsr= ""; //时间戳服务对应用户名
  1243. var _tsaPwd= ""; //时间戳服务对应用户的密码
  1244. var _tsaHashAlgo= ""; //时间戳使用的hash算法,例如”sha-1”,”sha-256”等
  1245. var _text=signatureCreator_textEx.value; //自定义文本信息
  1246. var _timeFormat=signatureCreator_timeFormatEx.value; //日期格式
  1247. var _widthPercentage=parseFloat(signatureCreator_widthPercentageEx.value); //宽偏移百分比
  1248. var _heightPercentage=parseFloat(signatureCreator_heightPercentageEx.value); //高偏移百分比
  1249. var _fontName=signatureCreator_fontNameEx.value; //字体
  1250. var _fontSize=parseInt(signatureCreator_fontSizeEx.value); //字体大小
  1251. var _A=parseInt(signatureCreator_fontColorAEx.value); //透明度
  1252. var _R=parseInt(signatureCreator_fontColorREx.value); //红色
  1253. var _G=parseInt(signatureCreator_fontColorGEx.value); //绿色
  1254. var _B=parseInt(signatureCreator_fontColorBEx.value); //蓝色
  1255. var params = {
  1256. srcFile: _srcFile, //源pdf文件
  1257. srcBytes: _srcBytes, //源Pdf文件的Base64编码
  1258. destFile: _destFile, //目标pdf文件
  1259. certEncode: _certEncode, //签名证书Base64编码
  1260. selMode: _selMode, //操作模式
  1261. signFieldText: _signFieldText, //签名域显示的文字
  1262. sealImageEncode: _sealImageEncode, //签章图片Base64编码
  1263. revInfoIncludeFlag: _revInfoIncludeFlag,//是否包含吊销信息
  1264. SignPosition: //签名位置对象
  1265. {
  1266. startPage: _positionStartPage, //PDF文档的开始页码
  1267. endPage: _positionEndPage, //PDF文档的结束页码
  1268. xPos: _xPos, //签名域/签章左下角的水平向右方向坐标
  1269. yPos: _yPos, //签名域/签章左下角的垂直向上方向坐标
  1270. width: _positioinWidth, //签名域/签章的宽度
  1271. height: _positionHeight //签名域/签章的高度
  1272. },
  1273. Tsa: //时间戳对象
  1274. {
  1275. tsaUrl: _tsaUrl, //时间戳地址
  1276. tsaUsr: _tsaUsr, //时间戳服务对应用户名
  1277. tsaPwd: _tsaPwd, //时间戳服务对应用户的密码
  1278. tsaHashAlgo: _tsaHashAlgo //时间戳使用的hash算法,例如”sha-1”,”sha-256”等
  1279. },
  1280. TimeObj:
  1281. {
  1282. text: _text, //自定义文本信息
  1283. timeFormat: _timeFormat, //日期格式
  1284. widthPercentage: _widthPercentage, //宽偏移百分比
  1285. heightPercentage: _heightPercentage,//高偏移百分比
  1286. fontName: _fontName, //字体
  1287. fontSize: _fontSize, //字体大小
  1288. FontColor:
  1289. {
  1290. A: _A,
  1291. R: _R,
  1292. G: _G,
  1293. B: _B
  1294. }
  1295. },
  1296. AppearanceObj:
  1297. {
  1298. appearanceType:parseInt(signatureCreator_appearanceType.value), //外观类型
  1299. width:parseInt(signatureCreator_appearanceWidth.value), //外观宽度
  1300. height:parseInt(signatureCreator_appearanceHeight.value), //外观高度
  1301. textSpirits:g_textSpirits //文本信息
  1302. }
  1303. };
  1304. NetcaPKI.SignatureCreatorSignSealEx(params)
  1305. .Then(function (res)
  1306. {
  1307. SignatureCreatorSuccessCallBackEx(res);
  1308. })
  1309. .Catch(function (res)
  1310. {
  1311. SignatureCreatorFailedCallBackEx(res);
  1312. });
  1313. }
  1314. function seal_SealKeyWord(selMode)
  1315. {
  1316. var _srcFile = signatureCreator_src_pathEx.value; //源Pdf文件
  1317. var _srcBytes = signatureCreator_srcBytesEx.value; //源Pdf文件字节流
  1318. var _destFile = signatureCreator_des_pathEx.value; //目标pdf文件
  1319. var _certEncode = signatureCreator_certEncodeEx.value; //签名证书Base64编码
  1320. var _selMode = parseInt(selMode.name); //操作模式
  1321. var _signFieldText = signatureCreator_signFieldTextEx.value; //签名域显示的文字
  1322. var _sealImageEncode = signatureCreator_sealImageEncodeEx.value;//签章图片Base64编码
  1323. var _revInfoIncludeFlag = (signatureCreator_revInfoIncludeFlagEx.value == 1) ? true : false; //是否包含吊销信息
  1324. var _tsaUrl= ""; //时间戳地址
  1325. var _tsaUsr= ""; //时间戳服务对应用户名
  1326. var _tsaPwd= ""; //时间戳服务对应用户的密码
  1327. var _tsaHashAlgo= ""; //时间戳使用的hash算法,例如”sha-1”,”sha-256”等
  1328. var _text=signatureCreator_textEx.value; //自定义文本信息
  1329. var _timeFormat=signatureCreator_timeFormatEx.value; //日期格式
  1330. var _widthPercentage=parseFloat(signatureCreator_widthPercentageEx.value); //宽偏移百分比
  1331. var _heightPercentage=parseFloat(signatureCreator_heightPercentageEx.value); //高偏移百分比
  1332. var _fontName=signatureCreator_fontNameEx.value; //字体
  1333. var _fontSize=parseInt(signatureCreator_fontSizeEx.value); //字体大小
  1334. var _A=parseInt(signatureCreator_fontColorAEx.value); //透明度
  1335. var _R=parseInt(signatureCreator_fontColorREx.value); //红色
  1336. var _G=parseInt(signatureCreator_fontColorGEx.value); //绿色
  1337. var _B=parseInt(signatureCreator_fontColorBEx.value); //蓝色
  1338. var _keyWord = signatureCreator_keyWordEx.value; //关键字
  1339. var _keyWordStartPage = parseInt(signatureCreator_keyword_startPageEx.value); //PDF文档的开始页码
  1340. var _keyWordEndPage = parseInt(signatureCreator_keyword_endPageEx.value); //PDF文档的开始页码
  1341. var _keyWordIndex = parseInt(signatureCreator_keyWordIndexEx.value); //关键字索引
  1342. var _keyWordWidth = parseInt(signatureCreator_keyword_widthEx.value); //签名域矩形的宽度
  1343. var _keyWordHeight = parseInt(signatureCreator_keyword_heightEx.value); //签名域矩形的高度
  1344. var _offsetX = parseInt(signatureCreator_offsetXEx.value); //水平偏移量
  1345. var _offsetY = parseInt(signatureCreator_offsetYEx.value); //垂直偏移量
  1346. var params = {
  1347. srcFile: _srcFile, //源pdf文件
  1348. srcBytes: _srcBytes, //源Pdf文件的Base64编码
  1349. destFile: _destFile, //目标pdf文件
  1350. certEncode: _certEncode, //签名证书Base64编码
  1351. selMode: _selMode, //操作模式
  1352. signFieldText: _signFieldText, //签名域显示的文字
  1353. sealImageEncode: _sealImageEncode, //签章图片Base64编码
  1354. revInfoIncludeFlag: _revInfoIncludeFlag,//是否包含吊销信息
  1355. SealKeyWord: //关键字对象
  1356. {
  1357. keyWord: _keyWord, //关键字
  1358. startPage: _keyWordStartPage, //PDF文档的开始页码
  1359. endPage: _keyWordEndPage, //PDF文档的结束页码
  1360. keyWordIndex: _keyWordIndex, //关键字索引
  1361. width: _keyWordWidth, //签名域矩形的宽度
  1362. height: _keyWordHeight, //签名域矩形的高度
  1363. offsetX: _offsetX, //水平偏移量
  1364. offsetY: _offsetY //垂直偏移量
  1365. },
  1366. Tsa: //时间戳对象
  1367. {
  1368. tsaUrl: _tsaUrl, //时间戳地址
  1369. tsaUsr: _tsaUsr, //时间戳服务对应用户名
  1370. tsaPwd: _tsaPwd, //时间戳服务对应用户的密码
  1371. tsaHashAlgo: _tsaHashAlgo //时间戳使用的hash算法,例如”sha-1”,”sha-256”等
  1372. },
  1373. TimeObj:
  1374. {
  1375. text: _text, //自定义信息
  1376. timeFormat: _timeFormat, //日期格式
  1377. widthPercentage: _widthPercentage, //宽偏移百分比
  1378. heightPercentage: _heightPercentage,//高偏移百分比
  1379. fontName: _fontName, //字体
  1380. fontSize: _fontSize, //字体大小
  1381. FontColor:
  1382. {
  1383. A: _A,
  1384. R: _R,
  1385. G: _G,
  1386. B: _B
  1387. }
  1388. },
  1389. AppearanceObj:
  1390. {
  1391. appearanceType:parseInt(signatureCreator_appearanceType.value), //外观类型
  1392. width:parseInt(signatureCreator_appearanceWidth.value), //外观宽度
  1393. height:parseInt(signatureCreator_appearanceHeight.value), //外观高度
  1394. textSpirits:g_textSpirits //文本信息
  1395. }
  1396. };
  1397. NetcaPKI.SignatureCreatorSignSealEx(params)
  1398. .Then(function (res)
  1399. {
  1400. SignatureCreatorSuccessCallBackEx(res);
  1401. })
  1402. .Catch(function (res)
  1403. {
  1404. SignatureCreatorFailedCallBackEx(res);
  1405. });
  1406. }
  1407. function SignatureCreatorSuccessCallBackEx(res)
  1408. {
  1409. var result = "签名/章成功, 目标文件的Base64编码:\n" + res.destFileEncode;
  1410. alert(result);
  1411. console.log(res.destFileEncode);
  1412. NetcaPDFSeal.preViewPDF(1, res.destFileEncode);
  1413. }
  1414. function SignatureCreatorFailedCallBackEx(res)
  1415. {
  1416. alert("签名/章失败 " + res.msg);
  1417. }
  1418. //获取签章软件版本号
  1419. function seal_getVersion() {
  1420. var params ={};
  1421. NetcaPKI.getSealClientVersion(params)
  1422. .Then(function(res) {
  1423. successGetSealClientVersionCallBack(res);
  1424. })
  1425. .Catch(function(res) {
  1426. failedGetSealClientVersionCallBack(res);
  1427. });
  1428. }
  1429. function successGetSealClientVersionCallBack(res) {
  1430. alert("获取签章软件版本号成功\n版本号为:" + res.version);
  1431. }
  1432. function failedGetSealClientVersionCallBack(res) {
  1433. alert("获取签章软件版本号失败," + res.msg);
  1434. }
  1435. function HashSuccessCallBack(res)
  1436. {
  1437. hashDataResult.value=res.hashValue;
  1438. }
  1439. function HashFailedCallBack(res)
  1440. {
  1441. alert(res.msg);
  1442. }
  1443. function hashSample() {
  1444. var _hashAlgo = parseInt(hashAlgoId.value);
  1445. var _text = utf8_to_b64(hashText.value);
  1446. var _flag = parseInt(hashflagId.value);
  1447. params = {
  1448. hashAlgo:_hashAlgo,
  1449. data: { //数据(DataParams)
  1450. text: _text
  1451. },
  1452. flag:_flag
  1453. };
  1454. NetcaPKI.HashData(params)
  1455. .Then(function(res){
  1456. HashSuccessCallBack(res);
  1457. })
  1458. .Catch(function (res) {
  1459. HashFailedCallBack(res);
  1460. });
  1461. }
  1462. function CipherSuccessCallBack(res)
  1463. {
  1464. var cipherUseEnc = cipherUseEncId.value=="1"?true:false;
  1465. if(cipherUseEnc)
  1466. {
  1467. cipherResult.value=res.cipherValue;
  1468. }
  1469. else
  1470. {
  1471. cipherResult.value=b64_to_utf8(res.clearValue);
  1472. }
  1473. }
  1474. function CipherFailedCallBack(res)
  1475. {
  1476. alert("对称加解密失败\n"+res.msg);
  1477. }
  1478. function cipherSample() {
  1479. var _algo=parseInt(cipherAlgoId.value);
  1480. var _useEnc = cipherUseEncId.value=="1"?true:false;
  1481. var _text ;
  1482. if(_useEnc==1)
  1483. {
  1484. _text=utf8_to_b64(cipherData.value);
  1485. }
  1486. else
  1487. {
  1488. _text=cipherData.value;
  1489. }
  1490. var _hexText = cipherKeyId.value;
  1491. params = {
  1492. algo:_algo,
  1493. data: { //数据(DataParams)
  1494. text: _text
  1495. },
  1496. key: { //数据(DataParams)
  1497. hexText: _hexText
  1498. },
  1499. useEnc:_useEnc
  1500. };
  1501. NetcaPKI.cipher(params)
  1502. .Then(function(res){
  1503. CipherSuccessCallBack(res);
  1504. })
  1505. .Catch(function (res) {
  1506. CipherFailedCallBack(res);
  1507. });
  1508. }
  1509. //验证证书
  1510. function verifyCertificate() {
  1511. var _certEncode = VerifyCertificate_certEncode.value;
  1512. var _bUseCrl = (VerifyCertificateverify_crlFlag.value == 1) ? true : false;
  1513. var _bUseOcsp = (VerifyCertificate_ocspFlag.value == 1) ? true : false;
  1514. var _crlEncode = VerifyCertificate_crlEncode.value;
  1515. var _ocspUrl = VerifyCertificate_ocspUrl.value;
  1516. var _time = VerifyCertificate_time.value;
  1517. var params = {
  1518. cert : {
  1519. "encode" : _certEncode
  1520. },
  1521. bUseCrl: _bUseCrl,
  1522. bUseOcsp: _bUseOcsp,
  1523. crlEncode: _crlEncode,
  1524. ocspUrl: _ocspUrl,
  1525. time: _time
  1526. };
  1527. NetcaPKI.verifyCertificate(params)
  1528. .Then(function(res) {
  1529. successVerifyCertificateCallBack(res);
  1530. })
  1531. .Catch(function(res) {
  1532. failedVerifyCertificateCallBack(res);
  1533. });
  1534. }
  1535. function successVerifyCertificateCallBack(res) {
  1536. alert("验证成功," + res.info);
  1537. }
  1538. function failedVerifyCertificateCallBack(res) {
  1539. alert("验证失败," + res.msg);
  1540. }
  1541. //验证签名PDF
  1542. function seal_verifySignPDF() {
  1543. var _srcFile = signatureVerifierVerify_src_path.value;
  1544. var _srcBytes = signatureVerifierVerify_srcBytes.value;
  1545. var _level = parseInt(signatureVerifier_level.value);
  1546. var params = {
  1547. srcFile : _srcFile,
  1548. srcBytes : _srcBytes,
  1549. level : _level
  1550. };
  1551. NetcaPKI.signatureVerifierVerifyPDF(params)
  1552. .Then(function(res) {
  1553. successSignatureVerifierVerifyPDF(res);
  1554. })
  1555. .Catch(function(res) {
  1556. failedSignatureVerifierVerifyPDF(res);
  1557. });
  1558. }
  1559. function successSignatureVerifierVerifyPDF(res) {
  1560. info = "";
  1561. for(i in res.VerifyInfos)
  1562. {
  1563. index = parseInt(i)+1;
  1564. info += "第"+ index +"个签名信息, " +
  1565. res.VerifyInfos[i].status +
  1566. ", 签名者:" + res.VerifyInfos[i].signerName +
  1567. ", 签名域:" + res.VerifyInfos[i].fieldName +
  1568. ", 签名证书:" + res.VerifyInfos[i].certEncode +
  1569. ", 签名摘要算法:" + res.VerifyInfos[i].hashAlgo +
  1570. ", 签名创建日期:" + res.VerifyInfos[i].signDate;
  1571. if(res.VerifyInfos[i].hasRevoke)
  1572. {
  1573. info += ",存在吊销信息" +
  1574. ", 证书吊销状态:" + res.VerifyInfos[i].revokeStatus;
  1575. }
  1576. else
  1577. {
  1578. info += ",不存在吊销信息";
  1579. }
  1580. if(res.VerifyInfos[i].hasTsa)
  1581. {
  1582. info += ", 存在时间戳信息";
  1583. }
  1584. else
  1585. {
  1586. info += ", 不存在时间戳信息";
  1587. }
  1588. if(res.VerifyInfos[i].isTsaValid)
  1589. {
  1590. info += ", 时间戳有效";
  1591. }
  1592. else
  1593. {
  1594. info += ", 时间戳无效";
  1595. }
  1596. info += ", 时间戳日期:" + res.VerifyInfos[i].tsaDate + "\n";
  1597. }
  1598. alert("验证证书成功:" + info);
  1599. console.log(info);
  1600. }
  1601. function failedSignatureVerifierVerifyPDF(res) {
  1602. alert("验证失败," + res.msg);
  1603. }
  1604. //撤销签名/章
  1605. function seal_undoSignPDF() {
  1606. var _signFile = signatureVerifierUndo_src_path.value;
  1607. var _signBytes = signatureVerifierUndo_srcBytes.value;
  1608. var _index = parseInt(signatureVerifierUndo_index.value);
  1609. var params = {
  1610. signFile : _signFile,
  1611. signBytes : _signBytes,
  1612. index : _index
  1613. };
  1614. NetcaPKI.signatureVerifierUndoPDF(params)
  1615. .Then(function(res) {
  1616. successSignatureVerifierUndoPDF(res);
  1617. })
  1618. .Catch(function(res) {
  1619. failedSignatureVerifierUndoPDF(res);
  1620. });
  1621. }
  1622. function successSignatureVerifierUndoPDF(res) {
  1623. alert("撤销成功,原文base64编码:" + res.srcBytes);
  1624. console.log(res.srcBytes);
  1625. document.getElementById("signatureVerifierUndo_destBytes").value = res.srcBytes;
  1626. }
  1627. function failedSignatureVerifierUndoPDF(res) {
  1628. alert("撤销失败," + res.msg);
  1629. }
  1630. function showNetcaAAVerifyStatusMsg(res)
  1631. {
  1632. if(res.certVerifyStatus=="0")
  1633. {
  1634. alert("验证证书有效");
  1635. }
  1636. else if(res.certVerifyStatus=="1")
  1637. {
  1638. alert("验证处理失败");
  1639. }
  1640. else if(res.certVerifyStatus=="2")
  1641. {
  1642. alert("证书格式有误");
  1643. }
  1644. else if(res.certVerifyStatus=="3")
  1645. {
  1646. alert("证书不在有效期内");
  1647. }
  1648. else if(res.certVerifyStatus=="4")
  1649. {
  1650. alert("密钥用途不合(KU和EKU)");
  1651. }
  1652. else if(res.certVerifyStatus=="5")
  1653. {
  1654. alert("证书名字不合(DN和SAN)");
  1655. }
  1656. else if(res.certVerifyStatus=="6")
  1657. {
  1658. alert("证书策略不合(取决于CVS的配置)");
  1659. }
  1660. else if(res.certVerifyStatus=="7")
  1661. {
  1662. alert("证书扩展不合(取决于CVS的配置)");
  1663. }
  1664. else if(res.certVerifyStatus=="8")
  1665. {
  1666. alert("证书链验证失败(包括了签名检查;基本约束检查;名字约束检查;策略约束检查;ACL检查等)");
  1667. }
  1668. else if(res.certVerifyStatus=="9")
  1669. {
  1670. alert("证书被注销");
  1671. }
  1672. else if(res.certVerifyStatus=="10")
  1673. {
  1674. alert("注销状态不能确定(如果设置了已过期的CRL或OCSP无法连接)");
  1675. }
  1676. else if(res.certVerifyStatus=="11")
  1677. {
  1678. alert("证书不受信任/未被授权");
  1679. }
  1680. else if(res.certVerifyStatus=="12")
  1681. {
  1682. alert("证书被暂时锁定/未激活");
  1683. }
  1684. else
  1685. {
  1686. alert("证书验证失败");
  1687. }
  1688. }
  1689. function netcaaaverifycertsuccess(res)
  1690. {
  1691. netcaaaResult.value=JSON.stringify(res);
  1692. showNetcaAAVerifyStatusMsg(res);
  1693. }
  1694. function netcaaaverifycertfail(res)
  1695. {
  1696. alert("验证证书失败:" + res.msg);
  1697. }
  1698. function netcaaa_verifycert_example()
  1699. {
  1700. /* 从USBKey中选择NETCA 颁发的签名证书 */
  1701. var _url = netcaaaurl.value;
  1702. var _verifytime = "";
  1703. var _encode="";
  1704. var _type = "";
  1705. var _condition = "";
  1706. //如果是输入的证书编码 可以直接射设置certEncode值
  1707. if( netcaaacert.value.length != 0 )
  1708. {
  1709. _encode=netcaaacert.value;
  1710. }
  1711. else
  1712. {
  1713. _type = "{\"UIFlag\":\"default\", \"InValidity\":true,\"Type\":\"signature\", \"Method\":\"device\",\"Value\":\"any\"}";
  1714. _condition = "IssuerCN~'NETCA' && InValidity='True' && CertType='Signature'";
  1715. }
  1716. var params = {
  1717. url:_url,
  1718. verifytime : _verifytime,
  1719. cert: { //证书(CertificateParams)
  1720. encode: _encode,
  1721. type: _type,
  1722. condition: _condition
  1723. }
  1724. };
  1725. NetcaPKI.netcaAA_VerifyUserCert(params)
  1726. .Then(function(res) {
  1727. netcaaaverifycertsuccess(res);
  1728. })
  1729. .Catch(function(res) {
  1730. netcaaaverifycertfail(res);
  1731. });
  1732. }
  1733. function netcaaachkonecertsuccess(res)
  1734. {
  1735. netcaaachkonecertResult.value=JSON.stringify(res);
  1736. showNetcaAAVerifyStatusMsg(res);
  1737. }
  1738. function netcaaachkonecertfail(res)
  1739. {
  1740. alert("验证证书失败:" + res.msg);
  1741. }
  1742. function netcaaachk_chkonecert_example()
  1743. {
  1744. /* 从USBKey中选择NETCA 颁发的签名证书 */
  1745. var _url = netcaaachkonecerturl.value;
  1746. var _encode = "";
  1747. var _type = "";
  1748. var _condition = "";
  1749. //如果是输入的证书编码 可以直接射设置certEncode值
  1750. if( netcaaachkonecert.value.length != 0 )
  1751. {
  1752. _encode=netcaaachkonecert.value;
  1753. }
  1754. else
  1755. {
  1756. _type = "{\"UIFlag\":\"default\", \"InValidity\":true,\"Type\":\"signature\", \"Method\":\"device\",\"Value\":\"any\"}";
  1757. _condition = "IssuerCN~'NETCA' && InValidity='True' && CertType='Signature'";
  1758. }
  1759. var params = {
  1760. url:_url,
  1761. cert: { //证书(CertificateParams)
  1762. encode: _encode,
  1763. type: _type,
  1764. condition: _condition
  1765. }
  1766. };
  1767. NetcaPKI.netcaAA_ChkOneCert(params)
  1768. .Then(function(res) {
  1769. netcaaachkonecertsuccess(res);
  1770. })
  1771. .Catch(function(res) {
  1772. netcaaachkonecertfail(res);
  1773. });
  1774. }
  1775. function modifyPwd()
  1776. {
  1777. var _sn = keySN.value;
  1778. var _type = parseInt(keyType.value);
  1779. var _oldPwd = oldPwd.value;
  1780. var _newPwd = modify_newPwd.value;
  1781. var params = {
  1782. sn: _sn,
  1783. type: _type,
  1784. oldPwd: _oldPwd,
  1785. newPwd: _newPwd
  1786. };
  1787. NetcaPKI.modifyKeyPwd(params)
  1788. .Then(function(res){
  1789. if (res.result == 1)
  1790. {
  1791. modifySuccess(res);
  1792. }
  1793. else
  1794. {
  1795. modifyFailed(res);
  1796. }
  1797. })
  1798. .Catch(function (res) {
  1799. alert(res.msg);
  1800. });
  1801. }
  1802. function modifySuccess(res)
  1803. {
  1804. var tip = "密码修改成功,密码剩余重试次数为" + res.retrynum;
  1805. DeviceOutputId.value = tip;
  1806. }
  1807. function modifyFailed(res)
  1808. {
  1809. var tip = "密码修改失败,密码剩余重试次数为" + res.retrynum + ",错误码=" + res.result;
  1810. DeviceOutputId.value = tip;
  1811. }
  1812. function unlockPwd()
  1813. {
  1814. var _sn = keySN.value;
  1815. var _type = parseInt(keyType.value);
  1816. var _unlockPwd = unlock_unlockPwd.value;
  1817. var _newPwd = unlock_newPwd.value;
  1818. var params = {
  1819. sn: _sn,
  1820. type: parseInt(_type),
  1821. unlockPwd: _unlockPwd,
  1822. newPwd: _newPwd
  1823. };
  1824. NetcaPKI.unlockKeyPwd(params)
  1825. .Then(function(res){
  1826. if (res.result == 1)
  1827. {
  1828. unlockSuccess(res);
  1829. }
  1830. else
  1831. {
  1832. unlockFailed(res);
  1833. }
  1834. })
  1835. .Catch(function (res) {
  1836. alert(res.msg);
  1837. });
  1838. }
  1839. function unlockSuccess(res)
  1840. {
  1841. var tip = "密码解锁成功,密码剩余重试次数为" + res.retrynum;
  1842. DeviceOutputId.value = tip;
  1843. }
  1844. function unlockFailed(res)
  1845. {
  1846. var tip = "密码解锁失败,密码剩余重试次数为" + res.retrynum + ",错误码=" + res.result;
  1847. DeviceOutputId.value = tip;
  1848. }
  1849. function generateP10()
  1850. {
  1851. var _sn = GenerateP10_sn.value;
  1852. var _type = parseInt(GenerateP10_type.value);
  1853. var _useKeypair = (GenerateP10_useKeypairFlag.value == 1)? true : false;
  1854. var _keypairAlgo = parseInt(GenerateP10_keypairAlgo.value);
  1855. var _keypairLabel = GenerateP10_keypairLabel.value;
  1856. var _keypairBits = parseInt(GenerateP10_keypairBits.value);
  1857. var _signAlgo = parseInt(GenerateP10_signAlgo.value);
  1858. var _c = GenerateP10_c.value;
  1859. var _st = GenerateP10_st.value;
  1860. var _l = GenerateP10_l.value;
  1861. var _o = GenerateP10_o.value;
  1862. var _email = GenerateP10_email.value;
  1863. var _ou = GenerateP10_ou.value;
  1864. var _cn = GenerateP10_cn.value;
  1865. var params = {
  1866. sn: _sn,
  1867. type: parseInt(_type),
  1868. useKeypair: _useKeypair,
  1869. keypairAlgo: parseInt(_keypairAlgo),
  1870. keypairLabel: _keypairLabel,
  1871. keypairBits: parseInt(_keypairBits),
  1872. signAlgo: parseInt(_signAlgo),
  1873. SubjectObj : {
  1874. c: _c,
  1875. st: _st,
  1876. l: _l,
  1877. o: _o,
  1878. email: _email,
  1879. ou: _ou,
  1880. cn: _cn
  1881. }
  1882. };
  1883. NetcaPKI.generateP10(params)
  1884. .Then(function(res) {
  1885. generateP10Success(res);
  1886. })
  1887. .Catch(function(res) {
  1888. generateP10Failed(res);
  1889. });
  1890. }
  1891. function generateP10Success(res)
  1892. {
  1893. alert("产生证书请求成功,编码:" + res.certReq);
  1894. console.log(res.certReq);
  1895. }
  1896. function generateP10Failed(res)
  1897. {
  1898. alert("产生证书请求失败," + res.msg);
  1899. }
  1900. function installCertificate()
  1901. {
  1902. var _sn = InstallCertificate_sn.value;
  1903. var _type = InstallCertificate_type.value;
  1904. var _encKeypair = InstallCertificate_encKeypairEncode.value;
  1905. var _encCert = InstallCertificate_encCertEncode.value;
  1906. var _signCert = InstallCertificate_signCertEncode.value;
  1907. var params = {
  1908. sn: _sn,
  1909. type: parseInt(_type),
  1910. encKeypair: _encKeypair,
  1911. encCert: _encCert,
  1912. signCert: _signCert
  1913. };
  1914. NetcaPKI.installCertificate(params)
  1915. .Then(function(res) {
  1916. installCertificateSuccess(res);
  1917. })
  1918. .Catch(function(res) {
  1919. installCertificateFailed(res);
  1920. });
  1921. }
  1922. function installCertificateSuccess(res)
  1923. {
  1924. alert("安装证书成功");
  1925. }
  1926. function installCertificateFailed(res)
  1927. {
  1928. alert("安装证书失败:" + res.msg);
  1929. }
  1930. function getNetcaSealImage(certEncode) {
  1931. var params = {
  1932. "cert":{
  1933. "encode":certEncode
  1934. }
  1935. };
  1936. NetcaPKI.getNetcaSealImage(params)
  1937. .Then(function(res){
  1938. GetNetcaSealImageSuccessCallBack(res);
  1939. })
  1940. .Catch(function (res) {
  1941. GetNetcaSealImageFailCallBack(res);
  1942. });
  1943. }
  1944. function GetNetcaSealImageSuccessCallBack(res)
  1945. {
  1946. alert("获取签章图片成功!");
  1947. alert(res.sealImageBase64);
  1948. console.log(res.sealImageBase64);
  1949. }
  1950. function GetNetcaSealImageFailCallBack(res)
  1951. {
  1952. alert(res.msg);
  1953. }
  1954. function uIDisplayCert()
  1955. {
  1956. var certEncode = DeviceOutputId.value;
  1957. var selectType = "Device";
  1958. var selectCondition = "InValidity='True' && CertType='Signature'";
  1959. var params = {
  1960. cert: {
  1961. "encode": certEncode,
  1962. "type": selectType,
  1963. "condition": selectCondition
  1964. }
  1965. };
  1966. NetcaPKI.displayCert(params)
  1967. .Then(function(res){
  1968. alert("证书显示成功");
  1969. })
  1970. .Catch(function (res) {
  1971. alert(res.msg);
  1972. });
  1973. }
  1974. function createData()
  1975. {
  1976. var certEncode = Data_certEncode.value;
  1977. var selectType = "Device";
  1978. var selectCondition = "InValidty='True' && CertType='Signature'";
  1979. var params = {
  1980. cert: {
  1981. "encode": certEncode,
  1982. "type": selectType,
  1983. "condition": selectCondition
  1984. },
  1985. device: {
  1986. "sn": Data_sn.value,
  1987. "type": parseInt(Data_type.value)
  1988. },
  1989. id: parseInt(CreateData_id.value),
  1990. noVerifyPermission: {
  1991. canRead: ((CreateData_noVerifyPermission_canRead.value == 1) ? true : false),
  1992. canWrite: ((CreateData_noVerifyPermission_canWrite.value == 1) ? true : false),
  1993. canDelete: ((CreateData_noVerifyPermission_canDelete.value == 1) ? true : false)
  1994. },
  1995. verifyUserPermission: {
  1996. canRead: ((CreateData_verifyUserPermission_canRead.value == 1) ? true : false),
  1997. canWrite: ((CreateData_verifyUserPermission_canWrite.value == 1) ? true : false),
  1998. canDelete: ((CreateData_verifyUserPermission_canDelete.value == 1) ? true : false)
  1999. },
  2000. length: parseInt(CreateData_length.value)
  2001. };
  2002. NetcaPKI.createData(params)
  2003. .Then(function(res) {
  2004. alert("创建数据成功");
  2005. })
  2006. .Catch(function(res) {
  2007. alert(res.msg);
  2008. });
  2009. }
  2010. function readData()
  2011. {
  2012. var certEncode = Data_certEncode.value;
  2013. var selectType = "Device";
  2014. var selectCondition = "InValidty='True' && CertType='Signature'";
  2015. var params = {
  2016. cert: {
  2017. "encode": certEncode,
  2018. "type": selectType,
  2019. "condition": selectCondition
  2020. },
  2021. device: {
  2022. "sn": Data_sn.value,
  2023. "type": parseInt(Data_type.value)
  2024. },
  2025. id: parseInt(ReadData_id.value),
  2026. offset: parseInt(ReadData_offset.value),
  2027. length: parseInt(ReadData_length.value)
  2028. };
  2029. NetcaPKI.readData(params)
  2030. .Then(function(res) {
  2031. alert("读取数据成功");
  2032. ReadData_data.value = res.data;
  2033. })
  2034. .Catch(function(res) {
  2035. alert(res.msg);
  2036. });
  2037. }
  2038. function writeData()
  2039. {
  2040. var certEncode = Data_certEncode.value;
  2041. var selectType = "Device";
  2042. var selectCondition = "InValidty='True' && CertType='Signature'";
  2043. var params = {
  2044. cert: {
  2045. "encode": certEncode,
  2046. "type": selectType,
  2047. "condition": selectCondition
  2048. },
  2049. device: {
  2050. "sn": Data_sn.value,
  2051. "type": parseInt(Data_type.value)
  2052. },
  2053. id: parseInt(WriteData_id.value),
  2054. offset: parseInt(WriteData_offset.value),
  2055. data: { //数据(DataParams)
  2056. text: WriteData_data.value
  2057. }
  2058. };
  2059. NetcaPKI.writeData(params)
  2060. .Then(function(res) {
  2061. alert("写入数据成功");
  2062. })
  2063. .Catch(function(res) {
  2064. alert(res.msg);
  2065. });
  2066. }
  2067. function deleteData()
  2068. {
  2069. var certEncode = Data_certEncode.value;
  2070. var selectType = "Device";
  2071. var selectCondition = "InValidty='True' && CertType='Signature'";
  2072. var params = {
  2073. cert: {
  2074. "encode": certEncode,
  2075. "type": selectType,
  2076. "condition": selectCondition
  2077. },
  2078. device: {
  2079. "sn": Data_sn.value,
  2080. "type": parseInt(Data_type.value)
  2081. },
  2082. id: parseInt(DeleteData_id.value)
  2083. };
  2084. NetcaPKI.deleteData(params)
  2085. .Then(function(res) {
  2086. alert("删除数据成功");
  2087. })
  2088. .Catch(function(res) {
  2089. alert(res.msg);
  2090. });
  2091. }
  2092. function MacSuccessCallBack(res)
  2093. {
  2094. macDataResult.value=res.macValue;
  2095. }
  2096. function MacFailedCallBack(res)
  2097. {
  2098. alert(res.msg);
  2099. }
  2100. function macSample() {
  2101. var _macAlgo = parseInt(macAlgoId.value);
  2102. var _key = macKey.value;
  2103. var _text = utf8_to_b64(macText.value);
  2104. var _flag = parseInt(macflagId.value);
  2105. params = {
  2106. macAlgo:_macAlgo,
  2107. key: { //数据(DataParams)
  2108. hexText: _key
  2109. },
  2110. data: { //数据(DataParams)
  2111. text: _text
  2112. },
  2113. flag:_flag
  2114. };
  2115. NetcaPKI.macData(params)
  2116. .Then(function(res){
  2117. MacSuccessCallBack(res);
  2118. })
  2119. .Catch(function (res) {
  2120. MacFailedCallBack(res);
  2121. });
  2122. }
  2123. function GenerateRandom()
  2124. {
  2125. var certEncode = GenerateRandom_certEncode.value;
  2126. var selectType = "Device";
  2127. var selectCondition = "InValidty='True' && CertType='Signature'";
  2128. var params = {
  2129. cert: {
  2130. "encode": certEncode,
  2131. "type": selectType,
  2132. "condition": selectCondition
  2133. },
  2134. device: {
  2135. "sn": GenerateRandom_sn.value,
  2136. "type": parseInt(GenerateRandom_type.value)
  2137. },
  2138. length: parseInt(GenerateRandom_length.value)
  2139. };
  2140. NetcaPKI.generateRandom(params)
  2141. .Then(function(res) {
  2142. GenerateRandom_randomData.value = res.randomData;
  2143. })
  2144. .Catch(function(res) {
  2145. alert(res.msg);
  2146. });
  2147. }
  2148. function signedDataGetInfo()
  2149. {
  2150. var _signedData = SignedDataGetInfoSignature.value;
  2151. var params = {
  2152. signedData: _signedData //signedData的编码值
  2153. };
  2154. NetcaPKI.signedDataGetInfo(params)
  2155. .Then(function (res) {
  2156. SuccessSignedDataGetInfoCallBack(res);
  2157. })
  2158. .Catch(function (res) {
  2159. FailedSignedDataGetInfoCallBack(res);
  2160. })
  2161. }
  2162. function SuccessSignedDataGetInfoCallBack(res)
  2163. {
  2164. SignedDataInfo.value = "signedData解析成功\n"+JSON.stringify(res);
  2165. }
  2166. function FailedSignedDataGetInfoCallBack(res)
  2167. {
  2168. alert("signedData解析失败\n"+res.msg);
  2169. }
  2170. //获取签名域信息
  2171. function getSignatureFieldInfo() {
  2172. var _srcFile = fieldInfo_src_path.value;
  2173. var _srcBytes = fieldInfo_srcBytes.value;
  2174. var params = {
  2175. srcFile : _srcFile,
  2176. srcBytes : _srcBytes
  2177. };
  2178. NetcaPKI.getSignatureFieldInfo(params)
  2179. .Then(function(res) {
  2180. successGetSignatureFieldInfo(res);
  2181. })
  2182. .Catch(function(res) {
  2183. alert("获取签名域信息失败," + res.msg);
  2184. });
  2185. }
  2186. function successGetSignatureFieldInfo(res) {
  2187. info = "";
  2188. for(i in res.signFields)
  2189. {
  2190. index = parseInt(i)+1;
  2191. info += "第"+ index +"个签名域信息, " +
  2192. "名称:" + res.signFields[i].name +
  2193. ", 页码:" + res.signFields[i].pageNum +
  2194. ", xPos:" + res.signFields[i].xPos +
  2195. ", yPos:" + res.signFields[i].yPos +
  2196. ", width:" + res.signFields[i].width +
  2197. ", height:" + res.signFields[i].height +
  2198. "\n";
  2199. }
  2200. alert("获取签名域信息成功:\n" + info);
  2201. console.log(info);
  2202. }
  2203. function getSealConfigInfo() {
  2204. var params = {};
  2205. NetcaPKI.getSealConfigInfo(params)
  2206. .Then(function(res) {
  2207. alert("获取配置信息成功:\n" + JSON.stringify(res));
  2208. console.log(JSON.stringify(res));
  2209. })
  2210. .Catch(function(res) {
  2211. alert("获取配置信息失败," + res.msg);
  2212. });
  2213. }
  2214. function SelectSealSigntureInfoWithDispaly() {
  2215. var params = {};
  2216. NetcaPKI.selectSealSigntureInfoWithDispaly (params)
  2217. .Then(function(res) {
  2218. document.getElementById("signatureCreator_sealImageEncode").value=res.picture;
  2219. document.getElementById("signatureCreator_sealImageEncodeEx").value=res.picture;
  2220. document.getElementById("insertImage_sealImageEncode").value=res.picture;
  2221. })
  2222. .Catch(function(res) {
  2223. alert("获取印章信息失败," + res.msg);
  2224. });
  2225. }
  2226. var g_textSpirits = new Array();
  2227. function addTextSpirit()
  2228. {
  2229. var _A=parseInt(signatureCreator_appearanceFontColorAEx.value); //透明度
  2230. var _R=parseInt(signatureCreator_appearanceFontColorREx.value); //红色
  2231. var _G=parseInt(signatureCreator_appearanceFontColorGEx.value); //绿色
  2232. var _B=parseInt(signatureCreator_appearanceFontColorBEx.value); //蓝色
  2233. var textSpirit = {
  2234. textSymbol : parseInt(signatureCreator_textSymbolEx.value),
  2235. timeFormat : signatureCreator_appearanceTimeFormatEx.value,
  2236. text : signatureCreator_appearanceTextEx.value,
  2237. widthPercentage : parseFloat(signatureCreator_appearanceWidthPercentageEx.value),
  2238. heightPercentage : parseFloat(signatureCreator_appearanceHeightPercentageEx.value),
  2239. fontName : signatureCreator_appearanceFontNameEx.value,
  2240. fontSize : parseInt(signatureCreator_appearanceFontSizeEx.value),
  2241. FontColor:
  2242. {
  2243. A: _A,
  2244. R: _R,
  2245. G: _G,
  2246. B: _B
  2247. },
  2248. }
  2249. g_textSpirits.push(textSpirit);
  2250. alert("增加外观信息成功,现有"+g_textSpirits.length + "个信息");
  2251. }
  2252. function clearTextSpirit()
  2253. {
  2254. g_textSpirits = [];
  2255. alert("清空外观信息成功");
  2256. }
  2257. function kdfSuccessCallBack(res)
  2258. {
  2259. kdfDataResult.value=res.key;
  2260. alert("密钥派生成功");
  2261. }
  2262. function kdfFailedCallBack(res)
  2263. {
  2264. alert(res.msg);
  2265. }
  2266. function kdfSample() {
  2267. var _kdfAlgo = parseInt(kdfAlgoId.value);
  2268. var _keyLen = parseInt(kdfKeyLen.value);
  2269. var _flag = parseInt(kdfflagId.value);
  2270. params = {
  2271. kdfAlgo:_kdfAlgo,
  2272. pwd: { //数据(DataParams)
  2273. hexText: kdfPwd.value
  2274. },
  2275. keyLen: _keyLen,
  2276. pkcs5Params: {
  2277. hashAlgo: parseInt(kdfPkcs5Hashalgo.value),
  2278. salt: { //数据(DataParams)
  2279. hexText: kdfSalt.value
  2280. },
  2281. iterCount: parseInt(kdfPkcs5IterCount.value)
  2282. },
  2283. flag: _flag
  2284. };
  2285. NetcaPKI.kdf(params)
  2286. .Then(function(res){
  2287. kdfSuccessCallBack(res);
  2288. })
  2289. .Catch(function (res) {
  2290. kdfFailedCallBack(res);
  2291. });
  2292. }
  2293. var g_imagePositions = new Array();
  2294. function addImagePosition() {
  2295. var _imageEncode = insertImage_sealImageEncode.value;
  2296. var _pageNum = parseInt(insertImage_pageNum.value);
  2297. var _xPos = parseInt(insertImage_xPos.value);
  2298. var _yPos = parseInt(insertImage_yPos.value);
  2299. var _width = parseInt(insertImage_width.value);
  2300. var _height = parseInt(insertImage_height.value);
  2301. var imagePosition = {
  2302. imageEncode : _imageEncode,
  2303. pageNum : _pageNum,
  2304. xPos : _xPos,
  2305. yPos : _yPos,
  2306. width : _width,
  2307. height : _height
  2308. }
  2309. g_imagePositions.push(imagePosition);
  2310. alert("增加图片位置信息成功,现有"+g_imagePositions.length + "个信息");
  2311. }
  2312. function clearImagePosition() {
  2313. g_imagePositions = [];
  2314. alert("清空图片位置信息成功");
  2315. }
  2316. function insertImageSuccessCallBack(res)
  2317. {
  2318. var result = "插入图片成功, 目标文件的Base64编码:\n" + res.destFileEncode;
  2319. alert(result);
  2320. if(res.destFileEncode.length >= 20*1024*1024)
  2321. {
  2322. alert("注意:目标文件大于20M,会造成浏览器卡顿");
  2323. }
  2324. NetcaPDFSeal.preViewPDF(1, res.destFileEncode);
  2325. }
  2326. function insertImageFailedCallBack(res)
  2327. {
  2328. alert(res.msg);
  2329. }
  2330. function insertImage() {
  2331. var _srcFile = insertImage_src_path.value;
  2332. var _srcBytes = insertImage_srcBytes.value;
  2333. var _destFile = insertImage__des_path.value;
  2334. var _imagePositions = g_imagePositions;
  2335. params = {
  2336. srcFile : _srcFile,
  2337. srcBytes : _srcBytes,
  2338. destFile : _destFile,
  2339. imagePositions : _imagePositions
  2340. };
  2341. NetcaPKI.insertImage(params)
  2342. .Then(function(res){
  2343. insertImageSuccessCallBack(res);
  2344. })
  2345. .Catch(function (res) {
  2346. insertImageFailedCallBack(res);
  2347. });
  2348. }
  2349. function getPdfPageInfoSuccessCallBack(res)
  2350. {
  2351. alert("获取PDF页面信息成功:" + JSON.stringify(res));
  2352. }
  2353. function getPdfPageInfoFailedCallBack(res)
  2354. {
  2355. alert(res.msg);
  2356. }
  2357. function getPdfPageInfo()
  2358. {
  2359. var _srcFile = getPdfPageInfo_src_path.value;
  2360. var _srcBytes = getPdfPageInfo_srcBytes.value;
  2361. params = {
  2362. srcFile : _srcFile,
  2363. srcBytes : _srcBytes
  2364. };
  2365. NetcaPKI.getPdfPageInfo(params)
  2366. .Then(function(res){
  2367. getPdfPageInfoSuccessCallBack(res);
  2368. })
  2369. .Catch(function (res) {
  2370. getPdfPageInfoFailedCallBack(res);
  2371. });
  2372. }
  2373. function printPDFSuccessCallBack(res)
  2374. {
  2375. alert("打印成功");
  2376. }
  2377. function printPDFFailedCallBack(res)
  2378. {
  2379. alert(res.msg);
  2380. }
  2381. function printPDF()
  2382. {
  2383. var _srcFile = printPDF_src_path.value;
  2384. var _srcBytes = printPDF_srcBytes.value;
  2385. params = {
  2386. srcFile : _srcFile,
  2387. srcBytes : _srcBytes
  2388. };
  2389. NetcaPKI.printPDF(params)
  2390. .Then(function(res){
  2391. printPDFSuccessCallBack(res);
  2392. })
  2393. .Catch(function (res) {
  2394. printPDFFailedCallBack(res);
  2395. });
  2396. }
  2397. function batchSeal()
  2398. {
  2399. var _srcFile = signatureCreator_batchseal_src_path.value; //源Pdf文件
  2400. var _srcBytes = signatureCreator_batchseal_srcBytes.value; //源Pdf文件字节流
  2401. var _destFile = signatureCreator_batchseal_des_path.value; //目标pdf文件
  2402. var _certEncode = signatureCreator_batchseal_certEncode.value; //签名证书Base64编码
  2403. var _sealImageEncode = signatureCreator_batchseal_sealImageEncode.value;//签章图片Base64编码
  2404. var _revInfoIncludeFlag = (signatureCreator_batchseal_revInfoIncludeFlag.value == 1) ? true : false; //是否包含吊销信息
  2405. var _signaturePage = parseInt(signatureCreator_batchseal_signaturePage.value); //P电子签章所在页码
  2406. var _startPage = parseInt(signatureCreator_batchseal_startPage.value); //开始页码
  2407. var _endPage = parseInt(signatureCreator_batchseal_endPage.value); //结束页码
  2408. var _xPos = parseInt(signatureCreator_batchseal_xpos.value); //签名域/签章左下角的水平向右方向坐标
  2409. var _yPos = parseInt(signatureCreator_batchseal_ypos.value); //签名域/签章左下角的垂直向上方向坐标
  2410. var _width = parseInt(signatureCreator_batchseal_width.value); //签名域/签章的宽度
  2411. var _height = parseInt(signatureCreator_batchseal_height.value); //签名域/签章的高度
  2412. var _tsaUrl= "http://tsa.cnca.net/NETCATimeStampServer/TSAServer.jsp"; //时间戳地址
  2413. var _tsaUsr= ""; //时间戳服务对应用户名
  2414. var _tsaPwd= ""; //时间戳服务对应用户的密码
  2415. var _tsaHashAlgo= ""; //时间戳使用的hash算法,例如”sha-1”,”sha-256”等
  2416. var params = {
  2417. srcFile: _srcFile, //源pdf文件
  2418. srcBytes: _srcBytes, //源Pdf文件的Base64编码
  2419. destFile: _destFile, //目标pdf文件
  2420. certEncode: _certEncode, //签名证书Base64编码
  2421. sealImageEncode: _sealImageEncode, //签章图片Base64编码
  2422. revInfoIncludeFlag: _revInfoIncludeFlag,//是否包含吊销信息
  2423. batchSeal: //签名位置对象
  2424. {
  2425. signaturePage: _signaturePage, //电子签章所在页码
  2426. startPage: _startPage, //开始页码
  2427. endPage: _endPage, //结束页码
  2428. xPos: _xPos, //签名域/签章左下角的水平向右方向坐标
  2429. yPos: _yPos, //签名域/签章左下角的垂直向上方向坐标
  2430. width: _width, //签名域/签章的宽度
  2431. height: _height //签名域/签章的高度
  2432. },
  2433. Tsa: //时间戳对象
  2434. {
  2435. tsaUrl: _tsaUrl, //时间戳地址
  2436. tsaUsr: _tsaUsr, //时间戳服务对应用户名
  2437. tsaPwd: _tsaPwd, //时间戳服务对应用户的密码
  2438. tsaHashAlgo: _tsaHashAlgo //时间戳使用的hash算法,例如”sha-1”,”sha-256”等
  2439. }
  2440. };
  2441. NetcaPKI.batchSeal(params)
  2442. .Then(function (res)
  2443. {
  2444. SignatureCreatorBatchSealSuccessCallBack(res);
  2445. })
  2446. .Catch(function (res)
  2447. {
  2448. SignatureCreatorBatchSealFailedCallBack(res);
  2449. });
  2450. }
  2451. function SignatureCreatorBatchSealSuccessCallBack(res)
  2452. {
  2453. var result = "签名/章成功, 目标文件的Base64编码:\n" + res.destFileEncode;
  2454. alert(result);
  2455. console.log(res.destFileEncode);
  2456. if(res.destFileEncode.length >= 20*1024*1024)
  2457. {
  2458. alert("注意:目标文件大于20M,会造成浏览器卡顿");
  2459. }
  2460. NetcaPDFSeal.preViewPDF(1, res.destFileEncode);
  2461. }
  2462. function SignatureCreatorBatchSealFailedCallBack(res)
  2463. {
  2464. alert("签名/章失败 " + res.msg);
  2465. }
  2466. function acrosspageSeal()
  2467. {
  2468. var _srcFile = signatureCreator_acrosspageseal_src_path.value; //源Pdf文件
  2469. var _srcBytes = signatureCreator_acrosspageseal_srcBytes.value; //源Pdf文件字节流
  2470. var _destFile = signatureCreator_acrosspageseal_des_path.value; //目标pdf文件
  2471. var _certEncode = signatureCreator_acrosspageseal_certEncode.value; //签名证书Base64编码
  2472. var _sealImageEncode = signatureCreator_acrosspageseal_sealImageEncode.value;//签章图片Base64编码
  2473. var _revInfoIncludeFlag = (signatureCreator_acrosspageseal_revInfoIncludeFlag.value == 1) ? true : false; //是否包含吊销信息
  2474. var _signaturePage = parseInt(signatureCreator_acrosspageseal_signaturePage.value); //P电子签章所在页码
  2475. var _startPage = parseInt(signatureCreator_acrosspageseal_startPage.value); //开始页码
  2476. var _endPage = parseInt(signatureCreator_acrosspageseal_endPage.value); //结束页码
  2477. var _xPos = parseInt(signatureCreator_acrosspageseal_xpos.value); //签名域/签章左下角的水平向右方向坐标
  2478. var _yPos = parseInt(signatureCreator_acrosspageseal_ypos.value); //签名域/签章左下角的垂直向上方向坐标
  2479. var _width = parseInt(signatureCreator_acrosspageseal_width.value); //签名域/签章的宽度
  2480. var _height = parseInt(signatureCreator_acrosspageseal_height.value); //签名域/签章的高度
  2481. var _tsaUrl= "http://tsa.cnca.net/NETCATimeStampServer/TSAServer.jsp"; //时间戳地址
  2482. var _tsaUsr= ""; //时间戳服务对应用户名
  2483. var _tsaPwd= ""; //时间戳服务对应用户的密码
  2484. var _tsaHashAlgo= ""; //时间戳使用的hash算法,例如”sha-1”,”sha-256”等
  2485. var params = {
  2486. srcFile: _srcFile, //源pdf文件
  2487. srcBytes: _srcBytes, //源Pdf文件的Base64编码
  2488. destFile: _destFile, //目标pdf文件
  2489. certEncode: _certEncode, //签名证书Base64编码
  2490. sealImageEncode: _sealImageEncode, //签章图片Base64编码
  2491. revInfoIncludeFlag: _revInfoIncludeFlag,//是否包含吊销信息
  2492. acrossPageSeal: //签名位置对象
  2493. {
  2494. signaturePage: _signaturePage, //电子签章所在页码
  2495. startPage: _startPage, //开始页码
  2496. endPage: _endPage, //结束页码
  2497. xPos: _xPos, //签名域/签章左下角的水平向右方向坐标
  2498. yPos: _yPos, //签名域/签章左下角的垂直向上方向坐标
  2499. width: _width, //签名域/签章的宽度
  2500. height: _height //签名域/签章的高度
  2501. },
  2502. Tsa: //时间戳对象
  2503. {
  2504. tsaUrl: _tsaUrl, //时间戳地址
  2505. tsaUsr: _tsaUsr, //时间戳服务对应用户名
  2506. tsaPwd: _tsaPwd, //时间戳服务对应用户的密码
  2507. tsaHashAlgo: _tsaHashAlgo //时间戳使用的hash算法,例如”sha-1”,”sha-256”等
  2508. }
  2509. };
  2510. NetcaPKI.acrosspageSeal(params)
  2511. .Then(function (res)
  2512. {
  2513. SignatureCreatorAcrosspageSealSuccessCallBack(res);
  2514. })
  2515. .Catch(function (res)
  2516. {
  2517. SignatureCreatorAcrosspageSealFailedCallBack(res);
  2518. });
  2519. }
  2520. function SignatureCreatorAcrosspageSealSuccessCallBack(res)
  2521. {
  2522. var result = "签名/章成功, 目标文件的Base64编码:\n" + res.destFileEncode;
  2523. alert(result);
  2524. console.log(res.destFileEncode);
  2525. if(res.destFileEncode.length >= 20*1024*1024)
  2526. {
  2527. alert("注意:目标文件大于20M,会造成浏览器卡顿");
  2528. }
  2529. NetcaPDFSeal.preViewPDF(1, res.destFileEncode);
  2530. }
  2531. function SignatureCreatorAcrosspageSealFailedCallBack(res)
  2532. {
  2533. alert("签名/章失败 " + res.msg);
  2534. }
  2535. var g_drawtexTtextSpirits = new Array();
  2536. function graphicsProcessDrawtext_addTextSpirit()
  2537. {
  2538. var _A=parseInt(graphicsProcessDrawtext_appearanceFontColorAEx.value); //透明度
  2539. var _R=parseInt(graphicsProcessDrawtext_appearanceFontColorREx.value); //红色
  2540. var _G=parseInt(graphicsProcessDrawtext_appearanceFontColorGEx.value); //绿色
  2541. var _B=parseInt(graphicsProcessDrawtext_appearanceFontColorBEx.value); //蓝色
  2542. var textSpirit = {
  2543. text : graphicsProcessDrawtext_appearanceTextEx.value,
  2544. widthPercentage : parseFloat(graphicsProcessDrawtext_appearanceWidthPercentageEx.value),
  2545. heightPercentage : parseFloat(graphicsProcessDrawtext_appearanceHeightPercentageEx.value),
  2546. fontName : graphicsProcessDrawtext_appearanceFontNameEx.value,
  2547. fontSize : parseInt(graphicsProcessDrawtext_appearanceFontSizeEx.value),
  2548. FontColor:
  2549. {
  2550. A: _A,
  2551. R: _R,
  2552. G: _G,
  2553. B: _B
  2554. },
  2555. }
  2556. g_drawtexTtextSpirits.push(textSpirit);
  2557. alert("增加外观信息成功,现有"+g_drawtexTtextSpirits.length + "个信息");
  2558. }
  2559. function graphicsProcessDrawtext_clearTextSpirit()
  2560. {
  2561. g_drawtexTtextSpirits = [];
  2562. alert("清空外观信息成功");
  2563. }
  2564. function graphicsProcessDrawText()
  2565. {
  2566. var _srcFile = graphicsProcessDrawtext_src_path.value; //源Pdf文件路径
  2567. var _srcBytes = graphicsProcessDrawtext_srcBytes.value; //源Pdf文件字节流
  2568. var _destFile = graphicsProcessDrawtext_des_path.value; //目标pdf文件
  2569. var _autoSize = graphicsProcessDrawtext_autoSize.value=="1"?true:false;
  2570. var params = {
  2571. srcFile: _srcFile, //源pdf文件
  2572. srcBytes: _srcBytes, //源Pdf文件的Base64编码
  2573. destFile: _destFile, //目标pdf文件
  2574. AppearanceObj:
  2575. {
  2576. appearanceType:parseInt(graphicsProcessDrawtext_appearanceType.value), //外观类型
  2577. width:parseInt(graphicsProcessDrawtext_appearanceWidth.value), //外观宽度
  2578. height:parseInt(graphicsProcessDrawtext_appearanceHeight.value), //外观高度
  2579. autoSize:_autoSize, //外观高度
  2580. textSpirits:g_drawtexTtextSpirits //文本信息
  2581. }
  2582. };
  2583. NetcaPKI.graphicsProcessDrawText(params)
  2584. .Then(function (res)
  2585. {
  2586. GraphicsProcessDrawtextSuccessCallBackEx(res);
  2587. })
  2588. .Catch(function (res)
  2589. {
  2590. GraphicsProcessDrawtextFailedCallBackEx(res);
  2591. });
  2592. }
  2593. function GraphicsProcessDrawtextSuccessCallBackEx(res)
  2594. {
  2595. var result = "产生新图片成功, 目标文件的Base64编码:\n" + res.destFileEncode;
  2596. alert(result);
  2597. }
  2598. function GraphicsProcessDrawtextFailedCallBackEx(res)
  2599. {
  2600. alert("产生新图片失败 " + res.msg);
  2601. }
  2602. function writeSeal()
  2603. {
  2604. var certEncode = Seal_certEncode.value;
  2605. var selectType = "Device";
  2606. var selectCondition = "InValidity='True' && CertType='Signature'";
  2607. var params = {
  2608. cert: {
  2609. "encode": certEncode,
  2610. "type": selectType,
  2611. "condition": selectCondition
  2612. },
  2613. device: {
  2614. "sn": Seal_sn.value,
  2615. "type": parseInt(Seal_type.value)
  2616. },
  2617. seSeals: [
  2618. {
  2619. sealData: Seal_write_se_sealData.value
  2620. }
  2621. ]
  2622. };
  2623. NetcaPKI.writeSeal(params)
  2624. .Then(function(res) {
  2625. alert("写入印章成功");
  2626. })
  2627. .Catch(function(res) {
  2628. alert(res.msg);
  2629. });
  2630. }
  2631. function readSeal()
  2632. {
  2633. var certEncode = Seal_certEncode.value;
  2634. var selectType = "Device";
  2635. var selectCondition = "InValidity='True' && CertType='Signature'";
  2636. var params = {
  2637. cert: {
  2638. "encode": certEncode,
  2639. "type": selectType,
  2640. "condition": selectCondition
  2641. },
  2642. device: {
  2643. "sn": Seal_sn.value,
  2644. "type": parseInt(Seal_type.value)
  2645. }
  2646. };
  2647. NetcaPKI.readSeal(params)
  2648. .Then(function(res) {
  2649. alert("读取印章成功:" + JSON.stringify(res));
  2650. })
  2651. .Catch(function(res) {
  2652. alert(res.msg);
  2653. });
  2654. }
  2655. NetcaPKI.writeSeal=function(params){
  2656. var requestQueryParams = {};
  2657. requestQueryParams["function"] ="WriteSeal";
  2658. requestQueryParams["param"] = params;
  2659. return NetcaPKI.SendNetcaCryptoJsonRpcMessage(requestQueryParams);
  2660. }
  2661. NetcaPKI.readSeal=function(params){
  2662. var requestQueryParams = {};
  2663. requestQueryParams["function"] ="ReadSeal";
  2664. requestQueryParams["param"] = params;
  2665. return NetcaPKI.SendNetcaCryptoJsonRpcMessage(requestQueryParams);
  2666. }