using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.IO; using Bowin.Common.JSON; using System.Web; namespace EMISOnline.Utility.FormValidate { public static class SSO { public static string SSOLogin() { string fromUrl = ""; string currentUrl = HttpContext.Current.Request.Url.AbsoluteUri; string getTicketUrl = Const.SSO_HOST + "Account/GetTicket?url=" + currentUrl; string authUrl = Const.SSO_HOST + "Account/AuthTicket"; string ticket = HttpContext.Current.Request["ticket"]; if (HttpContext.Current.Request.UrlReferrer != null) { fromUrl = HttpContext.Current.Request.UrlReferrer.AbsolutePath; } if (ticket == null && !fromUrl.StartsWith(Const.SSO_HOST)) { HttpContext.Current.Response.Redirect(getTicketUrl); return ""; } else if (ticket == null && fromUrl.StartsWith(Const.SSO_HOST)) { return ""; } else { WebRequest webRequest = (HttpWebRequest)WebRequest.Create(authUrl + "?ticket=" + ticket); webRequest.Method = "POST"; webRequest.ContentType = "text/json"; webRequest.ContentLength = 0; StreamReader sr = new StreamReader(webRequest.GetResponse().GetResponseStream()); string loginID = sr.ReadToEnd(); sr.Close(); return loginID.JsonToObject(); } } } }