| | 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.Certificates |
| | 7 | | { |
| | 8 | | internal class CertificateBackup : IJsonDeserializable, IJsonSerializable |
| | 9 | | { |
| | 10 | | private const string ValuePropertyName = "value"; |
| 0 | 11 | | private static readonly JsonEncodedText s_valuePropertyNameBytes = JsonEncodedText.Encode(ValuePropertyName); |
| | 12 | |
|
| 0 | 13 | | public byte[] Value { get; set; } |
| | 14 | |
|
| | 15 | | void IJsonDeserializable.ReadProperties(JsonElement json) |
| | 16 | | { |
| 0 | 17 | | if (json.TryGetProperty(ValuePropertyName, out JsonElement value)) |
| | 18 | | { |
| 0 | 19 | | Value = Base64Url.Decode(value.GetString()); |
| | 20 | | } |
| 0 | 21 | | } |
| | 22 | |
|
| | 23 | | void IJsonSerializable.WriteProperties(Utf8JsonWriter json) |
| | 24 | | { |
| 0 | 25 | | json.WriteString(s_valuePropertyNameBytes, Base64Url.Encode(Value)); |
| 0 | 26 | | } |
| | 27 | | } |
| | 28 | | } |