/// <summary> /// Handles the id PSSO request. /// </summary> /// <param name="context">The context.</param> /// <param name="request">The request.</param> /// <param name="response">The response.</param> /// <param name="session">The session.</param> private void HandleIdPSSORequest(HttpContext context, HttpRequest request, HttpResponse response, HttpSessionState session) { if (request.Cookies[FormsAuthentication.FormsCookieName] == null) return; var cookiestr = request.Cookies[FormsAuthentication.FormsCookieName].Value; var tkt = FormsAuthentication.Decrypt(cookiestr); if (tkt == null) return; var attributes = new MultiStringDictionary { {Constants.SUBJECT, tkt.Name}, {"NickName", "defaultNickName"}, {"Role", "Admin"} }; if (request[Constants.RESUME_PATH] == null) return; var attributesToSend = new MultiStringDictionary(); foreach (var pair in attributes) { var key = pair.Key; foreach (string value in pair.Value) { attributesToSend.Add(key, value); } } var strRedirect = "https://" + ConfigurationManager.AppSettings["PFHost"] + request[Constants.RESUME_PATH]; strRedirect = SetOpenToken(context, strRedirect, attributesToSend); response.Redirect(strRedirect, true); }
/// <summary> /// Sets the open token. /// </summary> /// <param name="context">The context.</param> /// <param name="url">The URL.</param> /// <param name="userInfo">The user info.</param> /// <returns></returns> private String SetOpenToken(HttpContext context, String url, MultiStringDictionary userInfo) { var response = context.Response; var propsPath = context.Request.PhysicalApplicationPath + @"\" + Constants.PFAGENT_PROPERTIES; var agent = new Agent(propsPath); var urlHelper = new UrlHelper(url); agent.WriteToken(userInfo, response, urlHelper, false); return urlHelper.ToString(); }