示例#1
0
        public ActionResult Login(SamlLoginModel model)
        {
            if (ModelState.IsValid)
            {
                AccountSettings accountSettings = new AccountSettings();

                var samlResponse = new Response(accountSettings);
                samlResponse.LoadXmlFromBase64(model.SAMLResponse);

                if (samlResponse.IsValid())
                {
                    FormsAuthentication.SetAuthCookie(samlResponse.GetNameID(), true);

                    // Redirect to targetURL, or to /Home by default

                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
                }
            }
            else
            {
                ModelState.AddModelError("", "The user name or password provided is incorrect.");
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
示例#2
0
        public AuthRequest(AppSettings appSettings, AccountSettings accountSettings)
        {
            this.appSettings = appSettings;
            this.accountSettings = accountSettings;

            id = "_" + System.Guid.NewGuid().ToString();
            issue_instant = DateTime.UtcNow.ToString("yyyy-mm-ddTH:mm:ssZ");
        }
示例#3
0
        public ActionResult Login()
        {
            AccountSettings accountSettings = new AccountSettings();

            AuthRequest req = new AuthRequest(new AppSettings(), accountSettings);

            return this.Redirect(accountSettings.idp_sso_target_url + "?SAMLRequest=" + Server.UrlEncode(req.GetRequest(AuthRequest.AuthRequestFormat.Base64)));
        }
示例#4
0
 public Response(AccountSettings accountSettings)
 {
     this.accountSettings = accountSettings;
     certificate = new Certificate();
     certificate.LoadCertificate(accountSettings.certificate);
 }