Ejemplo n.º 1
0
        public static string CreateToken(UserProfile userProfile, DateTime expires)
        {
            var token = new AccessTokenIdentity <int>
            {
                UserId  = userProfile.Id,
                Expires = expires
            };

            string input = ToJson(token);

            return(AesEncrypt(input));
        }
Ejemplo n.º 2
0
        public static AccessTokenIdentity <T> GetAccessToken <T>(string input)
        {
            string temp = AesDecrypt(input);

            if (string.IsNullOrWhiteSpace(temp))
            {
                return(null);
            }

            AccessTokenIdentity <T> token = null;

            try
            {
                token = Deserialize <AccessTokenIdentity <T> >(temp);
            }
            catch (Exception)
            {
            }

            return(token);
        }