Example #1
0
        public MsalAccountCacheItem GetAccount(MsalAccountCacheKey accountKey)
        {
            if (_accountCacheDictionary.TryGetValue(accountKey.ToString(), out var cacheItem))
            {
                return(cacheItem);
            }

            return(null);
        }
 public void DeleteAccount(MsalAccountCacheKey cacheKey)
 {
     if (!_accountCacheDictionary.TryRemove(cacheKey.ToString(), out _))
     {
         _logger.InfoPii(
             $"Cannot delete an account because it was already deleted. Key {cacheKey}",
             "Cannot delete an account because it was already deleted");
     }
 }
        public void MsalAccountCacheKey()
        {
            MsalAccountCacheKey key = new MsalAccountCacheKey("login.microsoftonline.com", "contoso.com", "uid.utid", "localId");

            Assert.AreEqual("uid.utid-login.microsoftonline.com-contoso.com", key.ToString());

            Assert.AreEqual("uid.utid-login.microsoftonline.com", key.GetiOSAccountKey());
            Assert.AreEqual("contoso.com", key.GetiOSServiceKey());
            Assert.AreEqual("localid", key.GetiOSGenericKey());
        }
Example #4
0
        public MsalAccountCacheItem GetAccount(MsalAccountCacheKey accountKey)
        {
            string partitionKey = CacheKeyFactory.GetKeyFromAccount(accountKey);

            AccountCacheDictionary.TryGetValue(partitionKey, out var partition);
            MsalAccountCacheItem cacheItem = null;

            partition?.TryGetValue(accountKey.ToString(), out cacheItem);
            return(cacheItem);
        }
        public string GetAccount(MsalAccountCacheKey accountKey)
        {
            var strKey = accountKey.ToString();

            if (!AccountCacheDictionary.ContainsKey(strKey))
            {
                return(null);
            }

            return(AccountCacheDictionary[strKey]);
        }
Example #6
0
        public string GetAccount(MsalAccountCacheKey accountKey)
        {
            var keyStr = accountKey.ToString();

            if (!_accountContainer.Values.ContainsKey(/*encodedKey*/ keyStr))
            {
                return(null);
            }

            return(CoreHelpers.ByteArrayToString(
                       GetCacheValue((ApplicationDataCompositeValue)_accountContainer.Values[
                                         /*CoreCryptographyHelpers.CreateBase64UrlEncodedSha256Hash(accountKey)*/ keyStr])));
        }
        public void MsalAccountCacheKey()
        {
            var key = new MsalAccountCacheKey(
                "login.microsoftonline.com",
                "contoso.com",
                "uid.utid",
                "localId",
                "AAD");

            Assert.AreEqual("uid.utid-login.microsoftonline.com-contoso.com", key.ToString());

            Assert.AreEqual("uid.utid-login.microsoftonline.com", key.iOSAccount);
            Assert.AreEqual("contoso.com", key.iOSService);
            Assert.AreEqual("localid", key.iOSGeneric);
            Assert.AreEqual(MsalCacheKeys.iOSAuthorityTypeToAttrType["AAD"], key.iOSType);
        }
Example #8
0
 public MsalAccountCacheItem GetAccount(MsalAccountCacheKey accountKey)
 {
     return(MsalAccountCacheItem.FromJsonString(_accountSharedPreference.GetString(accountKey.ToString(), null)));
 }
Example #9
0
 public void DeleteAccount(MsalAccountCacheKey cacheKey)
 {
     Delete(cacheKey.ToString(), _accountSharedPreference.Edit());
 }
Example #10
0
 public string GetAccount(MsalAccountCacheKey accountKey)
 {
     return(_accountSharedPreference.GetString(accountKey.ToString(), null));
 }
Example #11
0
 public void DeleteAccount(MsalAccountCacheKey cacheKey)
 {
     _accountCacheDictionary.Remove(cacheKey.ToString());
 }
Example #12
0
 public void DeleteAccount(MsalAccountCacheKey cacheKey)
 {
     _accountContainer.Values.Remove(/*CoreCryptographyHelpers.CreateBase64UrlEncodedSha256Hash(cacheKey)*/ cacheKey.ToString());
 }