-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from DuendeSoftware/features/persisted_grant_d…
…ata_container Enable data protection on persisted grants
- Loading branch information
Showing
7 changed files
with
117 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,35 @@ | ||
// Copyright (c) Duende Software. All rights reserved. | ||
// Copyright (c) Duende Software. All rights reserved. | ||
// See LICENSE in the project root for license information. | ||
|
||
|
||
using Newtonsoft.Json; | ||
using System; | ||
using System.Security.Claims; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
#pragma warning disable 1591 | ||
|
||
namespace Duende.IdentityServer.Stores.Serialization | ||
{ | ||
public class ClaimConverter : JsonConverter | ||
public class ClaimConverter : JsonConverter<Claim> | ||
{ | ||
public override bool CanConvert(Type objectType) | ||
public override Claim Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
return typeof(Claim) == objectType; | ||
} | ||
|
||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) | ||
{ | ||
var source = serializer.Deserialize<ClaimLite>(reader); | ||
var source = JsonSerializer.Deserialize<ClaimLite>(ref reader, options); | ||
var target = new Claim(source.Type, source.Value, source.ValueType); | ||
return target; | ||
} | ||
|
||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) | ||
public override void Write(Utf8JsonWriter writer, Claim value, JsonSerializerOptions options) | ||
{ | ||
var source = (Claim)value; | ||
|
||
var target = new ClaimLite | ||
{ | ||
Type = source.Type, | ||
Value = source.Value, | ||
ValueType = source.ValueType | ||
Type = value.Type, | ||
Value = value.Value, | ||
ValueType = value.ValueType | ||
}; | ||
|
||
serializer.Serialize(writer, target); | ||
JsonSerializer.Serialize(writer, target, options); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters