Exemple #1
0
        /// <summary>
        /// Actual cache read. Notifications should be sent before & after this method.
        /// Updates this.MostRecentlyUsedKey.
        /// </summary>
        /// <param name="credentialCacheKey">Key to look up</param>
        /// <returns>Result from cache.</returns>
        private AccountSession GetResultFromCache(CredentialCacheKey credentialCacheKey)
        {
            AccountSession cacheResult = null;

            if (this.cacheDictionary.TryGetValue(credentialCacheKey, out cacheResult))
            {
                this.MostRecentlyUsedKey = credentialCacheKey;
            }

            return(cacheResult);
        }
Exemple #2
0
        internal virtual AccountSession GetResultFromCache(string clientId, string userId)
        {
            var credentialCacheKey = new CredentialCacheKey
            {
                ClientId = clientId,
                UserId   = userId,
            };

            var cacheNotificationArgs = new CredentialCacheNotificationArgs {
                CredentialCache = this
            };

            this.OnBeforeAccess(cacheNotificationArgs);

            var result = this.GetResultFromCache(credentialCacheKey);

            this.OnAfterAccess(cacheNotificationArgs);

            return(result);
        }
Exemple #3
0
 /// <summary>
 /// Instantiates a new <see cref="CredentialCache"/>.
 /// </summary>
 /// <param name="blob">The cache contents for initialization.</param>
 /// <param name="serializer">The <see cref="ISerializer"/> for serializing cache contents.</param>
 public CredentialCache(byte[] blob, ISerializer serializer = null)
 {
     this.Serializer = serializer ?? new Serializer();
     this.InitializeCacheFromBlob(blob);
     this.MostRecentlyUsedKey = null;
 }