您现在的位置是:首页
>
java单点登录原理 单点登录在ASP.NET上的简单实现[3]
单点登录在ASP.NET上的简单实现[3] 在代码中 Security是通过Ha h一个随机产生的数字生成的 具有不确定性 和保密性 我们可以看到 Security同时保存在Se io 中和发送给Se
单点登录在ASP.NET上的简单实现[3]
在代码中 Security是通过Hash一个随机产生的数字生成的 具有不确定性 和保密性 我们可以看到 Security同时保存在Session中和发送给Service 我们把这个Security当作明文 在后面我们可以看到 Security在Service经过再一次Hash后作为密文发送回Shop 如果我们将Session保存的Security经过同样的Hash方法处理后等到的字符串如果和Service返回的密文相同 我们就能够在一定程度上保证Service应答的数据是没有经过修改的 using System;using System Web;using System Security Cryptography;using System Text;namespace Amethysture SSO Shop{ public class Page : System Web UI Page { private void CustomerValidate() { bool Pass = (bool) this Session[ Pass ]; if (!Pass) { string Security = ; Random Seed = new Random(); Security = Seed Next( int MaxValue) ToString(); byte[] Value; UnicodeEncoding Code = new UnicodeEncoding(); byte[] Message = Code GetBytes(Security); SHA Managed Arithmetic = new SHA Managed(); Value = Arithmetic ComputeHash(Message); Security = ; foreach(byte o in Value) { Security += (int) o + O ; } this Session[ Security ] = Security; this Session[ Url ] = this Request RawUrl; this Response Redirect(Project Service + /Validate aspx?WebSite= + Project WebSite + &Security= + Security); } } protected virtual void Initialize() { this Response Write( <> ); this Response Write( <head> ); this Response Write( <title>Amethysture SSO Project</title> ); this Response Write( <link rel=stylesheet type= text/css href= + project website + /Default css > ); this Response Write( </head> ); this Response Write( <body> ); this Response Write( <iframe width= height= src= + project service + /Customer aspx ></iframe> ); this Response Write( <div align= center > ); this Response Write( Amethysture SSO Shop Any Page ); this Response Write( </div> ); this Response Write( </body> ); this Response Write( </> ); } protected override void OnInit(EventArgs e) { base OnInit(e); this CustomerValidate(); this Initialize(); this Response End(); } }}![java单点登录原理 单点登录在ASP.NET上的简单实现[3]](http://img.zhputi.com/uploads/598d/598d0283eaa7e4c83d78008343c0af8717940.jpg)
Service的Global cs 现在我们页面转到了Service的Validate页面 我们转过来看Service的代码 在Global中我们同样定义了四个Session变量 都和Shop的Session用处类似 WebSite是保存请求用户即时状态的站点信息 以便能在登录后返回正确的请求站点
protected void Session_Start(Object sender EventArgs e){ this Session Add( UserID ); this Session Add( Pass false); this Session Add( WebSite ); this Session Add( Security );}
lishixinzhi/Article/program/net/201311/14963 很赞哦! (1054)
- 上一篇
岁月仍然上一句是什么 问一句 男人们都是从多大岁数开始被家里催婚的
问一句 男人们都是从多大岁数开始被家里催婚的 问一句 男人们都是从多大岁数开始被家里催婚的早的十几就催了,迟的几乎没有,除非实在不想结婚早,有的四十了还在催呢你们都是从多大开始催婚的?二十多岁吧这事急
- 下一篇
武汉天马电子厂怎么样 急. 怎么样可以进武汉电子厂阿? 武汉那里有没有人力资源公司? 也就是人力中介! 那些厂比较好.!
急. 怎么样可以进武汉电子厂阿? 武汉那里有没有人力资源公司? 也就是人力中介! 那些厂比较好. 急. 怎么样可以进武汉电子厂阿? 武汉那里有没有人力资源公司? 也就是人力中介! 那些厂比较好.您可以