| | 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 struct IssuerParameters |
| | 9 | | { |
| | 10 | | private const string IssuerNamePropertyName = "name"; |
| | 11 | | private const string CertificateTypePropertyName = "cty"; |
| | 12 | | private const string CertificateTransparencyPropertyName = "cert_transparency"; |
| | 13 | |
|
| 2 | 14 | | private static readonly JsonEncodedText s_issuerNamePropertyNameBytes = JsonEncodedText.Encode(IssuerNamePropert |
| 2 | 15 | | private static readonly JsonEncodedText s_certificateTypePropertyNameBytes = JsonEncodedText.Encode(CertificateT |
| 2 | 16 | | private static readonly JsonEncodedText s_certificateTransparencyPropertyNameNameBytes = JsonEncodedText.Encode( |
| | 17 | |
|
| 1174 | 18 | | internal string IssuerName { get; set; } |
| | 19 | |
|
| 0 | 20 | | internal string CertificateType { get; set; } |
| | 21 | |
|
| 292 | 22 | | internal bool? CertificateTransparency { get; set; } |
| | 23 | |
|
| | 24 | | internal void ReadProperties(JsonElement json) |
| | 25 | | { |
| 3368 | 26 | | foreach (JsonProperty prop in json.EnumerateObject()) |
| | 27 | | { |
| 872 | 28 | | switch (prop.Name) |
| | 29 | | { |
| | 30 | | case IssuerNamePropertyName: |
| 812 | 31 | | IssuerName = prop.Value.GetString(); |
| 812 | 32 | | break; |
| | 33 | |
|
| | 34 | | case CertificateTypePropertyName: |
| 0 | 35 | | CertificateType = prop.Value.GetString(); |
| 0 | 36 | | break; |
| | 37 | |
|
| | 38 | | case CertificateTransparencyPropertyName: |
| 60 | 39 | | CertificateTransparency = prop.Value.GetBoolean(); |
| | 40 | | break; |
| | 41 | | } |
| | 42 | | } |
| 812 | 43 | | } |
| | 44 | |
|
| | 45 | | internal void WriteProperties(Utf8JsonWriter json) |
| | 46 | | { |
| 74 | 47 | | if (IssuerName != null) |
| | 48 | | { |
| 74 | 49 | | json.WriteString(s_issuerNamePropertyNameBytes, IssuerName); |
| | 50 | | } |
| | 51 | |
|
| 74 | 52 | | if (CertificateType != null) |
| | 53 | | { |
| 0 | 54 | | json.WriteString(s_certificateTypePropertyNameBytes, CertificateType); |
| | 55 | | } |
| | 56 | |
|
| 74 | 57 | | if (CertificateTransparency.HasValue) |
| | 58 | | { |
| 60 | 59 | | json.WriteBoolean(s_certificateTransparencyPropertyNameNameBytes, CertificateTransparency.Value); |
| | 60 | | } |
| 74 | 61 | | } |
| | 62 | | } |
| | 63 | | } |