Example #1
0
 public static bool Authenticate(out ResponseToken token)
 {
     string tokenText = Request[Constants.ResponseToken];
     if (!ResponseToken.TryParse(tokenText, out token))
         return false;
     if (token.Seed != _seed)
         return false;
     SSOTicket ticket = new SSOTicket();
     ticket.UserId = token.UserId;
     ticket.TimeStamp = token.TimeStamp;
     ticket.ExpireDuration = token.ExpireDuration;
     ResetCookie(Constants.TokenCookieName, ticket.Encode());
     return true;
 }
Example #2
0
        public static bool TryParse(string tokenText, out ResponseToken token)
        {
            token = null;

            if (string.IsNullOrEmpty(tokenText))
                return false;

            string textToDecypt = HttpUtility.UrlDecode(tokenText);
            string[] vector = null;

            if (!SSOEncrypt.TryParseVector(textToDecypt, out vector))
                return false;

            if (vector.Length != 5)
                return false;

            string userId = vector[0];
            DateTime timeStamp = Convert.ToDateTime(vector[1]);
            int expire = Convert.ToInt32(vector[2]);
            string seed = vector[3];
            int resultCode = Convert.ToInt32(vector[4]);
            token = new ResponseToken(userId, timeStamp, expire, seed, resultCode);
            return true;
        }
Example #3
0
 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);
 }