예제 #1
0
        public void SaveAccount(MsalAccountCacheItem item)
        {
            ISharedPreferencesEditor editor = _accountSharedPreference.Edit();

            editor.PutString(item.GetKey().ToString(), item.ToJsonString());
            editor.Apply();
        }
예제 #2
0
        public void SaveAccount(MsalAccountCacheItem item)
        {
            string itemKey      = item.GetKey().ToString();
            string partitionKey = CacheKeyFactory.GetKeyFromCachedItem(item);

            AccountCacheDictionary
            .GetOrAdd(partitionKey, new ConcurrentDictionary <string, MsalAccountCacheItem>())[itemKey] = item;
        }
예제 #3
0
        private void MergeWamAccountIds(MsalAccountCacheItem msalAccountCacheItem)
        {
            var existingAccount = _accessor.GetAllAccounts()
                                  .SingleOrDefault(
                acc => string.Equals(
                    acc.GetKey().ToString(),
                    msalAccountCacheItem.GetKey().ToString(),
                    StringComparison.OrdinalIgnoreCase));
            var existingWamAccountIds = existingAccount?.WamAccountIds;

            msalAccountCacheItem.WamAccountIds.MergeDifferentEntries(existingWamAccountIds);
        }
예제 #4
0
        public void DeleteAccount(MsalAccountCacheItem item)
        {
            string partitionKey = CacheKeyFactory.GetKeyFromCachedItem(item);

            AccountCacheDictionary.TryGetValue(partitionKey, out var partition);
            if (partition == null || !partition.TryRemove(item.GetKey().ToString(), out _))
            {
                _logger.InfoPii(
                    $"Cannot delete account because it was not found in the cache. Key {item.GetKey()}.",
                    "Cannot delete account because it was not found in the cache");
            }
        }
        public void SaveAccount(MsalAccountCacheItem item)
        {
            var key     = item.GetKey();
            var account = key.GetiOSAccountKey();
            var service = key.GetiOSServiceKey();
            var generic = key.GetiOSGenericKey();

            var type = AuthorityTypeToAttrType[item.AuthorityType];

            var value = JsonHelper.SerializeToJson(item);

            Save(account, service, generic, type, value);
        }
        private void RefreshCacheView()
        {
            var tokenCache = App.MsalPublicClient.UserTokenCache;

            var requestContext = new RequestContext(null, new MsalLogger(Guid.NewGuid(), null));

            IDictionary <string, MsalAccessTokenCacheItem> accessTokens = new Dictionary <string, MsalAccessTokenCacheItem>();

            foreach (var accessItemStr in tokenCache.GetAllAccessTokenCacheItems(requestContext))
            {
                MsalAccessTokenCacheItem accessItem = JsonHelper.DeserializeFromJson <MsalAccessTokenCacheItem>(accessItemStr);
                accessTokens.Add(accessItem.GetKey().ToString(), accessItem);
            }
            accessTokenCacheItems.ItemsSource = accessTokens;

            IDictionary <string, MsalRefreshTokenCacheItem> refreshTokens = new Dictionary <string, MsalRefreshTokenCacheItem>();

            foreach (var refreshItemStr in tokenCache.GetAllRefreshTokenCacheItems(requestContext))
            {
                MsalRefreshTokenCacheItem refreshItem = JsonHelper.DeserializeFromJson <MsalRefreshTokenCacheItem>(refreshItemStr);
                refreshTokens.Add(refreshItem.GetKey().ToString(), refreshItem);
            }
            refreshTokenCacheItems.ItemsSource = refreshTokens;

            IDictionary <string, MsalIdTokenCacheItem> idTokens = new Dictionary <string, MsalIdTokenCacheItem>();

            foreach (var idItemStr in tokenCache.GetAllIdTokenCacheItems(requestContext))
            {
                MsalIdTokenCacheItem idItem = JsonHelper.DeserializeFromJson <MsalIdTokenCacheItem>(idItemStr);
                idTokens.Add(idItem.GetKey().ToString(), idItem);
            }
            idTokenCacheItems.ItemsSource = idTokens;

            IDictionary <string, MsalAccountCacheItem> accounts = new Dictionary <string, MsalAccountCacheItem>();

            foreach (var accountStr in tokenCache.GetAllAccountCacheItems(requestContext))
            {
                MsalAccountCacheItem accountItem = JsonHelper.DeserializeFromJson <MsalAccountCacheItem>(accountStr);
                accounts.Add(accountItem.GetKey().ToString(), accountItem);
            }
            accountsCacheItems.ItemsSource = accounts;
        }
예제 #7
0
 public void DeleteAccount(MsalAccountCacheItem item)
 {
     Delete(item.GetKey().ToString(), _accountSharedPreference.Edit());
 }
 public void SaveAccount(MsalAccountCacheItem item)
 {
     Save(item.GetKey(), item.ToJsonString());
 }
        public void SaveAccount(MsalAccountCacheItem item)
        {
            string key = item.GetKey().ToString();

            _accountCacheDictionary.AddOrUpdate(key, item, (k, oldValue) => item);
        }
예제 #10
0
        public void SaveAccount(MsalAccountCacheItem item)
        {
            string key = item.GetKey().ToString();

            _accountCacheDictionary[key] = item;
        }
 public void DeleteAccount(MsalAccountCacheItem item)
 {
     Remove(item.GetKey());
 }
예제 #12
0
 public void SaveAccount(MsalAccountCacheItem item)
 {
     _accountCacheDictionary[item.GetKey().ToString()] = item;
 }
 public void SaveAccount(MsalAccountCacheItem item)
 {
     AccountCacheDictionary[item.GetKey().ToString()] = JsonHelper.SerializeToJson(item);
 }
예제 #14
0
        public void SaveAccount(MsalAccountCacheItem item)
        {
            ApplicationDataCompositeValue composite = new ApplicationDataCompositeValue();

            SetCacheValue(composite, JsonHelper.SerializeToJson(item));
            _accountContainer.Values[/*CoreCryptographyHelpers.CreateBase64UrlEncodedSha256Hash(cacheKey)*/ item.GetKey().ToString()] = composite;
        }