diff options
Diffstat (limited to 'src/DotNetOpenAuth.OAuth2.Client/Configuration/OAuth2ClientSection.cs')
-rw-r--r-- | src/DotNetOpenAuth.OAuth2.Client/Configuration/OAuth2ClientSection.cs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/DotNetOpenAuth.OAuth2.Client/Configuration/OAuth2ClientSection.cs b/src/DotNetOpenAuth.OAuth2.Client/Configuration/OAuth2ClientSection.cs index 1ee5aa5..3bb6ffc 100644 --- a/src/DotNetOpenAuth.OAuth2.Client/Configuration/OAuth2ClientSection.cs +++ b/src/DotNetOpenAuth.OAuth2.Client/Configuration/OAuth2ClientSection.cs @@ -5,6 +5,7 @@ //----------------------------------------------------------------------- namespace DotNetOpenAuth.Configuration { + using System; using System.Configuration; using System.Diagnostics.Contracts; @@ -18,6 +19,11 @@ namespace DotNetOpenAuth.Configuration { private const string SectionName = OAuth2SectionGroup.SectionName + "/client"; /// <summary> + /// The name of the @maxAuthorizationTime attribute. + /// </summary> + private const string MaxAuthorizationTimePropertyName = "maxAuthorizationTime"; + + /// <summary> /// Initializes a new instance of the <see cref="OAuth2ClientSection"/> class. /// </summary> internal OAuth2ClientSection() { @@ -32,5 +38,24 @@ namespace DotNetOpenAuth.Configuration { return (OAuth2ClientSection)ConfigurationManager.GetSection(SectionName) ?? new OAuth2ClientSection(); } } + + /// <summary> + /// Gets or sets the maximum time a user can take to complete authentication. + /// </summary> + [ConfigurationProperty(MaxAuthorizationTimePropertyName, DefaultValue = "0:15")] // 15 minutes + [PositiveTimeSpanValidator] + internal TimeSpan MaxAuthorizationTime { + get { + Contract.Ensures(Contract.Result<TimeSpan>() > TimeSpan.Zero); + TimeSpan result = (TimeSpan)this[MaxAuthorizationTimePropertyName]; + Contract.Assume(result > TimeSpan.Zero); // our PositiveTimeSpanValidator should take care of this + return result; + } + + set { + Requires.InRange(value > TimeSpan.Zero, "value"); + this[MaxAuthorizationTimePropertyName] = value; + } + } } } |