| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System.Text.Json; |
| | 5 | |
|
| | 6 | | namespace Azure.Security.KeyVault.Keys |
| | 7 | | { |
| | 8 | | internal class KeyBackup : IJsonDeserializable, IJsonSerializable |
| | 9 | | { |
| | 10 | | private const string ValuePropertyName = "value"; |
| 2 | 11 | | private static readonly JsonEncodedText s_valuePropertyNameBytes = JsonEncodedText.Encode(ValuePropertyName); |
| | 12 | |
|
| 16 | 13 | | public byte[] Value { get; set; } |
| | 14 | |
|
| | 15 | | void IJsonDeserializable.ReadProperties(JsonElement json) |
| | 16 | | { |
| 4 | 17 | | if (json.TryGetProperty(ValuePropertyName, out JsonElement value)) |
| | 18 | | { |
| 4 | 19 | | Value = Base64Url.Decode(value.GetString()); |
| | 20 | | } |
| 4 | 21 | | } |
| | 22 | |
|
| | 23 | | void IJsonSerializable.WriteProperties(Utf8JsonWriter json) |
| | 24 | | { |
| 4 | 25 | | json.WriteString(s_valuePropertyNameBytes, Base64Url.Encode(Value)); |
| 4 | 26 | | } |
| | 27 | | } |
| | 28 | | } |