// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; using System.Globalization; namespace Microsoft.AspNetCore.Http.Authentication { /// /// Contains information describing an authentication provider. /// public class AuthenticationDescription { private const string DisplayNamePropertyKey = "DisplayName"; private const string AuthenticationSchemePropertyKey = "AuthenticationScheme"; /// /// Initializes a new instance of the class /// public AuthenticationDescription() : this(items: null) { } /// /// Initializes a new instance of the class /// /// public AuthenticationDescription(IDictionary items) { Items = items ?? new Dictionary(StringComparer.Ordinal); ; } /// /// Contains metadata about the authentication provider. /// public IDictionary Items { get; } /// /// Gets or sets the name used to reference the authentication middleware instance. /// public string AuthenticationScheme { get { return GetString(AuthenticationSchemePropertyKey); } set { Items[AuthenticationSchemePropertyKey] = value; } } /// /// Gets or sets the display name for the authentication provider. /// public string DisplayName { get { return GetString(DisplayNamePropertyKey); } set { Items[DisplayNamePropertyKey] = value; } } private string GetString(string name) { object value; if (Items.TryGetValue(name, out value)) { return Convert.ToString(value, CultureInfo.InvariantCulture); } return null; } } }