You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2942 lines
95 KiB
Plaintext

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

2020/03/16 12:04:32 [I] version 1.0
2020/03/16 12:04:32 [I] start websocket server, url: 127.0.0.1:30318
2020/03/16 12:04:36 [I] recv: <?xml version="1.0" encoding="UTF-8"?><getsignandtoken version="1"><challenge>7DbgT65HZFiNEQ5rK3X7eQ==</challenge></getsignandtoken>, message type 1
2020/03/20 12:55:55 [I] version 1.0
2020/03/20 12:55:55 [I] start websocket server, url: 127.0.0.1:30318
2020/03/20 12:55:57 [I] recv: <?xml version="1.0" encoding="UTF-8"?><getsignandtokenreq version="1"><challenge><!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>时间戳服务系统</title>
<link href="http://10.106.9.206:8080/ts-mgr/css/common.css" type="text/css" rel="stylesheet">
<link href="http://10.106.9.206:8080/ts-mgr/css/login.css" type="text/css" rel="stylesheet">
<SCRIPT language="JavaScript" src="http://10.106.9.206:8080/ts-mgr/js/jquery-1.10.2.min.js"></SCRIPT>
<SCRIPT language="JavaScript" src="http://10.106.9.206:8080/ts-mgr/js/common.js"></SCRIPT>
<script type="text/javascript" src="js/judge.js"></script>
<script type="text/javascript">
/*标签切换*/
$(document).ready(function () {
$(".login_nav").each(function () {
$(this).parents(".login_box").find(".info").hide();
$("li", this).each(function (index) {
$(this).parents(".login_box").find(".info").eq(index).css("display", $(this).is(
".on") ? "block" : "none");
$(this).bind("click", function () {
$(this).addClass("on").siblings().removeClass("on");
$(this).parents(".login_box").find(".info").hide().eq(index).show();
});
});
});
});
</script>
</head>
<body onkeydown="keyLogin();">
<div class="warp_login">
<div class="login_box">
<!-- <ul class="login_nav">
<li class="on">数字证书登录</li>
<li>动态口令登录</li>
</ul>
<div class="info">
<div class="aligncenter" style=" margin-bottom:30px;"><img src="images/zhengshu.png" width="160"
height="113"></div>
<p><input type="button" class="btn_login" value="数字证书登录" onClick="window.location.href='main.html'"></p>
</div> -->
<form id="login_form">
<div class="info">
<!-- <p><input type="password1" name="userName" id="userName" class="user_input" onFocus="this.value=''"
onBlur="if(!value){value=defaultValue;}" maxlength="16"></p>
<p style=" position:relative"><input type="password" name="userPassword" id="userPassword"
class="paw_input" maxlength="16" onFocus="this.value=''"
onBlur="if(!value){value=defaultValue;}"></p>
<p style="display:none"><input type="password1" class="code_input" value="验证码"
onFocus="this.value=''" onBlur="if(!value){value=defaultValue;}">
<img src="images/pic_code.gif" width="60" height="39" align="middle"> <span><a
href="#">换一张</a></span>
</p> -->
<p style="display:none">
<label id="randomNumber"></label>
<input type="hidden" id="identityticketInput" name="identityticket"/>
<input type="hidden" id="challengeInput" name="challenge"/>
</p>
<p><input id="s1" type="button" class="btn_login" value="登 录" onclick="javascript:login()"></p>
<!-- window.location.href='main.html' -->
</div>
</form>
</div>
<div class=" fotter">Copyright 数据通信科学技术研究所</div>
</div>
</body>
<!-- <script type="text/javascript" src="js/generator.js"></script> -->
<script type="text/javascript" src="js/xml2json.js"></script>
<script type="text/javascript">
var ws = null;
//第二步点击登录时链接websocket获取验证票据值
function login() {
//第三步:验证票据获取用户标识
function verifyidentityticket(challenge, identityticket) {
$.ajax({
url: "/ts-mgr/VerifyIdentity", //todo...验签票据服务地址,需要根据实际地址调整
type: "post",
dataType: "json",
data: {
challenge: challenge,
identityticket: identityticket,
appserverid: '' //todo...这个值不知道是多少???
},
success: function (res) {
var rmsid = '';
var data = Base64.decode(res);
var dataJson = $.xml2json(data);
if (data.result == 0) {
rmsid = data.userinfo.rmsid; //todo...验签票据处获取的值,我不清楚原来的值从哪里获取???
//todo...验证用户标识
}
},
error: function () {
console.error("验签票据服务请求错误!!!");
}
})
}
function loginRequest() {
$.ajax({
url: "/ts-mgr/login/userLoginSec.do",
type: "post",
dataType: "text",
data: $("#login_form").serialize(),
success: function (data) {
if(data == 4){
window.location.href = "main.jsp";
return ;
}
alert("无权限访问应用!!!")
// if(data == 2){
// alert("用户不存在!!!");
// return ;
// }
// if(data == 9){
// alert("用户被禁用!!!");
// return ;
// }
// if(data == 10){
// alert("未开启账号密码登录请使用USERKEY登录");
// return ;
// }
// if (data == 1) {
// alert("请输入用户名和密码")
// } else if (data == 2) {
// alert("账号或密码错误");
// } else if (data == 3) {
// alert("账号或密码错误");
// } else if (data == 9) {
// alert("用户被禁用");
// } else if (data == 10) {
// alert("未开启账号密码登陆");
// } else if (data == 200) {
// alert("用户已登录");
// } else if (data == 4) {
// window.location.href = "main.jsp";
// }
},
error: function () {
alert("请求异常,请联系管理员!!!");
}
})
}
createWebsocketLink(loginRequest);
//之前的代码
// var userName1 = document.getElementById("userName").value;
// var userPassword1 = document.getElementById("userPassword").value;
// if (userName1 == null || userName1 == "" || userPassword1 == null || userPassword1 == "") {
// alert("请输入用户名和密码");
// return;
// } else if (userName1.length < 2 || userName1.length > 16) {
// alert("账号或密码错误");
// return;
// } else if (filterCharacter(userName1)) {
// alert("账号或密码错误");
// return;
// } else if (userPassword1.length < 6) {
// alert("账号或密码错误");
// return;
// } else {
// $.ajax({
// url: "/ts-mgr/login/userLogin.do",
// type: "post",
// dataType: "text",
// data: $("#login_form").serialize(),
// success: function (data) {
// if (data == 1) {
// alert("请输入用户名和密码")
// } else if (data == 2) {
// alert("账号或密码错误");
// } else if (data == 3) {
// alert("账号或密码错误");
// } else if (data == 9) {
// alert("用户被禁用");
// } else if (data == 10) {
// alert("未开启账号密码登陆");
// } else if (data == 200) {
// alert("用户已登录");
// } else if (data == 4) {
// window.location.href = "main.jsp";
// }
// },
// error: function () {
// alert("账号和密码错误");
// }
// })
// }
}
//建立websocket链接
function createWebsocketLink(verifyidentityticketCallback) {
ws = new WebSocket("ws://127.0.0.1:30318/"); //todo...访问url,根据实际地址调整
//打开连接
ws.onopen = function () {
var label = document.getElementById("randomNumber");
var randomNumber = label.innerText.trim();
var str =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><getsignandtokenreq version=\"1\"><challenge>" +
randomNumber +
"</challenge></getsignandtokenreq>";
ws.send(str);
};
//处理响应消息
ws.onmessage = function (evt) {
var received_msg = evt.data; //received_msg为单点登录接口返回的票据数据xml格式应用根据格式解析。
var received_msg_json = $.xml2json(received_msg);
var identityticket = "";
var challenge = "";
if (received_msg_json.result === '1') { //用户标识失败
alert(received_msg_json.errorinfo);
return;
}
if (received_msg_json.result === '0') { //用户标识成功
var label = document.getElementById("randomNumber");
var identityticketInput = document.getElementById("identityticketInput");
var challengeInput = document.getElementById("challengeInput");
identityticket = received_msg_json.tokeninfo;
challenge = label.innerText.trim();
identityticketInput.value = identityticket;
challengeInput.value = challenge;
verifyidentityticketCallback(challenge, identityticket);
}
};
ws.onclose = function () {
//连接关闭消息,可不处理,或者打印调试日志
console.log("websocket连接关闭");
};
}
function keyLogin() {
if (event.keyCode == 13 || event.keyCode == 108) //回车键的键值为13
document.getElementById("s1").click(); //调用登录按钮的登录事件
}
// 第一步:获取随机数
function getRandomNumber() {
$.ajax({
url: "/ts-mgr/generatorController/generator.do",
type: "post",
success: function (data) {
//将随机数保存到页面元素中
var label = document.getElementById("randomNumber");
label.innerText = data;
},
error: function () {
console.error("获取随机数失败!!!");
}
})
}
//进入界面立即执行
getRandomNumber();
/**
*工具函数
*xml对象转json对象
*xmlObj:xml对象
*nodename:节点路径('ROOT/ITEM')
*isarray:true,强制返回数组对象
**/
function xmltojson(xmlObj, nodename, isarray) {
var obj = $(xmlObj);
var itemobj = {};
var nodenames = "";
var getAllAttrs = function (node) { //递归解析xml 转换成json对象
var _itemobj = {};
var notNull = false;
var nodechilds = node.childNodes;
var childlenght = nodechilds.length;
var _attrs = node.attributes;
var firstnodeName = "#text";
try {
firstnodeName = nodechilds[0].nodeName;
} catch (e) {}
if ((childlenght > 0 && firstnodeName != "#text") || _attrs.length > 0) {
var _childs = nodechilds;
var _childslength = nodechilds.length;
var _fileName_ = "";
if (undefined != _attrs) {
var _attrslength = _attrs.length;
for (var i = 0; i < _attrslength; i++) { //解析xml节点属性
var attrname = _attrs[i].nodeName;
var attrvalue = _attrs[i].nodeValue;
_itemobj[attrname] = attrvalue;
}
}
for (var j = 0; j < _childslength; j++) { //解析xml子节点
var _node = _childs[j];
var _fildName = _node.nodeName;
if ("#text" == _fildName) {
break;
};
if (_itemobj[_fildName] != undefined) { //如果有重复的节点需要转为数组格式
if (!(_itemobj[_fildName] instanceof Array)) {
var a = _itemobj[_fildName];
_itemobj[_fildName] = [a]; //如果该节点出现大于一个的情况 把第一个的值存放到数组中
}
}
var _fildValue = getAllAttrs(_node);
try {
_itemobj[_fildName].push(_fildValue);
} catch (e) {
_itemobj[_fildName] = _fildValue;
_itemobj["length"] = 1;
}
}
} else {
_itemobj = (node.textContent == undefined) ? node.text : node.textContent;
}
return _itemobj;
};
if (nodename) {
nodenames = nodename.split("/")
}
for (var i = 0; i < nodenames.length; i++) {
obj = obj.find(nodenames[i]);
}
$(obj).each(function (key, item) {
if (itemobj[item.nodeName] != undefined) {
if (!(itemobj[item.nodeName] instanceof Array)) {
var a = itemobj[item.nodeName];
itemobj[item.nodeName] = [a];
}
itemobj[item.nodeName].push(getAllAttrs(item));
} else {
if (nodenames.length > 0) {
itemobj[item.nodeName] = getAllAttrs(item);
} else {
itemobj[item.firstChild.nodeName] = getAllAttrs(item.firstChild);
}
}
});
if (nodenames.length > 1) {
itemobj = itemobj[nodenames[nodenames.length - 1]];
}
if (isarray && !(itemobj instanceof Array) && itemobj != undefined) {
itemobj = [itemobj];
}
return itemobj;
};
</script>
<script type="text/javascript" src="js/license.js"></script>
</html></challenge></getsignandtokenreq>, message type 1
2020/03/20 12:57:42 [I] recv: <?xml version="1.0" encoding="UTF-8"?><getsignandtokenreq version="1"><challenge><!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>时间戳服务系统</title>
<link href="http://10.106.9.206:8080/ts-mgr/css/common.css" type="text/css" rel="stylesheet">
<link href="http://10.106.9.206:8080/ts-mgr/css/login.css" type="text/css" rel="stylesheet">
<SCRIPT language="JavaScript" src="http://10.106.9.206:8080/ts-mgr/js/jquery-1.10.2.min.js"></SCRIPT>
<SCRIPT language="JavaScript" src="http://10.106.9.206:8080/ts-mgr/js/common.js"></SCRIPT>
<script type="text/javascript" src="js/judge.js"></script>
<script type="text/javascript">
/*标签切换*/
$(document).ready(function () {
$(".login_nav").each(function () {
$(this).parents(".login_box").find(".info").hide();
$("li", this).each(function (index) {
$(this).parents(".login_box").find(".info").eq(index).css("display", $(this).is(
".on") ? "block" : "none");
$(this).bind("click", function () {
$(this).addClass("on").siblings().removeClass("on");
$(this).parents(".login_box").find(".info").hide().eq(index).show();
});
});
});
});
</script>
</head>
<body onkeydown="keyLogin();">
<div class="warp_login">
<div class="login_box">
<!-- <ul class="login_nav">
<li class="on">数字证书登录</li>
<li>动态口令登录</li>
</ul>
<div class="info">
<div class="aligncenter" style=" margin-bottom:30px;"><img src="images/zhengshu.png" width="160"
height="113"></div>
<p><input type="button" class="btn_login" value="数字证书登录" onClick="window.location.href='main.html'"></p>
</div> -->
<form id="login_form">
<div class="info">
<!-- <p><input type="password1" name="userName" id="userName" class="user_input" onFocus="this.value=''"
onBlur="if(!value){value=defaultValue;}" maxlength="16"></p>
<p style=" position:relative"><input type="password" name="userPassword" id="userPassword"
class="paw_input" maxlength="16" onFocus="this.value=''"
onBlur="if(!value){value=defaultValue;}"></p>
<p style="display:none"><input type="password1" class="code_input" value="验证码"
onFocus="this.value=''" onBlur="if(!value){value=defaultValue;}">
<img src="images/pic_code.gif" width="60" height="39" align="middle"> <span><a
href="#">换一张</a></span>
</p> -->
<p style="display:none">
<label id="randomNumber"></label>
<input type="hidden" id="identityticketInput" name="identityticket"/>
<input type="hidden" id="challengeInput" name="challenge"/>
</p>
<p><input id="s1" type="button" class="btn_login" value="登 录" onclick="javascript:login()"></p>
<!-- window.location.href='main.html' -->
</div>
</form>
</div>
<div class=" fotter">Copyright 数据通信科学技术研究所</div>
</div>
</body>
<!-- <script type="text/javascript" src="js/generator.js"></script> -->
<script type="text/javascript" src="js/xml2json.js"></script>
<script type="text/javascript">
var ws = null;
//第二步点击登录时链接websocket获取验证票据值
function login() {
//第三步:验证票据获取用户标识
function verifyidentityticket(challenge, identityticket) {
$.ajax({
url: "/ts-mgr/VerifyIdentity", //todo...验签票据服务地址,需要根据实际地址调整
type: "post",
dataType: "json",
data: {
challenge: challenge,
identityticket: identityticket,
appserverid: '' //todo...这个值不知道是多少???
},
success: function (res) {
var rmsid = '';
var data = Base64.decode(res);
var dataJson = $.xml2json(data);
if (data.result == 0) {
rmsid = data.userinfo.rmsid; //todo...验签票据处获取的值,我不清楚原来的值从哪里获取???
//todo...验证用户标识
}
},
error: function () {
console.error("验签票据服务请求错误!!!");
}
})
}
function loginRequest() {
$.ajax({
url: "/ts-mgr/login/userLoginSec.do",
type: "post",
dataType: "text",
data: $("#login_form").serialize(),
success: function (data) {
if(data == 4){
window.location.href = "main.jsp";
return ;
}
alert("无权限访问应用!!!")
// if(data == 2){
// alert("用户不存在!!!");
// return ;
// }
// if(data == 9){
// alert("用户被禁用!!!");
// return ;
// }
// if(data == 10){
// alert("未开启账号密码登录请使用USERKEY登录");
// return ;
// }
// if (data == 1) {
// alert("请输入用户名和密码")
// } else if (data == 2) {
// alert("账号或密码错误");
// } else if (data == 3) {
// alert("账号或密码错误");
// } else if (data == 9) {
// alert("用户被禁用");
// } else if (data == 10) {
// alert("未开启账号密码登陆");
// } else if (data == 200) {
// alert("用户已登录");
// } else if (data == 4) {
// window.location.href = "main.jsp";
// }
},
error: function () {
alert("请求异常,请联系管理员!!!");
}
})
}
createWebsocketLink(loginRequest);
//之前的代码
// var userName1 = document.getElementById("userName").value;
// var userPassword1 = document.getElementById("userPassword").value;
// if (userName1 == null || userName1 == "" || userPassword1 == null || userPassword1 == "") {
// alert("请输入用户名和密码");
// return;
// } else if (userName1.length < 2 || userName1.length > 16) {
// alert("账号或密码错误");
// return;
// } else if (filterCharacter(userName1)) {
// alert("账号或密码错误");
// return;
// } else if (userPassword1.length < 6) {
// alert("账号或密码错误");
// return;
// } else {
// $.ajax({
// url: "/ts-mgr/login/userLogin.do",
// type: "post",
// dataType: "text",
// data: $("#login_form").serialize(),
// success: function (data) {
// if (data == 1) {
// alert("请输入用户名和密码")
// } else if (data == 2) {
// alert("账号或密码错误");
// } else if (data == 3) {
// alert("账号或密码错误");
// } else if (data == 9) {
// alert("用户被禁用");
// } else if (data == 10) {
// alert("未开启账号密码登陆");
// } else if (data == 200) {
// alert("用户已登录");
// } else if (data == 4) {
// window.location.href = "main.jsp";
// }
// },
// error: function () {
// alert("账号和密码错误");
// }
// })
// }
}
//建立websocket链接
function createWebsocketLink(verifyidentityticketCallback) {
ws = new WebSocket("ws://127.0.0.1:30318/"); //todo...访问url,根据实际地址调整
//打开连接
ws.onopen = function () {
var label = document.getElementById("randomNumber");
var randomNumber = label.innerText.trim();
var str =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><getsignandtokenreq version=\"1\"><challenge>" +
randomNumber +
"</challenge></getsignandtokenreq>";
ws.send(str);
};
//处理响应消息
ws.onmessage = function (evt) {
var received_msg = evt.data; //received_msg为单点登录接口返回的票据数据xml格式应用根据格式解析。
var received_msg_json = $.xml2json(received_msg);
var identityticket = "";
var challenge = "";
if (received_msg_json.result === '1') { //用户标识失败
alert(received_msg_json.errorinfo);
return;
}
if (received_msg_json.result === '0') { //用户标识成功
var label = document.getElementById("randomNumber");
var identityticketInput = document.getElementById("identityticketInput");
var challengeInput = document.getElementById("challengeInput");
identityticket = received_msg_json.tokeninfo;
challenge = label.innerText.trim();
identityticketInput.value = identityticket;
challengeInput.value = challenge;
verifyidentityticketCallback(challenge, identityticket);
}
};
ws.onclose = function () {
//连接关闭消息,可不处理,或者打印调试日志
console.log("websocket连接关闭");
};
}
function keyLogin() {
if (event.keyCode == 13 || event.keyCode == 108) //回车键的键值为13
document.getElementById("s1").click(); //调用登录按钮的登录事件
}
// 第一步:获取随机数
function getRandomNumber() {
$.ajax({
url: "/ts-mgr/generatorController/generator.do",
type: "post",
success: function (data) {
//将随机数保存到页面元素中
var label = document.getElementById("randomNumber");
label.innerText = data;
},
error: function () {
console.error("获取随机数失败!!!");
}
})
}
//进入界面立即执行
getRandomNumber();
/**
*工具函数
*xml对象转json对象
*xmlObj:xml对象
*nodename:节点路径('ROOT/ITEM')
*isarray:true,强制返回数组对象
**/
function xmltojson(xmlObj, nodename, isarray) {
var obj = $(xmlObj);
var itemobj = {};
var nodenames = "";
var getAllAttrs = function (node) { //递归解析xml 转换成json对象
var _itemobj = {};
var notNull = false;
var nodechilds = node.childNodes;
var childlenght = nodechilds.length;
var _attrs = node.attributes;
var firstnodeName = "#text";
try {
firstnodeName = nodechilds[0].nodeName;
} catch (e) {}
if ((childlenght > 0 && firstnodeName != "#text") || _attrs.length > 0) {
var _childs = nodechilds;
var _childslength = nodechilds.length;
var _fileName_ = "";
if (undefined != _attrs) {
var _attrslength = _attrs.length;
for (var i = 0; i < _attrslength; i++) { //解析xml节点属性
var attrname = _attrs[i].nodeName;
var attrvalue = _attrs[i].nodeValue;
_itemobj[attrname] = attrvalue;
}
}
for (var j = 0; j < _childslength; j++) { //解析xml子节点
var _node = _childs[j];
var _fildName = _node.nodeName;
if ("#text" == _fildName) {
break;
};
if (_itemobj[_fildName] != undefined) { //如果有重复的节点需要转为数组格式
if (!(_itemobj[_fildName] instanceof Array)) {
var a = _itemobj[_fildName];
_itemobj[_fildName] = [a]; //如果该节点出现大于一个的情况 把第一个的值存放到数组中
}
}
var _fildValue = getAllAttrs(_node);
try {
_itemobj[_fildName].push(_fildValue);
} catch (e) {
_itemobj[_fildName] = _fildValue;
_itemobj["length"] = 1;
}
}
} else {
_itemobj = (node.textContent == undefined) ? node.text : node.textContent;
}
return _itemobj;
};
if (nodename) {
nodenames = nodename.split("/")
}
for (var i = 0; i < nodenames.length; i++) {
obj = obj.find(nodenames[i]);
}
$(obj).each(function (key, item) {
if (itemobj[item.nodeName] != undefined) {
if (!(itemobj[item.nodeName] instanceof Array)) {
var a = itemobj[item.nodeName];
itemobj[item.nodeName] = [a];
}
itemobj[item.nodeName].push(getAllAttrs(item));
} else {
if (nodenames.length > 0) {
itemobj[item.nodeName] = getAllAttrs(item);
} else {
itemobj[item.firstChild.nodeName] = getAllAttrs(item.firstChild);
}
}
});
if (nodenames.length > 1) {
itemobj = itemobj[nodenames[nodenames.length - 1]];
}
if (isarray && !(itemobj instanceof Array) && itemobj != undefined) {
itemobj = [itemobj];
}
return itemobj;
};
</script>
<script type="text/javascript" src="js/license.js"></script>
</html></challenge></getsignandtokenreq>, message type 1
2020/03/20 12:57:45 [I] recv: <?xml version="1.0" encoding="UTF-8"?><getsignandtokenreq version="1"><challenge><!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>时间戳服务系统</title>
<link href="http://10.106.9.206:8080/ts-mgr/css/common.css" type="text/css" rel="stylesheet">
<link href="http://10.106.9.206:8080/ts-mgr/css/login.css" type="text/css" rel="stylesheet">
<SCRIPT language="JavaScript" src="http://10.106.9.206:8080/ts-mgr/js/jquery-1.10.2.min.js"></SCRIPT>
<SCRIPT language="JavaScript" src="http://10.106.9.206:8080/ts-mgr/js/common.js"></SCRIPT>
<script type="text/javascript" src="js/judge.js"></script>
<script type="text/javascript">
/*标签切换*/
$(document).ready(function () {
$(".login_nav").each(function () {
$(this).parents(".login_box").find(".info").hide();
$("li", this).each(function (index) {
$(this).parents(".login_box").find(".info").eq(index).css("display", $(this).is(
".on") ? "block" : "none");
$(this).bind("click", function () {
$(this).addClass("on").siblings().removeClass("on");
$(this).parents(".login_box").find(".info").hide().eq(index).show();
});
});
});
});
</script>
</head>
<body onkeydown="keyLogin();">
<div class="warp_login">
<div class="login_box">
<!-- <ul class="login_nav">
<li class="on">数字证书登录</li>
<li>动态口令登录</li>
</ul>
<div class="info">
<div class="aligncenter" style=" margin-bottom:30px;"><img src="images/zhengshu.png" width="160"
height="113"></div>
<p><input type="button" class="btn_login" value="数字证书登录" onClick="window.location.href='main.html'"></p>
</div> -->
<form id="login_form">
<div class="info">
<!-- <p><input type="password1" name="userName" id="userName" class="user_input" onFocus="this.value=''"
onBlur="if(!value){value=defaultValue;}" maxlength="16"></p>
<p style=" position:relative"><input type="password" name="userPassword" id="userPassword"
class="paw_input" maxlength="16" onFocus="this.value=''"
onBlur="if(!value){value=defaultValue;}"></p>
<p style="display:none"><input type="password1" class="code_input" value="验证码"
onFocus="this.value=''" onBlur="if(!value){value=defaultValue;}">
<img src="images/pic_code.gif" width="60" height="39" align="middle"> <span><a
href="#">换一张</a></span>
</p> -->
<p style="display:none">
<label id="randomNumber"></label>
<input type="hidden" id="identityticketInput" name="identityticket"/>
<input type="hidden" id="challengeInput" name="challenge"/>
</p>
<p><input id="s1" type="button" class="btn_login" value="登 录" onclick="javascript:login()"></p>
<!-- window.location.href='main.html' -->
</div>
</form>
</div>
<div class=" fotter">Copyright 数据通信科学技术研究所</div>
</div>
</body>
<!-- <script type="text/javascript" src="js/generator.js"></script> -->
<script type="text/javascript" src="js/xml2json.js"></script>
<script type="text/javascript">
var ws = null;
//第二步点击登录时链接websocket获取验证票据值
function login() {
//第三步:验证票据获取用户标识
function verifyidentityticket(challenge, identityticket) {
$.ajax({
url: "/ts-mgr/VerifyIdentity", //todo...验签票据服务地址,需要根据实际地址调整
type: "post",
dataType: "json",
data: {
challenge: challenge,
identityticket: identityticket,
appserverid: '' //todo...这个值不知道是多少???
},
success: function (res) {
var rmsid = '';
var data = Base64.decode(res);
var dataJson = $.xml2json(data);
if (data.result == 0) {
rmsid = data.userinfo.rmsid; //todo...验签票据处获取的值,我不清楚原来的值从哪里获取???
//todo...验证用户标识
}
},
error: function () {
console.error("验签票据服务请求错误!!!");
}
})
}
function loginRequest() {
$.ajax({
url: "/ts-mgr/login/userLoginSec.do",
type: "post",
dataType: "text",
data: $("#login_form").serialize(),
success: function (data) {
if(data == 4){
window.location.href = "main.jsp";
return ;
}
alert("无权限访问应用!!!")
// if(data == 2){
// alert("用户不存在!!!");
// return ;
// }
// if(data == 9){
// alert("用户被禁用!!!");
// return ;
// }
// if(data == 10){
// alert("未开启账号密码登录请使用USERKEY登录");
// return ;
// }
// if (data == 1) {
// alert("请输入用户名和密码")
// } else if (data == 2) {
// alert("账号或密码错误");
// } else if (data == 3) {
// alert("账号或密码错误");
// } else if (data == 9) {
// alert("用户被禁用");
// } else if (data == 10) {
// alert("未开启账号密码登陆");
// } else if (data == 200) {
// alert("用户已登录");
// } else if (data == 4) {
// window.location.href = "main.jsp";
// }
},
error: function () {
alert("请求异常,请联系管理员!!!");
}
})
}
createWebsocketLink(loginRequest);
//之前的代码
// var userName1 = document.getElementById("userName").value;
// var userPassword1 = document.getElementById("userPassword").value;
// if (userName1 == null || userName1 == "" || userPassword1 == null || userPassword1 == "") {
// alert("请输入用户名和密码");
// return;
// } else if (userName1.length < 2 || userName1.length > 16) {
// alert("账号或密码错误");
// return;
// } else if (filterCharacter(userName1)) {
// alert("账号或密码错误");
// return;
// } else if (userPassword1.length < 6) {
// alert("账号或密码错误");
// return;
// } else {
// $.ajax({
// url: "/ts-mgr/login/userLogin.do",
// type: "post",
// dataType: "text",
// data: $("#login_form").serialize(),
// success: function (data) {
// if (data == 1) {
// alert("请输入用户名和密码")
// } else if (data == 2) {
// alert("账号或密码错误");
// } else if (data == 3) {
// alert("账号或密码错误");
// } else if (data == 9) {
// alert("用户被禁用");
// } else if (data == 10) {
// alert("未开启账号密码登陆");
// } else if (data == 200) {
// alert("用户已登录");
// } else if (data == 4) {
// window.location.href = "main.jsp";
// }
// },
// error: function () {
// alert("账号和密码错误");
// }
// })
// }
}
//建立websocket链接
function createWebsocketLink(verifyidentityticketCallback) {
ws = new WebSocket("ws://127.0.0.1:30318/"); //todo...访问url,根据实际地址调整
//打开连接
ws.onopen = function () {
var label = document.getElementById("randomNumber");
var randomNumber = label.innerText.trim();
var str =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><getsignandtokenreq version=\"1\"><challenge>" +
randomNumber +
"</challenge></getsignandtokenreq>";
ws.send(str);
};
//处理响应消息
ws.onmessage = function (evt) {
var received_msg = evt.data; //received_msg为单点登录接口返回的票据数据xml格式应用根据格式解析。
var received_msg_json = $.xml2json(received_msg);
var identityticket = "";
var challenge = "";
if (received_msg_json.result === '1') { //用户标识失败
alert(received_msg_json.errorinfo);
return;
}
if (received_msg_json.result === '0') { //用户标识成功
var label = document.getElementById("randomNumber");
var identityticketInput = document.getElementById("identityticketInput");
var challengeInput = document.getElementById("challengeInput");
identityticket = received_msg_json.tokeninfo;
challenge = label.innerText.trim();
identityticketInput.value = identityticket;
challengeInput.value = challenge;
verifyidentityticketCallback(challenge, identityticket);
}
};
ws.onclose = function () {
//连接关闭消息,可不处理,或者打印调试日志
console.log("websocket连接关闭");
};
}
function keyLogin() {
if (event.keyCode == 13 || event.keyCode == 108) //回车键的键值为13
document.getElementById("s1").click(); //调用登录按钮的登录事件
}
// 第一步:获取随机数
function getRandomNumber() {
$.ajax({
url: "/ts-mgr/generatorController/generator.do",
type: "post",
success: function (data) {
//将随机数保存到页面元素中
var label = document.getElementById("randomNumber");
label.innerText = data;
},
error: function () {
console.error("获取随机数失败!!!");
}
})
}
//进入界面立即执行
getRandomNumber();
/**
*工具函数
*xml对象转json对象
*xmlObj:xml对象
*nodename:节点路径('ROOT/ITEM')
*isarray:true,强制返回数组对象
**/
function xmltojson(xmlObj, nodename, isarray) {
var obj = $(xmlObj);
var itemobj = {};
var nodenames = "";
var getAllAttrs = function (node) { //递归解析xml 转换成json对象
var _itemobj = {};
var notNull = false;
var nodechilds = node.childNodes;
var childlenght = nodechilds.length;
var _attrs = node.attributes;
var firstnodeName = "#text";
try {
firstnodeName = nodechilds[0].nodeName;
} catch (e) {}
if ((childlenght > 0 && firstnodeName != "#text") || _attrs.length > 0) {
var _childs = nodechilds;
var _childslength = nodechilds.length;
var _fileName_ = "";
if (undefined != _attrs) {
var _attrslength = _attrs.length;
for (var i = 0; i < _attrslength; i++) { //解析xml节点属性
var attrname = _attrs[i].nodeName;
var attrvalue = _attrs[i].nodeValue;
_itemobj[attrname] = attrvalue;
}
}
for (var j = 0; j < _childslength; j++) { //解析xml子节点
var _node = _childs[j];
var _fildName = _node.nodeName;
if ("#text" == _fildName) {
break;
};
if (_itemobj[_fildName] != undefined) { //如果有重复的节点需要转为数组格式
if (!(_itemobj[_fildName] instanceof Array)) {
var a = _itemobj[_fildName];
_itemobj[_fildName] = [a]; //如果该节点出现大于一个的情况 把第一个的值存放到数组中
}
}
var _fildValue = getAllAttrs(_node);
try {
_itemobj[_fildName].push(_fildValue);
} catch (e) {
_itemobj[_fildName] = _fildValue;
_itemobj["length"] = 1;
}
}
} else {
_itemobj = (node.textContent == undefined) ? node.text : node.textContent;
}
return _itemobj;
};
if (nodename) {
nodenames = nodename.split("/")
}
for (var i = 0; i < nodenames.length; i++) {
obj = obj.find(nodenames[i]);
}
$(obj).each(function (key, item) {
if (itemobj[item.nodeName] != undefined) {
if (!(itemobj[item.nodeName] instanceof Array)) {
var a = itemobj[item.nodeName];
itemobj[item.nodeName] = [a];
}
itemobj[item.nodeName].push(getAllAttrs(item));
} else {
if (nodenames.length > 0) {
itemobj[item.nodeName] = getAllAttrs(item);
} else {
itemobj[item.firstChild.nodeName] = getAllAttrs(item.firstChild);
}
}
});
if (nodenames.length > 1) {
itemobj = itemobj[nodenames[nodenames.length - 1]];
}
if (isarray && !(itemobj instanceof Array) && itemobj != undefined) {
itemobj = [itemobj];
}
return itemobj;
};
</script>
<script type="text/javascript" src="js/license.js"></script>
</html></challenge></getsignandtokenreq>, message type 1
2020/03/20 12:58:05 [I] recv: <?xml version="1.0" encoding="UTF-8"?><getsignandtokenreq version="1"><challenge><!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>时间戳服务系统</title>
<link href="http://10.106.9.206:8080/ts-mgr/css/common.css" type="text/css" rel="stylesheet">
<link href="http://10.106.9.206:8080/ts-mgr/css/login.css" type="text/css" rel="stylesheet">
<SCRIPT language="JavaScript" src="http://10.106.9.206:8080/ts-mgr/js/jquery-1.10.2.min.js"></SCRIPT>
<SCRIPT language="JavaScript" src="http://10.106.9.206:8080/ts-mgr/js/common.js"></SCRIPT>
<script type="text/javascript" src="js/judge.js"></script>
<script type="text/javascript">
/*标签切换*/
$(document).ready(function () {
$(".login_nav").each(function () {
$(this).parents(".login_box").find(".info").hide();
$("li", this).each(function (index) {
$(this).parents(".login_box").find(".info").eq(index).css("display", $(this).is(
".on") ? "block" : "none");
$(this).bind("click", function () {
$(this).addClass("on").siblings().removeClass("on");
$(this).parents(".login_box").find(".info").hide().eq(index).show();
});
});
});
});
</script>
</head>
<body onkeydown="keyLogin();">
<div class="warp_login">
<div class="login_box">
<!-- <ul class="login_nav">
<li class="on">数字证书登录</li>
<li>动态口令登录</li>
</ul>
<div class="info">
<div class="aligncenter" style=" margin-bottom:30px;"><img src="images/zhengshu.png" width="160"
height="113"></div>
<p><input type="button" class="btn_login" value="数字证书登录" onClick="window.location.href='main.html'"></p>
</div> -->
<form id="login_form">
<div class="info">
<!-- <p><input type="password1" name="userName" id="userName" class="user_input" onFocus="this.value=''"
onBlur="if(!value){value=defaultValue;}" maxlength="16"></p>
<p style=" position:relative"><input type="password" name="userPassword" id="userPassword"
class="paw_input" maxlength="16" onFocus="this.value=''"
onBlur="if(!value){value=defaultValue;}"></p>
<p style="display:none"><input type="password1" class="code_input" value="验证码"
onFocus="this.value=''" onBlur="if(!value){value=defaultValue;}">
<img src="images/pic_code.gif" width="60" height="39" align="middle"> <span><a
href="#">换一张</a></span>
</p> -->
<p style="display:none">
<label id="randomNumber"></label>
<input type="hidden" id="identityticketInput" name="identityticket"/>
<input type="hidden" id="challengeInput" name="challenge"/>
</p>
<p><input id="s1" type="button" class="btn_login" value="登 录" onclick="javascript:login()"></p>
<!-- window.location.href='main.html' -->
</div>
</form>
</div>
<div class=" fotter">Copyright 数据通信科学技术研究所</div>
</div>
</body>
<!-- <script type="text/javascript" src="js/generator.js"></script> -->
<script type="text/javascript" src="js/xml2json.js"></script>
<script type="text/javascript">
var ws = null;
//第二步点击登录时链接websocket获取验证票据值
function login() {
//第三步:验证票据获取用户标识
function verifyidentityticket(challenge, identityticket) {
$.ajax({
url: "/ts-mgr/VerifyIdentity", //todo...验签票据服务地址,需要根据实际地址调整
type: "post",
dataType: "json",
data: {
challenge: challenge,
identityticket: identityticket,
appserverid: '' //todo...这个值不知道是多少???
},
success: function (res) {
var rmsid = '';
var data = Base64.decode(res);
var dataJson = $.xml2json(data);
if (data.result == 0) {
rmsid = data.userinfo.rmsid; //todo...验签票据处获取的值,我不清楚原来的值从哪里获取???
//todo...验证用户标识
}
},
error: function () {
console.error("验签票据服务请求错误!!!");
}
})
}
function loginRequest() {
$.ajax({
url: "/ts-mgr/login/userLoginSec.do",
type: "post",
dataType: "text",
data: $("#login_form").serialize(),
success: function (data) {
if(data == 4){
window.location.href = "main.jsp";
return ;
}
alert("无权限访问应用!!!")
// if(data == 2){
// alert("用户不存在!!!");
// return ;
// }
// if(data == 9){
// alert("用户被禁用!!!");
// return ;
// }
// if(data == 10){
// alert("未开启账号密码登录请使用USERKEY登录");
// return ;
// }
// if (data == 1) {
// alert("请输入用户名和密码")
// } else if (data == 2) {
// alert("账号或密码错误");
// } else if (data == 3) {
// alert("账号或密码错误");
// } else if (data == 9) {
// alert("用户被禁用");
// } else if (data == 10) {
// alert("未开启账号密码登陆");
// } else if (data == 200) {
// alert("用户已登录");
// } else if (data == 4) {
// window.location.href = "main.jsp";
// }
},
error: function () {
alert("请求异常,请联系管理员!!!");
}
})
}
createWebsocketLink(loginRequest);
//之前的代码
// var userName1 = document.getElementById("userName").value;
// var userPassword1 = document.getElementById("userPassword").value;
// if (userName1 == null || userName1 == "" || userPassword1 == null || userPassword1 == "") {
// alert("请输入用户名和密码");
// return;
// } else if (userName1.length < 2 || userName1.length > 16) {
// alert("账号或密码错误");
// return;
// } else if (filterCharacter(userName1)) {
// alert("账号或密码错误");
// return;
// } else if (userPassword1.length < 6) {
// alert("账号或密码错误");
// return;
// } else {
// $.ajax({
// url: "/ts-mgr/login/userLogin.do",
// type: "post",
// dataType: "text",
// data: $("#login_form").serialize(),
// success: function (data) {
// if (data == 1) {
// alert("请输入用户名和密码")
// } else if (data == 2) {
// alert("账号或密码错误");
// } else if (data == 3) {
// alert("账号或密码错误");
// } else if (data == 9) {
// alert("用户被禁用");
// } else if (data == 10) {
// alert("未开启账号密码登陆");
// } else if (data == 200) {
// alert("用户已登录");
// } else if (data == 4) {
// window.location.href = "main.jsp";
// }
// },
// error: function () {
// alert("账号和密码错误");
// }
// })
// }
}
//建立websocket链接
function createWebsocketLink(verifyidentityticketCallback) {
ws = new WebSocket("ws://127.0.0.1:30318/"); //todo...访问url,根据实际地址调整
//打开连接
ws.onopen = function () {
var label = document.getElementById("randomNumber");
var randomNumber = label.innerText.trim();
var str =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><getsignandtokenreq version=\"1\"><challenge>" +
randomNumber +
"</challenge></getsignandtokenreq>";
ws.send(str);
};
//处理响应消息
ws.onmessage = function (evt) {
var received_msg = evt.data; //received_msg为单点登录接口返回的票据数据xml格式应用根据格式解析。
var received_msg_json = $.xml2json(received_msg);
var identityticket = "";
var challenge = "";
if (received_msg_json.result === '1') { //用户标识失败
alert(received_msg_json.errorinfo);
return;
}
if (received_msg_json.result === '0') { //用户标识成功
var label = document.getElementById("randomNumber");
var identityticketInput = document.getElementById("identityticketInput");
var challengeInput = document.getElementById("challengeInput");
identityticket = received_msg_json.tokeninfo;
challenge = label.innerText.trim();
identityticketInput.value = identityticket;
challengeInput.value = challenge;
verifyidentityticketCallback(challenge, identityticket);
}
};
ws.onclose = function () {
//连接关闭消息,可不处理,或者打印调试日志
console.log("websocket连接关闭");
};
}
function keyLogin() {
if (event.keyCode == 13 || event.keyCode == 108) //回车键的键值为13
document.getElementById("s1").click(); //调用登录按钮的登录事件
}
// 第一步:获取随机数
function getRandomNumber() {
$.ajax({
url: "/ts-mgr/generatorController/generator.do",
type: "post",
success: function (data) {
//将随机数保存到页面元素中
var label = document.getElementById("randomNumber");
label.innerText = data;
},
error: function () {
console.error("获取随机数失败!!!");
}
})
}
//进入界面立即执行
getRandomNumber();
/**
*工具函数
*xml对象转json对象
*xmlObj:xml对象
*nodename:节点路径('ROOT/ITEM')
*isarray:true,强制返回数组对象
**/
function xmltojson(xmlObj, nodename, isarray) {
var obj = $(xmlObj);
var itemobj = {};
var nodenames = "";
var getAllAttrs = function (node) { //递归解析xml 转换成json对象
var _itemobj = {};
var notNull = false;
var nodechilds = node.childNodes;
var childlenght = nodechilds.length;
var _attrs = node.attributes;
var firstnodeName = "#text";
try {
firstnodeName = nodechilds[0].nodeName;
} catch (e) {}
if ((childlenght > 0 && firstnodeName != "#text") || _attrs.length > 0) {
var _childs = nodechilds;
var _childslength = nodechilds.length;
var _fileName_ = "";
if (undefined != _attrs) {
var _attrslength = _attrs.length;
for (var i = 0; i < _attrslength; i++) { //解析xml节点属性
var attrname = _attrs[i].nodeName;
var attrvalue = _attrs[i].nodeValue;
_itemobj[attrname] = attrvalue;
}
}
for (var j = 0; j < _childslength; j++) { //解析xml子节点
var _node = _childs[j];
var _fildName = _node.nodeName;
if ("#text" == _fildName) {
break;
};
if (_itemobj[_fildName] != undefined) { //如果有重复的节点需要转为数组格式
if (!(_itemobj[_fildName] instanceof Array)) {
var a = _itemobj[_fildName];
_itemobj[_fildName] = [a]; //如果该节点出现大于一个的情况 把第一个的值存放到数组中
}
}
var _fildValue = getAllAttrs(_node);
try {
_itemobj[_fildName].push(_fildValue);
} catch (e) {
_itemobj[_fildName] = _fildValue;
_itemobj["length"] = 1;
}
}
} else {
_itemobj = (node.textContent == undefined) ? node.text : node.textContent;
}
return _itemobj;
};
if (nodename) {
nodenames = nodename.split("/")
}
for (var i = 0; i < nodenames.length; i++) {
obj = obj.find(nodenames[i]);
}
$(obj).each(function (key, item) {
if (itemobj[item.nodeName] != undefined) {
if (!(itemobj[item.nodeName] instanceof Array)) {
var a = itemobj[item.nodeName];
itemobj[item.nodeName] = [a];
}
itemobj[item.nodeName].push(getAllAttrs(item));
} else {
if (nodenames.length > 0) {
itemobj[item.nodeName] = getAllAttrs(item);
} else {
itemobj[item.firstChild.nodeName] = getAllAttrs(item.firstChild);
}
}
});
if (nodenames.length > 1) {
itemobj = itemobj[nodenames[nodenames.length - 1]];
}
if (isarray && !(itemobj instanceof Array) && itemobj != undefined) {
itemobj = [itemobj];
}
return itemobj;
};
</script>
<script type="text/javascript" src="js/license.js"></script>
</html></challenge></getsignandtokenreq>, message type 1
2020/03/20 12:58:13 [I] recv: <?xml version="1.0" encoding="UTF-8"?><getsignandtokenreq version="1"><challenge><!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>时间戳服务系统</title>
<link href="http://10.106.9.206:8080/ts-mgr/css/common.css" type="text/css" rel="stylesheet">
<link href="http://10.106.9.206:8080/ts-mgr/css/login.css" type="text/css" rel="stylesheet">
<SCRIPT language="JavaScript" src="http://10.106.9.206:8080/ts-mgr/js/jquery-1.10.2.min.js"></SCRIPT>
<SCRIPT language="JavaScript" src="http://10.106.9.206:8080/ts-mgr/js/common.js"></SCRIPT>
<script type="text/javascript" src="js/judge.js"></script>
<script type="text/javascript">
/*标签切换*/
$(document).ready(function () {
$(".login_nav").each(function () {
$(this).parents(".login_box").find(".info").hide();
$("li", this).each(function (index) {
$(this).parents(".login_box").find(".info").eq(index).css("display", $(this).is(
".on") ? "block" : "none");
$(this).bind("click", function () {
$(this).addClass("on").siblings().removeClass("on");
$(this).parents(".login_box").find(".info").hide().eq(index).show();
});
});
});
});
</script>
</head>
<body onkeydown="keyLogin();">
<div class="warp_login">
<div class="login_box">
<!-- <ul class="login_nav">
<li class="on">数字证书登录</li>
<li>动态口令登录</li>
</ul>
<div class="info">
<div class="aligncenter" style=" margin-bottom:30px;"><img src="images/zhengshu.png" width="160"
height="113"></div>
<p><input type="button" class="btn_login" value="数字证书登录" onClick="window.location.href='main.html'"></p>
</div> -->
<form id="login_form">
<div class="info">
<!-- <p><input type="password1" name="userName" id="userName" class="user_input" onFocus="this.value=''"
onBlur="if(!value){value=defaultValue;}" maxlength="16"></p>
<p style=" position:relative"><input type="password" name="userPassword" id="userPassword"
class="paw_input" maxlength="16" onFocus="this.value=''"
onBlur="if(!value){value=defaultValue;}"></p>
<p style="display:none"><input type="password1" class="code_input" value="验证码"
onFocus="this.value=''" onBlur="if(!value){value=defaultValue;}">
<img src="images/pic_code.gif" width="60" height="39" align="middle"> <span><a
href="#">换一张</a></span>
</p> -->
<p style="display:none">
<label id="randomNumber"></label>
<input type="hidden" id="identityticketInput" name="identityticket"/>
<input type="hidden" id="challengeInput" name="challenge"/>
</p>
<p><input id="s1" type="button" class="btn_login" value="登 录" onclick="javascript:login()"></p>
<!-- window.location.href='main.html' -->
</div>
</form>
</div>
<div class=" fotter">Copyright 数据通信科学技术研究所</div>
</div>
</body>
<!-- <script type="text/javascript" src="js/generator.js"></script> -->
<script type="text/javascript" src="js/xml2json.js"></script>
<script type="text/javascript">
var ws = null;
//第二步点击登录时链接websocket获取验证票据值
function login() {
//第三步:验证票据获取用户标识
function verifyidentityticket(challenge, identityticket) {
$.ajax({
url: "/ts-mgr/VerifyIdentity", //todo...验签票据服务地址,需要根据实际地址调整
type: "post",
dataType: "json",
data: {
challenge: challenge,
identityticket: identityticket,
appserverid: '' //todo...这个值不知道是多少???
},
success: function (res) {
var rmsid = '';
var data = Base64.decode(res);
var dataJson = $.xml2json(data);
if (data.result == 0) {
rmsid = data.userinfo.rmsid; //todo...验签票据处获取的值,我不清楚原来的值从哪里获取???
//todo...验证用户标识
}
},
error: function () {
console.error("验签票据服务请求错误!!!");
}
})
}
function loginRequest() {
$.ajax({
url: "/ts-mgr/login/userLoginSec.do",
type: "post",
dataType: "text",
data: $("#login_form").serialize(),
success: function (data) {
if(data == 4){
window.location.href = "main.jsp";
return ;
}
alert("无权限访问应用!!!")
// if(data == 2){
// alert("用户不存在!!!");
// return ;
// }
// if(data == 9){
// alert("用户被禁用!!!");
// return ;
// }
// if(data == 10){
// alert("未开启账号密码登录请使用USERKEY登录");
// return ;
// }
// if (data == 1) {
// alert("请输入用户名和密码")
// } else if (data == 2) {
// alert("账号或密码错误");
// } else if (data == 3) {
// alert("账号或密码错误");
// } else if (data == 9) {
// alert("用户被禁用");
// } else if (data == 10) {
// alert("未开启账号密码登陆");
// } else if (data == 200) {
// alert("用户已登录");
// } else if (data == 4) {
// window.location.href = "main.jsp";
// }
},
error: function () {
alert("请求异常,请联系管理员!!!");
}
})
}
createWebsocketLink(loginRequest);
//之前的代码
// var userName1 = document.getElementById("userName").value;
// var userPassword1 = document.getElementById("userPassword").value;
// if (userName1 == null || userName1 == "" || userPassword1 == null || userPassword1 == "") {
// alert("请输入用户名和密码");
// return;
// } else if (userName1.length < 2 || userName1.length > 16) {
// alert("账号或密码错误");
// return;
// } else if (filterCharacter(userName1)) {
// alert("账号或密码错误");
// return;
// } else if (userPassword1.length < 6) {
// alert("账号或密码错误");
// return;
// } else {
// $.ajax({
// url: "/ts-mgr/login/userLogin.do",
// type: "post",
// dataType: "text",
// data: $("#login_form").serialize(),
// success: function (data) {
// if (data == 1) {
// alert("请输入用户名和密码")
// } else if (data == 2) {
// alert("账号或密码错误");
// } else if (data == 3) {
// alert("账号或密码错误");
// } else if (data == 9) {
// alert("用户被禁用");
// } else if (data == 10) {
// alert("未开启账号密码登陆");
// } else if (data == 200) {
// alert("用户已登录");
// } else if (data == 4) {
// window.location.href = "main.jsp";
// }
// },
// error: function () {
// alert("账号和密码错误");
// }
// })
// }
}
//建立websocket链接
function createWebsocketLink(verifyidentityticketCallback) {
ws = new WebSocket("ws://127.0.0.1:30318/"); //todo...访问url,根据实际地址调整
//打开连接
ws.onopen = function () {
var label = document.getElementById("randomNumber");
var randomNumber = label.innerText.trim();
var str =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><getsignandtokenreq version=\"1\"><challenge>" +
randomNumber +
"</challenge></getsignandtokenreq>";
ws.send(str);
};
//处理响应消息
ws.onmessage = function (evt) {
var received_msg = evt.data; //received_msg为单点登录接口返回的票据数据xml格式应用根据格式解析。
var received_msg_json = $.xml2json(received_msg);
var identityticket = "";
var challenge = "";
if (received_msg_json.result === '1') { //用户标识失败
alert(received_msg_json.errorinfo);
return;
}
if (received_msg_json.result === '0') { //用户标识成功
var label = document.getElementById("randomNumber");
var identityticketInput = document.getElementById("identityticketInput");
var challengeInput = document.getElementById("challengeInput");
identityticket = received_msg_json.tokeninfo;
challenge = label.innerText.trim();
identityticketInput.value = identityticket;
challengeInput.value = challenge;
verifyidentityticketCallback(challenge, identityticket);
}
};
ws.onclose = function () {
//连接关闭消息,可不处理,或者打印调试日志
console.log("websocket连接关闭");
};
}
function keyLogin() {
if (event.keyCode == 13 || event.keyCode == 108) //回车键的键值为13
document.getElementById("s1").click(); //调用登录按钮的登录事件
}
// 第一步:获取随机数
function getRandomNumber() {
$.ajax({
url: "/ts-mgr/generatorController/generator.do",
type: "post",
success: function (data) {
//将随机数保存到页面元素中
var label = document.getElementById("randomNumber");
label.innerText = data;
},
error: function () {
console.error("获取随机数失败!!!");
}
})
}
//进入界面立即执行
getRandomNumber();
/**
*工具函数
*xml对象转json对象
*xmlObj:xml对象
*nodename:节点路径('ROOT/ITEM')
*isarray:true,强制返回数组对象
**/
function xmltojson(xmlObj, nodename, isarray) {
var obj = $(xmlObj);
var itemobj = {};
var nodenames = "";
var getAllAttrs = function (node) { //递归解析xml 转换成json对象
var _itemobj = {};
var notNull = false;
var nodechilds = node.childNodes;
var childlenght = nodechilds.length;
var _attrs = node.attributes;
var firstnodeName = "#text";
try {
firstnodeName = nodechilds[0].nodeName;
} catch (e) {}
if ((childlenght > 0 && firstnodeName != "#text") || _attrs.length > 0) {
var _childs = nodechilds;
var _childslength = nodechilds.length;
var _fileName_ = "";
if (undefined != _attrs) {
var _attrslength = _attrs.length;
for (var i = 0; i < _attrslength; i++) { //解析xml节点属性
var attrname = _attrs[i].nodeName;
var attrvalue = _attrs[i].nodeValue;
_itemobj[attrname] = attrvalue;
}
}
for (var j = 0; j < _childslength; j++) { //解析xml子节点
var _node = _childs[j];
var _fildName = _node.nodeName;
if ("#text" == _fildName) {
break;
};
if (_itemobj[_fildName] != undefined) { //如果有重复的节点需要转为数组格式
if (!(_itemobj[_fildName] instanceof Array)) {
var a = _itemobj[_fildName];
_itemobj[_fildName] = [a]; //如果该节点出现大于一个的情况 把第一个的值存放到数组中
}
}
var _fildValue = getAllAttrs(_node);
try {
_itemobj[_fildName].push(_fildValue);
} catch (e) {
_itemobj[_fildName] = _fildValue;
_itemobj["length"] = 1;
}
}
} else {
_itemobj = (node.textContent == undefined) ? node.text : node.textContent;
}
return _itemobj;
};
if (nodename) {
nodenames = nodename.split("/")
}
for (var i = 0; i < nodenames.length; i++) {
obj = obj.find(nodenames[i]);
}
$(obj).each(function (key, item) {
if (itemobj[item.nodeName] != undefined) {
if (!(itemobj[item.nodeName] instanceof Array)) {
var a = itemobj[item.nodeName];
itemobj[item.nodeName] = [a];
}
itemobj[item.nodeName].push(getAllAttrs(item));
} else {
if (nodenames.length > 0) {
itemobj[item.nodeName] = getAllAttrs(item);
} else {
itemobj[item.firstChild.nodeName] = getAllAttrs(item.firstChild);
}
}
});
if (nodenames.length > 1) {
itemobj = itemobj[nodenames[nodenames.length - 1]];
}
if (isarray && !(itemobj instanceof Array) && itemobj != undefined) {
itemobj = [itemobj];
}
return itemobj;
};
</script>
<script type="text/javascript" src="js/license.js"></script>
</html></challenge></getsignandtokenreq>, message type 1
2020/03/20 12:58:34 [I] recv: <?xml version="1.0" encoding="UTF-8"?><getsignandtokenreq version="1"><challenge><!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>时间戳服务系统</title>
<link href="http://10.106.9.206:8080/ts-mgr/css/common.css" type="text/css" rel="stylesheet">
<link href="http://10.106.9.206:8080/ts-mgr/css/login.css" type="text/css" rel="stylesheet">
<SCRIPT language="JavaScript" src="http://10.106.9.206:8080/ts-mgr/js/jquery-1.10.2.min.js"></SCRIPT>
<SCRIPT language="JavaScript" src="http://10.106.9.206:8080/ts-mgr/js/common.js"></SCRIPT>
<script type="text/javascript" src="js/judge.js"></script>
<script type="text/javascript">
/*标签切换*/
$(document).ready(function () {
$(".login_nav").each(function () {
$(this).parents(".login_box").find(".info").hide();
$("li", this).each(function (index) {
$(this).parents(".login_box").find(".info").eq(index).css("display", $(this).is(
".on") ? "block" : "none");
$(this).bind("click", function () {
$(this).addClass("on").siblings().removeClass("on");
$(this).parents(".login_box").find(".info").hide().eq(index).show();
});
});
});
});
</script>
</head>
<body onkeydown="keyLogin();">
<div class="warp_login">
<div class="login_box">
<!-- <ul class="login_nav">
<li class="on">数字证书登录</li>
<li>动态口令登录</li>
</ul>
<div class="info">
<div class="aligncenter" style=" margin-bottom:30px;"><img src="images/zhengshu.png" width="160"
height="113"></div>
<p><input type="button" class="btn_login" value="数字证书登录" onClick="window.location.href='main.html'"></p>
</div> -->
<form id="login_form">
<div class="info">
<!-- <p><input type="password1" name="userName" id="userName" class="user_input" onFocus="this.value=''"
onBlur="if(!value){value=defaultValue;}" maxlength="16"></p>
<p style=" position:relative"><input type="password" name="userPassword" id="userPassword"
class="paw_input" maxlength="16" onFocus="this.value=''"
onBlur="if(!value){value=defaultValue;}"></p>
<p style="display:none"><input type="password1" class="code_input" value="验证码"
onFocus="this.value=''" onBlur="if(!value){value=defaultValue;}">
<img src="images/pic_code.gif" width="60" height="39" align="middle"> <span><a
href="#">换一张</a></span>
</p> -->
<p style="display:none">
<label id="randomNumber"></label>
<input type="hidden" id="identityticketInput" name="identityticket"/>
<input type="hidden" id="challengeInput" name="challenge"/>
</p>
<p><input id="s1" type="button" class="btn_login" value="登 录" onclick="javascript:login()"></p>
<!-- window.location.href='main.html' -->
</div>
</form>
</div>
<div class=" fotter">Copyright 数据通信科学技术研究所</div>
</div>
</body>
<!-- <script type="text/javascript" src="js/generator.js"></script> -->
<script type="text/javascript" src="js/xml2json.js"></script>
<script type="text/javascript">
var ws = null;
//第二步点击登录时链接websocket获取验证票据值
function login() {
//第三步:验证票据获取用户标识
function verifyidentityticket(challenge, identityticket) {
$.ajax({
url: "/ts-mgr/VerifyIdentity", //todo...验签票据服务地址,需要根据实际地址调整
type: "post",
dataType: "json",
data: {
challenge: challenge,
identityticket: identityticket,
appserverid: '' //todo...这个值不知道是多少???
},
success: function (res) {
var rmsid = '';
var data = Base64.decode(res);
var dataJson = $.xml2json(data);
if (data.result == 0) {
rmsid = data.userinfo.rmsid; //todo...验签票据处获取的值,我不清楚原来的值从哪里获取???
//todo...验证用户标识
}
},
error: function () {
console.error("验签票据服务请求错误!!!");
}
})
}
function loginRequest() {
$.ajax({
url: "/ts-mgr/login/userLoginSec.do",
type: "post",
dataType: "text",
data: $("#login_form").serialize(),
success: function (data) {
if(data == 4){
window.location.href = "main.jsp";
return ;
}
alert("无权限访问应用!!!")
// if(data == 2){
// alert("用户不存在!!!");
// return ;
// }
// if(data == 9){
// alert("用户被禁用!!!");
// return ;
// }
// if(data == 10){
// alert("未开启账号密码登录请使用USERKEY登录");
// return ;
// }
// if (data == 1) {
// alert("请输入用户名和密码")
// } else if (data == 2) {
// alert("账号或密码错误");
// } else if (data == 3) {
// alert("账号或密码错误");
// } else if (data == 9) {
// alert("用户被禁用");
// } else if (data == 10) {
// alert("未开启账号密码登陆");
// } else if (data == 200) {
// alert("用户已登录");
// } else if (data == 4) {
// window.location.href = "main.jsp";
// }
},
error: function () {
alert("请求异常,请联系管理员!!!");
}
})
}
createWebsocketLink(loginRequest);
//之前的代码
// var userName1 = document.getElementById("userName").value;
// var userPassword1 = document.getElementById("userPassword").value;
// if (userName1 == null || userName1 == "" || userPassword1 == null || userPassword1 == "") {
// alert("请输入用户名和密码");
// return;
// } else if (userName1.length < 2 || userName1.length > 16) {
// alert("账号或密码错误");
// return;
// } else if (filterCharacter(userName1)) {
// alert("账号或密码错误");
// return;
// } else if (userPassword1.length < 6) {
// alert("账号或密码错误");
// return;
// } else {
// $.ajax({
// url: "/ts-mgr/login/userLogin.do",
// type: "post",
// dataType: "text",
// data: $("#login_form").serialize(),
// success: function (data) {
// if (data == 1) {
// alert("请输入用户名和密码")
// } else if (data == 2) {
// alert("账号或密码错误");
// } else if (data == 3) {
// alert("账号或密码错误");
// } else if (data == 9) {
// alert("用户被禁用");
// } else if (data == 10) {
// alert("未开启账号密码登陆");
// } else if (data == 200) {
// alert("用户已登录");
// } else if (data == 4) {
// window.location.href = "main.jsp";
// }
// },
// error: function () {
// alert("账号和密码错误");
// }
// })
// }
}
//建立websocket链接
function createWebsocketLink(verifyidentityticketCallback) {
ws = new WebSocket("ws://127.0.0.1:30318/"); //todo...访问url,根据实际地址调整
//打开连接
ws.onopen = function () {
var label = document.getElementById("randomNumber");
var randomNumber = label.innerText.trim();
var str =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><getsignandtokenreq version=\"1\"><challenge>" +
randomNumber +
"</challenge></getsignandtokenreq>";
ws.send(str);
};
//处理响应消息
ws.onmessage = function (evt) {
var received_msg = evt.data; //received_msg为单点登录接口返回的票据数据xml格式应用根据格式解析。
var received_msg_json = $.xml2json(received_msg);
var identityticket = "";
var challenge = "";
if (received_msg_json.result === '1') { //用户标识失败
alert(received_msg_json.errorinfo);
return;
}
if (received_msg_json.result === '0') { //用户标识成功
var label = document.getElementById("randomNumber");
var identityticketInput = document.getElementById("identityticketInput");
var challengeInput = document.getElementById("challengeInput");
identityticket = received_msg_json.tokeninfo;
challenge = label.innerText.trim();
identityticketInput.value = identityticket;
challengeInput.value = challenge;
verifyidentityticketCallback(challenge, identityticket);
}
};
ws.onclose = function () {
//连接关闭消息,可不处理,或者打印调试日志
console.log("websocket连接关闭");
};
}
function keyLogin() {
if (event.keyCode == 13 || event.keyCode == 108) //回车键的键值为13
document.getElementById("s1").click(); //调用登录按钮的登录事件
}
// 第一步:获取随机数
function getRandomNumber() {
$.ajax({
url: "/ts-mgr/generatorController/generator.do",
type: "post",
success: function (data) {
//将随机数保存到页面元素中
var label = document.getElementById("randomNumber");
label.innerText = data;
},
error: function () {
console.error("获取随机数失败!!!");
}
})
}
//进入界面立即执行
getRandomNumber();
/**
*工具函数
*xml对象转json对象
*xmlObj:xml对象
*nodename:节点路径('ROOT/ITEM')
*isarray:true,强制返回数组对象
**/
function xmltojson(xmlObj, nodename, isarray) {
var obj = $(xmlObj);
var itemobj = {};
var nodenames = "";
var getAllAttrs = function (node) { //递归解析xml 转换成json对象
var _itemobj = {};
var notNull = false;
var nodechilds = node.childNodes;
var childlenght = nodechilds.length;
var _attrs = node.attributes;
var firstnodeName = "#text";
try {
firstnodeName = nodechilds[0].nodeName;
} catch (e) {}
if ((childlenght > 0 && firstnodeName != "#text") || _attrs.length > 0) {
var _childs = nodechilds;
var _childslength = nodechilds.length;
var _fileName_ = "";
if (undefined != _attrs) {
var _attrslength = _attrs.length;
for (var i = 0; i < _attrslength; i++) { //解析xml节点属性
var attrname = _attrs[i].nodeName;
var attrvalue = _attrs[i].nodeValue;
_itemobj[attrname] = attrvalue;
}
}
for (var j = 0; j < _childslength; j++) { //解析xml子节点
var _node = _childs[j];
var _fildName = _node.nodeName;
if ("#text" == _fildName) {
break;
};
if (_itemobj[_fildName] != undefined) { //如果有重复的节点需要转为数组格式
if (!(_itemobj[_fildName] instanceof Array)) {
var a = _itemobj[_fildName];
_itemobj[_fildName] = [a]; //如果该节点出现大于一个的情况 把第一个的值存放到数组中
}
}
var _fildValue = getAllAttrs(_node);
try {
_itemobj[_fildName].push(_fildValue);
} catch (e) {
_itemobj[_fildName] = _fildValue;
_itemobj["length"] = 1;
}
}
} else {
_itemobj = (node.textContent == undefined) ? node.text : node.textContent;
}
return _itemobj;
};
if (nodename) {
nodenames = nodename.split("/")
}
for (var i = 0; i < nodenames.length; i++) {
obj = obj.find(nodenames[i]);
}
$(obj).each(function (key, item) {
if (itemobj[item.nodeName] != undefined) {
if (!(itemobj[item.nodeName] instanceof Array)) {
var a = itemobj[item.nodeName];
itemobj[item.nodeName] = [a];
}
itemobj[item.nodeName].push(getAllAttrs(item));
} else {
if (nodenames.length > 0) {
itemobj[item.nodeName] = getAllAttrs(item);
} else {
itemobj[item.firstChild.nodeName] = getAllAttrs(item.firstChild);
}
}
});
if (nodenames.length > 1) {
itemobj = itemobj[nodenames[nodenames.length - 1]];
}
if (isarray && !(itemobj instanceof Array) && itemobj != undefined) {
itemobj = [itemobj];
}
return itemobj;
};
</script>
<script type="text/javascript" src="js/license.js"></script>
</html></challenge></getsignandtokenreq>, message type 1
2020/03/20 13:15:21 [I] recv: <?xml version="1.0" encoding="UTF-8"?><getsignandtokenreq version="1"><challenge><!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>时间戳服务系统</title>
<link href="http://10.106.9.206:8080/ts-mgr/css/common.css" type="text/css" rel="stylesheet">
<link href="http://10.106.9.206:8080/ts-mgr/css/login.css" type="text/css" rel="stylesheet">
<SCRIPT language="JavaScript" src="http://10.106.9.206:8080/ts-mgr/js/jquery-1.10.2.min.js"></SCRIPT>
<SCRIPT language="JavaScript" src="http://10.106.9.206:8080/ts-mgr/js/common.js"></SCRIPT>
<script type="text/javascript" src="js/judge.js"></script>
<script type="text/javascript">
/*标签切换*/
$(document).ready(function () {
$(".login_nav").each(function () {
$(this).parents(".login_box").find(".info").hide();
$("li", this).each(function (index) {
$(this).parents(".login_box").find(".info").eq(index).css("display", $(this).is(
".on") ? "block" : "none");
$(this).bind("click", function () {
$(this).addClass("on").siblings().removeClass("on");
$(this).parents(".login_box").find(".info").hide().eq(index).show();
});
});
});
});
</script>
</head>
<body onkeydown="keyLogin();">
<div class="warp_login">
<div class="login_box">
<!-- <ul class="login_nav">
<li class="on">数字证书登录</li>
<li>动态口令登录</li>
</ul>
<div class="info">
<div class="aligncenter" style=" margin-bottom:30px;"><img src="images/zhengshu.png" width="160"
height="113"></div>
<p><input type="button" class="btn_login" value="数字证书登录" onClick="window.location.href='main.html'"></p>
</div> -->
<form id="login_form">
<div class="info">
<!-- <p><input type="password1" name="userName" id="userName" class="user_input" onFocus="this.value=''"
onBlur="if(!value){value=defaultValue;}" maxlength="16"></p>
<p style=" position:relative"><input type="password" name="userPassword" id="userPassword"
class="paw_input" maxlength="16" onFocus="this.value=''"
onBlur="if(!value){value=defaultValue;}"></p>
<p style="display:none"><input type="password1" class="code_input" value="验证码"
onFocus="this.value=''" onBlur="if(!value){value=defaultValue;}">
<img src="images/pic_code.gif" width="60" height="39" align="middle"> <span><a
href="#">换一张</a></span>
</p> -->
<p style="display:none">
<label id="randomNumber"></label>
<input type="hidden" id="identityticketInput" name="identityticket"/>
<input type="hidden" id="challengeInput" name="challenge"/>
</p>
<p><input id="s1" type="button" class="btn_login" value="登 录" onclick="javascript:login()"></p>
<!-- window.location.href='main.html' -->
</div>
</form>
</div>
<div class=" fotter">Copyright 数据通信科学技术研究所</div>
</div>
</body>
<!-- <script type="text/javascript" src="js/generator.js"></script> -->
<script type="text/javascript" src="js/xml2json.js"></script>
<script type="text/javascript">
var ws = null;
//第二步点击登录时链接websocket获取验证票据值
function login() {
//第三步:验证票据获取用户标识
function verifyidentityticket(challenge, identityticket) {
$.ajax({
url: "/ts-mgr/VerifyIdentity", //todo...验签票据服务地址,需要根据实际地址调整
type: "post",
dataType: "json",
data: {
challenge: challenge,
identityticket: identityticket,
appserverid: '' //todo...这个值不知道是多少???
},
success: function (res) {
var rmsid = '';
var data = Base64.decode(res);
var dataJson = $.xml2json(data);
if (data.result == 0) {
rmsid = data.userinfo.rmsid; //todo...验签票据处获取的值,我不清楚原来的值从哪里获取???
//todo...验证用户标识
}
},
error: function () {
console.error("验签票据服务请求错误!!!");
}
})
}
function loginRequest() {
$.ajax({
url: "/ts-mgr/login/userLoginSec.do",
type: "post",
dataType: "text",
data: $("#login_form").serialize(),
success: function (data) {
if(data == 4){
window.location.href = "main.jsp";
return ;
}
alert("无权限访问应用!!!")
// if(data == 2){
// alert("用户不存在!!!");
// return ;
// }
// if(data == 9){
// alert("用户被禁用!!!");
// return ;
// }
// if(data == 10){
// alert("未开启账号密码登录请使用USERKEY登录");
// return ;
// }
// if (data == 1) {
// alert("请输入用户名和密码")
// } else if (data == 2) {
// alert("账号或密码错误");
// } else if (data == 3) {
// alert("账号或密码错误");
// } else if (data == 9) {
// alert("用户被禁用");
// } else if (data == 10) {
// alert("未开启账号密码登陆");
// } else if (data == 200) {
// alert("用户已登录");
// } else if (data == 4) {
// window.location.href = "main.jsp";
// }
},
error: function () {
alert("请求异常,请联系管理员!!!");
}
})
}
createWebsocketLink(loginRequest);
//之前的代码
// var userName1 = document.getElementById("userName").value;
// var userPassword1 = document.getElementById("userPassword").value;
// if (userName1 == null || userName1 == "" || userPassword1 == null || userPassword1 == "") {
// alert("请输入用户名和密码");
// return;
// } else if (userName1.length < 2 || userName1.length > 16) {
// alert("账号或密码错误");
// return;
// } else if (filterCharacter(userName1)) {
// alert("账号或密码错误");
// return;
// } else if (userPassword1.length < 6) {
// alert("账号或密码错误");
// return;
// } else {
// $.ajax({
// url: "/ts-mgr/login/userLogin.do",
// type: "post",
// dataType: "text",
// data: $("#login_form").serialize(),
// success: function (data) {
// if (data == 1) {
// alert("请输入用户名和密码")
// } else if (data == 2) {
// alert("账号或密码错误");
// } else if (data == 3) {
// alert("账号或密码错误");
// } else if (data == 9) {
// alert("用户被禁用");
// } else if (data == 10) {
// alert("未开启账号密码登陆");
// } else if (data == 200) {
// alert("用户已登录");
// } else if (data == 4) {
// window.location.href = "main.jsp";
// }
// },
// error: function () {
// alert("账号和密码错误");
// }
// })
// }
}
//建立websocket链接
function createWebsocketLink(verifyidentityticketCallback) {
ws = new WebSocket("ws://127.0.0.1:30318/"); //todo...访问url,根据实际地址调整
//打开连接
ws.onopen = function () {
var label = document.getElementById("randomNumber");
var randomNumber = label.innerText.trim();
var str =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><getsignandtokenreq version=\"1\"><challenge>" +
randomNumber +
"</challenge></getsignandtokenreq>";
ws.send(str);
};
//处理响应消息
ws.onmessage = function (evt) {
var received_msg = evt.data; //received_msg为单点登录接口返回的票据数据xml格式应用根据格式解析。
var received_msg_json = $.xml2json(received_msg);
var identityticket = "";
var challenge = "";
if (received_msg_json.result === '1') { //用户标识失败
alert(received_msg_json.errorinfo);
return;
}
if (received_msg_json.result === '0') { //用户标识成功
var label = document.getElementById("randomNumber");
var identityticketInput = document.getElementById("identityticketInput");
var challengeInput = document.getElementById("challengeInput");
identityticket = received_msg_json.tokeninfo;
challenge = label.innerText.trim();
identityticketInput.value = identityticket;
challengeInput.value = challenge;
verifyidentityticketCallback(challenge, identityticket);
}
};
ws.onclose = function () {
//连接关闭消息,可不处理,或者打印调试日志
console.log("websocket连接关闭");
};
}
function keyLogin() {
if (event.keyCode == 13 || event.keyCode == 108) //回车键的键值为13
document.getElementById("s1").click(); //调用登录按钮的登录事件
}
// 第一步:获取随机数
function getRandomNumber() {
$.ajax({
url: "/ts-mgr/generatorController/generator.do",
type: "post",
success: function (data) {
//将随机数保存到页面元素中
var label = document.getElementById("randomNumber");
label.innerText = data;
},
error: function () {
console.error("获取随机数失败!!!");
}
})
}
//进入界面立即执行
getRandomNumber();
/**
*工具函数
*xml对象转json对象
*xmlObj:xml对象
*nodename:节点路径('ROOT/ITEM')
*isarray:true,强制返回数组对象
**/
function xmltojson(xmlObj, nodename, isarray) {
var obj = $(xmlObj);
var itemobj = {};
var nodenames = "";
var getAllAttrs = function (node) { //递归解析xml 转换成json对象
var _itemobj = {};
var notNull = false;
var nodechilds = node.childNodes;
var childlenght = nodechilds.length;
var _attrs = node.attributes;
var firstnodeName = "#text";
try {
firstnodeName = nodechilds[0].nodeName;
} catch (e) {}
if ((childlenght > 0 && firstnodeName != "#text") || _attrs.length > 0) {
var _childs = nodechilds;
var _childslength = nodechilds.length;
var _fileName_ = "";
if (undefined != _attrs) {
var _attrslength = _attrs.length;
for (var i = 0; i < _attrslength; i++) { //解析xml节点属性
var attrname = _attrs[i].nodeName;
var attrvalue = _attrs[i].nodeValue;
_itemobj[attrname] = attrvalue;
}
}
for (var j = 0; j < _childslength; j++) { //解析xml子节点
var _node = _childs[j];
var _fildName = _node.nodeName;
if ("#text" == _fildName) {
break;
};
if (_itemobj[_fildName] != undefined) { //如果有重复的节点需要转为数组格式
if (!(_itemobj[_fildName] instanceof Array)) {
var a = _itemobj[_fildName];
_itemobj[_fildName] = [a]; //如果该节点出现大于一个的情况 把第一个的值存放到数组中
}
}
var _fildValue = getAllAttrs(_node);
try {
_itemobj[_fildName].push(_fildValue);
} catch (e) {
_itemobj[_fildName] = _fildValue;
_itemobj["length"] = 1;
}
}
} else {
_itemobj = (node.textContent == undefined) ? node.text : node.textContent;
}
return _itemobj;
};
if (nodename) {
nodenames = nodename.split("/")
}
for (var i = 0; i < nodenames.length; i++) {
obj = obj.find(nodenames[i]);
}
$(obj).each(function (key, item) {
if (itemobj[item.nodeName] != undefined) {
if (!(itemobj[item.nodeName] instanceof Array)) {
var a = itemobj[item.nodeName];
itemobj[item.nodeName] = [a];
}
itemobj[item.nodeName].push(getAllAttrs(item));
} else {
if (nodenames.length > 0) {
itemobj[item.nodeName] = getAllAttrs(item);
} else {
itemobj[item.firstChild.nodeName] = getAllAttrs(item.firstChild);
}
}
});
if (nodenames.length > 1) {
itemobj = itemobj[nodenames[nodenames.length - 1]];
}
if (isarray && !(itemobj instanceof Array) && itemobj != undefined) {
itemobj = [itemobj];
}
return itemobj;
};
</script>
<script type="text/javascript" src="js/license.js"></script>
</html></challenge></getsignandtokenreq>, message type 1
2020/03/20 13:16:11 [I] recv: <?xml version="1.0" encoding="UTF-8"?><getsignandtokenreq version="1"><challenge><!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>时间戳服务系统</title>
<link href="http://10.106.9.206:8080/ts-mgr/css/common.css" type="text/css" rel="stylesheet">
<link href="http://10.106.9.206:8080/ts-mgr/css/login.css" type="text/css" rel="stylesheet">
<SCRIPT language="JavaScript" src="http://10.106.9.206:8080/ts-mgr/js/jquery-1.10.2.min.js"></SCRIPT>
<SCRIPT language="JavaScript" src="http://10.106.9.206:8080/ts-mgr/js/common.js"></SCRIPT>
<script type="text/javascript" src="js/judge.js"></script>
<script type="text/javascript">
/*标签切换*/
$(document).ready(function () {
$(".login_nav").each(function () {
$(this).parents(".login_box").find(".info").hide();
$("li", this).each(function (index) {
$(this).parents(".login_box").find(".info").eq(index).css("display", $(this).is(
".on") ? "block" : "none");
$(this).bind("click", function () {
$(this).addClass("on").siblings().removeClass("on");
$(this).parents(".login_box").find(".info").hide().eq(index).show();
});
});
});
});
</script>
</head>
<body onkeydown="keyLogin();">
<div class="warp_login">
<div class="login_box">
<!-- <ul class="login_nav">
<li class="on">数字证书登录</li>
<li>动态口令登录</li>
</ul>
<div class="info">
<div class="aligncenter" style=" margin-bottom:30px;"><img src="images/zhengshu.png" width="160"
height="113"></div>
<p><input type="button" class="btn_login" value="数字证书登录" onClick="window.location.href='main.html'"></p>
</div> -->
<form id="login_form">
<div class="info">
<!-- <p><input type="password1" name="userName" id="userName" class="user_input" onFocus="this.value=''"
onBlur="if(!value){value=defaultValue;}" maxlength="16"></p>
<p style=" position:relative"><input type="password" name="userPassword" id="userPassword"
class="paw_input" maxlength="16" onFocus="this.value=''"
onBlur="if(!value){value=defaultValue;}"></p>
<p style="display:none"><input type="password1" class="code_input" value="验证码"
onFocus="this.value=''" onBlur="if(!value){value=defaultValue;}">
<img src="images/pic_code.gif" width="60" height="39" align="middle"> <span><a
href="#">换一张</a></span>
</p> -->
<p style="display:none">
<label id="randomNumber"></label>
<input type="hidden" id="identityticketInput" name="identityticket"/>
<input type="hidden" id="challengeInput" name="challenge"/>
</p>
<p><input id="s1" type="button" class="btn_login" value="登 录" onclick="javascript:login()"></p>
<!-- window.location.href='main.html' -->
</div>
</form>
</div>
<div class=" fotter">Copyright 数据通信科学技术研究所</div>
</div>
</body>
<!-- <script type="text/javascript" src="js/generator.js"></script> -->
<script type="text/javascript" src="js/xml2json.js"></script>
<script type="text/javascript">
var ws = null;
//第二步点击登录时链接websocket获取验证票据值
function login() {
//第三步:验证票据获取用户标识
function verifyidentityticket(challenge, identityticket) {
$.ajax({
url: "/ts-mgr/VerifyIdentity", //todo...验签票据服务地址,需要根据实际地址调整
type: "post",
dataType: "json",
data: {
challenge: challenge,
identityticket: identityticket,
appserverid: '' //todo...这个值不知道是多少???
},
success: function (res) {
var rmsid = '';
var data = Base64.decode(res);
var dataJson = $.xml2json(data);
if (data.result == 0) {
rmsid = data.userinfo.rmsid; //todo...验签票据处获取的值,我不清楚原来的值从哪里获取???
//todo...验证用户标识
}
},
error: function () {
console.error("验签票据服务请求错误!!!");
}
})
}
function loginRequest() {
$.ajax({
url: "/ts-mgr/login/userLoginSec.do",
type: "post",
dataType: "text",
data: $("#login_form").serialize(),
success: function (data) {
if(data == 4){
window.location.href = "main.jsp";
return ;
}
alert("无权限访问应用!!!")
// if(data == 2){
// alert("用户不存在!!!");
// return ;
// }
// if(data == 9){
// alert("用户被禁用!!!");
// return ;
// }
// if(data == 10){
// alert("未开启账号密码登录请使用USERKEY登录");
// return ;
// }
// if (data == 1) {
// alert("请输入用户名和密码")
// } else if (data == 2) {
// alert("账号或密码错误");
// } else if (data == 3) {
// alert("账号或密码错误");
// } else if (data == 9) {
// alert("用户被禁用");
// } else if (data == 10) {
// alert("未开启账号密码登陆");
// } else if (data == 200) {
// alert("用户已登录");
// } else if (data == 4) {
// window.location.href = "main.jsp";
// }
},
error: function () {
alert("请求异常,请联系管理员!!!");
}
})
}
createWebsocketLink(loginRequest);
//之前的代码
// var userName1 = document.getElementById("userName").value;
// var userPassword1 = document.getElementById("userPassword").value;
// if (userName1 == null || userName1 == "" || userPassword1 == null || userPassword1 == "") {
// alert("请输入用户名和密码");
// return;
// } else if (userName1.length < 2 || userName1.length > 16) {
// alert("账号或密码错误");
// return;
// } else if (filterCharacter(userName1)) {
// alert("账号或密码错误");
// return;
// } else if (userPassword1.length < 6) {
// alert("账号或密码错误");
// return;
// } else {
// $.ajax({
// url: "/ts-mgr/login/userLogin.do",
// type: "post",
// dataType: "text",
// data: $("#login_form").serialize(),
// success: function (data) {
// if (data == 1) {
// alert("请输入用户名和密码")
// } else if (data == 2) {
// alert("账号或密码错误");
// } else if (data == 3) {
// alert("账号或密码错误");
// } else if (data == 9) {
// alert("用户被禁用");
// } else if (data == 10) {
// alert("未开启账号密码登陆");
// } else if (data == 200) {
// alert("用户已登录");
// } else if (data == 4) {
// window.location.href = "main.jsp";
// }
// },
// error: function () {
// alert("账号和密码错误");
// }
// })
// }
}
//建立websocket链接
function createWebsocketLink(verifyidentityticketCallback) {
ws = new WebSocket("ws://127.0.0.1:30318/"); //todo...访问url,根据实际地址调整
//打开连接
ws.onopen = function () {
var label = document.getElementById("randomNumber");
var randomNumber = label.innerText.trim();
var str =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><getsignandtokenreq version=\"1\"><challenge>" +
randomNumber +
"</challenge></getsignandtokenreq>";
ws.send(str);
};
//处理响应消息
ws.onmessage = function (evt) {
var received_msg = evt.data; //received_msg为单点登录接口返回的票据数据xml格式应用根据格式解析。
var received_msg_json = $.xml2json(received_msg);
var identityticket = "";
var challenge = "";
if (received_msg_json.result === '1') { //用户标识失败
alert(received_msg_json.errorinfo);
return;
}
if (received_msg_json.result === '0') { //用户标识成功
var label = document.getElementById("randomNumber");
var identityticketInput = document.getElementById("identityticketInput");
var challengeInput = document.getElementById("challengeInput");
identityticket = received_msg_json.tokeninfo;
challenge = label.innerText.trim();
identityticketInput.value = identityticket;
challengeInput.value = challenge;
verifyidentityticketCallback(challenge, identityticket);
}
};
ws.onclose = function () {
//连接关闭消息,可不处理,或者打印调试日志
console.log("websocket连接关闭");
};
}
function keyLogin() {
if (event.keyCode == 13 || event.keyCode == 108) //回车键的键值为13
document.getElementById("s1").click(); //调用登录按钮的登录事件
}
// 第一步:获取随机数
function getRandomNumber() {
$.ajax({
url: "/ts-mgr/generatorController/generator.do",
type: "post",
success: function (data) {
//将随机数保存到页面元素中
var label = document.getElementById("randomNumber");
label.innerText = data;
},
error: function () {
console.error("获取随机数失败!!!");
}
})
}
//进入界面立即执行
getRandomNumber();
/**
*工具函数
*xml对象转json对象
*xmlObj:xml对象
*nodename:节点路径('ROOT/ITEM')
*isarray:true,强制返回数组对象
**/
function xmltojson(xmlObj, nodename, isarray) {
var obj = $(xmlObj);
var itemobj = {};
var nodenames = "";
var getAllAttrs = function (node) { //递归解析xml 转换成json对象
var _itemobj = {};
var notNull = false;
var nodechilds = node.childNodes;
var childlenght = nodechilds.length;
var _attrs = node.attributes;
var firstnodeName = "#text";
try {
firstnodeName = nodechilds[0].nodeName;
} catch (e) {}
if ((childlenght > 0 && firstnodeName != "#text") || _attrs.length > 0) {
var _childs = nodechilds;
var _childslength = nodechilds.length;
var _fileName_ = "";
if (undefined != _attrs) {
var _attrslength = _attrs.length;
for (var i = 0; i < _attrslength; i++) { //解析xml节点属性
var attrname = _attrs[i].nodeName;
var attrvalue = _attrs[i].nodeValue;
_itemobj[attrname] = attrvalue;
}
}
for (var j = 0; j < _childslength; j++) { //解析xml子节点
var _node = _childs[j];
var _fildName = _node.nodeName;
if ("#text" == _fildName) {
break;
};
if (_itemobj[_fildName] != undefined) { //如果有重复的节点需要转为数组格式
if (!(_itemobj[_fildName] instanceof Array)) {
var a = _itemobj[_fildName];
_itemobj[_fildName] = [a]; //如果该节点出现大于一个的情况 把第一个的值存放到数组中
}
}
var _fildValue = getAllAttrs(_node);
try {
_itemobj[_fildName].push(_fildValue);
} catch (e) {
_itemobj[_fildName] = _fildValue;
_itemobj["length"] = 1;
}
}
} else {
_itemobj = (node.textContent == undefined) ? node.text : node.textContent;
}
return _itemobj;
};
if (nodename) {
nodenames = nodename.split("/")
}
for (var i = 0; i < nodenames.length; i++) {
obj = obj.find(nodenames[i]);
}
$(obj).each(function (key, item) {
if (itemobj[item.nodeName] != undefined) {
if (!(itemobj[item.nodeName] instanceof Array)) {
var a = itemobj[item.nodeName];
itemobj[item.nodeName] = [a];
}
itemobj[item.nodeName].push(getAllAttrs(item));
} else {
if (nodenames.length > 0) {
itemobj[item.nodeName] = getAllAttrs(item);
} else {
itemobj[item.firstChild.nodeName] = getAllAttrs(item.firstChild);
}
}
});
if (nodenames.length > 1) {
itemobj = itemobj[nodenames[nodenames.length - 1]];
}
if (isarray && !(itemobj instanceof Array) && itemobj != undefined) {
itemobj = [itemobj];
}
return itemobj;
};
</script>
<script type="text/javascript" src="js/license.js"></script>
</html></challenge></getsignandtokenreq>, message type 1