| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.Text.Json; |
| | 6 | |
|
| | 7 | | namespace Azure.Security.KeyVault.Certificates |
| | 8 | | { |
| | 9 | | internal struct CertificateAttributes |
| | 10 | | { |
| | 11 | | private const string EnabledPropertyName = "enabled"; |
| | 12 | | private const string NotBeforePropertyName = "nbf"; |
| | 13 | | private const string ExpiresPropertyName = "exp"; |
| | 14 | | private const string CreatedPropertyName = "created"; |
| | 15 | | private const string UpdatedPropertyName = "updated"; |
| | 16 | | private const string RecoverableDaysPropertyName = "recoverableDays"; |
| | 17 | | private const string RecoveryLevelPropertyName = "recoveryLevel"; |
| | 18 | |
|
| 108 | 19 | | public bool? Enabled { get; set; } |
| | 20 | |
|
| 0 | 21 | | public DateTimeOffset? NotBefore { get; set; } |
| | 22 | |
|
| 0 | 23 | | public DateTimeOffset? ExpiresOn { get; set; } |
| | 24 | |
|
| 0 | 25 | | public DateTimeOffset? CreatedOn { get; internal set; } |
| | 26 | |
|
| 0 | 27 | | public DateTimeOffset? UpdatedOn { get; internal set; } |
| | 28 | |
|
| 86 | 29 | | public int? RecoverableDays { get; internal set; } |
| | 30 | |
|
| 0 | 31 | | public string RecoveryLevel { get; internal set; } |
| | 32 | |
|
| | 33 | | internal void ReadProperties(JsonElement json) |
| | 34 | | { |
| 1232 | 35 | | foreach (JsonProperty prop in json.EnumerateObject()) |
| | 36 | | { |
| 536 | 37 | | switch (prop.Name) |
| | 38 | | { |
| | 39 | | case EnabledPropertyName: |
| 76 | 40 | | Enabled = prop.Value.GetBoolean(); |
| 76 | 41 | | break; |
| | 42 | |
|
| | 43 | | case NotBeforePropertyName: |
| 76 | 44 | | NotBefore = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64()); |
| 76 | 45 | | break; |
| | 46 | |
|
| | 47 | | case ExpiresPropertyName: |
| 76 | 48 | | ExpiresOn = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64()); |
| 76 | 49 | | break; |
| | 50 | |
|
| | 51 | | case CreatedPropertyName: |
| 76 | 52 | | CreatedOn = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64()); |
| 76 | 53 | | break; |
| | 54 | |
|
| | 55 | | case UpdatedPropertyName: |
| 76 | 56 | | UpdatedOn = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64()); |
| 76 | 57 | | break; |
| | 58 | |
|
| | 59 | | case RecoverableDaysPropertyName: |
| 80 | 60 | | RecoverableDays = prop.Value.GetInt32(); |
| 80 | 61 | | break; |
| | 62 | |
|
| | 63 | | case RecoveryLevelPropertyName: |
| 76 | 64 | | RecoveryLevel = prop.Value.GetString(); |
| | 65 | | break; |
| | 66 | | } |
| | 67 | | } |
| 80 | 68 | | } |
| | 69 | | } |
| | 70 | | } |