ukey验证.docx

上传人:b****8 文档编号:30479695 上传时间:2023-08-15 格式:DOCX 页数:26 大小:275.34KB
下载 相关 举报
ukey验证.docx_第1页
第1页 / 共26页
ukey验证.docx_第2页
第2页 / 共26页
ukey验证.docx_第3页
第3页 / 共26页
ukey验证.docx_第4页
第4页 / 共26页
ukey验证.docx_第5页
第5页 / 共26页
点击查看更多>>
下载资源
资源描述

ukey验证.docx

《ukey验证.docx》由会员分享,可在线阅读,更多相关《ukey验证.docx(26页珍藏版)》请在冰豆网上搜索。

ukey验证.docx

ukey验证

登录协同工作平台安全解决方案

[摘要]公司领导说登录验证的安全性如何保证,建议采用UKEY验证类似网银解决,调用第三方YT公司产品。

解决方案:

 

前端页面:

1.

--创建firefox,chrome等插件-->

2.  

3.      //加载皮肤

4.      varsetTheme=function(){

5.        E.DirectMethods.GetThemeUrl(cbTheme.getValue(),{

6.          success:

function(result){

7.              E.ResourceMgr.setTheme(result);

8.          }

9.        });

10.      };

11.      //回车出发

12.      document.onkeydown=function(event){

13.        e=event?

event:

(window.event?

window.event:

null);

14.        if(e.keyCode==13){

15.          //执行的方法  

16.          //alert('回车检测到了');

17.          //E.DirectMethods.Login();

18.          login();

19.        }

20.      }

21.

22.      vardigitArray=newArray('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f');

23.      functiontoHex(n){

24.        varresult=''

25.        varstart=true;

26.        for(vari=32;i>0;){

27.          i-=4;

28.          vardigit=(n>>i)&0xf;

29.

30.          if(!

start||digit!

=0){

31.              start=false;

32.              result+=digitArray[digit];

33.          }

34.        }

35.        return(result==''?

'0':

result);

36.      }

37.

38.      varlogin=function(){

39.        varIsCheck='N';

40.        if(window.location.host=="localhost:

23111"){

41.          varDevicePath,ret,n,mylen;

42.          try{

43.              //建立操作我们的锁的控件对象,用于操作我们的锁

44.              vars_simnew61;

45.

46.              //创建插件或控件

47.              if(navigator.userAgent.indexOf("MSIE")>0&&!

navigator.userAgent.indexOf("opera")>-1){

48.                s_simnew61=newActiveXObject("Syunew6A.s_simnew6");

49.              }

50.              else{

51.                s_simnew61=document.getElementById('s_simnew61');

52.              }

53.

54.

55.              //查找是否存在锁,这里使用了FindPort函数

56.              DevicePath=s_simnew61.FindPort(0);

57.              if(s_simnew61.LastError!

=0){

58.                window.alert("没有找到Ukey,请插入UKey");

59.                //window.location.href="err.html";

60.                return;

61.              }

62.

63.              //这里返回对随机数的HASH结果

64.              frmlogin.return_EncData.value=s_simnew61.EncString(frmlogin.rnd.value,DevicePath);

65.              if(s_simnew61.LastError!

=0){

66.                window.alert("ErrtoStrEnc,ErrCodeis:

"+s_simnew61.LastError.toString());

67.                return;

68.              }

69.              IsCheck='Y';

70.

71.              E.DirectMethods.Login(IsCheck);

72.

73.          }catch(e){

74.              alert("您在使用外网访问:

"+e.name+":

"+e.message+"。

可能是没有安装相应的控件或插件");

75.          }

76.        }else{

77.          E.DirectMethods.Login(IsCheck);

78.        }

79.

80.      };

81.  

82.  

83.      functionreloadCode(){

84.        varobj=document.getElementById('imgCode');

85.        obj.src="VerifyCode.aspx?

";

86.      }

87.

88.  

89.CS代码:

90.SoftKey2Kytsoftkey;

91.    StringKeyPath;

92.      privatestring_randomcode;

93.      ///

94.      ///随机数

95.      ///

96.      publicstringRandomcode

97.      {

98.        get{return_randomcode;}

99.        set{_randomcode=value;}

100.      }

101.      protectedvoidPage_Load(objectsender,EventArgse)

102.      {

103.        if(!

IsPostBack)

104.        {

105.          System.Randomrandom=newSystem.Random();

106.          Session["rnd"]=rnd.Value=random.Next(0,2147483646).ToString();

107.          Response.Cookies.Add(newHttpCookie("CheckCode",""));

108.        }

109.      }

110.

111.  

112.      [DirectMethod]

113.      publicvoidLogin(stringIsCheck)

114.      {

115.        Check(IsCheck);

116.      

117.      }

118.      ///

119.      ///登录验证

120.      ///

121.      ///

122.      privatevoidCheck(stringIsCheck) 

123.      {

124.        if(Request.Cookies["CheckCode"]==null)

125.        {

126.

127.          Notification.Show(newNotificationConfig

128.          {

129.              Title="提醒",

130.              Icon=Icon.Information,

131.              Html="

red;'>您的浏览器设置已被禁用Cookies,您必须设置浏览器允许使用Cookies选项后才能使用本系统。

"

132.          });

133.          return;

134.        }

135.        //验证码比较

136.        if(String.Compare(Request.Cookies["CheckCode"].Value.ToUpper(),this.txtVerifyCode.Text.ToString().Trim().ToUpper(),true)!

=0)

137.        {

138.          this.txtVerifyCode.SetValue("");

139.          Notification.Show(newNotificationConfig

140.          {

141.              Title="提醒",

142.              Icon=Icon.Information,

143.              Html="

red;'>验证码错误,请重新输入"

144.          });

145.          X.AddScript("document.getElementById('imgCode').src='VerifyCode.aspx?

';");

146.          return;

147.

148.

149.        }

150.        else

151.        {

152.          Utility.MD5md5=newUtility.MD5();

153.          DzPlatForm.Model.Usersuser=newModel.Users();

154.          user.USERNAME=Utility.Baseclass.SqlFilter(txtUserName.Text.Trim());//过滤危险字符

155.          user.PASSWORD=md5.MD5Encrypt(txtPassWord.Text.Trim());//md5.MD5Encrypt(Utility.Baseclass.SqlFilter(txtPassWord.Text.Trim()));//密码进行加密

156.

157.          stringsql="select*from[users]whereid=1";

158.          DataTabledt=DbHelperSQL.Query(sql,null).Tables[0];

159.

160.          DzPlatForm.BLL.UserBLLusermgr=newDzPlatForm.BLL.UserBLL();

161.          stringUserId=usermgr.LoginCheck(user);

162.

163.          if(UserId!

="")

164.          {

165.

166.              Model.LoginLoglg=newModel.LoginLog();

167.              lg.Name=txtUserName.Text.Trim();

168.              lg.Browser=Utility.IpBrowserHelper.getBrowser();

169.              lg.Ip=Utility.IpBrowserHelper.getIP();

170.              lg.System=Utility.IpBrowserHelper.SystemCheck();

171.              BLL.LoginBLLlogmgr=newBLL.LoginBLL();

172.              logmgr.LoginInfor(lg);

173.              usermgr.Record();

174.

175.              Model.Indentifyidf=newModel.Indentify();

176.              idf.Userid=int.Parse(UserId);

177.              BLL.IndentifyBLLidmgr=newBLL.IndentifyBLL();

178.              idmgr.GetIndentify(idf);

179.              Session["userid"]=UserId;

180.              Session["UserCode"]=txtUserName.Text.Trim();

181.              Session["UserName"]=idf.Name;

182.              Session["utype"]=idf.IsSystem;

183.              Session["uip"]=lg.Ip;

184.

185.

186.              //X.Msg.Show(newMessageBoxConfig

187.              //{

188.              //  Title="请等待",

189.              //  Message="正在加载项",

190.              //  ProgressText="初始化中...",

191.              //  Width=300,

192.              //  Progress=true,

193.              //  Closable=false,

194.              //  AnimEl=this.btnlogin.ClientID

195.              //});

196.

197.              //this.StartLongAction();

198.              StringstrData,m_StrEnc,Key,Flag;

199.

200.              Flag=IsCheck;

201.              //Key:

即增强算法密钥,这个要与设置在加密锁中的密钥一致

202.              //增强算法密钥可以是每一把都不相同,也可以是都相同,如果是不相同的可以根据用户名在从数据库中获取对应的增强算法密钥,可以根据安全性及自身具体情况而定,这里使用了一个固定的值

203.            //Key="1234567890ABCDEF1234567890ABCDEF";

204.              Key=idf.UkeyCode;

205.              //strData:

要进行加密的数据

206.              strData=rnd.Value.Trim();//Session["rnd"].ToString();

207.              //'在服务器端对数据进行加密运算

208.              m_StrEnc=Global.m_softkey.StrEnc(strData,Key);

209.              //比较客户端加密锁返回的加密结果与服务端的加密结果是否相符,如果相符就认为是合法用户,由于使用了随机数,从而实现了一次一密的高安全性,可以用于高安全性的身份验证

210.              if(Flag=="N")//内网不需要比对

211.              {

212.                Response.Redirect("Index.aspx");

213.              }

214.              else

215.              {

216.                if(m_StrEnc==return_EncData.Value)

217.                {

218.

219.                  Response.Redirect("Index.aspx");

220.                }

221.                else

222.                {

223.                  Notification.Show(newNotificationConfig

224.                  {

225.                      Title="提醒",

226.                      Icon=Icon.Information,

227.                      Html="

red;'>该用户不是合法用户

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 初中教育

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1