コード例 #1
0
        public UserIdamData GetUserIdamDataFromCookie(HttpContext context)
        {
            var cookie = new CookieHelper(Settings.UserDataCookieName, context);

            cookie.GetCookie();
            var encodedJwtToken = cookie.GetValue(Settings.UserDataCookieKey);

            if (string.IsNullOrEmpty(encodedJwtToken))
            {
                return(null);
            }

            var jwtToken = _encryptionService.Decode(encodedJwtToken);

            IEnumerable <Claim> claims;

            try
            {
                claims = _jwtTokenService.GetClaimsFromJwtToken(jwtToken, Settings.JwtTokenSecurityKey);
            }
            catch (Exception)
            {
                //_logManager.LogError("GetUserDataFromCookie failed", ex, this); // Uncomment for debug purposes
                return(null);
            }
            return(new UserIdamData(claims));
        }