您现在的位置是:首页
>
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 很赞哦! (1049)
相关文章
- 位运算符怎么运算 ASP.NET入门教程 9.2.1 运算符[3]
- java自学宝典怎么样 ASP.NET开发宝典:运行ASP.NET网站
- java中关于异常 ASP.Net之C#中的异常处理
- aspnet项目开发教程 ASP.NET入门教程 4.2.1 Login控件[4]
- aspnet项目开发教程 ASP.NET入门教程 4.2.1 Login控件[3]
- java如何调用存储过程 ASP.NET调用存储过程两种方法浅析
- sso单点登录跳转异常 单点登录在ASP.NET上的简单实现[5]
- java 路由框架 ASP.NET MVC 4框架揭秘:URL路由(2)
- java窗体设计 ASP.NET 窗体间传值实现方法
- aspnet教程 ASP.NET入门教程 4.2.1 Login控件[1]
爱学记

微信收款码
支付宝收款码