Exemple #1
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 (!SsoCipher.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);
        }
Exemple #2
0
        public static string GetRedirectToAppUrl(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());

            return(redirectUrl);
        }
Exemple #3
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);
            }
            return(true);
        }