コード例 #1
0
        private SamlVerifyResponse GetVerifyResponse(Guid appTicket, Guid userTicket, HttpApplication application)
        {
            SamlVerifyResponse response = null;
            XmlDocument        document = SamlVerifyRequest.CreateRequestXml(appTicket, userTicket);
            string             str      = new WebService().CheckAuthorization(document.InnerXml);

            if (!string.IsNullOrEmpty(str))
            {
                response = new SamlVerifyResponse(str);
            }
            return(response);
        }
コード例 #2
0
        protected virtual void VerifyUser(HttpApplication application)
        {
            if (string.IsNullOrEmpty(application.Request.QueryString["Ticket"]))
            {
                //application.Response.Redirect(SSOClientConfig.SignOnUrl + "?ActionUrl=" + application.Server.UrlEncode(application.Request.Url.AbsoluteUri), true);
                string site = "";
                System.Text.RegularExpressions.Match m = System.Text.RegularExpressions.Regex.Match(application.Request.Url.AbsoluteUri, "http://[^/]+/");
                if (m.Captures != null && m.Captures.Count > 0)
                {
                    site = m.Captures[0].Value;
                }

                application.Response.Redirect(SSOClientConfig.SignOnUrl + "?ActionUrl=" + application.Server.UrlEncode(site), true);
            }
            Guid userTicket             = new Guid(application.Request.QueryString["Ticket"]);
            Guid appTicket              = this.CreateGuid();
            SamlVerifyResponse response = this.GetVerifyResponse(appTicket, userTicket, application);

            if ((response != null) && (response.AppTicket == appTicket))
            {
                this.UserName = response.UserIdentity;
                this.OnAppEndVerifyUser(application);
                //application.Response.Redirect(this.RedirectUri(application.Request.Url.AbsoluteUri), true);
                //application.Response.Redirect(this.RedirectUri(application.Request.Url.AbsoluteUri.Replace("login.aspx", "Account/Logon?ReturnUrl=%2f")), true);
                System.Web.Security.FormsAuthentication.SetAuthCookie(this.UserName, false);

                string site = "";
                System.Text.RegularExpressions.Match m = System.Text.RegularExpressions.Regex.Match(application.Request.Url.AbsoluteUri, "http://[^/]+/");
                if (m.Captures != null && m.Captures.Count > 0)
                {
                    site = m.Captures[0].Value;
                }
                application.Response.Redirect(this.RedirectUri(site), true);
            }
            else
            {
                string url = SSOClientConfig.SignOnUrl + "?ActionUrl=" + application.Server.UrlEncode(application.Request.Url.AbsoluteUri);
                application.Response.Redirect(url, true);
            }
        }