-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Azure.Security.KeyVault.Certificates implementation #7530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7031af7
c409a34
f3cc0a2
50c05c5
01df37a
f555868
e838a9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for | ||
| // license information. | ||
|
|
||
| using System; | ||
|
|
||
| namespace Azure.Security.KeyVault.Certificates | ||
| { | ||
| /// <summary> | ||
| /// An action that will be executed. | ||
| /// </summary> | ||
| public struct Action | ||
| { | ||
| private string _value; | ||
| internal const string AutoRenewValue = "AutoRenew"; | ||
| internal const string EmailContactsValue = "EmailContacts"; | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the Action struct with the specfied value. | ||
| /// </summary> | ||
| public Action(string Action) | ||
| { | ||
| _value = Action; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// An action that will auto-renew a certificate | ||
| /// </summary> | ||
| public static readonly Action AutoRenew = new Action(AutoRenewValue); | ||
|
|
||
| /// <summary> | ||
| /// An action that will email certificate contacts | ||
| /// </summary> | ||
| public static readonly Action EmailContacts = new Action(EmailContactsValue); | ||
|
|
||
| public override bool Equals(object obj) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May as well implement public override bool Equals(object obj) => obj is Action action && Equals(action); |
||
| { | ||
| return obj is Action && this.Equals((CertificateKeyType)obj); | ||
| } | ||
|
|
||
| public bool Equals(Action other) | ||
| { | ||
| return string.CompareOrdinal(_value, other._value) == 0; | ||
| } | ||
|
|
||
| public override int GetHashCode() | ||
| { | ||
| return _value?.GetHashCode() ?? 0; | ||
| } | ||
|
|
||
| public override string ToString() | ||
| { | ||
| return _value; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could be null, and |
||
| } | ||
|
|
||
| public static bool operator ==(Action a, Action b) => a.Equals(b); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would box the |
||
|
|
||
| public static bool operator !=(Action a, Action b) => !a.Equals(b); | ||
|
|
||
| public static implicit operator Action(string value) => new Action(value); | ||
|
|
||
| public static implicit operator string(Action o) => o._value; | ||
| } | ||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for | ||
| // license information. | ||
|
|
||
| using System.Text.Json; | ||
|
|
||
| namespace Azure.Security.KeyVault.Certificates | ||
| { | ||
| /// <summary> | ||
| /// Details of an administrator of a certificate <see cref="Issuer"/> | ||
| /// </summary> | ||
| public class AdministratorDetails | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be implementing |
||
| { | ||
| /// <summary> | ||
| /// The email address of the administrator | ||
| /// </summary> | ||
| public string Email { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// The first name of the administrator | ||
| /// </summary> | ||
| public string FirstName { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// The last name of the administrator | ||
| /// </summary> | ||
| public string LastName { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// The phone number of the administrator | ||
| /// </summary> | ||
| public string Phone { get; set; } | ||
|
|
||
| private const string FirstNamePropertyName = "first_name"; | ||
| private const string LastNamePropertyName = "last_name"; | ||
| private const string EmailPropertyName = "email"; | ||
| private const string PhonePropertyName = "phone"; | ||
|
|
||
| internal void ReadProperties(JsonElement json) | ||
| { | ||
| foreach (JsonProperty prop in json.EnumerateObject()) | ||
| { | ||
| switch (prop.Name) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may be a bit of a random comment, but I just got to thinking: for roundtripping, should we store all unhandled properties in a property bag and write them back out? JSON.NET has an easy way to do this, but we could do something similar pretty easy with an |
||
| { | ||
| case FirstNamePropertyName: | ||
| FirstName = prop.Value.GetString(); | ||
| break; | ||
| case LastNamePropertyName: | ||
| LastName = prop.Value.GetString(); | ||
| break; | ||
| case EmailPropertyName: | ||
| Email = prop.Value.GetString(); | ||
| break; | ||
| case PhonePropertyName: | ||
| Phone = prop.Value.GetString(); | ||
| break; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private static readonly JsonEncodedText FirstNamePropertyNameBytes = JsonEncodedText.Encode(FirstNamePropertyName); | ||
| private static readonly JsonEncodedText LastNamePropertyNameBytes = JsonEncodedText.Encode(LastNamePropertyName); | ||
| private static readonly JsonEncodedText EmailPropertyNameBytes = JsonEncodedText.Encode(EmailPropertyName); | ||
| private static readonly JsonEncodedText PhonePropertyNameBytes = JsonEncodedText.Encode(PhonePropertyName); | ||
|
|
||
| internal void WriteProperties(Utf8JsonWriter json) | ||
| { | ||
| if (!string.IsNullOrEmpty(FirstName)) | ||
| { | ||
| json.WriteString(FirstNamePropertyNameBytes, FirstName); | ||
| } | ||
|
|
||
| if (!string.IsNullOrEmpty(LastName)) | ||
| { | ||
| json.WriteString(LastNamePropertyNameBytes, LastName); | ||
| } | ||
|
|
||
| if (!string.IsNullOrEmpty(Email)) | ||
| { | ||
| json.WriteString(EmailPropertyNameBytes, Email); | ||
| } | ||
|
|
||
| if (!string.IsNullOrEmpty(Phone)) | ||
| { | ||
| json.WriteString(PhonePropertyNameBytes, Phone); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,10 @@ | |
| <PackageTags>Microsoft Azure Key Vault Certificates</PackageTags> | ||
| <PackageReleaseNotes> | ||
| <![CDATA[ | ||
| Initial release of the Azure.Security.KeyVault.Certificates enabling: | ||
| - Management of Key Vault certififiates | ||
| - Management of Certificate Issuers | ||
| - Management of Certificate Contacts | ||
| ]]> | ||
| </PackageReleaseNotes> | ||
|
|
||
|
|
@@ -21,13 +25,17 @@ | |
| <!-- Import the Azure.Core project --> | ||
| <Import Project="$(MSBuildThisFileDirectory)..\..\..\core\Azure.Core\src\Azure.Core.props" /> | ||
|
|
||
| <Import Project="..\..\Azure.Security.KeyVault.Shared\Azure.Security.KeyVault.Shared.projitems" Label="Shared" /> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="System.Memory" /> | ||
| <PackageReference Include="System.Text.Json" /> | ||
| <PackageReference Include="System.Threading.Tasks.Extensions" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Compile Include="..\..\Azure.Security.KeyVault.Shared\ChallengeBasedAuthenticationPolicy.cs" /> | ||
| <Compile Include="$(AzureCoreSharedSources)ArrayBufferWriter.cs" /> | ||
| <Compile Include="$(AzureCoreSharedSources)PageResponseEnumerator.cs" /> | ||
| <Compile Include="..\..\Shared\*" /> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There shouldn't be anything in this directory anymore (i.e. it shouldn't exist). |
||
| </ItemGroup> | ||
| </Project> | ||
| </Project> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be lowercase "action". Also, for consistency, do we want all these values throughout structs like this to just be "value"?