Browse Source

[完善] 引入K1秘钥

develop
陈鹏飞 4 years ago
parent
commit
9c14b59c51
  1. 3
      angular.json
  2. 86
      package-lock.json
  3. 1
      package.json
  4. 8
      src/app/app-routing.module.ts
  5. 8
      src/app/app.module.ts
  6. 6
      src/app/m-token-k1/m-token-k1.component.html
  7. 3
      src/app/m-token-k1/m-token-k1.component.scss
  8. 97
      src/app/m-token-k1/m-token-k1.component.ts
  9. 62
      src/app/m-token-k1/m-token-k1.service.ts
  10. 646
      src/assets/mTokenK1/mToken_K1.js

3
angular.json

@ -35,7 +35,8 @@
],
"scripts": [
"node_modules/echarts/dist/echarts.js",
"./node_modules/swiper/js/swiper.min.js"
"./node_modules/swiper/js/swiper.min.js",
"src/assets/mTokenK1/mToken_K1.js"
]
},
"configurations": {

86
package-lock.json generated

@ -10508,8 +10508,7 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"aproba": {
"version": "1.2.0",
@ -10530,14 +10529,12 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -10552,20 +10549,17 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"core-util-is": {
"version": "1.0.2",
@ -10682,8 +10676,7 @@
"inherits": {
"version": "2.0.4",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"ini": {
"version": "1.3.5",
@ -10695,7 +10688,6 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@ -10710,7 +10702,6 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@ -10718,14 +10709,12 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"minipass": {
"version": "2.9.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
@ -10744,7 +10733,6 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
@ -10834,8 +10822,7 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"object-assign": {
"version": "4.1.1",
@ -10847,7 +10834,6 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@ -10933,8 +10919,7 @@
"safe-buffer": {
"version": "5.1.2",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"safer-buffer": {
"version": "2.1.2",
@ -10970,7 +10955,6 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@ -10990,7 +10974,6 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@ -11034,14 +11017,12 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"yallist": {
"version": "3.1.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
}
}
},
@ -11965,6 +11946,21 @@
"resolved": "https://registry.npm.taobao.org/ngx-cookie-service/download/ngx-cookie-service-3.0.2.tgz",
"integrity": "sha1-6N3jf5zqDjh3T+91j6NrcajC0wY="
},
"ngx-countdown": {
"version": "11.0.0",
"resolved": "https://registry.npm.taobao.org/ngx-countdown/download/ngx-countdown-11.0.0.tgz?cache=0&sync_timestamp=1605252859841&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fngx-countdown%2Fdownload%2Fngx-countdown-11.0.0.tgz",
"integrity": "sha1-xmy9NHJjPgEE1CE5caMId8H1JFs=",
"requires": {
"tslib": "^2.0.0"
},
"dependencies": {
"tslib": {
"version": "2.0.3",
"resolved": "https://registry.npm.taobao.org/tslib/download/tslib-2.0.3.tgz?cache=0&sync_timestamp=1602286724979&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftslib%2Fdownload%2Ftslib-2.0.3.tgz",
"integrity": "sha1-jgdBrEX8DCJuWKF7/D5kubxsphw="
}
}
},
"ngx-echarts": {
"version": "4.2.2",
"resolved": "https://registry.npm.taobao.org/ngx-echarts/download/ngx-echarts-4.2.2.tgz",
@ -17555,8 +17551,7 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"aproba": {
"version": "1.2.0",
@ -17599,8 +17594,7 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"concat-map": {
"version": "0.0.1",
@ -17611,8 +17605,7 @@
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"core-util-is": {
"version": "1.0.2",
@ -17729,8 +17722,7 @@
"inherits": {
"version": "2.0.4",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"ini": {
"version": "1.3.5",
@ -17742,7 +17734,6 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@ -17772,7 +17763,6 @@
"version": "2.9.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
@ -17791,7 +17781,6 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
@ -17881,8 +17870,7 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"object-assign": {
"version": "4.1.1",
@ -17894,7 +17882,6 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@ -17980,8 +17967,7 @@
"safe-buffer": {
"version": "5.1.2",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"safer-buffer": {
"version": "2.1.2",
@ -18017,7 +18003,6 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@ -18037,7 +18022,6 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@ -18081,14 +18065,12 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"yallist": {
"version": "3.1.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
}
}
},

1
package.json

@ -33,6 +33,7 @@
"firebase": "^7.6.2",
"ng2-file-upload": "^1.4.0",
"ngx-cookie-service": "^3.0.2",
"ngx-countdown": "^11.0.0",
"ngx-echarts": "^4.2.2",
"ngx-perfect-scrollbar": "^8.0.0",
"pixi-filters": "^3.1.1",

8
src/app/app-routing.module.ts

@ -6,6 +6,7 @@ import { NavigationComponent } from './navigation/navigation.component';
//路由守卫
import {AuthGuard} from './auth.guard'
import { MTokenK1Component } from './m-token-k1/m-token-k1.component';
@ -19,11 +20,8 @@ const routes: Routes = [
{path:'datacollection',loadChildren:() => import('./ui/ui.module').then(m => m.UiModule)}
]},
{path:'login',
component:LoginComponent}, //登录页
{path:'register',
component:RegisterComponent,}, //注册页
{path:'login', component:LoginComponent}, //登录页
{path:'register', component:RegisterComponent,}, //注册页
];

8
src/app/app.module.ts

@ -18,11 +18,14 @@ import { httpInterceptorProviders } from './http-interceptors/index'
import {CacheTokenService} from './http-interceptors/cache-token.service'
import { TreeService } from'./http-interceptors/tree.service'
import { CookieService } from 'ngx-cookie-service';//cookie插件
import { CountdownModule } from 'ngx-countdown'; //倒计时插件
import { MTokenK1Component } from './m-token-k1/m-token-k1.component';
@NgModule({
declarations: [
AppComponent,
HomeComponent
HomeComponent,
MTokenK1Component
],
imports: [
BrowserModule,
@ -35,7 +38,8 @@ import { CookieService } from 'ngx-cookie-service';//cookie插件
MatIconModule,
PagesModule,
FormsModule,
HttpClientModule
HttpClientModule,
CountdownModule
],
providers: [httpInterceptorProviders, CacheTokenService,TreeService,CookieService],
bootstrap: [AppComponent]

6
src/app/m-token-k1/m-token-k1.component.html

@ -0,0 +1,6 @@
<object id="mTokenPlugin" type="application/x-mtokenplugin" width="0" height="0">
<param value="pluginLoaded" />
</object>
<div style="text-align: center; margin-top: 10%;">
<countdown [config]="{leftTime: 5,format: '密钥验证失败,本页面将于s秒后关闭'}" (event)="handleEvent($event)"></countdown>
</div>

3
src/app/m-token-k1/m-token-k1.component.scss

@ -0,0 +1,3 @@
.count-down {
font-size: 50px;
}

97
src/app/m-token-k1/m-token-k1.component.ts

@ -0,0 +1,97 @@
import { Component, OnInit, Injectable } from '@angular/core';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router } from '@angular/router';
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
import {MTokenK1Service} from './m-token-k1.service' //引入服务
declare var mToken : any;
@Injectable({
providedIn: 'root'
})
@Component({
selector: 'app-m-token-k1',
templateUrl: './m-token-k1.component.html',
styleUrls: ['./m-token-k1.component.scss']
})
export class MTokenK1Component implements OnInit {
constructor(private router: Router,public snackBar: MatSnackBar,public mTokenK1: MTokenK1Service) { }
ngOnInit(): void {
}
// 路由守卫
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
return this.checkKey();
}
K1mToken = new mToken("mTokenPlugin")
keyBase64 = '5YyX5Lqs5a6J5L+h4oCU5LqM57u06aKE5qGI57yW5Yi25bel5YW3d2Vi'; //秘钥验证base64字符
password='12345678'; //秘钥验证用户密码
checkKey(): boolean {
this.K1mToken.LoadLibrary()
try { //try 捕获错误
let keyIndex = this.K1mToken.K1_mTokenFindDevice() //查找秘钥是否插入
if (keyIndex > 0) { //秘钥已插入
let keyUID = this.K1mToken.K1_mTokenGetUID(keyIndex) //读取秘钥UID
let isLogin = this.K1mToken.K1_mTokenOpen(keyUID,this.password)
if (isLogin == 0 ) { //密码验证成功
let keyMSG = window.atob( this.K1mToken.K1_mTokenReadUserStorage(keyUID,0,56) )
if (keyMSG==this.keyBase64) { //base64转码 验证
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('密钥验证成功','确定',config);
this.mTokenK1.startUp() //开始定时验证秘钥是否拔出
return true
} else { //base64验证失败
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 5000
this.snackBar.open('密钥错误,不为本公司发放密钥','确定',config);
this.router.navigate(['/login'])
return false
}
} else { //密码验证失败
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 5000
this.snackBar.open('密钥密码错误,请使用初始密码','确定',config);
this.router.navigate(['/login'])
return false
}
} else { //秘钥未插入
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 5000
this.snackBar.open('密钥未插入','确定',config);
this.router.navigate(['/login'])
return false
}
} catch (error) {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 5000
this.snackBar.open('请检查您密钥是否插入或者驱动是否已启动','确定',config);
this.router.navigate(['/login'])
return false
}
} //路由守卫
//倒计时插件关闭页面
handleEvent (e) {
if (e.left===0) {
window.close()
}
}
}

62
src/app/m-token-k1/m-token-k1.service.ts

@ -0,0 +1,62 @@
import { Injectable } from '@angular/core';
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
import { Router } from '@angular/router';
declare var mToken : any;
@Injectable({
providedIn: 'root'
})
export class MTokenK1Service {
constructor(public snackBar: MatSnackBar,private router: Router,) { }
public mTokenK1Timer; //定时器查询
K1mToken = new mToken("mTokenPlugin")
keyBase64 = '5YyX5Lqs5a6J5L+h4oCU5LqM57u06aKE5qGI57yW5Yi25bel5YW3d2Vi'; //秘钥验证base64字符
password='12345678'; //秘钥验证用户密码
public verificationURL = '/login' //验证url地址是否为验证页面
public verificationURLTwo = '/register' //验证url地址是否为验证页面
//验证秘钥定时器
startUp = ():void=>{
window.clearInterval(this.mTokenK1Timer)
this.mTokenK1Timer = window.setInterval( ()=>{
let url = this.router.url
if (url == this.verificationURL || url == this.verificationURLTwo) {
} else {
this.K1mToken.LoadLibrary()
let keyIndex = this.K1mToken.K1_mTokenFindDevice() //查找秘钥是否插入
if (keyIndex < 1) { //秘钥被拔出
this.goToEdit()
} else if (keyIndex > 0) { //秘钥存在
let keyUID = this.K1mToken.K1_mTokenGetUID(keyIndex) //读取秘钥UID
let isLogin = this.K1mToken.K1_mTokenOpen(keyUID,this.password)
if (isLogin==0) { //密码验证成功
let keyMSG = window.atob( this.K1mToken.K1_mTokenReadUserStorage(keyUID,0,56) )
if (keyMSG!=this.keyBase64) { //base64转码 验证失败
this.goToEdit() }
} else { //密码验证失败
this.goToEdit()
}
}
}
},10000)
}
//秘钥拔出,删除验证定时器,跳转页面
goToEdit () {
window.clearInterval(this.mTokenK1Timer) //删除定时器
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 5000
this.snackBar.open('密钥已被拔出,即将跳转页面','确定',config);
let that = this
window.setTimeout(()=>{
that.router.navigate(['/login'])
},5000)
}
}

646
src/assets/mTokenK1/mToken_K1.js

@ -0,0 +1,646 @@

function isIe()
{
return ("ActiveXObject" in window);
}
function mToken(obj){
this.obj = obj;
var g_mTokenPlugin = null;
this.LoadLibrary = function()
{
g_mTokenPlugin = new K1ClientPlugin();//新
if(g_mTokenPlugin == null)
{
return -1;
}
return 0;
};
this.K1_mTokenGetVersion = function()
{
if(g_mTokenPlugin == null)
{
return null;
}
return g_mTokenPlugin.mTokenGetVersion();
};
this.K1_mTokenFindDevice = function()
{
if(g_mTokenPlugin == null)
{
return -1;
}
return g_mTokenPlugin.mTokenFindDevice();
};
this.K1_mTokenGetLastError = function()
{
if(g_mTokenPlugin == null)
{
return -1;
}
return g_mTokenPlugin.mTokenGetLastError();
};
this.K1_mTokenGetUID = function(keyIndex)
{
if(g_mTokenPlugin == null)
{
return null;
}
return g_mTokenPlugin.mTokenGetUID(keyIndex);
};
this.K1_mTokenOpen = function(keyUID, keyPassword)
{
if(g_mTokenPlugin == null)
{
return -1;
}
return g_mTokenPlugin.mTokenOpen(keyUID, keyPassword, 1);
};
this.K1_mTokenClose = function()
{
if(g_mTokenPlugin == null)
{
return -1;
}
return g_mTokenPlugin.mTokenClose();
};
this.K1_mTokenChangePwd = function(keyUID,oldPassword, newPassword)
{
if(g_mTokenPlugin == null)
{
return -1;
}
return g_mTokenPlugin.mTokenChangePwd(keyUID, 1, oldPassword, newPassword);
};
this.K1_mTokenSHA1WithSeed = function(keyUID, randomStr)
{
if(g_mTokenPlugin == null)
{
return null;
}
return g_mTokenPlugin.mTokenSHA1WithSeed(keyUID, randomStr);
};
this.K1_mTokenSHA1WithSeedMac = function(keyUID, randomStr)
{
if(g_mTokenPlugin == null)
{
return null;
}
return g_mTokenPlugin.mTokenSHA1WithSeedMac(keyUID, randomStr);
};
this.K1_mTokenGenResetPwdRequest = function(keyUID, userInfo)
{
if(g_mTokenPlugin == null)
{
return -1;
}
return g_mTokenPlugin.mTokenGenResetPwdRequest(keyUID, userInfo);
};
this.K1_mTokenResetPassword = function(keyUID, serverResponse)
{
if(g_mTokenPlugin == null)
{
return -1;
}
return g_mTokenPlugin.mTokenResetPassword(keyUID, serverResponse);
};
this.K1_mTokenGenRandom = function(keyUID, randomLength)
{
if(g_mTokenPlugin == null)
{
return null;
}
return g_mTokenPlugin.mTokenGenRandom(keyUID, randomLength);
};
this.K1_mTokenReadSecureStorage = function(keyUID, offset, dataLength)
{
if(g_mTokenPlugin == null)
{
return null;
}
return g_mTokenPlugin.mTokenReadSecureStorage(keyUID, offset, dataLength);
};
this.K1_mTokenWriteSecureStorag = function(keyUID, offset, writeData)
{
if(g_mTokenPlugin == null)
{
return -1;
}
return g_mTokenPlugin.mTokenWriteSecureStorage(keyUID, offset, writeData);
};
this.K1_mTokenReadUserStorage = function(keyUID, offset, dataLength)
{
if(g_mTokenPlugin == null)
{
return null;
}
return g_mTokenPlugin.mTokenReadUserStorage(keyUID, offset, dataLength);
};
this.K1_mTokenWriteUserStorage = function(keyUID, offset, writeData)
{
if(g_mTokenPlugin == null)
{
return -1;
}
return g_mTokenPlugin.mTokenWriteUserStorage(keyUID, offset, writeData);
};
this.K1_mTokenGetURL = function(keyUID)
{
if(g_mTokenPlugin == null)
{
return null;
}
return g_mTokenPlugin.mTokenGetURL(keyUID);
};
this.K1_mTokenGetLabel = function(keyUID)
{
if(g_mTokenPlugin == null)
{
return null;
}
return g_mTokenPlugin.mTokenGetLabel(keyUID);
};
this.K1_mTokenGetCompanyName = function(keyUID)
{
if(g_mTokenPlugin == null)
{
return null;
}
return g_mTokenPlugin.mTokenGetCompanyName(keyUID);
};
this.K1_mTokenGetRemark = function(keyUID)
{
if(g_mTokenPlugin == null)
{
return null;
}
return g_mTokenPlugin.mTokenGetRemarks(keyUID);
};
this.K1_mTokenGetOpenType = function(keyUID)
{
if(g_mTokenPlugin == null)
{
return null;
}
return g_mTokenPlugin.mTokenGetOpenType(keyUID);
};
this.K1_mTokenPwdRetryCount = function(keyUID)
{
if(g_mTokenPlugin == null)
{
return null;
}
return g_mTokenPlugin.mTokenPwdRetryCount(keyUID, 1);
};
this.K1_mTokenEncrypt = function(keyUID, method, data)
{
if(g_mTokenPlugin == null)
{
return null;
}
return g_mTokenPlugin.mTokenEncrypt(keyUID, method, 1, data);
};
this.K1_mTokenDecrypt = function(keyUID, method, data)
{
if(g_mTokenPlugin == null)
{
return null;
}
return g_mTokenPlugin.mTokenDecrypt(keyUID, method, 1, data);
};
this.K1_GetMacAddr = function()
{
if(g_mTokenPlugin == null)
{
return null;
}
return g_mTokenPlugin.mTokenGetMacAddr();
};
var _TimerErrorMessage;
var _ExpireUrl;
/*******************************************************
*
* 函数名称K1_CheckExist()
* 检查USB Key是否存在
* 此方法结合K1_StartCheckTimer方法可用来定时
* 检测USB Key是否存在,不存在即返回到指定页面(
* _ExpireUrl)
*
**********************************************************/
function K1_CheckExist()
{
var rtn =g_mTokenPlugin.mTokenFindDevice();
if(rtn < 1)
{
if(_TimerErrorMessage != null)
{
alert(_TimerErrorMessage + " Error Code: " +g_mTokenPlugin.mTokenGetLastError());
}
if(_ExpireUrl != null)
{
window.location = _ExpireUrl;
}
}
return rtn;
};
/*******************************************************
*
* 函数名称K1_StartCheckTimer()
* 定时操作方法
* interval时间1000/errMsg输出的错误信息
* logonUrl跳转地址
* 此方法结合CheckExist方法可用来定时检测加
* 密Key是否存在,不存在即返回到指定页面(_ExpireUrl)
*
**********************************************************/
this.K1_StartCheckTimer = function(interval, errMsg, logonUrl)
{
_TimerErrorMessage = errMsg;
_ExpireUrl = logonUrl;
//定时检测
window.setInterval(K1_CheckExist, interval);
};
}
function K1ClientPlugin()
{
var url = "http://127.0.0.1:51111/K1_Client";
var xmlhttp ;
function AjaxIO(json) {
if(xmlhttp == null) {
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
if("https:" == document.location.protocol)
{
url = "https://127.0.0.1:51121/K1_Client";
}
xmlhttp.open("POST", url, false);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send("json=" + json);
}
this.mTokenGetVersion = function()
{
var json = '{"function":"mTokenGetVersion"}';
AjaxIO(json);
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = eval("(" + xmlhttp.responseText + ")");
return obj.outData;
}else{
return "";
}
};
this.mTokenFindDevice = function()
{
var json = '{"function":"mTokenFindDevice"}';
AjaxIO(json);
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = eval("(" + xmlhttp.responseText + ")");
return obj.devCount;
}else{
return -2;
}
};
this.mTokenGetLastError = function()
{
var json = '{"function":"mTokenGetLastError"}';
AjaxIO(json);
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = eval("(" + xmlhttp.responseText + ")");
return obj.errorCode;
}else{
return -2;
}
};
this.mTokenGetUID = function(keyIndex)
{
var json = '{"function":"mTokenGetUID", "keyIndex":' + keyIndex + '}';
AjaxIO(json);
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = eval("(" + xmlhttp.responseText + ")");
return obj.outData;
}else{
return "";
}
};
this.mTokenOpen = function(keyUID, keyPassword, type)
{
var json = '{"function":"mTokenOpen", "keyUID":"' + keyUID + '", "passWd":"' + keyPassword + '", "passWdType":' + type + '}';
AjaxIO(json);
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = eval("(" + xmlhttp.responseText + ")");
return obj.rtn;
}else{
return 1;
}
};
this.mTokenClose = function()
{
var json = '{"function":"mTokenClose"}';
AjaxIO(json);
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = eval("(" + xmlhttp.responseText + ")");
return obj.rtn;
}else{
return 1;
}
};
this.mTokenChangePwd = function(keyUID, type, oldPassword, newPassword)
{
var json = '{"function":"mTokenChangePwd", "keyUID":"' + keyUID + '", "oldUpin":"' + oldPassword + '", "newUpin":"' + newPassword + '", "passWdType":' + type + '}';
AjaxIO(json);
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = eval("(" + xmlhttp.responseText + ")");
return obj.rtn;
}else{
return 1;
}
};
this.mTokenSHA1WithSeed = function(keyUID, randomStr)
{
var json = '{"function":"mTokenSHA1WithSeed", "keyUID":"' + keyUID + '", "random":"' + randomStr + '"}';
AjaxIO(json);
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = eval("(" + xmlhttp.responseText + ")");
return obj.outData;
}else{
return "";
}
};
this.mTokenSHA1WithSeedMac = function(keyUID, randomStr)
{
var json = '{"function":"mTokenSHA1WithSeed", "keyUID":"' + keyUID + '", "random":"' + randomStr + '", "useMac":1}';
AjaxIO(json);
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = eval("(" + xmlhttp.responseText + ")");
return obj.outData;
}else{
return "";
}
};
this.mTokenGenResetPwdRequest = function(keyUID, userInfo)
{
var json = '{"function":"mTokenGenResetPwdRequest", "keyUID":"' + keyUID + '", "userInfo":"' + userInfo + '"}';
AjaxIO(json);
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = eval("(" + xmlhttp.responseText + ")");
return obj.outData;
}else{
return "";
}
};
this.mTokenResetPassword = function(keyUID, serverResponse)
{
var json = '{"function":"mTokenResetPassword", "keyUID":"' + keyUID + '", "response":"' + serverResponse + '"}';
AjaxIO(json);
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = eval("(" + xmlhttp.responseText + ")");
return obj.rtn;
}else{
return 1;
}
};
this.mTokenGenRandom = function(keyUID, randomLength)
{
var json = '{"function":"mTokenGenRandom", "keyUID":"' + keyUID + '", "inDataLen":' + randomLength + '}';
AjaxIO(json);
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = eval("(" + xmlhttp.responseText + ")");
return obj.outData;
}else{
return "";
}
};
this.mTokenReadSecureStorage = function(keyUID, offset, dataLength)
{
var json = '{"function":"mTokenReadSecureStorage", "keyUID":"' + keyUID + '", "offset":' + offset + ', "inDataLen":' + dataLength + '}';
AjaxIO(json);
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = eval("(" + xmlhttp.responseText + ")");
return obj.outData;
}else{
return "";
}
};
this.mTokenWriteSecureStorage = function(keyUID, offset, writeData)
{
var json = '{"function":"mTokenWriteSecureStorage", "keyUID":"' + keyUID + '", "offset":' + offset + ', "inData":"' + writeData + '"}';
AjaxIO(json);
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = eval("(" + xmlhttp.responseText + ")");
return obj.rtn;
}else{
return 1;
}
};
this.mTokenReadUserStorage = function(keyUID, offset, dataLength)
{
var json = '{"function":"mTokenReadUserStorage", "keyUID":"' + keyUID + '", "offset":' + offset + ', "inDataLen":' + dataLength + '}';
AjaxIO(json);
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = eval("(" + xmlhttp.responseText + ")");
return obj.outData;
}else{
return "";
}
};
this.mTokenWriteUserStorage = function(keyUID, offset, writeData)
{
var json = '{"function":"mTokenWriteUserStorage", "keyUID":"' + keyUID + '", "offset":' + offset + ', "inData":"' + writeData + '"}';
AjaxIO(json);
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = eval("(" + xmlhttp.responseText + ")");
return obj.rtn;
}else{
return 1;
}
};
this.mTokenGetURL = function(keyUID)
{
var json = '{"function":"mTokenGetURL", "keyUID":"' + keyUID + '"}';
AjaxIO(json);
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = eval("(" + xmlhttp.responseText + ")");
return obj.outData;
}else{
return "";
}
};
this.mTokenGetLabel = function(keyUID)
{
var json = '{"function":"mTokenGetLabel", "keyUID":"' + keyUID + '"}';
AjaxIO(json);
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = eval("(" + xmlhttp.responseText + ")");
return obj.outData;
}else{
return "";
}
};
this.mTokenGetCompanyName = function(keyUID)
{
var json = '{"function":"mTokenGetCompanyName", "keyUID":"' + keyUID + '"}';
AjaxIO(json);
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = eval("(" + xmlhttp.responseText + ")");
return obj.outData;
}else{
return "";
}
};
this.mTokenGetRemarks = function(keyUID)
{
var json = '{"function":"mTokenGetRemarks", "keyUID":"' + keyUID + '"}';
AjaxIO(json);
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = eval("(" + xmlhttp.responseText + ")");
return obj.outData;
}else{
return "";
}
};
this.mTokenGetOpenType = function(keyUID)
{
var json = '{"function":"mTokenGetOpenType", "keyUID":"' + keyUID + '"}';
AjaxIO(json);
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = eval("(" + xmlhttp.responseText + ")");
return obj.openType;
}else{
return -1;
}
};
this.mTokenPwdRetryCount = function(keyUID, passwdType)
{
var json = '{"function":"mTokenPwdRetryCount", "keyUID":"' + keyUID + '", "passWdType":' + passwdType + '}';
AjaxIO(json);
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = eval("(" + xmlhttp.responseText + ")");
return obj.pwdRetryCount;
}else{
return -1;
}
};
this.mTokenEncrypt = function(keyUID, method, paddingType, data)
{
var json = '{"function":"mTokenEncrypt", "keyUID":"' + keyUID + '", "method":' + method + ', "paddingType":' + paddingType + ', "inData":"' + data + '"}';
AjaxIO(json);
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = eval("(" + xmlhttp.responseText + ")");
return obj.outData;
}else{
return "";
}
};
this.mTokenDecrypt = function(keyUID, method, paddingType, data)
{
var json = '{"function":"mTokenDecrypt", "keyUID":"' + keyUID + '", "method":' + method + ', "paddingType":' + paddingType + ', "inData":"' + data + '"}';
AjaxIO(json);
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = eval("(" + xmlhttp.responseText + ")");
return obj.outData;
}else{
return "";
}
};
this.mTokenGetMacAddr = function()
{
var json = '{"function":"mTokenGetMacAddr"}';
AjaxIO(json);
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = eval("(" + xmlhttp.responseText + ")");
return obj.outData;
}else{
return "";
}
}
}
Loading…
Cancel
Save