| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using Azure.Core.Extensions; |
| | 6 | | using Azure.Security.KeyVault.Keys; |
| | 7 | | using Azure.Security.KeyVault.Keys.Cryptography; |
| | 8 | |
|
| | 9 | | namespace Microsoft.Extensions.Azure |
| | 10 | | { |
| | 11 | | /// <summary> |
| | 12 | | /// Extension methods to <see cref="KeyClient"/> or <see cref="CryptographyClient"/> to clients builder. |
| | 13 | | /// </summary> |
| | 14 | | public static class KeyClientBuilderExtensions |
| | 15 | | { |
| | 16 | | /// <summary> |
| | 17 | | /// Registers a <see cref="KeyClient"/> instance with the provided <paramref name="vaultUri"/> |
| | 18 | | /// </summary> |
| | 19 | | public static IAzureClientBuilder<KeyClient, KeyClientOptions> AddKeyClient<TBuilder>(this TBuilder builder, Uri |
| | 20 | | where TBuilder : IAzureClientFactoryBuilderWithCredential |
| | 21 | | { |
| 0 | 22 | | return builder.RegisterClientFactory<KeyClient, KeyClientOptions>((options, cred) => new KeyClient(vaultUri, |
| | 23 | | } |
| | 24 | |
|
| | 25 | | /// <summary> |
| | 26 | | /// Registers a <see cref="KeyClient"/> instance with connection options loaded from the provided <paramref name |
| | 27 | | /// </summary> |
| | 28 | | public static IAzureClientBuilder<KeyClient, KeyClientOptions> AddKeyClient<TBuilder, TConfiguration>(this TBuil |
| | 29 | | where TBuilder : IAzureClientFactoryBuilderWithConfiguration<TConfiguration> |
| | 30 | | { |
| 0 | 31 | | return builder.RegisterClientFactory<KeyClient, KeyClientOptions>(configuration); |
| | 32 | | } |
| | 33 | |
|
| | 34 | | /// <summary> |
| | 35 | | /// Registers a <see cref="KeyClient"/> instance with the provided <paramref name="vaultUri"/> |
| | 36 | | /// </summary> |
| | 37 | | public static IAzureClientBuilder<CryptographyClient, CryptographyClientOptions> AddCryptographyClient<TBuilder> |
| | 38 | | where TBuilder : IAzureClientFactoryBuilderWithCredential |
| | 39 | | { |
| 0 | 40 | | return builder.RegisterClientFactory<CryptographyClient, CryptographyClientOptions>((options, cred) => new C |
| | 41 | | } |
| | 42 | |
|
| | 43 | | /// <summary> |
| | 44 | | /// Registers a <see cref="KeyClient"/> instance with connection options loaded from the provided <paramref name |
| | 45 | | /// </summary> |
| | 46 | | public static IAzureClientBuilder<CryptographyClient, CryptographyClientOptions> AddCryptographyClient<TBuilder, |
| | 47 | | where TBuilder : IAzureClientFactoryBuilderWithConfiguration<TConfiguration> |
| | 48 | | { |
| 0 | 49 | | return builder.RegisterClientFactory<CryptographyClient, CryptographyClientOptions>(configuration); |
| | 50 | | } |
| | 51 | | } |
| | 52 | | } |