yc-ui2 0.2.2-beta2 → 0.2.2-beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. package/package.json +1 -1
  2. package/.env +0 -7
  3. package/babel.config.js +0 -5
  4. package/jsconfig.json +0 -19
  5. package/public/favicon.ico +0 -0
  6. package/public/index.html +0 -20
  7. package/src/App.vue +0 -70
  8. package/src/api/customerService.js +0 -56
  9. package/src/assets/ca/ca-bg.png +0 -0
  10. package/src/assets/ca/caBg.png +0 -0
  11. package/src/assets/customerService/admin.jpg +0 -0
  12. package/src/assets/customerService/chatTop.png +0 -0
  13. package/src/assets/customerService/ellipticalWenh.png +0 -0
  14. package/src/assets/customerService/enlarge.png +0 -0
  15. package/src/assets/customerService/personal.jpg +0 -0
  16. package/src/assets/customerService/personal1.jpg +0 -0
  17. package/src/assets/customerService/personal2.jpg +0 -0
  18. package/src/assets/slideVerify/1.jpg +0 -0
  19. package/src/assets/slideVerify/2.jpg +0 -0
  20. package/src/assets/slideVerify/3.jpg +0 -0
  21. package/src/assets/slideVerify/4.jpg +0 -0
  22. package/src/assets/slideVerify/5.jpg +0 -0
  23. package/src/assets/slideVerify/6.jpg +0 -0
  24. package/src/assets/slideVerify/7.jpg +0 -0
  25. package/src/assets/slideVerify/8.jpg +0 -0
  26. package/src/components/YcCA/index.vue +0 -536
  27. package/src/components/YcCustomerService/chat.vue +0 -337
  28. package/src/components/YcCustomerService/chatMixin.js +0 -128
  29. package/src/components/YcCustomerService/index.vue +0 -272
  30. package/src/components/YcQuestion/index.vue +0 -535
  31. package/src/components/YcSlideVerify/index.vue +0 -104
  32. package/src/main.js +0 -19
  33. package/src/packages/index.js +0 -29
  34. package/src/router/index.js +0 -20
  35. package/src/utils/auth.js +0 -6
  36. package/src/utils/mTokenPlugin/base64.js +0 -148
  37. package/src/utils/mTokenPlugin/base64_backups.js +0 -146
  38. package/src/utils/mTokenPlugin/hunca_mToken_core.js +0 -1447
  39. package/src/utils/mTokenPlugin/hunca_mToken_core2.js +0 -1455
  40. package/src/utils/mTokenPlugin/hunca_mToken_core_backups.js +0 -1425
  41. package/src/utils/mTokenPlugin/mToken.js +0 -3211
  42. package/src/utils/mTokenPlugin/mToken_backups.js +0 -3202
  43. package/src/utils/mTokenPluginBeijin/formateTime.js +0 -10
  44. package/src/utils/mTokenPluginBeijin/xtxasyn.js +0 -1156
  45. package/src/utils/request.js +0 -50
  46. package/src/views/question.vue +0 -32
  47. package/vue.config.js +0 -41
@@ -1,3202 +0,0 @@
1
- /*******************************************************
2
- *
3
- * 使用此JS脚本之前请先仔细阅读帮助文档!
4
- *
5
- * @author Fuly
6
- * @version 3.2.3
7
- * @date 2020/12/23
8
- *
9
- **********************************************************/
10
-
11
-
12
-
13
- var split;
14
-
15
- // Avoid running twice; that would break the `nativeSplit` reference
16
- split = split || function (undef) {
17
-
18
- var nativeSplit = String.prototype.split,
19
- compliantExecNpcg = /()??/.exec("")[1] === undef, // NPCG: nonparticipating capturing group
20
- self;
21
-
22
- self = function (str, separator, limit) {
23
- // If `separator` is not a regex, use `nativeSplit`
24
- if (Object.prototype.toString.call(separator) !== "[object RegExp]") {
25
- return nativeSplit.call(str, separator, limit);
26
- }
27
- var output = [],
28
- flags = (separator.ignoreCase ? "i" : "") +
29
- (separator.multiline ? "m" : "") +
30
- (separator.extended ? "x" : "") + // Proposed for ES6
31
- (separator.sticky ? "y" : ""), // Firefox 3+
32
- lastLastIndex = 0,
33
- // Make `global` and avoid `lastIndex` issues by working with a copy
34
- separator = new RegExp(separator.source, flags + "g"),
35
- separator2, match, lastIndex, lastLength;
36
- str += ""; // Type-convert
37
- if (!compliantExecNpcg) {
38
- // Doesn't need flags gy, but they don't hurt
39
- separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);
40
- }
41
- /* Values for `limit`, per the spec:
42
- * If undefined: 4294967295 // Math.pow(2, 32) - 1
43
- * If 0, Infinity, or NaN: 0
44
- * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
45
- * If negative number: 4294967296 - Math.floor(Math.abs(limit))
46
- * If other: Type-convert, then use the above rules
47
- */
48
- limit = limit === undef ?
49
- -1 >>> 0 : // Math.pow(2, 32) - 1
50
- limit >>> 0; // ToUint32(limit)
51
- while (match = separator.exec(str)) {
52
- // `separator.lastIndex` is not reliable cross-browser
53
- lastIndex = match.index + match[0].length;
54
- if (lastIndex > lastLastIndex) {
55
- output.push(str.slice(lastLastIndex, match.index));
56
- // Fix browsers whose `exec` methods don't consistently return `undefined` for
57
- // nonparticipating capturing groups
58
- if (!compliantExecNpcg && match.length > 1) {
59
- match[0].replace(separator2, function () {
60
- for (var i = 1; i < arguments.length - 2; i++) {
61
- if (arguments[i] === undef) {
62
- match[i] = undef;
63
- }
64
- }
65
- });
66
- }
67
- if (match.length > 1 && match.index < str.length) {
68
- Array.prototype.push.apply(output, match.slice(1));
69
- }
70
- lastLength = match[0].length;
71
- lastLastIndex = lastIndex;
72
- if (output.length >= limit) {
73
- break;
74
- }
75
- }
76
- if (separator.lastIndex === match.index) {
77
- separator.lastIndex++; // Avoid an infinite loop
78
- }
79
- }
80
- if (lastLastIndex === str.length) {
81
- if (lastLength || !separator.test("")) {
82
- output.push("");
83
- }
84
- } else {
85
- output.push(str.slice(lastLastIndex));
86
- }
87
- return output.length > limit ? output.slice(0, limit) : output;
88
- };
89
-
90
- // For convenience
91
- String.prototype.split = function (separator, limit) {
92
- return self(this, separator, limit);
93
- };
94
-
95
- return self;
96
-
97
- }();
98
-
99
-
100
- export function mToken (obj) {
101
- this.obj = obj;
102
-
103
- this.SAR_OK = 0;
104
- this.SAR_FALSE = 1;
105
-
106
- //分组加密算法标识
107
- this.SGD_SM1_ECB = 0x00000101;
108
- this.SGD_SM1_CBC = 0x00000102;
109
- this.SGD_SM1_CFB = 0x00000104;
110
- this.SGD_SM1_OFB = 0x00000108;
111
- this.SGD_SM1_MAC = 0x00000110;
112
- this.SGD_SSF33_ECB = 0x00000201;
113
- this.SGD_SSF33_CBC = 0x00000202;
114
- this.SGD_SSF33_CFB = 0x00000204;
115
- this.SGD_SSF33_OFB = 0x00000208;
116
- this.SGD_SSF33_MAC = 0x00000210;
117
- this.SGD_SM4_ECB = 0x00000401;
118
- this.SGD_SM4_CBC = 0x00000402;
119
- this.SGD_SM4_CFB = 0x00000404;
120
- this.SGD_SM4_OFB = 0x00000408;
121
- this.SGD_SM4_MAC = 0x00000410;
122
-
123
- this.SGD_VENDOR_DEFINED = 0x80000000;
124
- this.SGD_DES_ECB = this.SGD_VENDOR_DEFINED + 0x00000211
125
- this.SGD_DES_CBC = this.SGD_VENDOR_DEFINED + 0x00000212
126
-
127
- this.SGD_3DES168_ECB = this.SGD_VENDOR_DEFINED + 0x00000241
128
- this.SGD_3DES168_CBC = this.SGD_VENDOR_DEFINED + 0x00000242
129
-
130
- this.SGD_3DES112_ECB = this.SGD_VENDOR_DEFINED + 0x00000221
131
- this.SGD_3DES112_CBC = this.SGD_VENDOR_DEFINED + 0x00000222
132
-
133
- this.SGD_AES128_ECB = this.SGD_VENDOR_DEFINED + 0x00000111
134
- this.SGD_AES128_CBC = this.SGD_VENDOR_DEFINED + 0x00000112
135
-
136
- this.SGD_AES192_ECB = this.SGD_VENDOR_DEFINED + 0x00000121
137
- this.SGD_AES192_CBC = this.SGD_VENDOR_DEFINED + 0x00000122
138
-
139
- this.SGD_AES256_ECB = this.SGD_VENDOR_DEFINED + 0x00000141
140
- this.SGD_AES256_CBC = this.SGD_VENDOR_DEFINED + 0x00000142
141
-
142
-
143
- //非对称密码算法标识
144
- this.SGD_RSA = 0x00010000;
145
- this.SGD_SM2_1 = 0x00020100; //ECC签名
146
- this.SGD_SM2_2 = 0x00020200; //ECC密钥交换
147
- this.SGD_SM2_3 = 0x00020400; //ECC加密
148
-
149
- //密码杂凑算法标识
150
- this.SGD_SM3 = 0x00000001;
151
- this.SGD_SHA1 = 0x00000002;
152
- this.SGD_SHA256 = 0x00000004;
153
- this.SGD_RAW = 0x00000080;
154
- this.SGD_MD5 = 0x00000081;
155
- this.SGD_SHA384 = 0x00000082;
156
- this.SGD_SHA512 = 0x00000083;
157
-
158
-
159
- this.SGD_CERT_VERSION = 0x00000001;
160
- this.SGD_CERT_SERIAL = 0x00000002;
161
- this.SGD_CERT_ISSUE = 0x00000005;
162
- this.SGD_CERT_VALID_TIME = 0x00000006;
163
- this.SGD_CERT_SUBJECT = 0x00000007;
164
- this.SGD_CERT_DER_PUBLIC_KEY = 0x00000008;
165
- this.SGD_CERT_DER_EXTENSIONS = 0x00000009;
166
- this.SGD_CERT_NOT_BEFORE = 0x00000010;
167
- this.SGD_CERT_ISSUER_CN = 0x00000021;
168
- this.SGD_CERT_ISSUER_O = 0x00000022;
169
- this.SGD_CERT_ISSUER_OU = 0x00000023;
170
- this.SGD_CERT_ISSUER_C = 0x00000024;
171
- this.SGD_CERT_ISSUER_P = 0x00000025;
172
- this.SGD_CERT_ISSUER_L = 0x00000026;
173
- this.SGD_CERT_ISSUER_S = 0x00000027;
174
- this.SGD_CERT_ISSUER_EMAIL = 0x00000028;
175
-
176
- this.SGD_CERT_SUBJECT_CN = 0x00000031;
177
- this.SGD_CERT_SUBJECT_O = 0x00000032;
178
- this.SGD_CERT_SUBJECT_OU = 0x00000033;
179
- this.SGD_CERT_SUBJECT_EMALL = 0x00000034;
180
- this.SGD_REMAIN_TIME = 0x00000035;
181
- this.SGD_SIGNATURE_ALG = 0x00000036;
182
- this.SGD_CERT_SUBJECT_C = 0x00000037;
183
- this.SGD_CERT_SUBJECT_P = 0x00000038;
184
- this.SGD_CERT_SUBJECT_L = 0x00000039;
185
- this.SGD_CERT_SUBJECT_S = 0x0000003A;
186
-
187
- this.SGD_CERT_CRL = 0x00000041;
188
-
189
-
190
- this.SGD_DEVICE_SORT = 0x00000201;
191
- this.SGD_DEVICE_TYPE = 0x00000202;
192
- this.SGD_DEVICE_NAME = 0x00000203;
193
- this.SGD_DEVICE_MANUFACTURER = 0x00000204;
194
- this.SGD_DEVICE_HARDWARE_VERSION = 0x00000205;
195
- this.SGD_DEVICE_SOFTWARE_VERSION = 0x00000206;
196
- this.SGD_DEVICE_STANDARD_VERSION = 0x00000207;
197
- this.SGD_DEVICE_SERIAL_NUMBER = 0x00000208;
198
- this.SGD_DEVICE_SUPPORT_SYM_ALG = 0x00000209;
199
- this.SGD_DEVICE_SUPPORT_ASYM_ALG = 0x0000020A;
200
- this.SGD_DEVICE_SUPPORT_HASH_ALG = 0x0000020B;
201
- this.SGD_DEVICE_SUPPORT_STORANGE_SPACE = 0x0000020C;
202
- this.SGD_DEVICE_SUPPORT_FREE_SAPCE = 0x0000020D;
203
- this.SGD_DEVICE_RUNTIME = 0x0000020E;
204
- this.SGD_DEVICE_USED_TIMES = 0x0000020F;
205
- this.SGD_DEVICE_LOCATION = 0x00000210;
206
- this.SGD_DEVICE_DESCRIPTION = 0x00000211;
207
- this.SGD_DEVICE_MANAGER_INFO = 0x00000212;
208
- this.SGD_DEVICE_MAX_DATA_SIZE = 0x00000213;
209
-
210
- this.TRUE = 1;
211
- this.FALSE = 0;
212
-
213
- this.GM3000 = 1;
214
- this.K5 = 3;
215
- this.TF = 4;
216
- this.HT = 5;
217
- this.SJK1137 = 2;
218
-
219
- this.TYPE_UKEY = 1; //普通UKEY
220
- this.TYPE_FPKEY = 2; //指纹UKEY
221
-
222
- var g_mTokenPlugin = null;
223
- var g_deviceNames = null;
224
-
225
-
226
- this.SOF_GetLastError = function () {
227
- if (g_mTokenPlugin == null) {
228
- return -1;
229
- }
230
-
231
- return g_mTokenPlugin.SOF_GetLastError();
232
- }
233
-
234
- function isIe () {
235
- return ("ActiveXObject" in window);
236
- }
237
-
238
- function isMobile () {
239
- var browser = {
240
- versions: function () {
241
- var u = navigator.userAgent, app = navigator.appVersion;
242
- return {//移动终端浏览器版本信息
243
- trident: u.indexOf('Trident') > -1, //IE内核
244
- presto: u.indexOf('Presto') > -1, //opera内核
245
- webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
246
- gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
247
- mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
248
- ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
249
- android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或者uc浏览器
250
- iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器
251
- iPad: u.indexOf('iPad') > -1, //是否iPad
252
- webApp: u.indexOf('Safari') == -1
253
- //是否web应该程序,没有头部与底部
254
- };
255
- }(),
256
- language: (navigator.browserLanguage || navigator.language).toLowerCase()
257
- }
258
-
259
- if ((browser.versions.mobile) && (browser.versions.ios || browser.versions.android || browser.versions.iPhone || browser.versions.iPad)) {
260
- return true;
261
- }
262
- else {
263
- return false;
264
- }
265
- }
266
-
267
- this.SOF_LoadLibrary = function (type) {
268
- os = check_os();
269
- var ret;
270
- if (g_mTokenPlugin == null) {
271
- g_mTokenPlugin = new mTokenPlugin();
272
- }
273
-
274
- if (type == this.GM3000) {
275
- if (isMobile()) {
276
- ret = g_mTokenPlugin.SOF_LoadLibrary("1", "mToken OTG", "com.longmai.security.plugin.driver.otg.OTGDriver");
277
- }
278
- else {
279
- ret = g_mTokenPlugin.SOF_LoadLibrary("mtoken_gm3000_hnca.dll", "libgm3000.1.0.so", "libgm3000.1.0.dylib");
280
- }
281
- }
282
- else if (type == this.SJK1137) {
283
- ret = g_mTokenPlugin.SOF_LoadLibrary("SKF_APP.dll", "libhunca_hsic_skf.so", "libhunca_hsic_skf.dylib");
284
- }
285
- else if (type == this.HT) {
286
- ret = g_mTokenPlugin.SOF_LoadLibrary("HUNCA_HT_20522_SKF.dll", "libhunca_ht_h2070f63_skf.so", "libhunca_ht_h2070f63_skf.dylib");
287
- }
288
- else if (type == this.K5) {
289
- if (isMobile()) {
290
- ret = g_mTokenPlugin.SOF_LoadLibrary("2", "mToken K5 Bluetooth", "com.longmai.security.plugin.driver.ble.BLEDriver");
291
- }
292
- else {
293
- ret = g_mTokenPlugin.SOF_LoadLibrary("mtoken_k5.dll", "libgm3000.1.0.so", "libk5.1.0.dylib");
294
- }
295
- }
296
- else if (type == this.TF) {
297
- if (isMobile()) {
298
- ret = g_mTokenPlugin.SOF_LoadLibrary("0", "mToken TF/SD Card", "com.longmai.security.plugin.driver.tf.TFDriver");
299
- } else {
300
- ret = g_mTokenPlugin.SOF_LoadLibrary("mtoken_tf.dll", "libgm3000.1.0.so", "libtf.dylib");;
301
- }
302
- }
303
- else {
304
- return -1;
305
- }
306
-
307
- if (ret != 0) {
308
- return -2;
309
- }
310
- return this.SAR_OK;
311
- };
312
-
313
-
314
- this.SOF_EnumDevice = function () {
315
- if (g_mTokenPlugin == null) {
316
- return null;
317
- }
318
-
319
- var array = g_mTokenPlugin.SOF_EnumDevice();
320
- if (array == null || array.length <= 0) {
321
- return null;
322
- }
323
-
324
- return array.split("||");
325
-
326
- };
327
-
328
-
329
- this.SOF_GetVersion = function () {
330
- if (g_mTokenPlugin == null) {
331
- return null;
332
- }
333
-
334
- return g_mTokenPlugin.SOF_GetVersion();
335
- };
336
-
337
-
338
- this.SOF_GetDeviceInstance = function (DeviceName, ApplicationName) {
339
- if (g_mTokenPlugin == null) {
340
- return -1;
341
- }
342
-
343
- return g_mTokenPlugin.SOF_GetDeviceInstance(DeviceName, ApplicationName);
344
- };
345
-
346
- this.SOF_ReleaseDeviceInstance = function () {
347
- if (g_mTokenPlugin == null) {
348
- return -1;
349
- }
350
-
351
- return g_mTokenPlugin.SOF_ReleaseDeviceInstance()
352
- }
353
-
354
-
355
- this.SOF_GetUserList = function () {
356
- if (g_mTokenPlugin == null) {
357
- return null;
358
- }
359
-
360
- var array = g_mTokenPlugin.SOF_GetUserList();
361
- if (array == null || array.length <= 0)
362
- return null;
363
-
364
- var list = new Array();
365
- var user = array.split("&&&");
366
- var length = user.length;
367
- for (var i = 0; i < length; i++) {
368
- list[i] = user[i].split("||");
369
- }
370
-
371
- return list;
372
- };
373
-
374
-
375
- this.SOF_ExportUserCert = function (ContainerName, KeySpec) {
376
- if (g_mTokenPlugin == null) {
377
- return null;
378
- }
379
-
380
- return g_mTokenPlugin.SOF_ExportUserCert(ContainerName, KeySpec);
381
- };
382
-
383
-
384
- this.SOF_GetDeviceInfo = function (Type) {
385
- if (g_mTokenPlugin == null) {
386
- return null;
387
- }
388
-
389
- return g_mTokenPlugin.SOF_GetDeviceInfo(Type);
390
- };
391
-
392
-
393
- this.SOF_GetCertInfo = function (Base64EncodeCert, Type) {
394
- if (g_mTokenPlugin == null) {
395
- return null;
396
- }
397
-
398
- return g_mTokenPlugin.SOF_GetCertInfo(Base64EncodeCert, Type);
399
- };
400
-
401
- this.SOF_GetCertInfoByOid = function (Base64EncodeCert, OID) {
402
- if (g_mTokenPlugin == null) {
403
- return null;
404
- }
405
-
406
- return g_mTokenPlugin.SOF_GetCertInfoByOid(Base64EncodeCert, OID);
407
- }
408
-
409
- this.SOF_Login = function (PassWd) {
410
- if (g_mTokenPlugin == null) {
411
- return -1;
412
- }
413
-
414
- return g_mTokenPlugin.SOF_Login(PassWd);
415
- };
416
-
417
-
418
- this.SOF_LogOut = function () {
419
- if (g_mTokenPlugin == null) {
420
- return -1;
421
- }
422
-
423
- return g_mTokenPlugin.SOF_LogOut();
424
- };
425
-
426
-
427
- this.SOF_GetPinRetryCount = function () {
428
- if (g_mTokenPlugin == null) {
429
- return -1;
430
- }
431
-
432
- return g_mTokenPlugin.SOF_GetPinRetryCount();
433
- };
434
-
435
-
436
- this.SOF_ChangePassWd = function (OldPassWd, NewPassWd) {
437
- if (g_mTokenPlugin == null) {
438
- return -1;
439
- }
440
-
441
- return g_mTokenPlugin.SOF_ChangePassWd(OldPassWd, NewPassWd);
442
- };
443
-
444
-
445
- this.SOF_SetDigestMethod = function (DigestMethod) {
446
- if (g_mTokenPlugin == null) {
447
- return -1;
448
- }
449
-
450
- return g_mTokenPlugin.SOF_SetDigestMethod(DigestMethod);
451
- };
452
-
453
-
454
- this.SOF_SetUserID = function (UserID) {
455
- if (g_mTokenPlugin == null) {
456
- return -1;
457
- }
458
-
459
- return g_mTokenPlugin.SOF_SetUserID(UserID);
460
- };
461
-
462
-
463
- this.SOF_SetEncryptMethodAndIV = function (EncryptMethod, EncryptIV) {
464
- if (g_mTokenPlugin == null) {
465
- return -1;
466
- }
467
-
468
- return g_mTokenPlugin.SOF_SetEncryptMethodAndIV(EncryptMethod, EncryptIV);
469
- };
470
-
471
-
472
- this.SOF_EncryptFileToPKCS7 = function (Cert, InFile, OutFile, type) {
473
- if (g_mTokenPlugin == null) {
474
- return -1;
475
- }
476
-
477
- return g_mTokenPlugin.SOF_EncryptFileToPKCS7(Cert, InFile, OutFile, type);
478
- };
479
-
480
-
481
- this.SOF_SignFileToPKCS7 = function (ContainerName, InFile, OutFile) {
482
- if (g_mTokenPlugin == null) {
483
- return -1;
484
- }
485
-
486
- return g_mTokenPlugin.SOF_SignFileToPKCS7(ContainerName, InFile, OutFile);
487
- };
488
-
489
- this.SOF_VerifyFileToPKCS7 = function (strPkcs7Data, InFilePath) {
490
- if (g_mTokenPlugin == null) {
491
- return -1;
492
- }
493
-
494
- return g_mTokenPlugin.SOF_VerifyFileToPKCS7(strPkcs7Data, InFilePath);
495
- };
496
-
497
- this.SOF_DecryptFileToPKCS7 = function (ContainerName, keySpec, Pkcs7Data, InFile, OutFile, type) {
498
- if (g_mTokenPlugin == null) {
499
- return -1;
500
- }
501
-
502
- return g_mTokenPlugin.SOF_DecryptFileToPKCS7(ContainerName, keySpec, Pkcs7Data, InFile, OutFile, type);
503
- };
504
-
505
- this.SOF_DigestData = function (ContainerName, nData, InDataLen) {
506
- if (g_mTokenPlugin == null) {
507
- return null;
508
- }
509
-
510
- return g_mTokenPlugin.SOF_DigestData(ContainerName, nData, InDataLen);
511
- };
512
-
513
- this.SOF_SignData = function (ContainerName, ulKeySpec, InData, InDataLen) {
514
- if (g_mTokenPlugin == null) {
515
- return null;
516
- }
517
-
518
- return g_mTokenPlugin.SOF_SignData(ContainerName, ulKeySpec, InData, InDataLen);
519
- };
520
- //交互式签名
521
- this.SOF_SignDataInteractive = function (ContainerName, ulKeySpec, InData, InDataLen) {
522
- if (g_mTokenPlugin == null) {
523
- return null;
524
- }
525
-
526
- return g_mTokenPlugin.SOF_SignDataInteractive(ContainerName, ulKeySpec, InData, InDataLen);
527
- }
528
-
529
-
530
- this.SOF_SignDataToPKCS7 = function (ContainerName, ulKeySpec, InData, ulDetached) {
531
- if (g_mTokenPlugin == null) {
532
- return null;
533
- }
534
-
535
- return g_mTokenPlugin.SOF_SignDataToPKCS7(ContainerName, ulKeySpec, InData, ulDetached);
536
- };
537
-
538
-
539
-
540
- this.SOF_VerifyDataToPKCS7 = function (Base64EncodeCert, InData, SignedValue) {
541
- if (g_mTokenPlugin == null) {
542
- return -1;
543
- }
544
-
545
- return g_mTokenPlugin.SOF_VerifyDataToPKCS7(Base64EncodeCert, InData, SignedValue);
546
- };
547
-
548
-
549
- this.SOF_VerifySignedData = function (Base64EncodeCert, digestMethod, InData, SignedValue) {
550
- if (g_mTokenPlugin == null) {
551
- return -1;
552
- }
553
-
554
- return g_mTokenPlugin.SOF_VerifySignedData(Base64EncodeCert, digestMethod, InData, SignedValue);
555
- };
556
-
557
-
558
- this.SOF_EncryptDataPKCS7 = function (Base64EncodeCert, InData, InDataLen) {
559
- if (g_mTokenPlugin == null) {
560
- return null;
561
- }
562
-
563
- return g_mTokenPlugin.SOF_EncryptDataPKCS7(Base64EncodeCert, InData, InDataLen);
564
- };
565
-
566
-
567
- this.SOF_DecryptDataPKCS7 = function (ContainerName, ulKeySpec, InData) {
568
- if (g_mTokenPlugin == null) {
569
- return null;
570
- }
571
-
572
- return g_mTokenPlugin.SOF_DecryptDataPKCS7(ContainerName, ulKeySpec, InData);
573
- };
574
-
575
-
576
- this.SOF_GenRemoteUnblockRequest = function () {
577
- if (g_mTokenPlugin == null) {
578
- return null;
579
- }
580
-
581
- return g_mTokenPlugin.SOF_GenRemoteUnblockRequest();
582
- };
583
-
584
-
585
- this.SOF_GenResetpwdResponse = function (request, soPin, userPin) {
586
- if (g_mTokenPlugin == null) {
587
- return null;
588
- }
589
-
590
- return g_mTokenPlugin.SOF_GenResetpwdResponse(request, soPin, userPin);
591
- };
592
-
593
-
594
- this.SOF_RemoteUnblockPIN = function (request) {
595
- if (g_mTokenPlugin == null) {
596
- return null;
597
- }
598
-
599
- return g_mTokenPlugin.SOF_RemoteUnblockPIN(request);
600
- };
601
-
602
-
603
- this.SOF_SignDataToPKCS7 = function (ContainerName, ulKeySpec, InData, ulDetached) {
604
- if (g_mTokenPlugin == null) {
605
- return null;
606
- }
607
-
608
- return g_mTokenPlugin.SOF_SignDataToPKCS7(ContainerName, ulKeySpec, InData, ulDetached);
609
- };
610
-
611
-
612
- this.SOF_VerifyDataToPKCS7 = function (strPkcs7Data, OriginalText, ulDetached) {
613
- if (g_mTokenPlugin == null) {
614
- return null;
615
- }
616
-
617
- return g_mTokenPlugin.SOF_VerifyDataToPKCS7(strPkcs7Data, OriginalText, ulDetached);
618
- };
619
-
620
- //按expType导出的公钥,格式为国密规范指定的格式或DER格式
621
- this.SOF_ExportPubKey = function (containerName, cerType, expType) {
622
- if (g_mTokenPlugin == null) {
623
- return null;
624
- }
625
-
626
- return g_mTokenPlugin.SOF_ExportPubKey(containerName, cerType, expType);
627
- }
628
-
629
- this.SOF_EncryptByPubKey = function (strPubKey, strInput, cerType) {
630
- if (g_mTokenPlugin == null) {
631
- return null;
632
- }
633
-
634
- return g_mTokenPlugin.SOF_EncryptByPubKey(strPubKey, strInput, cerType);
635
- }
636
-
637
- this.SOF_DecryptByPrvKey = function (containerName, cerType, strAsymCipher) {
638
- if (g_mTokenPlugin == null) {
639
- return null;
640
- }
641
-
642
- return g_mTokenPlugin.SOF_DecryptByPrvKey(containerName, cerType, strAsymCipher);
643
- }
644
-
645
- //RA客户端相关接口:P10及证书导入等
646
- this.SOF_GenerateP10Request = function (deviceName, container, dn, asymAlg, keySpec, keyLength) {
647
- if (g_mTokenPlugin == null) {
648
- return null;
649
- }
650
-
651
- return g_mTokenPlugin.SOF_GenerateP10Request(deviceName, container, dn, asymAlg, keySpec, keyLength);
652
- }
653
-
654
- this.SOF_EnumCertContiner = function () {
655
- if (g_mTokenPlugin == null) {
656
- return null;
657
- }
658
-
659
- return g_mTokenPlugin.SOF_EnumCertContiner();
660
- }
661
-
662
- this.SOF_FindContainer = function (certSN) {
663
- if (g_mTokenPlugin == null) {
664
- return null;
665
- }
666
-
667
- return g_mTokenPlugin.SOF_FindContainer(certSN);
668
- }
669
-
670
- this.SOF_DeleteCert = function (certSN) {
671
- if (g_mTokenPlugin == null) {
672
- return null;
673
- }
674
-
675
- return g_mTokenPlugin.SOF_DeleteCert(certSN);
676
- }
677
-
678
- this.SOF_DeleteContainer = function (certSN) {
679
- if (g_mTokenPlugin == null) {
680
- return null;
681
- }
682
-
683
- return g_mTokenPlugin.SOF_DeleteContainer(certSN);
684
- }
685
-
686
- this.SOF_SignByCert = function (certSN, plain) {
687
- if (g_mTokenPlugin == null) {
688
- return null;
689
- }
690
-
691
- return g_mTokenPlugin.SOF_SignByCert(certSN, plain);
692
- }
693
-
694
- this.SOF_VerifyByCert = function (certSN, plain, signature) {
695
- if (g_mTokenPlugin == null) {
696
- return null;
697
- }
698
-
699
- return g_mTokenPlugin.SOF_VerifyByCert(certSN, plain, signature);
700
- }
701
-
702
-
703
- this.SOF_ImportCert = function (container, cert, keySpec) {
704
- if (g_mTokenPlugin == null) {
705
- return null;
706
- }
707
-
708
- return g_mTokenPlugin.SOF_ImportCert(container, cert, keySpec);
709
- }
710
-
711
- this.SOF_ImportCryptoCertAndKey = function (container, cert, nAsymAlg, EncryptedSessionKeyData, symAlg, EncryptedPrivateKeyData, mode) {
712
- if (g_mTokenPlugin == null) {
713
- return null;
714
- }
715
-
716
- return g_mTokenPlugin.SOF_ImportCryptoCertAndKey(container, cert, nAsymAlg, EncryptedSessionKeyData, symAlg, EncryptedPrivateKeyData, mode);
717
- }
718
-
719
- this.SOF_VerifyByExtCert = function (cert, plain, signature, digestMethod) {
720
- if (g_mTokenPlugin == null) {
721
- return null;
722
- }
723
-
724
- return g_mTokenPlugin.SOF_VerifyByExtCert(cert, plain, signature, digestMethod);
725
- }
726
-
727
- this.SOF_GenerateRandom = function (length) {
728
- if (g_mTokenPlugin == null) {
729
- return null;
730
- }
731
-
732
- return g_mTokenPlugin.SOF_GenerateRandom(length);
733
- }
734
-
735
- this.SOF_SymEncryptFile = function (sessionKey, srcfile, destfile, type) {
736
- if (g_mTokenPlugin == null) {
737
- return null;
738
- }
739
-
740
- return g_mTokenPlugin.SOF_SymEncryptFile(sessionKey, srcfile, destfile, type);
741
- }
742
-
743
- this.SOF_SymDecryptFile = function (sessionKey, srcfile, destfile, type) {
744
- if (g_mTokenPlugin == null) {
745
- return null;
746
- }
747
-
748
- return g_mTokenPlugin.SOF_SymDecryptFile(sessionKey, srcfile, destfile, type);
749
- }
750
-
751
- this.SOF_SymEncryptData = function (sessionKey, inData) {
752
- if (g_mTokenPlugin == null) {
753
- return null;
754
- }
755
-
756
- return g_mTokenPlugin.SOF_SymEncryptData(sessionKey, inData);
757
- }
758
-
759
- this.SOF_SymDecryptData = function (sessionKey, inData) {
760
- if (g_mTokenPlugin == null) {
761
- return null;
762
- }
763
-
764
- return g_mTokenPlugin.SOF_SymDecryptData(sessionKey, inData);
765
- }
766
-
767
- this.SOF_GenerateQRCode = function (qrcode_text) {
768
- if (g_mTokenPlugin == null) {
769
- return null;
770
- }
771
-
772
- return g_mTokenPlugin.SOF_GenerateQRCode(qrcode_text);
773
- }
774
-
775
-
776
- this.SOF_VerifyPinMS = function (responseKey) {
777
- if (g_mTokenPlugin == null) {
778
- return null;
779
- }
780
-
781
- return g_mTokenPlugin.SOF_VerifyPinMS(responseKey);
782
- }
783
-
784
- this.SOF_GetHardwareType = function () {
785
- if (g_mTokenPlugin == null) {
786
- return null;
787
- }
788
-
789
- return g_mTokenPlugin.SOF_GetHardwareType();
790
- }
791
-
792
- this.SOF_VerifyFingerprint = function () {
793
- if (g_mTokenPlugin == null) {
794
- return null;
795
- }
796
-
797
- return g_mTokenPlugin.SOF_VerifyFingerprint();
798
- }
799
-
800
-
801
- this.SOF_EnumFiles = function () {
802
- if (g_mTokenPlugin == null) {
803
- return null;
804
- }
805
-
806
- var array = g_mTokenPlugin.SOF_EnumFiles();
807
- if (array == null || array.length <= 0) {
808
- return null;
809
- }
810
-
811
- return array.split("||");
812
- }
813
-
814
- this.SOF_ReadFile = function (fileName, offset, length) {
815
- if (g_mTokenPlugin == null) {
816
- return null;
817
- }
818
- return g_mTokenPlugin.SOF_ReadFile(fileName, Number(offset), Number(length));
819
- }
820
-
821
- this.SOF_WriteFile = function (fileName, offset, data) {
822
- if (g_mTokenPlugin == null) {
823
- return null;
824
- }
825
- return g_mTokenPlugin.SOF_WriteFile(fileName, offset, data);
826
- }
827
-
828
- this.SOF_CreateFile = function (fileName, length, readRight, writeRight) {
829
- if (g_mTokenPlugin == null) {
830
- return null;
831
- }
832
- return g_mTokenPlugin.SOF_CreateFile(fileName, length, readRight, writeRight);
833
- }
834
-
835
- this.SOF_DeleteFile = function (fileName) {
836
- if (g_mTokenPlugin == null) {
837
- return null;
838
- }
839
- return g_mTokenPlugin.SOF_DeleteFile(fileName);
840
- }
841
-
842
-
843
- }
844
-
845
- //判断插件名称是否存在
846
- function hasPlugin (name) {
847
- name = name.toLowerCase();
848
- for (var i = 0; i < navigator.plugins.length; i++) {
849
- if (navigator.plugins[i].name.toLowerCase().indexOf(name) > -1) {
850
- return true;
851
- }
852
- }
853
- return false;
854
- }
855
- //判断系统
856
- function check_os () {
857
- var windows = (navigator.userAgent.indexOf("Windows", 0) != -1) ? 1 : 0;
858
- var mac = (navigator.userAgent.indexOf("mac", 0) != -1) ? 1 : 0;
859
- var linux = (navigator.userAgent.indexOf("Linux", 0) != -1) ? 1 : 0;
860
- var unix = (navigator.userAgent.indexOf("X11", 0) != -1) ? 1 : 0;
861
- var os_type = "";
862
- if (windows) os_type = "MS Windows";
863
- else if (linux) os_type = "Lunix";
864
- if (hasPlugin("mPlugin1.0.0.1")) {
865
- linuxWin = 2;
866
- return "id_mPluginV2Router";
867
- } else {
868
- linuxWin = 1;
869
- return "mTokenPlugin";
870
- }
871
-
872
-
873
- }
874
- var linuxWin = 0;
875
- var os;
876
-
877
- function mTokenPlugin () {
878
- var _xmlhttp;
879
- var retJSON = "";
880
-
881
- function AjaxIO (json_in) {
882
- //id_mPluginV2Router mTokenPlugin
883
- if (os == "id_mPluginV2Router") {
884
- var router = null;
885
- //var url = "http://192.168.1.25:51235/alpha";
886
- var url = "http://127.0.0.1:51235/alpha";
887
-
888
- router = document.getElementById("id_mPluginV2Router");
889
- if (null == router) {
890
- alert("无法获取到插件,请确认已经安装好插件!");
891
- }
892
- /*
893
- if("https:" == document.location.protocol)
894
- {
895
- url = "https://127.0.0.1:51245/alpha";
896
- }
897
- */
898
- var json = json_in;
899
-
900
- retJSON = router.invoke(url, json);
901
- return retJSON;
902
- } else {
903
-
904
- var _curDevName = "";
905
- var _url = "http://127.0.0.1:51235/alpha";
906
- var json = json_in;
907
- if (_xmlhttp == null) {
908
- if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
909
- _xmlhttp = new XMLHttpRequest();
910
- } else { // code for IE6, IE5
911
- _xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
912
- }
913
- }
914
-
915
- /***
916
- if ("https:" == document.location.protocol) {
917
- _url = "https://127.0.0.1:51245/alpha";
918
- }
919
- ***/
920
- _xmlhttp.open("POST", _url, false);
921
- _xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
922
- _xmlhttp.send("json=" + json);
923
- }
924
-
925
-
926
-
927
-
928
- };
929
-
930
- function GetHttpResult () {
931
- if (_xmlhttp.readyState == 4 && _xmlhttp.status == 200) {
932
- var obj = eval("(" + _xmlhttp.responseText + ")");
933
- return obj;
934
- }
935
- else {
936
- return null;
937
- }
938
- }
939
-
940
- this.SOF_GetLastError = function () {
941
- var json = '{"function":"SOF_GetLastError"}';
942
- if (linuxWin == 2) {
943
- var retJSON = "";
944
- try {
945
- retJSON = AjaxIO(json);
946
- } catch (e) {
947
- return -3;
948
- }
949
-
950
-
951
- if (retJSON.length > 3) {
952
- var obj = eval("(" + retJSON + ")");
953
- return obj.errorCode;
954
- } else {
955
- return -2;
956
-
957
- }
958
- } else {
959
- try {
960
- AjaxIO(json);
961
- } catch (e) {
962
- return -3;
963
- }
964
- var ret = GetHttpResult();
965
- if (ret) {
966
- return ret.rtn;
967
- }
968
-
969
- return -2;
970
- }
971
- }
972
-
973
- this.SOF_LoadLibrary = function (windows, linux, mac) {
974
- var json = '{"function":"SOF_LoadLibrary", "winDllName":"' + windows + '", "linuxSOName":"' + linux + '", "macDylibName":"' + mac + '"}';
975
- if (linuxWin == 2) {
976
- var retJSON = "";
977
- try {
978
- retJSON = AjaxIO(json);
979
- } catch (e) {
980
- return -3;
981
- }
982
-
983
-
984
- if (retJSON.length > 3) {
985
- var obj = eval("(" + retJSON + ")");
986
- return obj.rtn;
987
- } else {
988
- return -2;
989
-
990
- }
991
- } else {
992
- try {
993
- AjaxIO(json);
994
- } catch (e) {
995
- return -3;
996
- }
997
- var ret = GetHttpResult();
998
- if (ret) {
999
- return ret.rtn;
1000
- }
1001
-
1002
- return -2;
1003
- }
1004
- };
1005
-
1006
-
1007
- this.SOF_EnumDevice = function () {
1008
- var json = '{"function":"SOF_EnumDevice"}';
1009
- if (linuxWin == 2) {
1010
- var retJSON = "";
1011
- try {
1012
- retJSON = AjaxIO(json);
1013
- } catch (e) {
1014
- return -3;
1015
- }
1016
-
1017
-
1018
- if (retJSON.length > 3) {
1019
- var obj = eval("(" + retJSON + ")");
1020
- return obj.array;
1021
- } else {
1022
- return -2;
1023
-
1024
- }
1025
- } else {
1026
- try {
1027
- AjaxIO(json);
1028
- } catch (e) {
1029
- return -3;
1030
- }
1031
- var ret = GetHttpResult();
1032
- if (ret) {
1033
- return ret.array;
1034
- }
1035
-
1036
- return -2;
1037
- }
1038
- };
1039
-
1040
-
1041
- this.SOF_GetVersion = function () {
1042
- var json = '{"function":"SOF_GetVersion"}';
1043
- if (linuxWin == 2) {
1044
- var retJSON = "";
1045
- try {
1046
- retJSON = AjaxIO(json);
1047
- } catch (e) {
1048
- return -3;
1049
- }
1050
-
1051
-
1052
- if (retJSON.length > 3) {
1053
- var obj = eval("(" + retJSON + ")");
1054
- return obj.version;
1055
- } else {
1056
- return -2;
1057
-
1058
- }
1059
- } else {
1060
- try {
1061
- AjaxIO(json);
1062
- } catch (e) {
1063
- return -3;
1064
- }
1065
- var ret = GetHttpResult();
1066
- if (ret) {
1067
- return ret.version;
1068
- }
1069
-
1070
- return -2;
1071
- }
1072
- };
1073
-
1074
- var _curDevName;
1075
- this.SOF_GetDeviceInstance = function (DeviceName, ApplicationName) {
1076
- var json = '{"function":"SOF_GetDeviceInstance", "deviceName":"' + DeviceName + '", "applicationName":"' + ApplicationName + '"}';
1077
- if (linuxWin == 2) {
1078
- var retJSON = "";
1079
- try {
1080
- _curDevName = DeviceName;
1081
- retJSON = AjaxIO(json);
1082
- } catch (e) {
1083
- return -3;
1084
- }
1085
-
1086
-
1087
- if (retJSON.length > 3) {
1088
- var obj = eval("(" + retJSON + ")");
1089
- return obj.rtn;
1090
- } else {
1091
- return -2;
1092
-
1093
- }
1094
- } else {
1095
- try {
1096
- AjaxIO(json);
1097
- } catch (e) {
1098
- return -3;
1099
- }
1100
- var ret = GetHttpResult();
1101
- if (ret) {
1102
- if (ret.rtn == 0) {
1103
- _curDevName = DeviceName;
1104
- }
1105
- return ret.rtn;
1106
- }
1107
-
1108
- return -2;
1109
- }
1110
- };
1111
-
1112
- this.SOF_ReleaseDeviceInstance = function () {
1113
- var json = '{"function":"SOF_ReleaseDeviceInstance", "deviceName":"' + _curDevName + '"}';
1114
- if (linuxWin == 2) {
1115
- var retJSON = "";
1116
- try {
1117
- retJSON = AjaxIO(json);
1118
- }
1119
- catch (e) {
1120
- return -3;
1121
- }
1122
-
1123
- if (retJSON.length > 3) {
1124
- var obj = eval("(" + retJSON + ")");
1125
- return obj.array;
1126
- } else {
1127
- return -2;
1128
-
1129
- }
1130
- } else {
1131
- try {
1132
- AjaxIO(json);
1133
- } catch (e) {
1134
- return -3;
1135
- }
1136
- var ret = GetHttpResult();
1137
- if (ret) {
1138
- return ret.rtn;
1139
- }
1140
-
1141
- return -2;
1142
- }
1143
- };
1144
-
1145
- this.SOF_GetUserList = function () {
1146
- var json = '{"function":"SOF_GetUserList", "deviceName":"' + _curDevName + '"}';
1147
- if (linuxWin == 2) {
1148
- var retJSON = "";
1149
- try {
1150
- retJSON = AjaxIO(json);
1151
- } catch (e) {
1152
- return -3;
1153
- }
1154
-
1155
-
1156
- if (retJSON.length > 3) {
1157
- var obj = eval("(" + retJSON + ")");
1158
- return obj.array;
1159
- } else {
1160
- return -2;
1161
-
1162
- }
1163
- } else {
1164
- try {
1165
- AjaxIO(json);
1166
- } catch (e) {
1167
- return -3;
1168
- }
1169
- var ret = GetHttpResult();
1170
- if (ret) {
1171
- return ret.array;
1172
- }
1173
-
1174
- return -2;
1175
- }
1176
- };
1177
-
1178
-
1179
- this.SOF_ExportUserCert = function (ContainerName, KeySpec) {
1180
-
1181
- var json = '{"function":"SOF_ExportUserCert", "deviceName":"' + _curDevName + '", "containerName":"' + ContainerName + '", "keySpec":' + KeySpec + '}';
1182
- if (linuxWin == 2) {
1183
- var retJSON = "";
1184
- try {
1185
- retJSON = AjaxIO(json);
1186
- } catch (e) {
1187
- return -3;
1188
- }
1189
-
1190
-
1191
- if (retJSON.length > 3) {
1192
- var obj = eval("(" + retJSON + ")");
1193
- return obj.cert;
1194
- } else {
1195
- return -2;
1196
-
1197
- }
1198
- } else {
1199
- try {
1200
- AjaxIO(json);
1201
- } catch (e) {
1202
- return -3;
1203
- }
1204
- var ret = GetHttpResult();
1205
- if (ret) {
1206
- return ret.cert;
1207
- }
1208
-
1209
- return -2;
1210
- }
1211
- };
1212
-
1213
-
1214
- this.SOF_GetDeviceInfo = function (Type) {
1215
- var json = '{"function":"SOF_GetDeviceInfo", "deviceName":"' + _curDevName + '", "type":' + Type + '}';
1216
- if (linuxWin == 2) {
1217
- var retJSON = "";
1218
- try {
1219
- retJSON = AjaxIO(json);
1220
- } catch (e) {
1221
- return -3;
1222
- }
1223
-
1224
-
1225
- if (retJSON.length > 3) {
1226
- var obj = eval("(" + retJSON + ")");
1227
- return obj.info;
1228
- } else {
1229
- return -2;
1230
-
1231
- }
1232
- } else {
1233
- try {
1234
- AjaxIO(json);
1235
- } catch (e) {
1236
- return -3;
1237
- }
1238
- var ret = GetHttpResult();
1239
- if (ret) {
1240
- return ret.info;
1241
- }
1242
-
1243
- return -2;
1244
- }
1245
-
1246
- };
1247
-
1248
-
1249
- this.SOF_GetCertInfo = function (Base64EncodeCert, Type) {
1250
- var json = '{"function":"SOF_GetCertInfo", "base64EncodeCert":"' + Base64EncodeCert + '", "type":' + Type + '}';
1251
- if (linuxWin == 2) {
1252
- var retJSON = "";
1253
- try {
1254
- retJSON = AjaxIO(json);
1255
- } catch (e) {
1256
- return -3;
1257
- }
1258
-
1259
-
1260
- if (retJSON.length > 3) {
1261
- var obj = eval("(" + retJSON + ")");
1262
- return obj.info;
1263
- } else {
1264
- return -2;
1265
-
1266
- }
1267
- } else {
1268
- try {
1269
- AjaxIO(json);
1270
- } catch (e) {
1271
- return -3;
1272
- }
1273
- var ret = GetHttpResult();
1274
- if (ret) {
1275
- return ret.info;
1276
- }
1277
-
1278
- return -2;
1279
- }
1280
-
1281
- };
1282
-
1283
-
1284
- this.SOF_GetCertInfoByOid = function (Base64EncodeCert, OID) {
1285
- var json = '{"function":"SOF_GetCertInfoByOid", "base64EncodeCert":"' + Base64EncodeCert + '", "oid":"' + OID + '"}';
1286
- if (linuxWin == 2) {
1287
- var retJSON = "";
1288
- try {
1289
- retJSON = AjaxIO(json);
1290
- } catch (e) {
1291
- return -3;
1292
- }
1293
-
1294
-
1295
- if (retJSON.length > 3) {
1296
- var obj = eval("(" + retJSON + ")");
1297
- return obj.info;
1298
- } else {
1299
- return -2;
1300
-
1301
- }
1302
- } else {
1303
- try {
1304
- AjaxIO(json);
1305
- }
1306
- catch (e) {
1307
- return -3;
1308
- }
1309
-
1310
- var ret = GetHttpResult();
1311
- if (ret) {
1312
- return ret.info;
1313
- }
1314
-
1315
- return null;
1316
- }
1317
-
1318
- };
1319
-
1320
-
1321
-
1322
- this.SOF_Login = function (PassWd) {
1323
-
1324
- var json = '{"function":"SOF_Login", "deviceName":"' + _curDevName + '", "passWd":"' + PassWd + '"}';
1325
- if (linuxWin == 2) {
1326
- var retJSON = "";
1327
- try {
1328
- retJSON = AjaxIO(json);
1329
- } catch (e) {
1330
- return -3;
1331
- }
1332
-
1333
-
1334
- if (retJSON.length > 3) {
1335
- var obj = eval("(" + retJSON + ")");
1336
- return obj.rtn;
1337
- } else {
1338
- return -2;
1339
-
1340
- }
1341
- } else {
1342
- try {
1343
- AjaxIO(json);
1344
- } catch (e) {
1345
- return -3;
1346
- }
1347
- var ret = GetHttpResult();
1348
- if (ret) {
1349
- return ret.rtn;
1350
- }
1351
-
1352
- return -2;
1353
- }
1354
- };
1355
-
1356
-
1357
- this.SOF_LogOut = function () {
1358
-
1359
- var json = '{"function":"SOF_LogOut", "deviceName":"' + _curDevName + '"}';
1360
- if (linuxWin == 2) {
1361
- var retJSON = "";
1362
- try {
1363
- retJSON = AjaxIO(json);
1364
- } catch (e) {
1365
- return -3;
1366
- }
1367
-
1368
-
1369
- if (retJSON.length > 3) {
1370
- var obj = eval("(" + retJSON + ")");
1371
- return obj.rtn;
1372
- } else {
1373
- return -2;
1374
-
1375
- }
1376
- } else {
1377
- try {
1378
- AjaxIO(json);
1379
- } catch (e) {
1380
- return -3;
1381
- }
1382
- var ret = GetHttpResult();
1383
- if (ret) {
1384
- return ret.rtn;
1385
- }
1386
-
1387
- return -2;
1388
- }
1389
- };
1390
-
1391
-
1392
- this.SOF_GetPinRetryCount = function () {
1393
-
1394
- var json = '{"function":"SOF_GetPinRetryCount", "deviceName":"' + _curDevName + '"}';
1395
- if (linuxWin == 2) {
1396
- var retJSON = "";
1397
- try {
1398
- retJSON = AjaxIO(json);
1399
- } catch (e) {
1400
- return -3;
1401
- }
1402
-
1403
-
1404
- if (retJSON.length > 3) {
1405
- var obj = eval("(" + retJSON + ")");
1406
- return obj.retryCount;
1407
- } else {
1408
- return -2;
1409
-
1410
- }
1411
- } else {
1412
- try {
1413
- AjaxIO(json);
1414
- } catch (e) {
1415
- return -3;
1416
- }
1417
- var ret = GetHttpResult();
1418
- if (ret) {
1419
- return ret.retryCount;
1420
- }
1421
-
1422
- return -2;
1423
- }
1424
- };
1425
-
1426
-
1427
- this.SOF_ChangePassWd = function (OldPassWd, NewPassWd) {
1428
-
1429
- var json = '{"function":"SOF_ChangePassWd", "deviceName":"' + _curDevName + '", "oldUpin":"' + OldPassWd + '", "newUpin":"' + NewPassWd + '"}';
1430
- if (linuxWin == 2) {
1431
- var retJSON = "";
1432
- try {
1433
- retJSON = AjaxIO(json);
1434
- } catch (e) {
1435
- return -3;
1436
- }
1437
-
1438
-
1439
- if (retJSON.length > 3) {
1440
- var obj = eval("(" + retJSON + ")");
1441
- return obj.rtn;
1442
- } else {
1443
- return -2;
1444
-
1445
- }
1446
- } else {
1447
- try {
1448
- AjaxIO(json);
1449
- } catch (e) {
1450
- return -3;
1451
- }
1452
- var ret = GetHttpResult();
1453
- if (ret) {
1454
- return ret.rtn;
1455
- }
1456
-
1457
- return -2;
1458
- }
1459
- };
1460
-
1461
-
1462
- this.SOF_SetDigestMethod = function (DigestMethod) {
1463
-
1464
- var json = '{"function":"SOF_SetDigestMethod","deviceName":"' + _curDevName + '", "digestMethod":' + DigestMethod + '}';
1465
- if (linuxWin == 2) {
1466
- var retJSON = "";
1467
- try {
1468
- retJSON = AjaxIO(json);
1469
- } catch (e) {
1470
- return -3;
1471
- }
1472
-
1473
-
1474
- if (retJSON.length > 3) {
1475
- var obj = eval("(" + retJSON + ")");
1476
- return obj.rtn;
1477
- } else {
1478
- return -2;
1479
-
1480
- }
1481
- } else {
1482
- try {
1483
- AjaxIO(json);
1484
- } catch (e) {
1485
- return -3;
1486
- }
1487
- var ret = GetHttpResult();
1488
- if (ret) {
1489
- return ret.rtn;
1490
- }
1491
-
1492
- return -2;
1493
- }
1494
- };
1495
-
1496
-
1497
- this.SOF_SetUserID = function (UserID) {
1498
-
1499
- var json = '{"function":"SOF_SetUserID","deviceName":"' + _curDevName + '", "userID":"' + UserID + '"}';
1500
- if (linuxWin == 2) {
1501
- var retJSON = "";
1502
- try {
1503
- retJSON = AjaxIO(json);
1504
- } catch (e) {
1505
- return -3;
1506
- }
1507
-
1508
-
1509
- if (retJSON.length > 3) {
1510
- var obj = eval("(" + retJSON + ")");
1511
- return obj.rtn;
1512
- } else {
1513
- return -2;
1514
-
1515
- }
1516
- } else {
1517
- try {
1518
- AjaxIO(json);
1519
- } catch (e) {
1520
- return -3;
1521
- }
1522
- var ret = GetHttpResult();
1523
- if (ret) {
1524
- return ret.rtn;
1525
- }
1526
-
1527
- return -2;
1528
- }
1529
- };
1530
-
1531
-
1532
- this.SOF_SetEncryptMethodAndIV = function (EncryptMethod, EncryptIV) {
1533
-
1534
- var json = '{"function":"SOF_SetEncryptMethodAndIV","deviceName":"' + _curDevName + '", "encryptMethod":' + EncryptMethod + ', "encryptIV":"' + EncryptIV + '"}';
1535
- if (linuxWin == 2) {
1536
- var retJSON = "";
1537
- try {
1538
- retJSON = AjaxIO(json);
1539
- } catch (e) {
1540
- return -3;
1541
- }
1542
-
1543
-
1544
- if (retJSON.length > 3) {
1545
- var obj = eval("(" + retJSON + ")");
1546
- return obj.rtn;
1547
- } else {
1548
- return -2;
1549
-
1550
- }
1551
- } else {
1552
- try {
1553
- AjaxIO(json);
1554
- } catch (e) {
1555
- return -3;
1556
- }
1557
- var ret = GetHttpResult();
1558
- if (ret) {
1559
- return ret.rtn;
1560
- }
1561
-
1562
- return -2;
1563
- }
1564
- };
1565
-
1566
-
1567
- this.SOF_EncryptFileToPKCS7 = function (Cert, InFile, OutFile, type) {
1568
-
1569
- var json = '{"function":"SOF_EncryptFileToPKCS7", "deviceName":"' + _curDevName + '", "cert":"' + Cert + '", "inFile":"' + InFile.replace(/\\/g, '\\\\') + '", "outFile":"' + OutFile.replace(/\\/g, '\\\\') + '", "type":' + type + '}';
1570
- if (linuxWin == 2) {
1571
- var retJSON = "";
1572
- try {
1573
- retJSON = AjaxIO(json);
1574
- } catch (e) {
1575
- return -3;
1576
- }
1577
-
1578
-
1579
- if (retJSON.length > 3) {
1580
- var obj = eval("(" + retJSON + ")");
1581
- return obj.envelopData;
1582
- } else {
1583
- return -2;
1584
-
1585
- }
1586
- } else {
1587
- try {
1588
- AjaxIO(json);
1589
- } catch (e) {
1590
- return -3;
1591
- }
1592
- var ret = GetHttpResult();
1593
- if (ret) {
1594
- return ret.envelopData;
1595
- }
1596
-
1597
- return -2;
1598
- }
1599
- };
1600
-
1601
-
1602
- this.SOF_SignFileToPKCS7 = function (ContainerName, KeySpec, InFile) {
1603
-
1604
- var json = '{"function":"SOF_SignFileToPKCS7", "deviceName":"' + _curDevName + '", "containerName":"' + ContainerName + '", "KeySpec":' + KeySpec + ', "inFile":"' + InFile.replace(/\\/g, '\\\\') + '"}';
1605
- if (linuxWin == 2) {
1606
- var retJSON = "";
1607
- try {
1608
- retJSON = AjaxIO(json);
1609
- } catch (e) {
1610
- return -3;
1611
- }
1612
-
1613
-
1614
- if (retJSON.length > 3) {
1615
- var obj = eval("(" + retJSON + ")");
1616
- return obj.signed;
1617
- } else {
1618
- return -2;
1619
-
1620
- }
1621
- } else {
1622
- try {
1623
- AjaxIO(json);
1624
- } catch (e) {
1625
- return -3;
1626
- }
1627
- var ret = GetHttpResult();
1628
- if (ret) {
1629
- return ret.signed;
1630
- }
1631
-
1632
- return -2;
1633
- }
1634
- };
1635
-
1636
-
1637
- this.SOF_VerifyFileToPKCS7 = function (strPkcs7Data, InFilePath) {
1638
- var json = '{"function":"SOF_VerifyFileToPKCS7", "deviceName":"' + _curDevName + '","strPkcs7Data":"' + strPkcs7Data + '", "inFile":"' + InFilePath.replace(/\\/g, '\\\\') + '"}';
1639
- if (linuxWin == 2) {
1640
- var retJSON = "";
1641
- try {
1642
- retJSON = AjaxIO(json);
1643
- } catch (e) {
1644
- return -3;
1645
- }
1646
-
1647
-
1648
- if (retJSON.length > 3) {
1649
- var obj = eval("(" + retJSON + ")");
1650
- return obj.rtn;
1651
- } else {
1652
- return -2;
1653
-
1654
- }
1655
- } else {
1656
- try {
1657
- AjaxIO(json);
1658
- } catch (e) {
1659
- return -3;
1660
- }
1661
- var ret = GetHttpResult();
1662
- if (ret) {
1663
- return ret.rtn;
1664
- }
1665
-
1666
- return -2;
1667
- }
1668
- };
1669
-
1670
-
1671
- this.SOF_DecryptFileToPKCS7 = function (ContainerName, keySpec, Pkcs7Data, InFile, OutFile, type) {
1672
-
1673
- var json = '{"function":"SOF_DecryptFileToPKCS7", "deviceName":"' + _curDevName + '", "containerName":"' + ContainerName + '", "keySpec":' + keySpec + ', "pkcs7Data":"' + Pkcs7Data + '", "inFile":"' + InFile.replace(/\\/g, '\\\\') + '", "outFile":"' + OutFile.replace(/\\/g, '\\\\') + '", "type":' + type + '}';
1674
- if (linuxWin == 2) {
1675
- var retJSON = "";
1676
- try {
1677
- retJSON = AjaxIO(json);
1678
- } catch (e) {
1679
- return -3;
1680
- }
1681
-
1682
-
1683
- if (retJSON.length > 3) {
1684
- var obj = eval("(" + retJSON + ")");
1685
- return obj.rtn;
1686
- } else {
1687
- return -2;
1688
-
1689
- }
1690
- } else {
1691
- try {
1692
- AjaxIO(json);
1693
- } catch (e) {
1694
- return -3;
1695
- }
1696
- var ret = GetHttpResult();
1697
- if (ret) {
1698
- return ret.rtn;
1699
- }
1700
-
1701
- return -2;
1702
- }
1703
- };
1704
-
1705
-
1706
- this.SOF_DigestData = function (ContainerName, InData, InDataLen) {
1707
-
1708
- var json = '{"function":"SOF_DigestData","deviceName":"' + _curDevName + '", "containerName":"' + ContainerName + '", "inData":"' + InData + '", "inDataLen":' + InDataLen + '}';
1709
- if (linuxWin == 2) {
1710
- var retJSON = "";
1711
- try {
1712
- retJSON = AjaxIO(json);
1713
- } catch (e) {
1714
- return -3;
1715
- }
1716
-
1717
-
1718
- if (retJSON.length > 3) {
1719
- var obj = eval("(" + retJSON + ")");
1720
- return obj.digest;
1721
- } else {
1722
- return -2;
1723
-
1724
- }
1725
- } else {
1726
- try {
1727
- AjaxIO(json);
1728
- } catch (e) {
1729
- return -3;
1730
- }
1731
- var ret = GetHttpResult();
1732
- if (ret) {
1733
- return ret.digest;
1734
- }
1735
-
1736
- return -2;
1737
- }
1738
- };
1739
-
1740
- //交互式签名
1741
- this.SOF_SignDataInteractive = function (ContainerName, ulKeySpec, inData, InDataLen) {
1742
- var InDataBase64 = inData; //对报文进行Base64编码
1743
- var json = '{"function":"SOF_SignDataInteractive", "deviceName":"' + _curDevName + '", "containerName":"' + ContainerName + '", "keySpec":' + ulKeySpec + ', "inData":"' + InDataBase64 + '", "inDataLen":' + InDataLen + '}';
1744
-
1745
- if (linuxWin == 2) {
1746
- var retJSON = "";
1747
- try {
1748
- retJSON = AjaxIO(json);
1749
- } catch (e) {
1750
- return -3;
1751
- }
1752
-
1753
-
1754
- if (retJSON.length > 3) {
1755
- var obj = eval("(" + retJSON + ")");
1756
- return obj.signed;
1757
- } else {
1758
- return -2;
1759
-
1760
- }
1761
- } else {
1762
- try {
1763
- AjaxIO(json);
1764
- }
1765
- catch (e) {
1766
- return -3;
1767
- }
1768
-
1769
-
1770
- var ret = GetHttpResult();
1771
- if (ret) {
1772
- return ret.signed;
1773
- }
1774
-
1775
- return null;
1776
- }
1777
- };
1778
-
1779
- this.SOF_SignData = function (ContainerName, ulKeySpec, InData, InDataLen) {
1780
-
1781
- var json = '{"function":"SOF_SignDataEx", "deviceName":"' + _curDevName + '", "containerName":"' + ContainerName + '", "keySpec":' + ulKeySpec + ', "inData":"' + InData + '", "inDataLen":' + InDataLen + '}';
1782
- if (linuxWin == 2) {
1783
- var retJSON = "";
1784
- try {
1785
- retJSON = AjaxIO(json);
1786
- } catch (e) {
1787
- return -3;
1788
- }
1789
-
1790
-
1791
- if (retJSON.length > 3) {
1792
- var obj = eval("(" + retJSON + ")");
1793
- return obj.signed;
1794
- } else {
1795
- return -2;
1796
-
1797
- }
1798
- } else {
1799
- try {
1800
- AjaxIO(json);
1801
- } catch (e) {
1802
- return -3;
1803
- }
1804
- var ret = GetHttpResult();
1805
- if (ret) {
1806
- return ret.signed;
1807
- }
1808
-
1809
- return -2;
1810
- }
1811
- };
1812
-
1813
-
1814
- this.SOF_VerifySignedData = function (Base64EncodeCert, digestMethod, InData, SignedValue) {
1815
- var json = '{"function":"SOF_VerifySignedDataEx","deviceName":"' + _curDevName + '", "base64EncodeCert":"' + Base64EncodeCert + '", "digestMethod":' + digestMethod + ', "inData":"' + InData + '", "signedValue":"' + SignedValue + '"}';
1816
- if (linuxWin == 2) {
1817
- var retJSON = "";
1818
- try {
1819
- retJSON = AjaxIO(json);
1820
- } catch (e) {
1821
- return -3;
1822
- }
1823
-
1824
-
1825
- if (retJSON.length > 3) {
1826
- var obj = eval("(" + retJSON + ")");
1827
- return obj.rtn;
1828
- } else {
1829
- return -2;
1830
-
1831
- }
1832
- } else {
1833
- try {
1834
- AjaxIO(json);
1835
- } catch (e) {
1836
- return -3;
1837
- }
1838
- var ret = GetHttpResult();
1839
- if (ret) {
1840
- return ret.rtn;
1841
- }
1842
-
1843
- return -2;
1844
- }
1845
- };
1846
-
1847
-
1848
- this.SOF_EncryptDataPKCS7 = function (Base64EncodeCert, InData, InDataLen) {
1849
-
1850
- var json = '{"function":"SOF_EncryptDataPKCS7", "deviceName":"' + _curDevName + '", "base64EncodeCert":"' + Base64EncodeCert + '", "inData":"' + InData + '", "inDataLen":' + InDataLen + '}';
1851
- if (linuxWin == 2) {
1852
- var retJSON = "";
1853
- try {
1854
- retJSON = AjaxIO(json);
1855
- } catch (e) {
1856
- return -3;
1857
- }
1858
-
1859
-
1860
- if (retJSON.length > 3) {
1861
- var obj = eval("(" + retJSON + ")");
1862
- return obj.encrypedData;
1863
- } else {
1864
- return -2;
1865
-
1866
- }
1867
- } else {
1868
- try {
1869
- AjaxIO(json);
1870
- } catch (e) {
1871
- return -3;
1872
- }
1873
- var ret = GetHttpResult();
1874
- if (ret) {
1875
- return ret.encrypedData;
1876
- }
1877
-
1878
- return -2;
1879
- }
1880
-
1881
- };
1882
-
1883
-
1884
- this.SOF_DecryptDataPKCS7 = function (ContainerName, ulKeySpec, InData) {
1885
-
1886
- var json = '{"function":"SOF_DecryptDataPKCS7", "deviceName":"' + _curDevName + '", "containerName":"' + ContainerName + '", "keySpec":' + ulKeySpec + ', "inData":"' + InData + '"}';
1887
- if (linuxWin == 2) {
1888
- var retJSON = "";
1889
- try {
1890
- retJSON = AjaxIO(json);
1891
- } catch (e) {
1892
- return -3;
1893
- }
1894
-
1895
-
1896
- if (retJSON.length > 3) {
1897
- var obj = eval("(" + retJSON + ")");
1898
- return obj.decryptedData;
1899
- } else {
1900
- return -2;
1901
-
1902
- }
1903
- } else {
1904
- try {
1905
- AjaxIO(json);
1906
- } catch (e) {
1907
- return -3;
1908
- }
1909
- var ret = GetHttpResult();
1910
- if (ret) {
1911
- return ret.decryptedData;
1912
- }
1913
-
1914
- return -2;
1915
- }
1916
- };
1917
-
1918
-
1919
- this.SOF_GenRemoteUnblockRequest = function () {
1920
-
1921
- var json = '{"function":"SOF_GenRemoteUnblockRequest", "deviceName":"' + _curDevName + '"}';
1922
- if (linuxWin == 2) {
1923
- var retJSON = "";
1924
- try {
1925
- retJSON = AjaxIO(json);
1926
- } catch (e) {
1927
- return -3;
1928
- }
1929
-
1930
-
1931
- if (retJSON.length > 3) {
1932
- var obj = eval("(" + retJSON + ")");
1933
- return obj.request;
1934
- } else {
1935
- return -2;
1936
-
1937
- }
1938
- } else {
1939
- try {
1940
- AjaxIO(json);
1941
- } catch (e) {
1942
- return -3;
1943
- }
1944
- var ret = GetHttpResult();
1945
- if (ret) {
1946
- return ret.request;
1947
- }
1948
-
1949
- return -2;
1950
- }
1951
- };
1952
-
1953
-
1954
- this.SOF_GenResetpwdResponse = function (request, soPin, userPin) {
1955
-
1956
- var json = '{"function":"SOF_GenResetpwdResponse", "deviceName":"' + _curDevName + '", "request":"' + request + '", "soPin":"' + soPin + '", "userPin":"' + userPin + '"}';
1957
- if (linuxWin == 2) {
1958
- var retJSON = "";
1959
- try {
1960
- retJSON = AjaxIO(json);
1961
- } catch (e) {
1962
- return -3;
1963
- }
1964
-
1965
-
1966
- if (retJSON.length > 3) {
1967
- var obj = eval("(" + retJSON + ")");
1968
- return obj.request;
1969
- } else {
1970
- return -2;
1971
-
1972
- }
1973
- } else {
1974
- try {
1975
- AjaxIO(json);
1976
- } catch (e) {
1977
- return -3;
1978
- }
1979
- var ret = GetHttpResult();
1980
- if (ret) {
1981
- return ret.request;
1982
- }
1983
-
1984
- return -2;
1985
- }
1986
- };
1987
-
1988
-
1989
- this.SOF_RemoteUnblockPIN = function (request) {
1990
-
1991
- var json = '{"function":"SOF_RemoteUnblockPIN", "deviceName":"' + _curDevName + '", "request":"' + request + '"}';
1992
- if (linuxWin == 2) {
1993
- var retJSON = "";
1994
- try {
1995
- retJSON = AjaxIO(json);
1996
- } catch (e) {
1997
- return -3;
1998
- }
1999
-
2000
-
2001
- if (retJSON.length > 3) {
2002
- var obj = eval("(" + retJSON + ")");
2003
- return obj.rtn;
2004
- } else {
2005
- return -2;
2006
-
2007
- }
2008
- } else {
2009
- try {
2010
- AjaxIO(json);
2011
- } catch (e) {
2012
- return -3;
2013
- }
2014
- var ret = GetHttpResult();
2015
- if (ret) {
2016
- return ret.rtn;
2017
- }
2018
-
2019
- return -2;
2020
- }
2021
- };
2022
-
2023
-
2024
- this.SOF_SignDataToPKCS7 = function (ContainerName, ulKeySpec, InData, ulDetached) {
2025
-
2026
- var json = '{"function":"SOF_SignDataToPKCS7", "deviceName":"' + _curDevName + '", "containerName":"' + ContainerName + '", "keySpec":' + ulKeySpec + ', "inData":"' + InData + '", "detached":' + ulDetached + '}';
2027
- if (linuxWin == 2) {
2028
- var retJSON = "";
2029
- try {
2030
- retJSON = AjaxIO(json);
2031
- } catch (e) {
2032
- return -3;
2033
- }
2034
-
2035
-
2036
- if (retJSON.length > 3) {
2037
- var obj = eval("(" + retJSON + ")");
2038
- return obj.pkcs7;
2039
- } else {
2040
- return -2;
2041
-
2042
- }
2043
- } else {
2044
- try {
2045
- AjaxIO(json);
2046
- } catch (e) {
2047
- return -3;
2048
- }
2049
- var ret = GetHttpResult();
2050
- if (ret) {
2051
- return ret.pkcs7;
2052
- }
2053
-
2054
- return -2;
2055
- }
2056
- };
2057
-
2058
-
2059
- this.SOF_VerifyDataToPKCS7 = function (strPkcs7Data, OriginalText, ulDetached) {
2060
-
2061
- var json = '{"function":"SOF_VerifyDataToPKCS7", "deviceName":"' + _curDevName + '", "pkcs7":"' + strPkcs7Data + '", "original":"' + OriginalText + '", "detached":' + ulDetached + '}';
2062
- if (linuxWin == 2) {
2063
- var retJSON = "";
2064
- try {
2065
- retJSON = AjaxIO(json);
2066
- } catch (e) {
2067
- return -3;
2068
- }
2069
-
2070
-
2071
- if (retJSON.length > 3) {
2072
- var obj = eval("(" + retJSON + ")");
2073
- return obj.rtn;
2074
- } else {
2075
- return -2;
2076
-
2077
- }
2078
- } else {
2079
- try {
2080
- AjaxIO(json);
2081
- } catch (e) {
2082
- return -3;
2083
- }
2084
- var ret = GetHttpResult();
2085
- if (ret) {
2086
- return ret.rtn;
2087
- }
2088
-
2089
- return -2;
2090
- }
2091
- };
2092
-
2093
- //按expType导出的公钥,格式为国密规范指定的格式或DER格式或裸数据格式
2094
- this.SOF_ExportPubKey = function (containerName, keySpec, expType) //expType=1: 国密格式; 2:DER; 3:RAW (SM2 public key ONLY: X|Y, X,Y各为32字节)
2095
- {
2096
- var json = '{"function":"SOF_ExportPubKeyEx","deviceName":"' + _curDevName + '", "containerName":"' + containerName + '", "keySpec":' + keySpec + ', "expType":' + expType + '}';
2097
- if (linuxWin == 2) {
2098
- var retJSON = "";
2099
- try {
2100
- retJSON = AjaxIO(json);
2101
- } catch (e) {
2102
- return -3;
2103
- }
2104
-
2105
-
2106
- if (retJSON.length > 3) {
2107
- var obj = eval("(" + retJSON + ")");
2108
- return obj.pubKey;
2109
- } else {
2110
- return -2;
2111
-
2112
- }
2113
- } else {
2114
- try {
2115
- AjaxIO(json);
2116
- } catch (e) {
2117
- return -3;
2118
- }
2119
- var ret = GetHttpResult();
2120
- if (ret) {
2121
- return ret.pubKey;
2122
- }
2123
-
2124
- return -2;
2125
- }
2126
- }
2127
-
2128
- //公钥加密
2129
- this.SOF_EncryptByPubKey = function (strPubKey, strInput, cerType) {
2130
- var json = '{"function":"SOF_EncryptByPubKey", "deviceName":"' + _curDevName + '", "pubKey":"' + strPubKey + '", "asymPlain":"' + strInput + '", "keySpec":' + cerType + '}';
2131
- if (linuxWin == 2) {
2132
- var retJSON = "";
2133
- try {
2134
- retJSON = AjaxIO(json);
2135
- } catch (e) {
2136
- return -3;
2137
- }
2138
-
2139
-
2140
- if (retJSON.length > 3) {
2141
- var obj = eval("(" + retJSON + ")");
2142
- return obj.asymCipher;
2143
- } else {
2144
- return -2;
2145
-
2146
- }
2147
- } else {
2148
- try {
2149
- AjaxIO(json);
2150
- }
2151
- catch (e) {
2152
- return -3;
2153
- }
2154
-
2155
- var ret = GetHttpResult();
2156
- if (ret) {
2157
- return ret.asymCipher;
2158
- }
2159
-
2160
- return null;
2161
- }
2162
- }
2163
-
2164
- //私钥解密
2165
- this.SOF_DecryptByPrvKey = function (containerName, cerType, strAsymCipher) {
2166
- var json = '{"function":"SOF_DecryptByPrvKey", "deviceName":"' + _curDevName + '", "containerName":"' + containerName + '", "asymCipher":"' + strAsymCipher + '", "keySpec":' + cerType + '}';
2167
- if (linuxWin == 2) {
2168
- var retJSON = "";
2169
- try {
2170
- retJSON = AjaxIO(json);
2171
- } catch (e) {
2172
- return -3;
2173
- }
2174
-
2175
-
2176
- if (retJSON.length > 3) {
2177
- var obj = eval("(" + retJSON + ")");
2178
- return obj.asymPlain;
2179
- } else {
2180
- return -2;
2181
-
2182
- }
2183
- } else {
2184
- try {
2185
- AjaxIO(json);
2186
- }
2187
- catch (e) {
2188
- return -3;
2189
- }
2190
-
2191
- var ret = GetHttpResult();
2192
- if (ret) {
2193
- return ret.asymPlain;
2194
- }
2195
-
2196
- return null;
2197
- }
2198
- }
2199
-
2200
- //RA客户端控件
2201
- this.SOF_CreateKeyPair = function (container, keySpec, asymAlg, keyLength) {
2202
- var json = '{"function":"SOF_CreateKeyPair","deviceName":"' + _curDevName + '", "containerName":"' + container + '", "asymAlg":' + asymAlg + ', "keySpec":' + keySpec + ',"keyLength":' + keyLength + '}';
2203
- if (linuxWin == 2) {
2204
- var retJSON = "";
2205
- try {
2206
- retJSON = AjaxIO(json);
2207
- } catch (e) {
2208
- return -3;
2209
- }
2210
-
2211
-
2212
- if (retJSON.length > 3) {
2213
- var obj = eval("(" + retJSON + ")");
2214
- return obj.rtn;
2215
- } else {
2216
- return -2;
2217
-
2218
- }
2219
- } else {
2220
- try {
2221
- AjaxIO(json);
2222
- }
2223
- catch (e) {
2224
- return -3;
2225
- }
2226
-
2227
- var ret = GetHttpResult();
2228
- if (ret) {
2229
- return ret.rtn;
2230
- }
2231
-
2232
- return -2;
2233
- }
2234
- }
2235
-
2236
- this.SOF_EnumCertContiner = function () {
2237
- var json = '{"function":"SOF_EnumCertContiner", "deviceName":"' + _curDevName + '"}';
2238
- if (linuxWin == 2) {
2239
- var retJSON = "";
2240
- try {
2241
- retJSON = AjaxIO(json);
2242
- } catch (e) {
2243
- return -3;
2244
- }
2245
-
2246
-
2247
- if (retJSON.length > 3) {
2248
- var obj = eval("(" + retJSON + ")");
2249
- return obj.containerName;
2250
- } else {
2251
- return -2;
2252
-
2253
- }
2254
- } else {
2255
- try {
2256
- AjaxIO(json);
2257
- }
2258
- catch (e) {
2259
- return -3;
2260
- }
2261
-
2262
- var ret = GetHttpResult();
2263
- if (ret) {
2264
- return ret.containerName;
2265
- }
2266
-
2267
- return "";
2268
- }
2269
- }
2270
-
2271
- this.SOF_FindContainer = function (certSN) {
2272
- var json = '{"function":"SOF_FindContainer","deviceName":"' + _curDevName + '", "certSN":"' + certSN + '"}';
2273
- if (linuxWin == 2) {
2274
- var retJSON = "";
2275
- try {
2276
- retJSON = AjaxIO(json);
2277
- } catch (e) {
2278
- return -3;
2279
- }
2280
-
2281
-
2282
- if (retJSON.length > 3) {
2283
- var obj = eval("(" + retJSON + ")");
2284
- return obj.containerName;
2285
- } else {
2286
- return -2;
2287
-
2288
- }
2289
- } else {
2290
- try {
2291
- AjaxIO(json);
2292
- }
2293
- catch (e) {
2294
- return -3;
2295
- }
2296
-
2297
- var ret = GetHttpResult();
2298
- if (ret) {
2299
- return ret.containerName;
2300
- }
2301
-
2302
- return "";
2303
- }
2304
- }
2305
-
2306
- this.SOF_DeleteCert = function (certSN) {
2307
- var json = '{"function":"SOF_DeleteCert","deviceName":"' + _curDevName + '", "certSN":"' + certSN + '"}';
2308
- if (linuxWin == 2) {
2309
- var retJSON = "";
2310
- try {
2311
- retJSON = AjaxIO(json);
2312
- } catch (e) {
2313
- return -3;
2314
- }
2315
-
2316
-
2317
- if (retJSON.length > 3) {
2318
- var obj = eval("(" + retJSON + ")");
2319
- return obj.rtn;
2320
- } else {
2321
- return -2;
2322
-
2323
- }
2324
- } else {
2325
- try {
2326
- AjaxIO(json);
2327
- }
2328
- catch (e) {
2329
- return -3;
2330
- }
2331
-
2332
- var ret = GetHttpResult();
2333
- if (ret) {
2334
- return ret.rtn;
2335
- }
2336
-
2337
- return -2;
2338
- }
2339
- }
2340
-
2341
- this.SOF_DeleteContainer = function (certSN) {
2342
- var json = '{"function":"SOF_DeleteContainer", "deviceName":"' + _curDevName + '", "certSN":"' + certSN + '"}';
2343
- if (linuxWin == 2) {
2344
- var retJSON = "";
2345
- try {
2346
- retJSON = AjaxIO(json);
2347
- } catch (e) {
2348
- return -3;
2349
- }
2350
-
2351
-
2352
- if (retJSON.length > 3) {
2353
- var obj = eval("(" + retJSON + ")");
2354
- return obj.rtn;
2355
- } else {
2356
- return -2;
2357
-
2358
- }
2359
- } else {
2360
- try {
2361
- AjaxIO(json);
2362
- }
2363
- catch (e) {
2364
- return -3;
2365
- }
2366
-
2367
- var ret = GetHttpResult();
2368
- if (ret) {
2369
- return ret.rtn;
2370
- }
2371
-
2372
- return -2;
2373
- }
2374
- }
2375
-
2376
- this.SOF_SignByCert = function (certSN, plain) {
2377
- var json = '{"function":"SOF_SignByCert", "deviceName":"' + _curDevName + '", "certSN":"' + certSN + '", "inData":"' + plain + '"}';
2378
- if (linuxWin == 2) {
2379
- var retJSON = "";
2380
- try {
2381
- retJSON = AjaxIO(json);
2382
- } catch (e) {
2383
- return -3;
2384
- }
2385
-
2386
-
2387
- if (retJSON.length > 3) {
2388
- var obj = eval("(" + retJSON + ")");
2389
- return obj.signed;
2390
- } else {
2391
- return -2;
2392
-
2393
- }
2394
- } else {
2395
- try {
2396
- AjaxIO(json);
2397
- }
2398
- catch (e) {
2399
- return -3;
2400
- }
2401
-
2402
- var ret = GetHttpResult();
2403
- if (ret) {
2404
- return ret.signed;
2405
- }
2406
-
2407
- return null;
2408
- }
2409
- }
2410
-
2411
- this.SOF_VerifyByCert = function (certSN, plain, signature, digestMethod) {
2412
-
2413
- var json = '{"function":"SOF_VerifyByCert", "deviceName":"' + _curDevName + '", "certSN":"' + certSN + '","digestMethod":' + digestMethod + ', "inData":"' + plain + '", "signed":"' + signature + '"}';
2414
- if (linuxWin == 2) {
2415
- var retJSON = "";
2416
- try {
2417
- retJSON = AjaxIO(json);
2418
- } catch (e) {
2419
- return -3;
2420
- }
2421
-
2422
-
2423
- if (retJSON.length > 3) {
2424
- var obj = eval("(" + retJSON + ")");
2425
- return obj.rtn;
2426
- } else {
2427
- return -2;
2428
-
2429
- }
2430
- } else {
2431
- try {
2432
- AjaxIO(json);
2433
- }
2434
- catch (e) {
2435
- return -3;
2436
- }
2437
- var ret = GetHttpResult();
2438
- if (ret) {
2439
- return ret.rtn;
2440
- }
2441
-
2442
- return -2;
2443
- }
2444
- }
2445
-
2446
- this.SOF_VerifyByExtCert = function (cert, plain, signature, digestMethod) {
2447
- var json = '{"function":"SOF_VerifyByExtCert","deviceName":"' + _curDevName + '", "cert":"' + cert + '", "digestMethod":' + digestMethod + ', "inData":"' + plain + '", "signed":"' + signature + '"}';
2448
- if (linuxWin == 2) {
2449
- var retJSON = "";
2450
- try {
2451
- retJSON = AjaxIO(json);
2452
- } catch (e) {
2453
- return -3;
2454
- }
2455
-
2456
-
2457
- if (retJSON.length > 3) {
2458
- var obj = eval("(" + retJSON + ")");
2459
- return obj.rtn;
2460
- } else {
2461
- return -2;
2462
-
2463
- }
2464
- } else {
2465
- try {
2466
- AjaxIO(json);
2467
- }
2468
- catch (e) {
2469
- return -3;
2470
- }
2471
-
2472
- var ret = GetHttpResult();
2473
- if (ret) {
2474
- return ret.rtn;
2475
- }
2476
-
2477
- return -2;
2478
- }
2479
- }
2480
-
2481
- // this.SOF_GenerateP10Request = function (container, dn, asymAlg, keySpec, keyLength) {
2482
- // var json = '{"function":"SOF_GenerateP10Request", "deviceName":"' + _curDevName + '", "containerName":"' + container + '", "certDN":"' + dn + '", "asymAlg":' + asymAlg + ', "keySpec":' + keySpec + ',"keyLength":' + keyLength + '}';
2483
- // if (linuxWin == 2) {
2484
- // var retJSON = "";
2485
- // try {
2486
- // retJSON = AjaxIO(json);
2487
- // } catch (e) {
2488
- // return -3;
2489
- // }
2490
- //
2491
- //
2492
- // if (retJSON.length > 3) {
2493
- // var obj = eval("(" + retJSON + ")");
2494
- // return obj.outData;
2495
- // } else {
2496
- // return -2;
2497
- //
2498
- // }
2499
- // } else {
2500
- // try {
2501
- // AjaxIO(json);
2502
- // }
2503
- // catch (e) {
2504
- // return -3;
2505
- // }
2506
- //
2507
- // var ret = GetHttpResult();
2508
- // if (ret) {
2509
- // return ret.outData;
2510
- // }
2511
- //
2512
- // return null;
2513
- // }
2514
- // }
2515
- this.SOF_GenerateP10Request = function (_curDevName, container, dn, asymAlg, keySpec, keyLength) {
2516
- var json = '{"function":"SOF_GenerateP10Request", "deviceName":"' + _curDevName + '", "containerName":"' + container + '", "certDN":"' + dn + '", "asymAlg":' + asymAlg + ', "keySpec":' + keySpec + ',"keyLength":' + keyLength + '}';
2517
- if (linuxWin == 2) {
2518
- var retJSON = "";
2519
- try {
2520
- retJSON = AjaxIO(json);
2521
- } catch (e) {
2522
- return -3;
2523
- }
2524
-
2525
-
2526
- if (retJSON.length > 3) {
2527
- var obj = eval("(" + retJSON + ")");
2528
- return obj.outData;
2529
- } else {
2530
- return -2;
2531
-
2532
- }
2533
- } else {
2534
- try {
2535
- AjaxIO(json);
2536
- }
2537
- catch (e) {
2538
- return -3;
2539
- }
2540
-
2541
- var ret = GetHttpResult();
2542
- if (ret) {
2543
- return ret.outData;
2544
- }
2545
-
2546
- return null;
2547
- }
2548
- }
2549
- this.SOF_ImportCert = function (container, cert, keySpec) {
2550
- var json = '{"function":"SOF_ImportCert", "deviceName":"' + _curDevName + '", "containerName":"' + container + '", "cert":"' + cert + '", "keySpec":' + keySpec + '}';
2551
- if (linuxWin == 2) {
2552
- var retJSON = "";
2553
- try {
2554
- retJSON = AjaxIO(json);
2555
- } catch (e) {
2556
- return -3;
2557
- }
2558
-
2559
-
2560
- if (retJSON.length > 3) {
2561
- var obj = eval("(" + retJSON + ")");
2562
- return obj.rtn;
2563
- } else {
2564
- return -2;
2565
-
2566
- }
2567
- } else {
2568
- try {
2569
- AjaxIO(json);
2570
- }
2571
- catch (e) {
2572
- return -3;
2573
- }
2574
-
2575
- var ret = GetHttpResult();
2576
- if (ret) {
2577
- return ret.rtn;
2578
- }
2579
-
2580
- return -2;
2581
- }
2582
- }
2583
-
2584
- this.SOF_ImportCryptoCertAndKey = function (container, cert, nAsymAlg, EncryptedSessionKeyData, symAlg, EncryptedPrivateKeyData, mode) {
2585
- var json = '{"function":"SOF_ImportCryptoCertAndKey", "deviceName":"' + _curDevName + '", "containerName":"' + container + '", "cert":"' + cert + '", "asymAlg":' + nAsymAlg + ', "sessionKey":"' + EncryptedSessionKeyData + '", "symAlg":"' + symAlg + '", "encrypedData":"' + EncryptedPrivateKeyData + ', + "mode":' + mode + '}';
2586
- if (linuxWin == 2) {
2587
- var retJSON = "";
2588
- try {
2589
- retJSON = AjaxIO(json);
2590
- } catch (e) {
2591
- return -3;
2592
- }
2593
-
2594
-
2595
- if (retJSON.length > 3) {
2596
- var obj = eval("(" + retJSON + ")");
2597
- return obj.rtn;
2598
- } else {
2599
- return -2;
2600
-
2601
- }
2602
- } else {
2603
- try {
2604
- AjaxIO(json);
2605
- }
2606
- catch (e) {
2607
- return -3;
2608
- }
2609
-
2610
- var ret = GetHttpResult();
2611
- if (ret) {
2612
- return ret.rtn;
2613
- }
2614
-
2615
- return -2;
2616
- }
2617
- }
2618
-
2619
- this.SOF_GenerateRandom = function (length) {
2620
- var json = '{"function":"SOF_GenRandom", "deviceName":"' + _curDevName + '", "inDataLen":' + length + '}';
2621
- if (linuxWin == 2) {
2622
- var retJSON = "";
2623
- try {
2624
- retJSON = AjaxIO(json);
2625
- } catch (e) {
2626
- return -3;
2627
- }
2628
-
2629
-
2630
- if (retJSON.length > 3) {
2631
- var obj = eval("(" + retJSON + ")");
2632
- return obj.outData;
2633
- } else {
2634
- return -2;
2635
-
2636
- }
2637
- } else {
2638
- try {
2639
- AjaxIO(json);
2640
- }
2641
- catch (e) {
2642
- return -3;
2643
- }
2644
-
2645
- var ret = GetHttpResult();
2646
- if (ret) {
2647
- return ret.outData;
2648
- }
2649
-
2650
- return -2;
2651
- }
2652
- }
2653
-
2654
- this.SOF_SymEncryptFile = function (sessionKey, srcfile, destfile, type) {
2655
- var json = '{"function":"SOF_SymEncryptFile", "deviceName":"' + _curDevName + '", "sessionKey":"' + sessionKey + '", "inFile":"' + srcfile.replace(/\\/g, '\\\\') + '", "outFile":"' + destfile.replace(/\\/g, '\\\\') + '", "type":' + type + '}';
2656
- if (linuxWin == 2) {
2657
- var retJSON = "";
2658
- try {
2659
- retJSON = AjaxIO(json);
2660
- } catch (e) {
2661
- return -3;
2662
- }
2663
-
2664
-
2665
- if (retJSON.length > 3) {
2666
- var obj = eval("(" + retJSON + ")");
2667
- return obj.rtn;
2668
- } else {
2669
- return -2;
2670
-
2671
- }
2672
- } else {
2673
- try {
2674
- AjaxIO(json);
2675
- }
2676
- catch (e) {
2677
- return -3;
2678
- }
2679
-
2680
- var ret = GetHttpResult();
2681
- if (ret) {
2682
- return ret.rtn;
2683
- }
2684
-
2685
- return -2;
2686
- }
2687
- }
2688
-
2689
- this.SOF_SymDecryptFile = function (sessionKey, srcfile, destfile, type) {
2690
- var json = '{"function":"SOF_SymDecryptFile", "deviceName":"' + _curDevName + '", "sessionKey":"' + sessionKey + '", "inFile":"' + srcfile.replace(/\\/g, '\\\\') + '", "outFile":"' + destfile.replace(/\\/g, '\\\\') + '", "type":' + type + '}';
2691
- if (linuxWin == 2) {
2692
- var retJSON = "";
2693
- try {
2694
- retJSON = AjaxIO(json);
2695
- } catch (e) {
2696
- return -3;
2697
- }
2698
-
2699
-
2700
- if (retJSON.length > 3) {
2701
- var obj = eval("(" + retJSON + ")");
2702
- return obj.rtn;
2703
- } else {
2704
- return -2;
2705
-
2706
- }
2707
- } else {
2708
- try {
2709
- AjaxIO(json);
2710
- }
2711
- catch (e) {
2712
- return -3;
2713
- }
2714
-
2715
- var ret = GetHttpResult();
2716
- if (ret) {
2717
- return ret.rtn;
2718
- }
2719
-
2720
- return -2;
2721
- }
2722
- }
2723
-
2724
- this.SOF_SymEncryptData = function (sessionKey, inData) {
2725
- var json = '{"function":"SOF_SymEncryptData", "deviceName":"' + _curDevName + '", "sessionKey":"' + sessionKey + '", "inData":"' + inData + '"}';
2726
- if (linuxWin == 2) {
2727
- var retJSON = "";
2728
- try {
2729
- retJSON = AjaxIO(json);
2730
- } catch (e) {
2731
- return -3;
2732
- }
2733
-
2734
-
2735
- if (retJSON.length > 3) {
2736
- var obj = eval("(" + retJSON + ")");
2737
- return obj.outData;
2738
- } else {
2739
- return -2;
2740
-
2741
- }
2742
- } else {
2743
- try {
2744
- AjaxIO(json);
2745
- }
2746
- catch (e) {
2747
- return -3;
2748
- }
2749
-
2750
- var ret = GetHttpResult();
2751
- if (ret) {
2752
- return ret.outData;
2753
- }
2754
-
2755
- return null;
2756
- }
2757
- }
2758
-
2759
- this.SOF_SymDecryptData = function (sessionKey, inData) {
2760
- var json = '{"function":"SOF_SymDecryptData", "deviceName":"' + _curDevName + '", "sessionKey":"' + sessionKey + '", "inData":"' + inData + '"}';
2761
- if (linuxWin == 2) {
2762
- var retJSON = "";
2763
- try {
2764
- retJSON = AjaxIO(json);
2765
- } catch (e) {
2766
- return -3;
2767
- }
2768
-
2769
-
2770
- if (retJSON.length > 3) {
2771
- var obj = eval("(" + retJSON + ")");
2772
- return obj.outData;
2773
- } else {
2774
- return -2;
2775
-
2776
- }
2777
- } else {
2778
- try {
2779
- AjaxIO(json);
2780
- }
2781
- catch (e) {
2782
- return -3;
2783
- }
2784
-
2785
- var ret = GetHttpResult();
2786
- if (ret) {
2787
- return ret.outData;
2788
- }
2789
-
2790
- return null;
2791
- }
2792
- }
2793
-
2794
- /////////////////////////////////////////////////////////////////
2795
- this.SOF_GenerateQRCode = function (qrcode_text_in) {
2796
- var qrcode_text = qrcode_text_in.replace(/"/g, '\\"');
2797
- var json = '{"module":"libQR","function":"SOF_GenerateQRCode", "inData":"' + qrcode_text + '"}';
2798
- if (linuxWin == 2) {
2799
- var retJSON = "";
2800
- try {
2801
- retJSON = AjaxIO(json);
2802
- } catch (e) {
2803
- return -3;
2804
- }
2805
-
2806
-
2807
- if (retJSON.length > 3) {
2808
- var obj = eval("(" + retJSON + ")");
2809
- return obj.outData;
2810
- } else {
2811
- return -2;
2812
-
2813
- }
2814
- } else {
2815
- try {
2816
- AjaxIO(json);
2817
- }
2818
- catch (e) {
2819
- return -3;
2820
- }
2821
-
2822
- var ret = GetHttpResult();
2823
- if (ret) {
2824
- return ret.outData;
2825
- }
2826
-
2827
- return null;
2828
- }
2829
- }
2830
-
2831
- this.SOF_VerifyPinMS = function (responseKey) {
2832
- var json = '{"function":"SOF_VerifyPinMS", "deviceName":"' + _curDevName + '", "passWd":"' + responseKey + '"}';
2833
- if (linuxWin == 2) {
2834
- var retJSON = "";
2835
- try {
2836
- retJSON = AjaxIO(json);
2837
- } catch (e) {
2838
- return -3;
2839
- }
2840
-
2841
-
2842
- if (retJSON.length > 3) {
2843
- var obj = eval("(" + retJSON + ")");
2844
- return obj.rtn;
2845
- } else {
2846
- return -2;
2847
-
2848
- }
2849
- } else {
2850
- try {
2851
- AjaxIO(json);
2852
- }
2853
- catch (e) {
2854
- return -3;
2855
- }
2856
-
2857
- var ret = GetHttpResult();
2858
- if (ret) {
2859
- return ret.rtn;
2860
- }
2861
-
2862
- return -2;
2863
- }
2864
- }
2865
- /////////////////////////////////////////////////////////////////
2866
- this.SOF_GetHardwareType = function () {
2867
- var json = '{"function":"SOF_GetHardwareType", "deviceName":"' + _curDevName + '"}';
2868
- if (linuxWin == 2) {
2869
- var retJSON = "";
2870
- try {
2871
- retJSON = AjaxIO(json);
2872
- } catch (e) {
2873
- return -3;
2874
- }
2875
-
2876
-
2877
- if (retJSON.length > 3) {
2878
- var obj = eval("(" + retJSON + ")");
2879
- return obj.type;
2880
- } else {
2881
- return -2;
2882
-
2883
- }
2884
- } else {
2885
- try {
2886
- AjaxIO(json);
2887
- }
2888
- catch (e) {
2889
- return -3;
2890
- }
2891
-
2892
- var ret = GetHttpResult();
2893
- if (ret) {
2894
- return ret.type;
2895
- }
2896
-
2897
- return -2;
2898
- }
2899
- }
2900
-
2901
- this.SOF_VerifyFingerprint = function () {
2902
- var json = '{"function":"SOF_VerifyFingerprint", "deviceName":"' + _curDevName + '"}';
2903
- if (linuxWin == 2) {
2904
- var retJSON = "";
2905
- try {
2906
- retJSON = AjaxIO(json);
2907
- } catch (e) {
2908
- return -3;
2909
- }
2910
-
2911
-
2912
- if (retJSON.length > 3) {
2913
- var obj = eval("(" + retJSON + ")");
2914
- return obj.rtn;
2915
- } else {
2916
- return -2;
2917
-
2918
- }
2919
- } else {
2920
- try {
2921
- AjaxIO(json);
2922
- }
2923
- catch (e) {
2924
- return -3;
2925
- }
2926
-
2927
- var ret = GetHttpResult();
2928
- if (ret) {
2929
- return ret.rtn;
2930
- }
2931
-
2932
- return -2;
2933
- }
2934
- }
2935
-
2936
- this.SOF_EnumFiles = function () {
2937
- var json = '{"function":"SOF_EnumFiles", "deviceName":"' + _curDevName + '"}';
2938
- if (linuxWin == 2) {
2939
- var retJSON = "";
2940
- try {
2941
- retJSON = AjaxIO(json);
2942
- } catch (e) {
2943
- return -3;
2944
- }
2945
-
2946
-
2947
- if (retJSON.length > 3) {
2948
- var obj = eval("(" + retJSON + ")");
2949
- return obj.array;
2950
- } else {
2951
- return -2;
2952
-
2953
- }
2954
- } else {
2955
- try {
2956
- AjaxIO(json);
2957
- }
2958
- catch (e) {
2959
- return -3;
2960
- }
2961
-
2962
- var ret = GetHttpResult();
2963
- if (ret) {
2964
- return ret.array;
2965
- }
2966
-
2967
- return -2;
2968
- }
2969
- }
2970
-
2971
- this.SOF_ReadFile = function (fileName, offset, length) {
2972
- var json = '{"function":"SOF_ReadFile", "deviceName":"' + _curDevName + '", "fileName":"' + fileName + '", "offset":' + offset + ',"length":' + length + '}';
2973
- if (linuxWin == 2) {
2974
- var retJSON = "";
2975
- try {
2976
- retJSON = AjaxIO(json);
2977
- } catch (e) {
2978
- return -3;
2979
- }
2980
-
2981
-
2982
- if (retJSON.length > 3) {
2983
- var obj = eval("(" + retJSON + ")");
2984
- return obj.outData;
2985
- } else {
2986
- return -2;
2987
-
2988
- }
2989
- } else {
2990
- try {
2991
- AjaxIO(json);
2992
- }
2993
- catch (e) {
2994
- return -3;
2995
- }
2996
-
2997
- var ret = GetHttpResult();
2998
- if (ret) {
2999
- return ret.outData;
3000
- }
3001
- }
3002
- }
3003
-
3004
- this.SOF_WriteFile = function (fileName, offset, data) {
3005
- var json = '{"function":"SOF_WriteFile", "deviceName":"' + _curDevName + '", "fileName":"' + fileName + '", "offset":' + offset + ',"inData":"' + data + '"}';
3006
- if (linuxWin == 2) {
3007
- var retJSON = "";
3008
- try {
3009
- retJSON = AjaxIO(json);
3010
- } catch (e) {
3011
- return -3;
3012
- }
3013
-
3014
-
3015
- if (retJSON.length > 3) {
3016
- var obj = eval("(" + retJSON + ")");
3017
- return obj.rtn;
3018
- } else {
3019
- return -2;
3020
-
3021
- }
3022
- } else {
3023
- try {
3024
- AjaxIO(json);
3025
- }
3026
- catch (e) {
3027
- return -3;
3028
- }
3029
-
3030
- var ret = GetHttpResult();
3031
- if (ret) {
3032
- return ret.rtn;
3033
- }
3034
- }
3035
- }
3036
-
3037
- this.SOF_CreateFile = function (fileName, length, readRight, writeRight) {
3038
- var json = '{"function":"SOF_CreateFile", "deviceName":"' + _curDevName + '","fileName":"' + fileName + '", "length" :' + length + ', "readRight":' + readRight + ',"writeRight":' + writeRight + '}';
3039
- if (linuxWin == 2) {
3040
- var retJSON = "";
3041
- try {
3042
- retJSON = AjaxIO(json);
3043
- } catch (e) {
3044
- return -3;
3045
- }
3046
-
3047
-
3048
- if (retJSON.length > 3) {
3049
- var obj = eval("(" + retJSON + ")");
3050
- return obj.rtn;
3051
- } else {
3052
- return -2;
3053
-
3054
- }
3055
- } else {
3056
- try {
3057
- AjaxIO(json);
3058
- }
3059
- catch (e) {
3060
- return -3;
3061
- }
3062
-
3063
- var ret = GetHttpResult();
3064
- if (ret) {
3065
- return ret.rtn;
3066
- }
3067
- }
3068
- }
3069
-
3070
- this.SOF_DeleteFile = function (fileName) {
3071
- var json = '{"function":"SOF_DeleteFile", "deviceName":"' + _curDevName + '","fileName":"' + fileName + '"}';
3072
- if (linuxWin == 2) {
3073
- var retJSON = "";
3074
- try {
3075
- retJSON = AjaxIO(json);
3076
- } catch (e) {
3077
- return -3;
3078
- }
3079
-
3080
-
3081
- if (retJSON.length > 3) {
3082
- var obj = eval("(" + retJSON + ")");
3083
- return obj.rtn;
3084
- } else {
3085
- return -2;
3086
-
3087
- }
3088
- } else {
3089
- try {
3090
- AjaxIO(json);
3091
- }
3092
- catch (e) {
3093
- return -3;
3094
- }
3095
-
3096
- var ret = GetHttpResult();
3097
- if (ret) {
3098
- return ret.rtn;
3099
- }
3100
- }
3101
- }
3102
-
3103
- //Socket API
3104
- this.SocketConnect = function (HostName, Port) {
3105
- var json = '{"module":"libSocket","function":"SocketConnect", "HostName":"' + HostName + '", "Port":' + Port + '}';
3106
- if (linuxWin == 2) {
3107
- var retJSON = "";
3108
- try {
3109
- retJSON = AjaxIO(json);
3110
- } catch (e) {
3111
- return -3;
3112
- }
3113
-
3114
-
3115
- if (retJSON.length > 3) {
3116
- var obj = eval("(" + retJSON + ")");
3117
- return obj.rtn;
3118
- } else {
3119
- return -2;
3120
-
3121
- }
3122
- } else {
3123
- try {
3124
- AjaxIO(json);
3125
- }
3126
- catch (e) {
3127
- return -3;
3128
- }
3129
-
3130
- var ret = GetHttpResult();
3131
- if (ret) {
3132
- return ret.rtn;
3133
- }
3134
- }
3135
- }
3136
-
3137
- this.SocketDisConnect = function () {
3138
- var json = '{"module":"libSocket","function":"SocketDisConnect"}';
3139
- if (linuxWin == 2) {
3140
- var retJSON = "";
3141
- try {
3142
- retJSON = AjaxIO(json);
3143
- } catch (e) {
3144
- return -3;
3145
- }
3146
-
3147
-
3148
- if (retJSON.length > 3) {
3149
- var obj = eval("(" + retJSON + ")");
3150
- return obj.rtn;
3151
- } else {
3152
- return -2;
3153
-
3154
- }
3155
- } else {
3156
- try {
3157
- AjaxIO(json);
3158
- }
3159
- catch (e) {
3160
- return -3;
3161
- }
3162
-
3163
- var ret = GetHttpResult();
3164
- if (ret) {
3165
- return ret.rtn;
3166
- }
3167
- }
3168
- }
3169
-
3170
- this.SocketSendText = function (SendText) {
3171
- var json = '{"module":"libSocket","function":"SocketSendText", "SendText":"' + SendText + '"}';
3172
- if (linuxWin == 2) {
3173
- var retJSON = "";
3174
- try {
3175
- retJSON = AjaxIO(json);
3176
- } catch (e) {
3177
- return -3;
3178
- }
3179
-
3180
-
3181
- if (retJSON.length > 3) {
3182
- var obj = eval("(" + retJSON + ")");
3183
- return obj.RecvText;
3184
- } else {
3185
- return -2;
3186
-
3187
- }
3188
- } else {
3189
- try {
3190
- AjaxIO(json);
3191
- }
3192
- catch (e) {
3193
- return -3;
3194
- }
3195
-
3196
- var ret = GetHttpResult();
3197
- if (ret) {
3198
- return ret.RecvText;
3199
- }
3200
- }
3201
- }
3202
- }