allen
          專注于java ee技術,包括struts,jsf,webwork,spring,hibernate,ibatis
          posts - 7,  comments - 9,  trackbacks - 0

          using System;
          using System.Collections;
          using System.ComponentModel;
          using System.Data;
          using System.Drawing;
          using System.Web;
          using System.Web.SessionState;
          using System.Web.UI;
          using System.Web.UI.WebControls;
          using System.Web.UI.HtmlControls;
          using System.Xml;
          using System.Net;
          using System.IO;
          namespace ssotest
          {
          ?/// <summary>
          ?/// login 的摘要說明。
          ?/// </summary>
          ?public class login : System.Web.UI.Page
          ?{
          ??protected System.Web.UI.WebControls.Label Label1;
          ??private const string CASHOST = "https://localhost:8443/cas/";
          ??


          ??private void Page_Load(object sender, System.EventArgs e)
          ??{
          ???// 在此處放置用戶代碼以初始化頁面
          ???String tkt=Request.QueryString["ticket"];
          ???string service = Request.Url.GetLeftPart(UriPartial.Path);
          ???if (tkt == null || tkt.Length == 0)
          ???{
          ????string redir = CASHOST + "login?" +???????????????? "service=" + service;
          ????Response.Redirect(redir);
          ????return ;
          ???}
          ???string validateurl = CASHOST + "serviceValidate?" +
          ????"ticket=" + tkt + "&"+
          ????"service=" + service;
          ???//Response.Write(validateurl);
          ???System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();
          ???StreamReader Reader = new StreamReader( new WebClient().OpenRead(validateurl));
          ???string resp = Reader.ReadToEnd();
          ???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;
          ???while (reader.Read())
          ???{
          ????if (reader.IsStartElement())
          ????{
          ????? string tag = reader.LocalName;
          ????? if (tag=="user")????????????????
          ?????? netid = reader.ReadString();????????????????
          ????}
          ???}
          ??? reader.Close();
          ???if (netid == null)
          ???{
          ????Label1.Text = "CAS returned to this application, but then refused to validate your identity.";????????
          ???}
          ???else
          ???{
          ????? Label1.Text = "Welcome " + netid;?
          ???? // FormsAuthentication.RedirectFromLoginPage(netid, false);
          ???}
          ??}
          ??public class TrustAllCertificatePolicy : System.Net.ICertificatePolicy

          ??{

          ???public TrustAllCertificatePolicy()

          ???{}

          ?

          ???public bool CheckValidationResult(ServicePoint sp,

          ????System.Security.Cryptography.X509Certificates.X509Certificate cert,

          ????WebRequest req, int problem)

          ???{

          ????return true;

          ???}

          ??}


          ??#region Web 窗體設計器生成的代碼
          ??override protected void OnInit(EventArgs e)
          ??{
          ???//
          ???// CODEGEN: 該調用是 ASP.NET Web 窗體設計器所必需的。
          ???//
          ???InitializeComponent();
          ???base.OnInit(e);
          ??}
          ??
          ??/// <summary>
          ??/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
          ??/// 此方法的內容。
          ??/// </summary>
          ??private void InitializeComponent()
          ??{???
          ???this.Load += new System.EventHandler(this.Page_Load);

          ??}
          ??#endregion
          ?}
          }

          posted on 2006-11-09 11:51 robbin163 閱讀(1386) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿(3)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 明光市| 新民市| 紫金县| 运城市| 南投市| 日喀则市| 宣城市| 昭苏县| 晋中市| 永德县| 四平市| 盐亭县| 宁夏| 苗栗县| 滨海县| 巩义市| 河南省| 遂川县| 三门峡市| 蓬莱市| 南靖县| 北宁市| 乌拉特中旗| 沙坪坝区| 定安县| 东莞市| 乐亭县| 永德县| 锡林郭勒盟| 罗城| 湘潭县| 抚顺县| 潢川县| 彝良县| 凌海市| 苏州市| 遂川县| 五华县| 武威市| 清水县| 卓尼县|