//-----------------------------------------------------------------------
//
// Copyright (c) Outercurve Foundation. All rights reserved.
//
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.Configuration {
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics.CodeAnalysis;
using Validation;
///
/// A configuration collection of trusted OP Endpoints.
///
internal class TrustedProviderConfigurationCollection : ConfigurationElementCollection {
///
/// The name of the "rejectAssertionsFromUntrustedProviders" element.
///
private const string RejectAssertionsFromUntrustedProvidersConfigName = "rejectAssertionsFromUntrustedProviders";
///
/// Initializes a new instance of the class.
///
internal TrustedProviderConfigurationCollection() {
}
///
/// Initializes a new instance of the class.
///
/// The elements to initialize the collection with.
[SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors", Justification = "Seems unavoidable")]
internal TrustedProviderConfigurationCollection(IEnumerable elements) {
Requires.NotNull(elements, "elements");
foreach (TrustedProviderEndpointConfigurationElement element in elements) {
this.BaseAdd(element);
}
}
///
/// Gets or sets a value indicating whether any login attempt coming from an OpenID Provider Endpoint that is not on this
/// whitelist of trusted OP Endpoints will be rejected. If the trusted providers list is empty and this value
/// is true, all assertions are rejected.
///
[ConfigurationProperty(RejectAssertionsFromUntrustedProvidersConfigName, DefaultValue = false)]
internal bool RejectAssertionsFromUntrustedProviders {
get { return (bool)this[RejectAssertionsFromUntrustedProvidersConfigName]; }
set { this[RejectAssertionsFromUntrustedProvidersConfigName] = value; }
}
///
/// When overridden in a derived class, creates a new .
///
///
/// A new .
///
protected override ConfigurationElement CreateNewElement() {
return new TrustedProviderEndpointConfigurationElement();
}
///
/// Gets the element key for a specified configuration element when overridden in a derived class.
///
/// The to return the key for.
///
/// An that acts as the key for the specified .
///
protected override object GetElementKey(ConfigurationElement element) {
return ((TrustedProviderEndpointConfigurationElement)element).ProviderEndpoint;
}
}
}