whychdw
2021-08-11 16616e3334b87a2967cd2ad49c5c872104e746b1
提交内容
1个文件已添加
4个文件已修改
289 ■■■■ 已修改文件
nfdw_stand/WebRoot/classes/js/SoftUKey.js 115 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
nfdw_stand/WebRoot/classes/login.jsp 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
nfdw_stand/WebRoot/js/SoftUKey.js 117 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
nfdw_stand/WebRoot/login.jsp 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
nfdw_stand/WebRoot_photo/test.jpg 补丁 | 查看 | 原始文档 | blame | 历史
nfdw_stand/WebRoot/classes/js/SoftUKey.js
@@ -279,4 +279,119 @@
    }catch (e) {
        console.log("获取签名异常:"+e)
    }
}
/**
 * 校验ukey的签名
 * @param randomNumber
 * @param callback
 */
SoftUKey.prototype.checkSign = function(userName, randomNumber, callback) {
    try {
        let s_simnew1 = new this.SoftKey3W();     //创建UK类
        let inPath, sign, uKeyId, publicX, publicY;
        // 开启监听
        s_simnew1.Socket_UK.onopen = function() {
            s_simnew1.ResetOrder();//这里调用ResetOrder将计数清零,这样,消息处理处就会收到0序号的消息,通过计数及序号的方式,从而生产流程
        }
        // 监听获取到的信息
        s_simnew1.Socket_UK.onmessage = function(Msg) {
            let UK_Data = JSON.parse(Msg.data);
            if(UK_Data.type!="Process")return ;//如果不是流程处理消息,则跳过
            // 根据收到的序号执行函数
            switch(UK_Data.order) {
                case 0:
                    s_simnew1.FindPort(0); //发送命令取UK的路径
                    break;
                case 1:
                    if(UK_Data.LastError!=0) {
                        window.alert ( "未发现加密锁,请插入加密锁");
                        s_simnew1.Socket_UK.close();
                        return false;
                    }
                    // 设置路径
                    inPath=UK_Data.return_value;//获得返回的UK的路径
                    s_simnew1.GetProduceDate(inPath);//返回芯片唯一ID
                    break;
                case 2:
                    if(UK_Data.LastError!=0){
                        window.alert("返回芯片唯一ID时出现错误,错误码为:"+UK_Data.LastError.toString());
                        s_simnew1.Socket_UK.close();
                        return false;
                    }
                    uKeyId = UK_Data.return_value;
                    //返回设置在锁中的公钥X
                    s_simnew1.GetPubKeyX(inPath);
                    break;
                case 3:
                    if(UK_Data.LastError!=0){
                        window.alert("返回设置在锁中的公钥X时出现错误,错误码为:"+UK_Data.LastError.toString());
                        s_simnew1.Socket_UK.close();
                        return false;
                    }
                    publicX = UK_Data.return_value;
                    // 返回设置在锁中的公钥Y
                    s_simnew1.GetPubKeyY(inPath);
                    break;
                case 4:
                    if(UK_Data.LastError!=0){
                        window.alert("返回设置在锁中的公钥Y时出现错误,错误码为:"+UK_Data.LastError.toString());
                        s_simnew1.Socket_UK.close();
                        return false;
                    }
                    publicY = UK_Data.return_value;
                    // 对数据进行签名
                    s_simnew1.YtSign(randomNumber,"123", inPath);
                    break;
                case 5:
                    if(UK_Data.LastError!=0){
                        window.alert("对数据进行签名时出现错误,错误码为:"+UK_Data.LastError.toString());
                        s_simnew1.Socket_UK.close();
                        return false;
                    }
                    sign = UK_Data.return_value;
                    s_simnew1.YtVerfiy(userName, randomNumber, publicX, publicY, sign, inPath);
                    break;
                case 6:
                    if(UK_Data.LastError!=0){
                        // 执行回调函数
                        if(typeof callback == 'function') {
                            callback({
                                code: 1,
                                errorCode: UK_Data.LastError.toString(),
                                msg: "uKey验签失败",
                            });
                        }
                        s_simnew1.Socket_UK.close();
                        return false;
                    }
                    // 执行回调函数
                    if(typeof callback == 'function') {
                        callback({
                            code: 1,
                            errorCode: 0,
                            msg: "uKey验签成功",
                        });
                    }
                    //所有工作处理完成后,关掉Socket
                    s_simnew1.Socket_UK.close();
                    break;
            }
        }
        // 关闭监听
        s_simnew1.Socket_UK.onclose = function() {
            console.log("关闭获取签名")
        }
    }catch (e) {
        console.log("获取签名异常:"+e)
    }
}
nfdw_stand/WebRoot/classes/login.jsp
@@ -338,6 +338,7 @@
            },
            getRandomFromServer() {
                let self = this;
                let userName = self.info.name.trim();
                $.ajax({
                    type: 'post',
                    url: 'LoginAction_getRandom',
@@ -346,7 +347,7 @@
                        let rs = JSON.parse(res.result);
                        if(rs.code == 1) {
                            let randomNumber = rs.data;
                            self.softUKey.getSign(randomNumber, self.checkUKeySign);
                            self.softUKey.checkSign(userName, randomNumber, self.checkUKeySign);
                        }else {
                            self.$message.error("服务器连接异常!");
                        }
@@ -357,28 +358,7 @@
                });
            },
            checkUKeySign(result) {
                let reg = new RegExp("&", "g");
                result.inPath = result.inPath.replace(reg, "%26");
                result.inPath = result.inPath.replace(/\\/g, "huodongwei");
                let self = this;
                $.ajax({
                    type: 'post',
                    url: 'LoginAction_verify',
                    data: 'json='+JSON.stringify(result),
                    success: function(res) {
                        let rs = JSON.parse(res.result);
                        if(rs.code == 1) {
                            self.checkUser();
                        }else {
                            self.msg = rs.msg;
                            //self.checkUser();
                        }
                    },
                    error: function(error) {
                        self.msg = "uKey验签校验失败!";
                        console.log(error);
                    },
                });
                console.log(result);
            },
            showVerify: function() {
                if(this.info.name.trim() && this.info.password.trim()
nfdw_stand/WebRoot/js/SoftUKey.js
@@ -279,4 +279,121 @@
    }catch (e) {
        console.log("获取签名异常:"+e)
    }
}
/**
 * 校验ukey的签名
 * @param randomNumber
 * @param callback
 */
SoftUKey.prototype.checkSign = function(userName, randomNumber, callback) {
    try {
        let s_simnew1 = new this.SoftKey3W();     //创建UK类
        let inPath, sign, uKeyId, publicX, publicY;
        // 开启监听
        s_simnew1.Socket_UK.onopen = function() {
            s_simnew1.ResetOrder();//这里调用ResetOrder将计数清零,这样,消息处理处就会收到0序号的消息,通过计数及序号的方式,从而生产流程
        }
        // 监听获取到的信息
        s_simnew1.Socket_UK.onmessage = function(Msg) {
            let UK_Data = JSON.parse(Msg.data);
            if(UK_Data.type!="Process")return ;//如果不是流程处理消息,则跳过
            // 根据收到的序号执行函数
            switch(UK_Data.order) {
                case 0:
                    s_simnew1.FindPort(0); //发送命令取UK的路径
                    break;
                case 1:
                    if(UK_Data.LastError!=0) {
                        window.alert ( "未发现加密锁,请插入加密锁");
                        s_simnew1.Socket_UK.close();
                        return false;
                    }
                    // 设置路径
                    inPath=UK_Data.return_value;//获得返回的UK的路径
                    s_simnew1.GetProduceDate(inPath);//返回芯片唯一ID
                    break;
                case 2:
                    if(UK_Data.LastError!=0){
                        window.alert("返回芯片唯一ID时出现错误,错误码为:"+UK_Data.LastError.toString());
                        s_simnew1.Socket_UK.close();
                        return false;
                    }
                    uKeyId = UK_Data.return_value;
                    //返回设置在锁中的公钥X
                    s_simnew1.GetPubKeyX(inPath);
                    break;
                case 3:
                    if(UK_Data.LastError!=0){
                        window.alert("返回设置在锁中的公钥X时出现错误,错误码为:"+UK_Data.LastError.toString());
                        s_simnew1.Socket_UK.close();
                        return false;
                    }
                    publicX = UK_Data.return_value;
                    // 返回设置在锁中的公钥Y
                    s_simnew1.GetPubKeyY(inPath);
                    break;
                case 4:
                    if(UK_Data.LastError!=0){
                        window.alert("返回设置在锁中的公钥Y时出现错误,错误码为:"+UK_Data.LastError.toString());
                        s_simnew1.Socket_UK.close();
                        return false;
                    }
                    publicY = UK_Data.return_value;
                    // 对数据进行签名
                    s_simnew1.YtSign(randomNumber,"123", inPath);
                    break;
                case 5:
                    if(UK_Data.LastError!=0){
                        window.alert("对数据进行签名时出现错误,错误码为:"+UK_Data.LastError.toString());
                        s_simnew1.Socket_UK.close();
                        return false;
                    }
                    sign = UK_Data.return_value;
                    s_simnew1.YtVerfiy(userName, randomNumber, publicX, publicY, sign, inPath);
                    break;
                case 6:
                    if(UK_Data.LastError!=0){
                        // 执行回调函数
                        if(typeof callback == 'function') {
                            callback({
                                code: 1,
                                errorCode: UK_Data.LastError.toString(),
                                msg: "uKey验签失败",
                            });
                        }
                        s_simnew1.Socket_UK.close();
                        return false;
                    }
                    let isGood = UK_Data.return_value;
                    let text = isGood?"uKey验签成功": "uKey验签失败";
                    // 执行回调函数
                    if(typeof callback == 'function') {
                        callback({
                            code: isGood,
                            errorCode: 0,
                            msg: text,
                        });
                    }
                    //所有工作处理完成后,关掉Socket
                    s_simnew1.Socket_UK.close();
                    break;
            }
        }
        // 关闭监听
        s_simnew1.Socket_UK.onclose = function() {
            console.log("关闭获取签名")
        }
    }catch (e) {
        console.log("获取签名异常:"+e)
    }
}
nfdw_stand/WebRoot/login.jsp
@@ -338,6 +338,7 @@
            },
            getRandomFromServer() {
                let self = this;
                let userName = self.info.name.trim();
                $.ajax({
                    type: 'post',
                    url: 'LoginAction_getRandom',
@@ -346,7 +347,7 @@
                        let rs = JSON.parse(res.result);
                        if(rs.code == 1) {
                            let randomNumber = rs.data;
                            self.softUKey.getSign(randomNumber, self.checkUKeySign);
                            self.softUKey.checkSign(userName, randomNumber, self.checkUKeySign);
                        }else {
                            self.$message.error("服务器连接异常!");
                        }
@@ -357,28 +358,11 @@
                });
            },
            checkUKeySign(result) {
                let reg = new RegExp("&", "g");
                result.inPath = result.inPath.replace(reg, "%26");
                result.inPath = result.inPath.replace(/\\/g, "huodongwei");
                let self = this;
                $.ajax({
                    type: 'post',
                    url: 'LoginAction_verify',
                    data: 'json='+JSON.stringify(result),
                    success: function(res) {
                        let rs = JSON.parse(res.result);
                        if(rs.code == 1) {
                            self.checkUser();
                        }else {
                            self.msg = rs.msg;
                            //self.checkUser();
                        }
                    },
                    error: function(error) {
                        self.msg = "uKey验签校验失败!";
                        console.log(error);
                    },
                });
                if(result.code == 1) {
                    this.checkUser();
                }else {
                    this.msg = result.msg;
                }
            },
            showVerify: function() {
                if(this.info.name.trim() && this.info.password.trim()
@@ -439,7 +423,6 @@
                        UName,
                    }),
                    success: function(res) {
                        console.log(res);
                        let rs = JSON.parse(res.result);
                        if(rs.code == 1) {
                            self.$Message.message('success', {
nfdw_stand/WebRoot_photo/test.jpg