//----------------------------------------------------------------------- // // Copyright (c) Outercurve Foundation. All rights reserved. // //----------------------------------------------------------------------- namespace DotNetOpenAuth.Configuration { using System; using System.Configuration; using Validation; /// /// Represents the <oauth2/client> section in the host's .config file. /// internal class OAuth2ClientSection : ConfigurationSection { /// /// The name of the oauth2/client section. /// private const string SectionName = OAuth2SectionGroup.SectionName + "/client"; /// /// The name of the @maxAuthorizationTime attribute. /// private const string MaxAuthorizationTimePropertyName = "maxAuthorizationTime"; /// /// Initializes a new instance of the class. /// internal OAuth2ClientSection() { } /// /// Gets the configuration section from the .config file. /// internal static OAuth2ClientSection Configuration { get { return (OAuth2ClientSection)ConfigurationManager.GetSection(SectionName) ?? new OAuth2ClientSection(); } } /// /// Gets or sets the maximum time a user can take to complete authentication. /// [ConfigurationProperty(MaxAuthorizationTimePropertyName, DefaultValue = "0:15")] // 15 minutes [PositiveTimeSpanValidator] internal TimeSpan MaxAuthorizationTime { get { TimeSpan result = (TimeSpan)this[MaxAuthorizationTimePropertyName]; Assumes.True(result > TimeSpan.Zero); // our PositiveTimeSpanValidator should take care of this return result; } set { Requires.Range(value > TimeSpan.Zero, "value"); this[MaxAuthorizationTimePropertyName] = value; } } } }