protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         if (string.IsNullOrEmpty(Convert.ToString(HttpContext.Current.Session["user"])))
         {
             // replace with an instance of the users account.
             AccountSettings accountSettings = new AccountSettings();
             Response samlResponse = new Response(accountSettings);
             samlResponse.LoadXmlFromBase64(Request.Form["SAMLResponse"]);
             if (samlResponse.IsValid())
             {
                 lblUser.Text += "<b>User:"******"</b><br>";
                 foreach (KeyValuePair<string, string> kvp in samlResponse.AttibuteCollection())
                 {
                     lblUser.Text +=kvp.Key + " = " + kvp.Value+"<br>";
                 }
                 HttpContext.Current.Session["user"] = lblUser.Text;
             }
             else
             {
                 HttpContext.Current.Session["user"] = "";
                 lblUser.Text = "Failed";
             }
         }
         else
         {
             //Response.Redirect("ServicePage.aspx");
             lblUser.Text = Convert.ToString(HttpContext.Current.Session["user"]);
         }
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            AccountSettings accountSettings = new AccountSettings();

            LogoutResponse samlResponse = new LogoutResponse(accountSettings);
            samlResponse.LoadXmlFromBase64(Request.Form["SAMLResponse"]);
            if(samlResponse.IsValid())
            {
                HttpContext.Current.Session["user"] = "";
                lblMsg.Text = "<h1>You are logged out</h1>";
            }
            else
            {
                lblMsg.Text = "Logout failed";
            }
            //Response.Write(samlResponse.ToString());
        }
 protected void lnkInitiateSSO_Click(object sender, EventArgs e)
 {
     AccountSettings accountSettings = new AccountSettings();
     LogoutRequest req = new LogoutRequest(new AppSettings(), accountSettings);
     Response.Redirect(accountSettings.idp_slo_target_url + "?SAMLRequest=" + Server.UrlEncode(req.GetRequest(LogoutRequest.LogoutRequestFormat.Base64)));
 }
示例#4
0
 public Response(AccountSettings accountSettings)
 {
     this.accountSettings = accountSettings;
     certificate = new Certificate();
     certificate.LoadCertificate(accountSettings.certificate);
 }
示例#5
0
            public LogoutRequest(AppSettings appSettings, AccountSettings accountSettings)
            {
                this.appSettings = appSettings;
                this.accountSettings = accountSettings;

                id = "_" + System.Guid.NewGuid().ToString();
                issue_instant = DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ");
            }