public void MsalAccessTokenCacheKey_IsDifferentWhenEnvAndScopesAreDifferent()
        {
            MsalAccessTokenCacheKey key1 = new MsalAccessTokenCacheKey("env", "tid", "uid", "cid", "scope1 scope2");
            MsalAccessTokenCacheKey key2 = new MsalAccessTokenCacheKey("env", "tid", "uid", "cid",
                                                                       string.Join(" ", Enumerable.Range(1, 100).Select(i => "scope" + i)));

            Assert.AreNotEqual(key1.GetUWPFixedSizeKey(), key2.GetUWPFixedSizeKey());
            Assert.IsTrue(key2.GetUWPFixedSizeKey().Length < 255);
            Assert.IsTrue(key1.GetUWPFixedSizeKey().Length < 255);
        }
예제 #2
0
        public string GetAccessToken(MsalAccessTokenCacheKey accessTokenKey)
        {
            var keyStr = accessTokenKey.GetUWPFixedSizeKey();

            if (!_accessTokenContainer.Values.ContainsKey(/*encodedKey*/ keyStr))
            {
                return(null);
            }
            return(CoreHelpers.ByteArrayToString(
                       GetCacheValue((ApplicationDataCompositeValue)_accessTokenContainer.Values[
                                         /*CoreCryptographyHelpers.CreateBase64UrlEncodedSha256Hash(accessTokenKey)*/ keyStr])));
        }
        public void MsalAccessTokenCacheKey()
        {
            MsalAccessTokenCacheKey key = new MsalAccessTokenCacheKey("login.microsoftonline.com", "contoso.com", "uid.utid", "clientid", "user.read user.write");

            Assert.AreEqual("uid.utid-login.microsoftonline.com-accesstoken-clientid-contoso.com-user.read user.write", key.ToString());

            Assert.AreEqual("uid.utid-login.microsoftonline.com", key.GetiOSAccountKey());
            Assert.AreEqual("accesstoken-clientid-contoso.com-user.read user.write", key.GetiOSServiceKey());
            Assert.AreEqual("accesstoken-clientid-contoso.com", key.GetiOSGenericKey());

            Assert.AreEqual("uid.utid-login.microsoftonline.com-accesstoken-clientid-contoso.com-n5wvhdusof/wfsjgk1muxrk89nwfynymsl4qefkynbu=", key.GetUWPFixedSizeKey());
        }
예제 #4
0
 public void DeleteAccessToken(MsalAccessTokenCacheKey cacheKey)
 {
     _accessTokenContainer.Values.Remove(/*CoreCryptographyHelpers.CreateBase64UrlEncodedSha256Hash(cacheKey)*/ cacheKey.GetUWPFixedSizeKey());
 }