Beispiel #1
0
 internal static void Cleanup()
 {
     if (DelegatedPrincipalCache.cleanupTime > DateTime.UtcNow)
     {
         return;
     }
     lock (DelegatedPrincipalCache.syncObj)
     {
         if (!(DelegatedPrincipalCache.cleanupTime > DateTime.UtcNow))
         {
             List <DelegatedPrincipalCache.CacheKey> list = new List <DelegatedPrincipalCache.CacheKey>();
             foreach (DelegatedPrincipalCache.CacheKey cacheKey in DelegatedPrincipalCache.delegatedCache.Keys)
             {
                 DelegatedPrincipalCacheData data = DelegatedPrincipalCache.delegatedCache[cacheKey];
                 if (DelegatedPrincipalCache.IsCacheBucketExpired(data))
                 {
                     list.Add(cacheKey);
                 }
             }
             foreach (DelegatedPrincipalCache.CacheKey key in list)
             {
                 DelegatedPrincipalCache.delegatedCache.Remove(key);
             }
             DelegatedPrincipalCache.cleanupTime = DateTime.UtcNow.AddHours(6.0);
         }
     }
 }
Beispiel #2
0
        internal static DelegatedPrincipalCacheData GetEntry(string targetOrgId, string userId, string securityToken)
        {
            DelegatedPrincipalCache.CacheKey key = new DelegatedPrincipalCache.CacheKey(targetOrgId, userId, securityToken);
            DelegatedPrincipalCacheData      delegatedPrincipalCacheData = null;

            if (DelegatedPrincipalCache.delegatedCache.ContainsKey(key))
            {
                lock (DelegatedPrincipalCache.syncObj)
                {
                    if (DelegatedPrincipalCache.delegatedCache.TryGetValue(key, out delegatedPrincipalCacheData))
                    {
                        if (delegatedPrincipalCacheData != null && DelegatedPrincipalCache.IsCacheBucketExpired(delegatedPrincipalCacheData))
                        {
                            DelegatedPrincipalCache.delegatedCache.Remove(key);
                            delegatedPrincipalCacheData = null;
                        }
                        else
                        {
                            delegatedPrincipalCacheData.LastReadTime = DateTime.UtcNow;
                        }
                    }
                }
            }
            return(delegatedPrincipalCacheData);
        }