diff --git a/Directory.Packages.props b/Directory.Packages.props
index dfb0f023f4..31af7e4bda 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -30,6 +30,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -55,6 +68,10 @@
+
@@ -67,20 +84,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/build/platform_and_feature_flags.props b/build/platform_and_feature_flags.props
index 4d52be6563..5a01ea5b09 100644
--- a/build/platform_and_feature_flags.props
+++ b/build/platform_and_feature_flags.props
@@ -1,11 +1,11 @@
-
- $(DefineConstants);SUPPORTS_SYSTEM_TEXT_JSON;NET_CORE;SUPPORTS_CONFIDENTIAL_CLIENT;SUPPORTS_CUSTOM_CACHE;SUPPORTS_BROKER;SUPPORTS_WIN32;
+
+ $(DefineConstants)SUPPORTS_MTLS;NET_CORE;SUPPORTS_CONFIDENTIAL_CLIENT;SUPPORTS_CUSTOM_CACHE;SUPPORTS_BROKER;SUPPORTS_WIN32;
$(DefineConstants);SUPPORTS_OTEL;
-
+
$(DefineConstants);SUPPORTS_MTLS;
@@ -15,7 +15,7 @@
$(DefineConstants);SUPPORTS_BROKER;SUPPORTS_CONFIDENTIAL_CLIENT;SUPPORTS_CUSTOM_CACHE;SUPPORTS_WIN32
- $(DefineConstants);iOS;SUPPORTS_BROKER
+ $(DefineConstants);iOS;SUPPORTS_BROKER
$(DefineConstants);NETSTANDARD;SUPPORTS_CONFIDENTIAL_CLIENT;SUPPORTS_BROKER;SUPPORTS_CUSTOM_CACHE;SUPPORTS_WIN32;
diff --git a/src/client/Microsoft.Identity.Client/AppConfig/AbstractApplicationBuilder.cs b/src/client/Microsoft.Identity.Client/AppConfig/AbstractApplicationBuilder.cs
index c537327a81..15242e74bd 100644
--- a/src/client/Microsoft.Identity.Client/AppConfig/AbstractApplicationBuilder.cs
+++ b/src/client/Microsoft.Identity.Client/AppConfig/AbstractApplicationBuilder.cs
@@ -13,11 +13,7 @@
using Microsoft.Identity.Client.PlatformsCommon.Interfaces;
using Microsoft.Identity.Client.Utils;
using Microsoft.IdentityModel.Abstractions;
-#if SUPPORTS_SYSTEM_TEXT_JSON
using System.Text.Json;
-#else
-using Microsoft.Identity.Json;
-#endif
namespace Microsoft.Identity.Client
{
diff --git a/src/client/Microsoft.Identity.Client/AppConfig/BaseAbstractApplicationBuilder.cs b/src/client/Microsoft.Identity.Client/AppConfig/BaseAbstractApplicationBuilder.cs
index ad42a6cf88..4c0b52b2db 100644
--- a/src/client/Microsoft.Identity.Client/AppConfig/BaseAbstractApplicationBuilder.cs
+++ b/src/client/Microsoft.Identity.Client/AppConfig/BaseAbstractApplicationBuilder.cs
@@ -14,11 +14,7 @@
using Microsoft.Identity.Client.Utils;
using Microsoft.IdentityModel.Abstractions;
using Microsoft.Identity.Client.Internal;
-#if SUPPORTS_SYSTEM_TEXT_JSON
using System.Text.Json;
-#else
-using Microsoft.Identity.Json;
-#endif
namespace Microsoft.Identity.Client
{
diff --git a/src/client/Microsoft.Identity.Client/AppConfig/TraceTelemetryConfig.cs b/src/client/Microsoft.Identity.Client/AppConfig/TraceTelemetryConfig.cs
index a85541e57a..81922beb7e 100644
--- a/src/client/Microsoft.Identity.Client/AppConfig/TraceTelemetryConfig.cs
+++ b/src/client/Microsoft.Identity.Client/AppConfig/TraceTelemetryConfig.cs
@@ -6,11 +6,7 @@
using System.ComponentModel;
using System.Diagnostics;
using Microsoft.Identity.Client.Utils;
-#if SUPPORTS_SYSTEM_TEXT_JSON
using JObject = System.Text.Json.Nodes.JsonObject;
-#else
-using Microsoft.Identity.Json.Linq;
-#endif
namespace Microsoft.Identity.Client
{
diff --git a/src/client/Microsoft.Identity.Client/AuthScheme/PoP/PopAuthenticationOperation.cs b/src/client/Microsoft.Identity.Client/AuthScheme/PoP/PopAuthenticationOperation.cs
index a2723fe9b9..bfd6a9a3f6 100644
--- a/src/client/Microsoft.Identity.Client/AuthScheme/PoP/PopAuthenticationOperation.cs
+++ b/src/client/Microsoft.Identity.Client/AuthScheme/PoP/PopAuthenticationOperation.cs
@@ -11,13 +11,8 @@
using Microsoft.Identity.Client.Internal;
using Microsoft.Identity.Client.OAuth2;
using Microsoft.Identity.Client.Utils;
-#if SUPPORTS_SYSTEM_TEXT_JSON
using JObject = System.Text.Json.Nodes.JsonObject;
using JToken = System.Text.Json.Nodes.JsonNode;
-#else
-using Microsoft.Identity.Json;
-using Microsoft.Identity.Json.Linq;
-#endif
namespace Microsoft.Identity.Client.AuthScheme.PoP
{
diff --git a/src/client/Microsoft.Identity.Client/Cache/Adal/AdalResult.cs b/src/client/Microsoft.Identity.Client/Cache/Adal/AdalResult.cs
index 8275f0afba..60fe7b001a 100644
--- a/src/client/Microsoft.Identity.Client/Cache/Adal/AdalResult.cs
+++ b/src/client/Microsoft.Identity.Client/Cache/Adal/AdalResult.cs
@@ -1,12 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
-#if SUPPORTS_SYSTEM_TEXT_JSON
-using Microsoft.Identity.Client.Platforms.net;
+using Microsoft.Identity.Client.Platforms.Json;
using JsonProperty = System.Text.Json.Serialization.JsonIncludeAttribute;
-#else
-using Microsoft.Identity.Json;
-#endif
namespace Microsoft.Identity.Client.Cache
{
@@ -14,7 +10,6 @@ namespace Microsoft.Identity.Client.Cache
/// Contains the results of an ADAL token acquisition. Access Tokens from ADAL are not compatible
/// with MSAL, only Refresh Tokens are.
///
- [JsonObject]
[Preserve(AllMembers = true)]
internal sealed class AdalResult
{
diff --git a/src/client/Microsoft.Identity.Client/Cache/Adal/AdalResultWrapper.cs b/src/client/Microsoft.Identity.Client/Cache/Adal/AdalResultWrapper.cs
index 8b619df328..00e865116e 100644
--- a/src/client/Microsoft.Identity.Client/Cache/Adal/AdalResultWrapper.cs
+++ b/src/client/Microsoft.Identity.Client/Cache/Adal/AdalResultWrapper.cs
@@ -2,35 +2,20 @@
// Licensed under the MIT License.
using Microsoft.Identity.Client.Utils;
-#if SUPPORTS_SYSTEM_TEXT_JSON
-using Microsoft.Identity.Client.Platforms.net;
-#else
-using Microsoft.Identity.Json;
-#endif
+using Microsoft.Identity.Client.Platforms.Json;
namespace Microsoft.Identity.Client.Cache
{
- [JsonObject]
[Preserve(AllMembers = true)]
internal class AdalResultWrapper
{
-
-#if !SUPPORTS_SYSTEM_TEXT_JSON
- [JsonProperty]
-#endif
public AdalResult Result { get; set; }
-#if !SUPPORTS_SYSTEM_TEXT_JSON
- [JsonProperty]
-#endif
public string RawClientInfo { get; set; }
///
/// Gets the Refresh Token associated with the requested Access Token. Note: not all operations will return a Refresh Token.
///
-#if !SUPPORTS_SYSTEM_TEXT_JSON
- [JsonProperty]
-#endif
public string RefreshToken { get; set; }
///
@@ -40,9 +25,6 @@ internal class AdalResultWrapper
// This is only needed for AcquireTokenByAuthorizationCode in which parameter resource is optional and we need
// to get it from the STS response.
-#if !SUPPORTS_SYSTEM_TEXT_JSON
- [JsonProperty]
-#endif
internal string ResourceInResponse { get; set; }
///
@@ -63,9 +45,6 @@ public string Serialize()
return JsonHelper.SerializeToJson(this);
}
-#if !SUPPORTS_SYSTEM_TEXT_JSON
- [JsonProperty]
-#endif
public string UserAssertionHash { get; set; }
internal AdalResultWrapper Clone()
diff --git a/src/client/Microsoft.Identity.Client/Cache/Adal/AdalUserInfo.cs b/src/client/Microsoft.Identity.Client/Cache/Adal/AdalUserInfo.cs
index 448f5e143c..8718232cba 100644
--- a/src/client/Microsoft.Identity.Client/Cache/Adal/AdalUserInfo.cs
+++ b/src/client/Microsoft.Identity.Client/Cache/Adal/AdalUserInfo.cs
@@ -2,19 +2,14 @@
// Licensed under the MIT License.
using System;
-#if SUPPORTS_SYSTEM_TEXT_JSON
-using Microsoft.Identity.Client.Platforms.net;
+using Microsoft.Identity.Client.Platforms.Json;
using JsonProperty = System.Text.Json.Serialization.JsonIncludeAttribute;
-#else
-using Microsoft.Identity.Json;
-#endif
namespace Microsoft.Identity.Client.Cache
{
///
/// Contains information of a single user. This information is used for token cache lookup. Also if created with userId, userId is sent to the service when login_hint is accepted.
///
- [JsonObject]
[Preserve(AllMembers = true)]
internal sealed class AdalUserInfo
{
diff --git a/src/client/Microsoft.Identity.Client/Cache/ITokenCacheSerializable.cs b/src/client/Microsoft.Identity.Client/Cache/ITokenCacheSerializable.cs
index d0e0c920d0..2caaabe37e 100644
--- a/src/client/Microsoft.Identity.Client/Cache/ITokenCacheSerializable.cs
+++ b/src/client/Microsoft.Identity.Client/Cache/ITokenCacheSerializable.cs
@@ -2,11 +2,7 @@
// Licensed under the MIT License.
using System.Collections.Generic;
-#if SUPPORTS_SYSTEM_TEXT_JSON
using JToken = System.Text.Json.Nodes.JsonNode;
-#else
-using Microsoft.Identity.Json.Linq;
-#endif
namespace Microsoft.Identity.Client.Cache
{
diff --git a/src/client/Microsoft.Identity.Client/Cache/Items/CacheSerializationContract.cs b/src/client/Microsoft.Identity.Client/Cache/Items/CacheSerializationContract.cs
index 8689bb5095..5b5beb7452 100644
--- a/src/client/Microsoft.Identity.Client/Cache/Items/CacheSerializationContract.cs
+++ b/src/client/Microsoft.Identity.Client/Cache/Items/CacheSerializationContract.cs
@@ -4,26 +4,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
-#if SUPPORTS_SYSTEM_TEXT_JSON
using System.Text.Json;
using System.Text.Json.Nodes;
using JObject = System.Text.Json.Nodes.JsonObject;
using JToken = System.Text.Json.Nodes.JsonNode;
-#else
-using Microsoft.Identity.Json;
-using Microsoft.Identity.Json.Linq;
-#endif
namespace Microsoft.Identity.Client.Cache.Items
{
internal class CacheSerializationContract
{
-#if SUPPORTS_SYSTEM_TEXT_JSON
private static readonly JsonSerializerOptions NeverIgnoreJsonOptions = new()
{
DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.Never
};
-#endif
private static readonly IEnumerable s_knownPropertyNames = new[] {
StorageJsonValues.CredentialTypeAccessToken,
@@ -56,14 +49,11 @@ public CacheSerializationContract(IDictionary unknownNodes)
internal static CacheSerializationContract FromJsonString(string json)
{
-#if SUPPORTS_SYSTEM_TEXT_JSON
var root = JsonNode.Parse(json, documentOptions: new JsonDocumentOptions
{
AllowTrailingCommas = true
}).AsObject();
-#else
- var root = JObject.Parse(json);
-#endif
+
var unknownNodes = ExtractUnknownNodes(root);
var contract = new CacheSerializationContract(unknownNodes);
@@ -136,7 +126,6 @@ internal static CacheSerializationContract FromJsonString(string json)
return contract;
// private method for enumerating collection
-#if SUPPORTS_SYSTEM_TEXT_JSON
static IEnumerable GetElement(JsonObject root, string key)
{
foreach (var token in root[key].AsObject())
@@ -144,24 +133,12 @@ static IEnumerable GetElement(JsonObject root, string key)
yield return token.Value as JObject;
}
}
-#else
- static IEnumerable GetElement(JObject root, string key)
- {
- foreach (var token in root[key].Values())
- {
- yield return token as JObject;
- }
- }
-#endif
+
}
private static IDictionary ExtractUnknownNodes(JObject root)
{
-#if SUPPORTS_SYSTEM_TEXT_JSON
return root
-#else
- return (root as IDictionary)
-#endif
.Where(kvp => !s_knownPropertyNames.Any(p => string.Equals(kvp.Key, p, StringComparison.OrdinalIgnoreCase)))
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
}
@@ -218,23 +195,10 @@ internal string ToJsonString()
// Anything else
foreach (var kvp in UnknownNodes)
{
-#if SUPPORTS_SYSTEM_TEXT_JSON
root[kvp.Key] = kvp.Value != null ? JToken.Parse(kvp.Value.ToJsonString()) : null;
-#else
- root[kvp.Key] = kvp.Value;
-#endif
}
-#if SUPPORTS_SYSTEM_TEXT_JSON
+
return root.ToJsonString(NeverIgnoreJsonOptions);
-#else
- return JsonConvert.SerializeObject(
- root,
- Formatting.None,
- new JsonSerializerSettings
- {
- NullValueHandling = NullValueHandling.Include
- });
-#endif
}
}
}
diff --git a/src/client/Microsoft.Identity.Client/Cache/Items/MsalAccessTokenCacheItem.cs b/src/client/Microsoft.Identity.Client/Cache/Items/MsalAccessTokenCacheItem.cs
index ac6afb88c0..980500cdd6 100644
--- a/src/client/Microsoft.Identity.Client/Cache/Items/MsalAccessTokenCacheItem.cs
+++ b/src/client/Microsoft.Identity.Client/Cache/Items/MsalAccessTokenCacheItem.cs
@@ -9,12 +9,8 @@
using Microsoft.Identity.Client.Internal;
using Microsoft.Identity.Client.OAuth2;
using Microsoft.Identity.Client.Utils;
-#if SUPPORTS_SYSTEM_TEXT_JSON
using System.Text.Json;
using JObject = System.Text.Json.Nodes.JsonObject;
-#else
-using Microsoft.Identity.Json.Linq;
-#endif
namespace Microsoft.Identity.Client.Cache.Items
{
@@ -57,11 +53,7 @@ internal MsalAccessTokenCacheItem(
#if !MOBILE
private IDictionary AcquireCacheParametersFromResponse(
IEnumerable persistedCacheParameters,
-#if SUPPORTS_SYSTEM_TEXT_JSON
Dictionary extraDataFromResponse)
-#else
- Dictionary extraDataFromResponse)
-#endif
{
if (persistedCacheParameters == null || !persistedCacheParameters.Any())
{
@@ -70,17 +62,11 @@ private IDictionary AcquireCacheParametersFromResponse(
var cacheParameters = extraDataFromResponse?
.Where(x => persistedCacheParameters.Contains(x.Key, StringComparer.InvariantCultureIgnoreCase))
-#if SUPPORTS_SYSTEM_TEXT_JSON
.ToDictionary(x => x.Key, x => x.Value.ToString());
-#else
- //Avoid formatting arrays because it adds new lines after every element
- .ToDictionary(x => x.Key, x => x.Value.Type == JTokenType.Array || x.Value.Type == JTokenType.Object ?
- x.Value.ToString(Json.Formatting.None) :
- x.Value.ToString());
-#endif
return cacheParameters;
}
#endif
+
internal /* for test */ MsalAccessTokenCacheItem(
string preferredCacheEnv,
string clientId,
diff --git a/src/client/Microsoft.Identity.Client/Cache/Items/MsalAccountCacheItem.cs b/src/client/Microsoft.Identity.Client/Cache/Items/MsalAccountCacheItem.cs
index 620971affe..a7c5b5fc10 100644
--- a/src/client/Microsoft.Identity.Client/Cache/Items/MsalAccountCacheItem.cs
+++ b/src/client/Microsoft.Identity.Client/Cache/Items/MsalAccountCacheItem.cs
@@ -10,12 +10,9 @@
using Microsoft.Identity.Client.Cache.Keys;
using Microsoft.Identity.Client.Internal;
using Microsoft.Identity.Client.Utils;
-#if SUPPORTS_SYSTEM_TEXT_JSON
using System.Text.Json.Nodes;
using JObject = System.Text.Json.Nodes.JsonObject;
-#else
-using Microsoft.Identity.Json.Linq;
-#endif
+
namespace Microsoft.Identity.Client.Cache.Items
{
@@ -236,7 +233,6 @@ internal override JObject ToJObject()
SetItemIfValueNotNull(json, StorageJsonKeys.AccountSource, AccountSource);
if (WamAccountIds != null && WamAccountIds.Any())
{
-#if SUPPORTS_SYSTEM_TEXT_JSON
var obj = new JsonObject();
foreach (KeyValuePair accId in WamAccountIds)
@@ -245,9 +241,6 @@ internal override JObject ToJObject()
}
json[StorageJsonKeys.WamAccountIds] = obj;
-#else
- json[StorageJsonKeys.WamAccountIds] = JObject.FromObject(WamAccountIds);
-#endif
}
return json;
diff --git a/src/client/Microsoft.Identity.Client/Cache/Items/MsalAppMetadataCacheItem.cs b/src/client/Microsoft.Identity.Client/Cache/Items/MsalAppMetadataCacheItem.cs
index c509421db2..a717732f50 100644
--- a/src/client/Microsoft.Identity.Client/Cache/Items/MsalAppMetadataCacheItem.cs
+++ b/src/client/Microsoft.Identity.Client/Cache/Items/MsalAppMetadataCacheItem.cs
@@ -5,11 +5,7 @@
using System.Collections.Generic;
using Microsoft.Identity.Client.Cache.Keys;
using Microsoft.Identity.Client.Utils;
-#if SUPPORTS_SYSTEM_TEXT_JSON
using JObject = System.Text.Json.Nodes.JsonObject;
-#else
-using Microsoft.Identity.Json.Linq;
-#endif
namespace Microsoft.Identity.Client.Cache.Items
{
diff --git a/src/client/Microsoft.Identity.Client/Cache/Items/MsalCacheItemBase.cs b/src/client/Microsoft.Identity.Client/Cache/Items/MsalCacheItemBase.cs
index 14320119ce..1e3d983afe 100644
--- a/src/client/Microsoft.Identity.Client/Cache/Items/MsalCacheItemBase.cs
+++ b/src/client/Microsoft.Identity.Client/Cache/Items/MsalCacheItemBase.cs
@@ -2,11 +2,7 @@
// Licensed under the MIT License.
using Microsoft.Identity.Client.Utils;
-#if SUPPORTS_SYSTEM_TEXT_JSON
using JObject = System.Text.Json.Nodes.JsonObject;
-#else
-using Microsoft.Identity.Json.Linq;
-#endif
namespace Microsoft.Identity.Client.Cache.Items
{
diff --git a/src/client/Microsoft.Identity.Client/Cache/Items/MsalCredentialCacheItemBase.cs b/src/client/Microsoft.Identity.Client/Cache/Items/MsalCredentialCacheItemBase.cs
index 974da7b55f..abb2891ea1 100644
--- a/src/client/Microsoft.Identity.Client/Cache/Items/MsalCredentialCacheItemBase.cs
+++ b/src/client/Microsoft.Identity.Client/Cache/Items/MsalCredentialCacheItemBase.cs
@@ -2,11 +2,7 @@
// Licensed under the MIT License.
using Microsoft.Identity.Client.Utils;
-#if SUPPORTS_SYSTEM_TEXT_JSON
using JObject = System.Text.Json.Nodes.JsonObject;
-#else
-using Microsoft.Identity.Json.Linq;
-#endif
namespace Microsoft.Identity.Client.Cache.Items
{
diff --git a/src/client/Microsoft.Identity.Client/Cache/Items/MsalIdTokenCacheItem.cs b/src/client/Microsoft.Identity.Client/Cache/Items/MsalIdTokenCacheItem.cs
index 76b8344b20..54ad3330e1 100644
--- a/src/client/Microsoft.Identity.Client/Cache/Items/MsalIdTokenCacheItem.cs
+++ b/src/client/Microsoft.Identity.Client/Cache/Items/MsalIdTokenCacheItem.cs
@@ -6,11 +6,7 @@
using Microsoft.Identity.Client.Internal;
using Microsoft.Identity.Client.OAuth2;
using Microsoft.Identity.Client.Utils;
-#if SUPPORTS_SYSTEM_TEXT_JSON
using JObject = System.Text.Json.Nodes.JsonObject;
-#else
-using Microsoft.Identity.Json.Linq;
-#endif
namespace Microsoft.Identity.Client.Cache.Items
{
diff --git a/src/client/Microsoft.Identity.Client/Cache/Items/MsalItemWithAdditionalFields.cs b/src/client/Microsoft.Identity.Client/Cache/Items/MsalItemWithAdditionalFields.cs
index b26b1630f0..60b73cad94 100644
--- a/src/client/Microsoft.Identity.Client/Cache/Items/MsalItemWithAdditionalFields.cs
+++ b/src/client/Microsoft.Identity.Client/Cache/Items/MsalItemWithAdditionalFields.cs
@@ -3,13 +3,9 @@
using System;
using Microsoft.Identity.Client.Utils;
-#if SUPPORTS_SYSTEM_TEXT_JSON
using System.Text.Json.Nodes;
using JObject = System.Text.Json.Nodes.JsonObject;
using JToken = System.Text.Json.Nodes.JsonNode;
-#else
-using Microsoft.Identity.Json.Linq;
-#endif
namespace Microsoft.Identity.Client.Cache.Items
{
@@ -48,22 +44,15 @@ private static void SetValueIfFilterMatches(JObject json, string key, JToken val
{
bool shouldSetValue = true;
-#if SUPPORTS_SYSTEM_TEXT_JSON
var asObj = value as JsonValue;
-#else
- object asObj = value.ToObject