public static bool TryParse(string text, out SsoTicket ticket) { ticket = null; string[] vector; if (!SsoCipher.TryParseVector(text, out vector)) { return(false); } if (vector.Length != 3) { return(false); } ticket = new SsoTicket(); ticket._userId = vector[0]; ticket._timeStamp = Convert.ToDateTime(vector[1]); ticket._expireDuration = Convert.ToInt32(vector[2]); return(true); }
public static SsoTicket GetAuthenticatedTicket() { HttpCookie cookie = Request.Cookies[Constants.TokenCookieName]; if (cookie == null) { return(null); } string cookieText = cookie.Value; if (string.IsNullOrEmpty(cookieText)) { return(null); } SsoTicket ticket; if (!SsoTicket.TryParse(cookieText, out ticket)) { return(null); } return(ticket); }
//public static void RedirectToApp(string returnUrl, ResponseToken token) //{ // char appendChar = '?'; // if (returnUrl.IndexOf('?') != -1) // appendChar = '&'; // string redirectUrl = string.Format("{0}{1}{2}={3}", returnUrl, appendChar, Constants.ResponseToken, token.Encode()); // Response.Redirect(redirectUrl); //} public static void GenerateTicket(SsoTicket ticket) { ResetCookie(Constants.TokenCookieName, ticket.Encode()); }