Пример #1
0
        public string GenerateNewTokenWithExpiryData(string userNameShaEncryptedString)
        {
            var periodSliding  = _configurationReader.GetSlidingExpiration();
            var periodAbsolute = _configurationReader.GetAbsoluteExpiration();

            var userTokenData = new UserTokenData();
            var now           = DateTime.Now;

            userTokenData.SlidingExpiration  = now.AddMinutes(periodSliding);
            userTokenData.PresentTime        = DateTime.Now;
            userTokenData.AbsoluteExpiration = now.AddHours(periodAbsolute);
            userTokenData.CipherUserName     = userNameShaEncryptedString;

            var newToken = AesHelper
                           .Encrypt(
                JsonConvert
                .SerializeObject(
                    userTokenData));

            return(newToken);
        }