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 閱讀(1385) 評論(0)  編輯  收藏

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


          網站導航:
           

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

          常用鏈接

          留言簿(3)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 玉环县| 南陵县| 桑植县| 普陀区| 蒲城县| 宜兰市| 永康市| 大渡口区| 杭锦旗| 金阳县| 辽源市| 慈溪市| 辽阳县| 安泽县| 沈阳市| 岫岩| 德钦县| 万源市| 广德县| 二手房| 新源县| 铜川市| 莱阳市| 盐津县| 襄樊市| 长治县| 洪江市| 曲阳县| 荣成市| 上虞市| 揭阳市| 东乡| 华安县| 东莞市| 青河县| 沙田区| 双辽市| 达拉特旗| 彭泽县| 进贤县| 昌乐县|