- 浏览: 760741 次
- 性别:
- 来自: 广州
文章分类
最新评论
-
corelengine:
好文,支持一下!
在 Spring Web Flow 项目中应用 Hessian 服务 -
corelengine:
感谢分享,不过你的工程太简单了,怎么可以导入eclipse
Spring Web Flow 2.0 入门 例子源码 -
chenrongtao2132:
melody404 写道请教博主一个问题
登录成功以后为什么老 ...
CAS 单点登录安装笔记4 -- asp.net client端的设置 -
chxiaowu:
从头到尾没发现 那里有 cxf bean配置啊。。。。
WebService开发笔记 3 -- 增强访问 WebService 的安全性 -
chxiaowu:
严重: StandardWrapper.Throwable
o ...
WebService开发笔记 3 -- 增强访问 WebService 的安全性
CAS 单点登录安装笔记4
--- asp.net client端的设置
1、首先修改web.Config文件,加入以下设置:
本人对.net不是很熟悉,感觉这里的配置类似java web应用程序中的过滤器,当用户访问web页时首先跳转到login.aspx页面进行验证。
2、加入以下c#代码到login.aspx页面的加载事件中:
以上代码参照了ja-sig网站的解决方案:http://www.ja-sig.org/wiki/display/CASC/ASP.NET+Forms+Authentication
3、以为这样就可以了,运行时可以跳到sso服务器进行验证,但跳转以后报以下错误:
" System.Net.WebException。 基础连接已关闭。 无法建立与远程服务器信任关系 "。
应该与CAS Server端安装了数字证书,而.net Client端并没有安装相应的证书有关。
可以通过配置IIS服务器,支持HTTPS SSL协议实现安全数据交换中介绍的步骤导入CAS 服务端的数字证书,或者通过http://support.microsoft.com/kb/823177/上介绍的解决方案进行处理:
实现类
客户端代码中包含下列代码:
所有代码见附件WebSite.rar,将其部署到你的IIS服务器就可以了。
关于IIS服务器的设置见asp.net一夜速成教程
--- asp.net client端的设置
1、首先修改web.Config文件,加入以下设置:
<authentication mode="Forms" > <forms name="casauth" loginUrl="login.aspx" /> </authentication> <authorization> <deny users="?" /> </authorization>
本人对.net不是很熟悉,感觉这里的配置类似java web应用程序中的过滤器,当用户访问web页时首先跳转到login.aspx页面进行验证。
2、加入以下c#代码到login.aspx页面的加载事件中:
//CAS 身份验证 服务器地址 private const string CASHOST = "https://sso.gzps.net:8443/cas/"; protected void Page_Load(object sender, EventArgs e) { System.Net.ServicePointManager.CertificatePolicy = new MyPolicy(); // Look for the "ticket=" after the "?" in the URL string tkt = Request.QueryString["ticket"]; // This page is the CAS service=, but discard any query string residue string service = Request.Url.GetLeftPart(UriPartial.Path); // First time through there is no ticket=, so redirect to CAS login if (tkt == null || tkt.Length == 0) { string redir = CASHOST + "login?" + "service=" + service; Response.Redirect(redir); return; } // Second time (back from CAS) there is a ticket= to validate string validateurl = CASHOST + "serviceValidate?" + "ticket=" + tkt + "&"+ "service=" + service; StreamReader Reader = new StreamReader( new WebClient().OpenRead(validateurl)); string resp = Reader.ReadToEnd(); // I like to have the text in memory for debugging rather than parsing the stream // Some boilerplate to set up the parse. NameTable nt = new NameTable(); XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt); XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None); XmlTextReader reader = new XmlTextReader(resp, XmlNodeType.Element, context); string netid = null; // A very dumb use of XML. Just scan for the "user". If it isn't there, its an error. while (reader.Read()) { if (reader.IsStartElement()) { string tag = reader.LocalName; if (tag=="user") netid = reader.ReadString(); } } // if you want to parse the proxy chain, just add the logic above reader.Close(); // If there was a problem, leave the message on the screen. Otherwise, return to original page. if (netid == null) { Label1.Text = "CAS returned to this application, but then refused to validate your identity."; } else { Session["UserName"] = netid; Label1.Text = "Welcome " + netid; FormsAuthentication.RedirectFromLoginPage(netid, false); // set netid in ASP.NET blocks } } }
以上代码参照了ja-sig网站的解决方案:http://www.ja-sig.org/wiki/display/CASC/ASP.NET+Forms+Authentication
3、以为这样就可以了,运行时可以跳到sso服务器进行验证,但跳转以后报以下错误:
" System.Net.WebException。 基础连接已关闭。 无法建立与远程服务器信任关系 "。
应该与CAS Server端安装了数字证书,而.net Client端并没有安装相应的证书有关。
可以通过配置IIS服务器,支持HTTPS SSL协议实现安全数据交换中介绍的步骤导入CAS 服务端的数字证书,或者通过http://support.microsoft.com/kb/823177/上介绍的解决方案进行处理:
实现类
using System.Net; using System.Security.Cryptography.X509Certificates; public class MyPolicy : ICertificatePolicy { public bool CheckValidationResult( ServicePoint srvPoint , X509Certificate certificate , WebRequest request , int certificateProblem) { //Return True to force the certificate to be accepted. return true; } // end CheckValidationResult } // class MyPolicy
客户端代码中包含下列代码:
System.Net.ServicePointManager.CertificatePolicy = new MyPolicy();
所有代码见附件WebSite.rar,将其部署到你的IIS服务器就可以了。
关于IIS服务器的设置见asp.net一夜速成教程
- WebSite.rar (4 KB)
- 描述: asp.net 与cas结合的实例程序
- 下载次数: 1122
评论
3 楼
chenrongtao2132
2012-06-21
melody404 写道
请教博主一个问题
登录成功以后为什么老是显示default.aspx
代码里好像也没有看到在哪设置了这个
请问可以换成其他的吗?多谢了哈
登录成功以后为什么老是显示default.aspx
代码里好像也没有看到在哪设置了这个
请问可以换成其他的吗?多谢了哈
2 楼
melody404
2009-03-04
请教博主一个问题
登录成功以后为什么老是显示default.aspx
代码里好像也没有看到在哪设置了这个
请问可以换成其他的吗?多谢了哈
登录成功以后为什么老是显示default.aspx
代码里好像也没有看到在哪设置了这个
请问可以换成其他的吗?多谢了哈
1 楼
xutianle
2009-02-17
谢谢,正需要这个!!!!!!!!
发表评论
-
Android开发笔记
2009-10-19 09:11 16301.复制数据库文件: D:\Program Files\and ... -
天气预报的 WebService 服务网站
2009-06-29 10:53 0http://www.webxml.com.cn/WebSer ... -
在 Spring Web Flow 项目中应用 Hessian 服务
2009-05-21 11:19 2555原来作的一个项目因为页面跳转比较多,应用了S ... -
Spring Web Flow 2.0 入门 例子源码
2008-12-22 11:34 11754developerWorks 中有一篇教材讲解了 Spr ... -
JAD反编译工具
2008-05-29 11:33 5050This is README file for Jad - t ... -
压力测试与系统调优
2008-05-04 16:19 2304最近用loadrunne ... -
通过压力测试排查Bug(二)--排查Bug
2008-05-04 11:44 1815最近的一个项目 ... -
通过压力测试排查Bug(一)--测试过程
2008-05-04 11:05 1609最近的一个项目应用了Acegi作为安全框架,项目试运 ... -
WebService开发笔记 3 -- 增强访问 WebService 的安全性
2008-03-19 09:50 21810在WebService开发笔记 1中我们创建了一个WebSer ... -
WebService开发笔记 2 -- VS 2005 访问WebServcie更简单
2008-03-12 19:32 11148WebService开发笔记 2 -- VS 2005 访问W ... -
WebService开发笔记 1 -- 利用cxf开发WebService竟然如此简单
2008-03-12 18:37 27506WebService开发笔记 1 -- 利用cxf开发WebS ... -
Tomcat 配置 -- 打开中文文件名的附件
2008-03-04 10:23 1902设计了文件上传的工具,但在Tomcat服务器上访问中文文件名的 ... -
常用的System.getProperty()
2008-03-02 11:53 29常用的System.getProperty()System.g ... -
CAS 单点登录安装笔记3 -- 与acegi集成
2008-02-28 23:38 8254CAS 单点登录安装笔记3 -- 与acegi集成 在我的项 ... -
CAS 单点登录安装笔记2 -- 配置CAS,访问自己的用户表
2008-02-27 17:45 6999CAS 单点登录安装笔记2 1.修改cas/webapp/ ... -
CAS 单点登录安装笔记1 -- 基本设置与数字证书的安装
2008-02-26 16:35 5704安装JA-SIG SSO系统笔记1 (关于配置访问数据库的用 ... -
JAVA文档
2007-12-19 16:05 1169JAVA相关文档 http://www.lybbs.net/n ... -
Tomcat性能调优(2)
2007-12-19 15:37 2895原文出处:http://www.lybbs.n ... -
Spring 通过 Tomcat 6.0 下的数据源连接池 访问Oracle数据库
2007-12-17 18:26 5950头疼的老问题,折腾了一天,tomcat6.0数据源配置 to ... -
Tomcat数据源配置总结 转载
2007-12-17 16:52 1470成功配置环境Tomcat5.0.28+MSSQLServer2 ...
相关推荐
acegi-context配置文件 博文链接:https://lib.iteye.com/blog/165980
CAS单点登录CAS4.0.0+.Net Client,.net客户端实现登录验证和Cookie检测
单点登录服务端项目cas-server单点登录服务端项目cas-server 单点登录服务端项目cas-server 单点登录服务端项目cas-server 单点登录服务端项目cas-server 单点登录服务端项目cas-server 单点登录服务端项目cas-...
。net的cas单点登录代码
单点登录 sso cas带超详细文档,包含(cas-server-webapp-4.0.0.war、c3p0-0.9.1.2.jar、cas-client-core-3.3.3.jar、cas-server-support-jdbc-4.0.0.jar、cas-server-webapp-support-4.0.0.jar、commons-logging-...
spring下使用shiro+cas配置单点登录,多个系统之间的访问,每次只需要登录一次 ## 系统模块说明 1. cas: 单点登录模块,这里直接拿的是cas的项目改了点样式而已 2. doc: 文档目录,里面有数据库生成语句,采用的...
cas 。net单点登录demo cas 。net单点登录demo cas 。net单点登录demo
赠送jar包:cas-client-core-3.2.1.jar; 赠送原API文档:cas-client-core-3.2.1-javadoc.jar; 赠送源代码:cas-client-core-3.2.1-sources.jar; 赠送Maven依赖信息文件:cas-client-core-3.2.1.pom; 包含翻译后...
单点登录(Single Sign On , 简称 SSO )是目前比较流行的服务于企业业务整合的解决...CAS Client 支持非常多的客户端(这里指单点登录系统中的各个 Web 应用),包括 Java, .Net, PHP, Perl, Apache, uPortal, Ruby 等。
Apereo .NET CAS client提供了.Net 集成到...outRich support for Microsoft ASP.NET platform integration through Forms Authentication framework开源地址:https://github.com/apereo/dotnet-cas-client中文介绍:...
cas-server-3.4.11和cas-client-3.2.1
cas-client3.5单点登录官方客户端程序demo
CAS实现单点登录,使用c#实现!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
java开发 用于cas单点登录的客户端 cas-client-core-3.2.0-sources.jar源码包
cas-client-3.2.1-release.zip