예제 #1
0
        // Returns keyImpl owned by cache, thus KeyHolder is not used
        public IKeyImpl TryGet(KeyIdentity identity, KeyDisposition disposition, KeySecurity samDesired)
        {
            lock (this)
            {
                CacheKey cacheKey = new CacheKey {
                    Identity = identity, Disposition = disposition
                };
                if (!cachedKeyImpls_.ContainsKey(cacheKey))
                {
                    return(null);
                }

                KeyImplHolder cached = cachedKeyImpls_[cacheKey];
                if (!samDesired.IsSubSetOf(cached.GetKeyImpl().GetAccessMode()))
                {
                    return(null);
                }

                return(cached.GetKeyImpl());
            }
        }
예제 #2
0
 // If the keyImpl is added, returns NotOwningKeyImplHolder,
 // otherwise returns original KeyImplHolder
 public KeyImplHolder Add(KeyIdentity identity, KeyDisposition disposition, KeyImplHolder keyHolder)
 {
     lock (this)
     {
         CacheKey cacheKey = new CacheKey {
             Identity = identity, Disposition = disposition
         };
         if (cachedKeyImpls_.ContainsKey(cacheKey))
         {
             return(keyHolder);
         }
         cachedKeyImpls_.Add(cacheKey, keyHolder);
         return(new NotOwningKeyImplHolder(keyHolder.GetKeyImpl()));
     }
 }