Beispiel #1
0
        public override void AddOrUpdate(System.IdentityModel.Tokens.SessionSecurityTokenCacheKey key,
                                         System.IdentityModel.Tokens.SessionSecurityToken value, DateTime expiryTime)
        {
            string tokenId        = null;
            var    claimsIdentity = Thread.CurrentPrincipal.Identity as ClaimsIdentity;

            if (claimsIdentity != null && claimsIdentity.BootstrapContext != null)
            {
                var bootstrap = claimsIdentity.BootstrapContext as BootstrapContext;
                if (bootstrap != null && bootstrap.SecurityToken != null)
                {
                    tokenId = bootstrap.SecurityToken.Id;
                }
            }

            var data = cache.AddOrUpdate(new bUtility.TokenCache.Types.SessionSecurity.SessionCacheEntry
            {
                EndpointId                = key.EndpointId,
                ContextId                 = key?.ContextId?.ToString(),
                KeyGeneration             = GetKeyGenerationString(key),
                ExpiryTime                = expiryTime,
                SessionSecurityTokenValue = value,
                UserName = Thread.CurrentPrincipal.Identity.Name,
                SessionSecurityTokenID = tokenId
            });

            if (data)
            {
                _internalCache.AddOrUpdate(key, value, expiryTime);
            }
        }
Beispiel #2
0
        public Response <bool> AddOrUpdate(Request <SessionCacheEntry> request)
        {
            var data = Service.AddOrUpdate(request.Payload);

            return(new Response <bool> {
                Payload = data
            });
        }