/// <summary>
        /// Serializes the entire token cache
        /// </summary>
        /// <param name="tokenCacheAccessor">Token cache accessor to perform cache read operations</param>
        /// <returns>array of bytes containing the serialized cache</returns>
        internal static byte[] SerializeUnifiedCache(ITokenCacheAccessor tokenCacheAccessor)
        {
            // reads the underlying in-memory dictionary and dumps out the content as a JSON
            Dictionary <string, IEnumerable <string> > cacheDict = new Dictionary <string, IEnumerable <string> >
            {
                [AccessTokenKey]  = tokenCacheAccessor.GetAllAccessTokensAsString(),
                [RefreshTokenKey] = tokenCacheAccessor.GetAllRefreshTokensAsString(),
                [IdTokenKey]      = tokenCacheAccessor.GetAllIdTokensAsString(),
                [AccountKey]      = tokenCacheAccessor.GetAllAccountsAsString()
            };

            return(JsonHelper.SerializeToJson(cacheDict).ToByteArray());
        }
Example #2
0
 /// <inheritdoc />
 public ICollection <string> GetAllAccessTokensAsString()
 {
     return(_tokenCacheAccessor.GetAllAccessTokensAsString());
 }