Exemplo n.º 1
0
 private void OnAfterAccess(CredentialCacheNotificationArgs args)
 {
     if (this.AfterAccess != null)
     {
         this.AfterAccess(args);
     }
 }
Exemplo n.º 2
0
 private void OnBeforeAccess(CredentialCacheNotificationArgs args)
 {
     if (this.BeforeAccess != null)
     {
         this.BeforeAccess(args);
     }
 }
Exemplo n.º 3
0
 private void OnBeforeWrite(CredentialCacheNotificationArgs args)
 {
     if (this.BeforeWrite != null)
     {
         this.BeforeWrite(args);
     }
 }
Exemplo n.º 4
0
        public virtual void Clear()
        {
            var cacheNotificationArgs = new CredentialCacheNotificationArgs {
                CredentialCache = this
            };

            this.OnBeforeAccess(cacheNotificationArgs);
            this.OnBeforeWrite(cacheNotificationArgs);

            this.cacheDictionary.Clear();

            this.HasStateChanged = true;
            this.OnAfterAccess(cacheNotificationArgs);
        }
Exemplo n.º 5
0
        internal virtual void AddToCache(AccountSession accountSession)
        {
            var cacheNotificationArgs = new CredentialCacheNotificationArgs {
                CredentialCache = this
            };

            this.OnBeforeAccess(cacheNotificationArgs);
            this.OnBeforeWrite(cacheNotificationArgs);

            var cacheKey = this.GetKeyForAuthResult(accountSession);

            this.cacheDictionary[cacheKey] = accountSession;

            this.HasStateChanged = true;
            this.OnAfterAccess(cacheNotificationArgs);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Clears the cache contents.
        /// </summary>
        public override void Clear()
        {
            // ADAL caching doesn't notify the delegates of access on Clear(). Call them explicitly
            // for consistency with CredentialCache behavior since the cache is being accessed and written.
            var cacheNotificationArgs = new CredentialCacheNotificationArgs {
                CredentialCache = this
            };

            this.OnBeforeAccess(cacheNotificationArgs);
            this.OnBeforeWrite(cacheNotificationArgs);

            this.TokenCache.Clear();

            this.OnAfterAccess(cacheNotificationArgs);
            this.HasStateChanged = true;
        }
Exemplo n.º 7
0
        internal virtual void DeleteFromCache(AccountSession accountSession)
        {
            if (accountSession != null)
            {
                var cacheNotificationArgs = new CredentialCacheNotificationArgs {
                    CredentialCache = this
                };
                this.OnBeforeAccess(cacheNotificationArgs);
                this.OnBeforeWrite(cacheNotificationArgs);

                var credentialCacheKey = this.GetKeyForAuthResult(accountSession);
                this.cacheDictionary.Remove(credentialCacheKey);

                this.HasStateChanged = true;

                this.OnAfterAccess(cacheNotificationArgs);
            }
        }
Exemplo n.º 8
0
        internal virtual AccountSession GetResultFromCache(AccountType accountType, string clientId, string userId)
        {
            var cacheNotificationArgs = new CredentialCacheNotificationArgs {
                CredentialCache = this
            };

            this.OnBeforeAccess(cacheNotificationArgs);

            var credentialCacheKey = new CredentialCacheKey
            {
                AccountType = accountType,
                ClientId    = clientId,
                UserId      = userId,
            };

            AccountSession cacheResult = null;

            this.cacheDictionary.TryGetValue(credentialCacheKey, out cacheResult);

            this.OnAfterAccess(cacheNotificationArgs);

            return(cacheResult);
        }
 protected void OnBeforeWrite(CredentialCacheNotificationArgs args)
 {
     if (this.BeforeWrite != null)
     {
         this.BeforeWrite(args);
     }
 }
 private void AfterAccess(CredentialCacheNotificationArgs args)
 {
     Assert.AreEqual(this.credentialCache, args.CredentialCache, "Unexpected cache present in args.");
     this.afterAccessCalled = true;
 }
        internal virtual AccountSession GetResultFromCache(AccountType accountType, string clientId, string userId)
        {
            var cacheNotificationArgs = new CredentialCacheNotificationArgs { CredentialCache = this };
            this.OnBeforeAccess(cacheNotificationArgs);

            var credentialCacheKey = new CredentialCacheKey
            {
                AccountType = accountType,
                ClientId = clientId,
                UserId = userId,
            };

            AccountSession cacheResult = null;
            this.cacheDictionary.TryGetValue(credentialCacheKey, out cacheResult);

            this.OnAfterAccess(cacheNotificationArgs);

            return cacheResult;
        }
        internal virtual void DeleteFromCache(AccountSession accountSession)
        {
            if (accountSession != null)
            {
                var cacheNotificationArgs = new CredentialCacheNotificationArgs { CredentialCache = this };
                this.OnBeforeAccess(cacheNotificationArgs);
                this.OnBeforeWrite(cacheNotificationArgs);

                var credentialCacheKey = this.GetKeyForAuthResult(accountSession);
                this.cacheDictionary.Remove(credentialCacheKey);

                this.HasStateChanged = true;

                this.OnAfterAccess(cacheNotificationArgs);
            }
        }
        internal virtual void AddToCache(AccountSession accountSession)
        {
            var cacheNotificationArgs = new CredentialCacheNotificationArgs { CredentialCache = this };

            this.OnBeforeAccess(cacheNotificationArgs);
            this.OnBeforeWrite(cacheNotificationArgs);

            var cacheKey = this.GetKeyForAuthResult(accountSession);
            this.cacheDictionary[cacheKey] = accountSession;

            this.HasStateChanged = true;
            this.OnAfterAccess(cacheNotificationArgs);
        }
        /// <summary>
        /// Clears the cache contents.
        /// </summary>
        public virtual void Clear()
        {
            var cacheNotificationArgs = new CredentialCacheNotificationArgs { CredentialCache = this };

            this.OnBeforeAccess(cacheNotificationArgs);
            this.OnBeforeWrite(cacheNotificationArgs);

            this.cacheDictionary.Clear();

            this.HasStateChanged = true;
            this.OnAfterAccess(cacheNotificationArgs);
        }
        /// <summary>
        /// Clears the cache contents.
        /// </summary>
        public override void Clear()
        {
            // ADAL caching doesn't notify the delegates of access on Clear(). Call them explicitly
            // for consistency with CredentialCache behavior since the cache is being accessed and written.
            var cacheNotificationArgs = new CredentialCacheNotificationArgs { CredentialCache = this };

            this.OnBeforeAccess(cacheNotificationArgs);
            this.OnBeforeWrite(cacheNotificationArgs);

            this.TokenCache.Clear();

            this.OnAfterAccess(cacheNotificationArgs);
            this.HasStateChanged = true;
        }
 private void BeforeWrite(CredentialCacheNotificationArgs args)
 {
     Assert.AreEqual(this.credentialCache, args.CredentialCache, "Unexpected cache present in args.");
     this.beforeWriteCalled = true;
 }
 protected void OnBeforeAccess(CredentialCacheNotificationArgs args)
 {
     if (this.BeforeAccess != null)
     {
         this.BeforeAccess(args);
     }
 }
Exemplo n.º 18
0
 private void OnAfterAccess(CredentialCacheNotificationArgs args)
 {
     if (this.AfterAccess != null)
     {
         this.AfterAccess(args);
     }
 }