Example #1
0
 public void Initialize(ClaimsPrincipal principal, ITokenCache tokenCache)
 {
     this.principal = principal;
     tokenCache.SetBeforeAccess(BeforeAccessNotification);
     tokenCache.SetAfterAccess(AfterAccessNotification);
     tokenCache.SetBeforeWrite(BeforeWriteNotification);
 }
Example #2
0
        /// <summary>Initializes the cache instance</summary>
        /// <param name="tokenCache">The ITokenCache passed through the constructor</param>
        /// <param name="user">The signed-in user for whom the cache needs to be established..</param>
        private void Initialize(ITokenCache tokenCache, ClaimsPrincipal user)
        {
            SignedInUser = user;

            tokenCache.SetBeforeAccess(UserTokenCacheBeforeAccessNotification);
            tokenCache.SetAfterAccess(UserTokenCacheAfterAccessNotification);
            tokenCache.SetBeforeWrite(UserTokenCacheBeforeWriteNotification);
        }
        /// <summary>Initializes this instance of TokenCacheProvider with essentials to initialize themselves.</summary>
        /// <param name="tokenCache">The token cache instance of MSAL application.</param>
        /// <param name="httpcontext">The Httpcontext whose Session will be used for caching.This is required by some providers.</param>
        public void Initialize(ITokenCache tokenCache, HttpContext httpcontext)
        {
            this.AppCacheId = this.appId + "_AppTokenCache";

            tokenCache.SetBeforeAccessAsync(this.AppTokenCacheBeforeAccessNotificationAsync);
            tokenCache.SetAfterAccessAsync(this.AppTokenCacheAfterAccessNotificationAsync);
            tokenCache.SetBeforeWrite(this.AppTokenCacheBeforeWriteNotification);
        }
Example #4
0
 /// <summary>Initializes this instance of TokenCacheProvider with essentials to initialize themselves.</summary>
 /// <param name="tokenCache">The token cache instance of MSAL application</param>
 /// <param name="httpcontext">The Httpcontext whose Session will be used for caching.This is required by some providers.</param>
 /// <param name="user">The signed-in user for whom the cache needs to be established. Not needed by all providers.</param>
 public void Initialize(ITokenCache tokenCache, HttpContext httpcontext, ClaimsPrincipal user)
 {
     _signedInUser   = user;
     _userTokenCache = tokenCache;
     _userTokenCache.SetBeforeAccess(UserTokenCacheBeforeAccessNotification);
     _userTokenCache.SetAfterAccess(UserTokenCacheAfterAccessNotification);
     _userTokenCache.SetBeforeWrite(UserTokenCacheBeforeWriteNotification);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="MSALAppMemoryTokenCache"/> class.
        /// </summary>
        /// <param name="tokenCache">The client's instance of the token cache.</param>
        /// <param name="clientId">The application's id (Client ID).</param>
        public MSALAppMemoryTokenCache(ITokenCache tokenCache, string clientId)
        {
            this.AppCacheId = clientId + "_AppTokenCache";

            tokenCache.SetBeforeAccess(AppTokenCacheBeforeAccessNotification);
            tokenCache.SetAfterAccess(AppTokenCacheAfterAccessNotification);
            tokenCache.SetBeforeWrite(AppTokenCacheBeforeWriteNotification);
        }
Example #6
0
        /// <summary>Initializes this instance of TokenCacheProvider with essentials to initialize themselves.</summary>
        /// <param name="tokenCache">The token cache instance of MSAL application</param>
        /// <param name="httpcontext">The Httpcontext whose Session will be used for caching.This is required by some providers.</param>
        public void Initialize(ITokenCache tokenCache, HttpContext httpcontext)
        {
            _apptokenCache = tokenCache;
            _apptokenCache.SetBeforeAccess(AppTokenCacheBeforeAccessNotification);
            _apptokenCache.SetAfterAccess(AppTokenCacheAfterAccessNotification);
            _apptokenCache.SetBeforeWrite(AppTokenCacheBeforeWriteNotification);

            ReadCacheForSignedInApp();
        }
Example #7
0
        public void Initialize(ITokenCache tokenCache, string username)
        {
            _userTokenCache = tokenCache;
            _userTokenCache.SetBeforeAccess(UserTokenCacheBeforeAccessNotification);
            _userTokenCache.SetAfterAccess(UserTokenCacheAfterAccessNotification);
            _userTokenCache.SetBeforeWrite(UserTokenCacheBeforeWriteNotification);

            _signedInUserName = username;
        }
Example #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MSALAppSessionTokenCache"/> class.
        /// </summary>
        /// <param name="tokenCache">The client's instance of the token cache.</param>
        /// <param name="clientId">The application's id (Client ID).</param>
        public MSALAppSessionTokenCache(ITokenCache tokenCache, string clientId, HttpContextBase httpcontext)
        {
            this.HttpContextInstance = httpcontext;
            this.AppCacheId          = clientId + "_AppTokenCache";

            tokenCache.SetBeforeAccess(AppTokenCacheBeforeAccessNotification);
            tokenCache.SetAfterAccess(AppTokenCacheAfterAccessNotification);
            tokenCache.SetBeforeWrite(AppTokenCacheBeforeWriteNotification);
        }
Example #9
0
        /// <summary>Initializes this instance of TokenCacheProvider with essentials to initialize themselves.</summary>
        /// <param name="tokenCache">The token cache instance of MSAL application</param>
        /// <param name="httpcontext">The Httpcontext whose Session will be used for caching.This is required by some providers.</param>
        public void Initialize(ITokenCache tokenCache, HttpContext httpcontext)
        {
            _appCacheId  = _appId + "_AppTokenCache";
            _httpContext = httpcontext;

            _apptokenCache = tokenCache;
            _apptokenCache.SetBeforeAccess(AppTokenCacheBeforeAccessNotification);
            _apptokenCache.SetAfterAccess(AppTokenCacheAfterAccessNotification);
            _apptokenCache.SetBeforeWrite(AppTokenCacheBeforeWriteNotification);
        }
Example #10
0
 /// <summary>Initializes the cache instance</summary>
 /// <param name="tokenCache">The <see cref="ITokenCache"/> passed through the constructor</param>
 /// <param name="httpcontext">The current <see cref="HttpContext" /></param>
 /// <param name="user">The signed in user's ClaimPrincipal, could be null.
 /// If the calling app has it available, then it should pass it themselves.</param>
 public void Initialize(ITokenCache tokenCache, HttpContext httpcontext, ClaimsPrincipal user)
 {
     if (tokenCache == null)
     {
         throw new ArgumentNullException(nameof(tokenCache));
     }
     tokenCache.SetBeforeAccess(this.UserTokenCacheBeforeAccessNotification);
     tokenCache.SetAfterAccess(this.UserTokenCacheAfterAccessNotification);
     tokenCache.SetBeforeWrite(this.UserTokenCacheBeforeWriteNotification);
 }
Example #11
0
        /// <summary>Initializes the cache instance</summary>
        /// <param name="tokenCache">The ITokenCache passed through the constructor</param>
        /// <param name="user">The signed-in user for whom the cache needs to be established..</param>
        private void Initialize(ITokenCache tokenCache, ClaimsPrincipal user)
        {
            this.SignedInUser = user;

            tokenCache.SetBeforeAccess(UserTokenCacheBeforeAccessNotification);
            tokenCache.SetAfterAccess(UserTokenCacheAfterAccessNotification);
            tokenCache.SetBeforeWrite(UserTokenCacheBeforeWriteNotification);

            if (this.SignedInUser == null)
            {
                // No users signed in yet, so we return
                return;
            }
        }
Example #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MSALAppMemoryTokenCache"/> class.
        /// </summary>
        /// <param name="tokenCache">The client's instance of the token cache.</param>
        /// <param name="clientId">The application's id (Client ID).</param>
        public MSALAppMemoryTokenCache(ITokenCache tokenCache, string clientId)
        {
            AppCacheId = clientId + "_AppTokenCache";

            if (AppTokenCache == null)
            {
                AppTokenCache = tokenCache;
                AppTokenCache.SetBeforeAccess(AppTokenCacheBeforeAccessNotification);
                AppTokenCache.SetAfterAccess(AppTokenCacheAfterAccessNotification);
                AppTokenCache.SetBeforeWrite(AppTokenCacheBeforeWriteNotification);
            }

            LoadAppTokenCacheFromMemory();
        }
        /// <summary>Initializes this instance of TokenCacheProvider with essentials to initialize themselves.</summary>
        /// <param name="tokenCache">The token cache instance of MSAL application</param>
        /// <param name="httpcontext">The Httpcontext whose Session will be used for caching.This is required by some providers.</param>
        /// <param name="user">The signed-in user for whom the cache needs to be established. Not needed by all providers.</param>
        public void Initialize(ITokenCache tokenCache, HttpContext httpcontext, ClaimsPrincipal user)
        {
            _signedInUser = user;

            _userTokenCache = tokenCache;
            _userTokenCache.SetBeforeAccess(UserTokenCacheBeforeAccessNotification);
            _userTokenCache.SetAfterAccess(UserTokenCacheAfterAccessNotification);
            _userTokenCache.SetBeforeWrite(UserTokenCacheBeforeWriteNotification);

            if (_signedInUser == null)
            {
                // No users signed in yet, so we return
                return;
            }
        }
        /// <summary>Initializes the cache instance</summary>
        /// <param name="tokenCache">The ITokenCache passed through the constructor</param>
        /// <param name="user">The signed-in user for whom the cache needs to be established..</param>
        private void Initialize(ITokenCache tokenCache, ClaimsPrincipal user)
        {
            SignedInUser = user;

            UserTokenCache = tokenCache;
            UserTokenCache.SetBeforeAccess(UserTokenCacheBeforeAccessNotification);
            UserTokenCache.SetAfterAccess(UserTokenCacheAfterAccessNotification);
            UserTokenCache.SetBeforeWrite(UserTokenCacheBeforeWriteNotification);

            if (SignedInUser == null)
            {
                // No users signed in yet, so we return
                return;
            }

            LoadUserTokenCacheFromMemory();
        }
Example #15
0
 /// <summary>Initializes this instance of TokenCacheProvider with essentials to initialize themselves.</summary>
 /// <param name="tokenCache">The token cache instance of MSAL application</param>
 /// <param name="httpcontext">The Httpcontext whose Session will be used for caching.This is required by some providers.</param>
 /// <param name="user">The signed-in user for whom the cache needs to be established. Not needed by all providers.</param>
 public void Initialize(ITokenCache tokenCache, HttpContext httpcontext, ClaimsPrincipal user)
 {
     tokenCache.SetBeforeAccess(this.UserTokenCacheBeforeAccessNotification);
     tokenCache.SetAfterAccess(this.UserTokenCacheAfterAccessNotification);
     tokenCache.SetBeforeWrite(this.UserTokenCacheBeforeWriteNotification);
 }
 public void Initialize(ITokenCache tokenCache)
 {
     tokenCache.SetBeforeAccess(BeforeAccessNotification);
     tokenCache.SetAfterAccess(AfterAccessNotification);
     tokenCache.SetBeforeWrite(BeforeWriteNotification);
 }
 /// <summary>Initializes this instance of TokenCacheProvider with essentials to initialize themselves.</summary>
 /// <param name="tokenCache">The token cache instance of MSAL application.</param>
 /// <param name="httpcontext">The Httpcontext whose Session will be used for caching.This is required by some providers.</param>
 public void Initialize(ITokenCache tokenCache, HttpContext httpcontext)
 {
     tokenCache.SetBeforeAccess(this.AppTokenCacheBeforeAccessNotification);
     tokenCache.SetAfterAccess(this.AppTokenCacheAfterAccessNotification);
     tokenCache.SetBeforeWrite(this.AppTokenCacheBeforeWriteNotification);
 }
Example #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MSALAppMemoryTokenCache"/> class.
 /// </summary>
 /// <param name="tokenCache">The client's instance of the token cache.</param>
 public MSALAppMemoryTokenCache(ITokenCache tokenCache)
 {
     tokenCache.SetBeforeAccess(AppTokenCacheBeforeAccessNotification);
     tokenCache.SetAfterAccess(AppTokenCacheAfterAccessNotification);
     tokenCache.SetBeforeWrite(AppTokenCacheBeforeWriteNotification);
 }
 /// <summary>Initializes the cache instance</summary>
 /// <param name="tokenCache">The ITokenCache passed through the constructor</param>
 /// <param name="user">The signed-in user for whom the cache needs to be established..</param>
 private void Initialize(ITokenCache tokenCache)
 {
     tokenCache.SetBeforeAccess(UserTokenCacheBeforeAccessNotification);
     tokenCache.SetAfterAccess(UserTokenCacheAfterAccessNotification);
     tokenCache.SetBeforeWrite(UserTokenCacheBeforeWriteNotification);
 }
 public AppTokenCacheWrapper(ITokenCache appTokenCache)
 {
     appTokenCache.SetBeforeAccess(AppTokenCacheBeforeAccessNotification);
     appTokenCache.SetBeforeWrite(AppTokenCacheBeforeWriteNotification);
     appTokenCache.SetAfterAccess(AppTokenCacheAfterAccessNotification);
 }