Example #1
0
        public override SessionSecurityToken Get(SessionSecurityTokenCacheKey key)
        {
            Log.DebugFormat("Key: {0}", key);
            var token = m_MemoryCache.Get(key);

            if (token != null)
            {
                Log.DebugFormat("Token: {0} - found in memory cache", token.Id);
                return(token);
            }

            var tokenWithExpiry = m_SessionSecurityTokenStore.ReadTokenFromStore(key);

            if (tokenWithExpiry == null || tokenWithExpiry.Item2 == null)
            {
                Log.DebugFormat("Token key: {0} - not in cache", key);
                return(null);
            }
            var expiry = tokenWithExpiry.Item1;

            token = tokenWithExpiry.Item2;
            Log.DebugFormat("Token: {0} Expiry: {1} - found in persistent cache", token.Id, expiry);
            Log.DebugFormat("Refreshing token {0} in memory cache", token.Id);
            m_MemoryCache.AddOrUpdate(key, token, expiry);
            return(token);
        }
Example #2
0
        public SecurityContextSecurityToken GetContext(System.Xml.UniqueId contextId, System.Xml.UniqueId generation)
        {
            SessionSecurityToken         token = null;
            SessionSecurityTokenCacheKey key   = new SessionSecurityTokenCacheKey(_claimsHandler.EndpointId, contextId, generation);

            token = _tokenCache.Get(key);

            SecurityContextSecurityToken sctToken = null;

            if (token != null && token.IsSecurityContextSecurityTokenWrapper)
            {
                sctToken = SecurityContextSecurityTokenHelper.ConvertSessionTokenToSecurityContextSecurityToken(token);
            }

            return(sctToken);
        }
        public override SessionSecurityToken Get(SessionSecurityTokenCacheKey key)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            var token = inner.Get(key);

            if (token != null)
            {
                return(token);
            }

            var item = tokenCacheRepository.Get(key.ToString());

            if (item == null)
            {
                return(null);
            }

            token = BytesToToken(item.Token);

            // update in-mem cache from database
            inner.AddOrUpdate(key, token, item.Expires);

            return(token);
        }
Example #4
0
        public SessionSecurityToken Get(string endpointId, string contextId, string keyGeneration)
        {
            SessionSecurityToken token = internalCache.Get(new SessionSecurityTokenCacheKey(endpointId, GetContextId(contextId), GetKeyGeneration(keyGeneration)));

            return(token);
        }