< Summary

Class:Microsoft.Azure.KeyVault.AggregateKeyResolver
Assembly:Microsoft.Azure.KeyVault.Extensions
File(s):C:\Git\azure-sdk-for-net\sdk\keyvault\Microsoft.Azure.KeyVault.Extensions\src\AggregateKeyResolver.cs
Covered lines:0
Uncovered lines:11
Coverable lines:11
Total lines:60
Line coverage:0% (0 of 11)
Covered branches:0
Total branches:6
Branch coverage:0% (0 of 6)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-0%100%
Add(...)-0%0%
ResolveKeyAsync()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\keyvault\Microsoft.Azure.KeyVault.Extensions\src\AggregateKeyResolver.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License. See License.txt in the project root for
 3// license information.
 4
 5using System;
 6using System.Collections.Concurrent;
 7using System.Threading;
 8using System.Threading.Tasks;
 9using Microsoft.Azure.KeyVault.Core;
 10
 11namespace Microsoft.Azure.KeyVault
 12{
 13    /// <summary>
 14    /// The collection of key resolvers that would iterate on a key id to resolve to <see cref="IKey"/>.
 15    /// </summary>
 16    public class AggregateKeyResolver : IKeyResolver
 17    {
 018        private readonly ConcurrentBag<IKeyResolver> _resolvers = new ConcurrentBag<IKeyResolver>();
 19
 20        /// <summary>
 21        /// Adds a key resolver to the collection of key resolvers.
 22        /// </summary>
 23        /// <param name="resolver">The key resolver to add to the collection</param>
 24        /// <returns></returns>
 25        public AggregateKeyResolver Add( IKeyResolver resolver )
 26        {
 027            if ( resolver == null )
 028                throw new ArgumentNullException( "resolver" );
 29
 030            _resolvers.Add( resolver );
 31
 032            return this;
 33        }
 34
 35        #region IKeyResolver
 36
 37        /// <summary>
 38        /// Resolve a key indicated by its ID to the corresponding <see cref="IKey"/>
 39        /// </summary>
 40        /// <param name="kid"> the key identifier </param>
 41        /// <param name="token"> the cancellation token </param>
 42        /// <returns> task result of the <see cref="IKey"/></returns>
 43        public async Task<IKey> ResolveKeyAsync( string kid, CancellationToken token )
 44        {
 045            foreach ( var resolver in _resolvers )
 46            {
 047                IKey resolved = await resolver.ResolveKeyAsync( kid, token ).ConfigureAwait( false );
 48
 049                if ( resolved != null )
 50                {
 051                    return resolved;
 52                }
 53            }
 54
 055            return null;
 056        }
 57
 58        #endregion
 59    }
 60}

Methods/Properties

.ctor()
Add(...)
ResolveKeyAsync()