Skip to content

Commit 28e7cc3

Browse files
committed
Fixup product code
1 parent ec3cc75 commit 28e7cc3

File tree

57 files changed

+124
-721
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+124
-721
lines changed

src/client/Microsoft.Identity.Client/ApiConfig/AcquireTokenForClientParameterBuilder.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ protected override void Validate()
135135
{
136136
string authorityUri = ServiceBundle.Config.Authority.AuthorityInfo.CanonicalAuthority.AbsoluteUri;
137137

138-
if (ServiceBundle.Config.Authority.AuthorityInfo.AuthorityType != AuthorityType.Aad)
138+
if (ServiceBundle.Config.Authority.AuthorityInfo.AuthorityType != AuthorityType.Aad &&
139+
ServiceBundle.Config.Authority.AuthorityInfo.AuthorityType != AuthorityType.Dsts)
139140
{
140141
throw new MsalClientException(
141142
MsalError.InvalidAuthorityType,
@@ -149,7 +150,9 @@ protected override void Validate()
149150
MsalErrorMessage.MtlsNonTenantedAuthorityNotAllowedMessage);
150151
}
151152

152-
if (string.IsNullOrEmpty(ServiceBundle.Config.AzureRegion))
153+
// Check for Azure region only if the authority is AAD
154+
if (ServiceBundle.Config.Authority.AuthorityInfo.AuthorityType == AuthorityType.Aad &&
155+
string.IsNullOrEmpty(ServiceBundle.Config.AzureRegion))
153156
{
154157
throw new MsalClientException(
155158
MsalError.MtlsPopWithoutRegion,

src/client/Microsoft.Identity.Client/AppConfig/AbstractApplicationBuilder.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@
1313
using Microsoft.Identity.Client.PlatformsCommon.Interfaces;
1414
using Microsoft.Identity.Client.Utils;
1515
using Microsoft.IdentityModel.Abstractions;
16-
#if SUPPORTS_SYSTEM_TEXT_JSON
1716
using System.Text.Json;
18-
#else
19-
using Microsoft.Identity.Json;
20-
#endif
2117

2218
namespace Microsoft.Identity.Client
2319
{

src/client/Microsoft.Identity.Client/AppConfig/BaseAbstractApplicationBuilder.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@
1414
using Microsoft.Identity.Client.Utils;
1515
using Microsoft.IdentityModel.Abstractions;
1616
using Microsoft.Identity.Client.Internal;
17-
#if SUPPORTS_SYSTEM_TEXT_JSON
1817
using System.Text.Json;
19-
#else
20-
using Microsoft.Identity.Json;
21-
#endif
2218

2319
namespace Microsoft.Identity.Client
2420
{

src/client/Microsoft.Identity.Client/AppConfig/TraceTelemetryConfig.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66
using System.ComponentModel;
77
using System.Diagnostics;
88
using Microsoft.Identity.Client.Utils;
9-
#if SUPPORTS_SYSTEM_TEXT_JSON
109
using JObject = System.Text.Json.Nodes.JsonObject;
11-
#else
12-
using Microsoft.Identity.Json.Linq;
13-
#endif
1410

1511
namespace Microsoft.Identity.Client
1612
{

src/client/Microsoft.Identity.Client/AuthScheme/PoP/PopAuthenticationOperation.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,8 @@
1111
using Microsoft.Identity.Client.Internal;
1212
using Microsoft.Identity.Client.OAuth2;
1313
using Microsoft.Identity.Client.Utils;
14-
#if SUPPORTS_SYSTEM_TEXT_JSON
1514
using JObject = System.Text.Json.Nodes.JsonObject;
1615
using JToken = System.Text.Json.Nodes.JsonNode;
17-
#else
18-
using Microsoft.Identity.Json;
19-
using Microsoft.Identity.Json.Linq;
20-
#endif
2116

2217
namespace Microsoft.Identity.Client.AuthScheme.PoP
2318
{

src/client/Microsoft.Identity.Client/Cache/Adal/AdalResult.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
#if SUPPORTS_SYSTEM_TEXT_JSON
5-
using Microsoft.Identity.Client.Platforms.net;
4+
using Microsoft.Identity.Client.Platforms.Json;
65
using JsonProperty = System.Text.Json.Serialization.JsonIncludeAttribute;
7-
#else
8-
using Microsoft.Identity.Json;
9-
#endif
106

117
namespace Microsoft.Identity.Client.Cache
128
{
139
/// <summary>
1410
/// Contains the results of an ADAL token acquisition. Access Tokens from ADAL are not compatible
1511
/// with MSAL, only Refresh Tokens are.
1612
/// </summary>
17-
[JsonObject]
1813
[Preserve(AllMembers = true)]
1914
internal sealed class AdalResult
2015
{

src/client/Microsoft.Identity.Client/Cache/Adal/AdalResultWrapper.cs

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,20 @@
22
// Licensed under the MIT License.
33

44
using Microsoft.Identity.Client.Utils;
5-
#if SUPPORTS_SYSTEM_TEXT_JSON
6-
using Microsoft.Identity.Client.Platforms.net;
7-
#else
8-
using Microsoft.Identity.Json;
9-
#endif
5+
using Microsoft.Identity.Client.Platforms.Json;
106

117
namespace Microsoft.Identity.Client.Cache
128
{
13-
[JsonObject]
149
[Preserve(AllMembers = true)]
1510
internal class AdalResultWrapper
1611
{
17-
18-
#if !SUPPORTS_SYSTEM_TEXT_JSON
19-
[JsonProperty]
20-
#endif
2112
public AdalResult Result { get; set; }
2213

23-
#if !SUPPORTS_SYSTEM_TEXT_JSON
24-
[JsonProperty]
25-
#endif
2614
public string RawClientInfo { get; set; }
2715

2816
/// <summary>
2917
/// Gets the Refresh Token associated with the requested Access Token. Note: not all operations will return a Refresh Token.
3018
/// </summary>
31-
#if !SUPPORTS_SYSTEM_TEXT_JSON
32-
[JsonProperty]
33-
#endif
3419
public string RefreshToken { get; set; }
3520

3621
/// <summary>
@@ -40,9 +25,6 @@ internal class AdalResultWrapper
4025

4126
// This is only needed for AcquireTokenByAuthorizationCode in which parameter resource is optional and we need
4227
// to get it from the STS response.
43-
#if !SUPPORTS_SYSTEM_TEXT_JSON
44-
[JsonProperty]
45-
#endif
4628
internal string ResourceInResponse { get; set; }
4729

4830
/// <summary>
@@ -63,9 +45,6 @@ public string Serialize()
6345
return JsonHelper.SerializeToJson(this);
6446
}
6547

66-
#if !SUPPORTS_SYSTEM_TEXT_JSON
67-
[JsonProperty]
68-
#endif
6948
public string UserAssertionHash { get; set; }
7049

7150
internal AdalResultWrapper Clone()

src/client/Microsoft.Identity.Client/Cache/Adal/AdalUserInfo.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,14 @@
22
// Licensed under the MIT License.
33

44
using System;
5-
#if SUPPORTS_SYSTEM_TEXT_JSON
6-
using Microsoft.Identity.Client.Platforms.net;
5+
using Microsoft.Identity.Client.Platforms.Json;
76
using JsonProperty = System.Text.Json.Serialization.JsonIncludeAttribute;
8-
#else
9-
using Microsoft.Identity.Json;
10-
#endif
117

128
namespace Microsoft.Identity.Client.Cache
139
{
1410
/// <summary>
1511
/// 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.
1612
/// </summary>
17-
[JsonObject]
1813
[Preserve(AllMembers = true)]
1914
internal sealed class AdalUserInfo
2015
{

src/client/Microsoft.Identity.Client/Cache/ITokenCacheSerializable.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
// Licensed under the MIT License.
33

44
using System.Collections.Generic;
5-
#if SUPPORTS_SYSTEM_TEXT_JSON
65
using JToken = System.Text.Json.Nodes.JsonNode;
7-
#else
8-
using Microsoft.Identity.Json.Linq;
9-
#endif
106

117
namespace Microsoft.Identity.Client.Cache
128
{

src/client/Microsoft.Identity.Client/Cache/Items/CacheSerializationContract.cs

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,19 @@
44
using System;
55
using System.Collections.Generic;
66
using System.Linq;
7-
#if SUPPORTS_SYSTEM_TEXT_JSON
87
using System.Text.Json;
98
using System.Text.Json.Nodes;
109
using JObject = System.Text.Json.Nodes.JsonObject;
1110
using JToken = System.Text.Json.Nodes.JsonNode;
12-
#else
13-
using Microsoft.Identity.Json;
14-
using Microsoft.Identity.Json.Linq;
15-
#endif
1611

1712
namespace Microsoft.Identity.Client.Cache.Items
1813
{
1914
internal class CacheSerializationContract
2015
{
21-
#if SUPPORTS_SYSTEM_TEXT_JSON
2216
private static readonly JsonSerializerOptions NeverIgnoreJsonOptions = new()
2317
{
2418
DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.Never
2519
};
26-
#endif
2720

2821
private static readonly IEnumerable<string> s_knownPropertyNames = new[] {
2922
StorageJsonValues.CredentialTypeAccessToken,
@@ -56,14 +49,11 @@ public CacheSerializationContract(IDictionary<string, JToken> unknownNodes)
5649

5750
internal static CacheSerializationContract FromJsonString(string json)
5851
{
59-
#if SUPPORTS_SYSTEM_TEXT_JSON
6052
var root = JsonNode.Parse(json, documentOptions: new JsonDocumentOptions
6153
{
6254
AllowTrailingCommas = true
6355
}).AsObject();
64-
#else
65-
var root = JObject.Parse(json);
66-
#endif
56+
6757
var unknownNodes = ExtractUnknownNodes(root);
6858

6959
var contract = new CacheSerializationContract(unknownNodes);
@@ -136,32 +126,19 @@ internal static CacheSerializationContract FromJsonString(string json)
136126
return contract;
137127

138128
// private method for enumerating collection
139-
#if SUPPORTS_SYSTEM_TEXT_JSON
140129
static IEnumerable<JsonObject> GetElement(JsonObject root, string key)
141130
{
142131
foreach (var token in root[key].AsObject())
143132
{
144133
yield return token.Value as JObject;
145134
}
146135
}
147-
#else
148-
static IEnumerable<JObject> GetElement(JObject root, string key)
149-
{
150-
foreach (var token in root[key].Values())
151-
{
152-
yield return token as JObject;
153-
}
154-
}
155-
#endif
136+
156137
}
157138

158139
private static IDictionary<string, JToken> ExtractUnknownNodes(JObject root)
159140
{
160-
#if SUPPORTS_SYSTEM_TEXT_JSON
161141
return root
162-
#else
163-
return (root as IDictionary<string, JToken>)
164-
#endif
165142
.Where(kvp => !s_knownPropertyNames.Any(p => string.Equals(kvp.Key, p, StringComparison.OrdinalIgnoreCase)))
166143
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
167144
}
@@ -218,23 +195,10 @@ internal string ToJsonString()
218195
// Anything else
219196
foreach (var kvp in UnknownNodes)
220197
{
221-
#if SUPPORTS_SYSTEM_TEXT_JSON
222198
root[kvp.Key] = kvp.Value != null ? JToken.Parse(kvp.Value.ToJsonString()) : null;
223-
#else
224-
root[kvp.Key] = kvp.Value;
225-
#endif
226199
}
227-
#if SUPPORTS_SYSTEM_TEXT_JSON
200+
228201
return root.ToJsonString(NeverIgnoreJsonOptions);
229-
#else
230-
return JsonConvert.SerializeObject(
231-
root,
232-
Formatting.None,
233-
new JsonSerializerSettings
234-
{
235-
NullValueHandling = NullValueHandling.Include
236-
});
237-
#endif
238202
}
239203
}
240204
}

0 commit comments

Comments
 (0)