diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2012-04-01 09:37:25 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2012-04-01 09:37:25 -0700 |
commit | 247d4f5fccab45f8b37438835f9a4c33b5450f6a (patch) | |
tree | 3ae9c4eb3aaeb65fc39f389796662ff753811ce9 /src | |
parent | cc78ccd887b76df0587a47a2c126c541cdce4d7d (diff) | |
download | DotNetOpenAuth-247d4f5fccab45f8b37438835f9a4c33b5450f6a.zip DotNetOpenAuth-247d4f5fccab45f8b37438835f9a4c33b5450f6a.tar.gz DotNetOpenAuth-247d4f5fccab45f8b37438835f9a4c33b5450f6a.tar.bz2 |
Simplified ClientDescription class and made it more flexible at the same
time.
Diffstat (limited to 'src')
-rw-r--r-- | src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ClientDescription.cs | 27 | ||||
-rw-r--r-- | src/DotNetOpenAuth.OAuth2.ClientAuthorization/OAuth2/IClientDescription.cs | 2 |
2 files changed, 11 insertions, 18 deletions
diff --git a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ClientDescription.cs b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ClientDescription.cs index 1ec9789..28fcaf5 100644 --- a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ClientDescription.cs +++ b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ClientDescription.cs @@ -16,11 +16,6 @@ namespace DotNetOpenAuth.OAuth2 { /// </summary> public class ClientDescription : IClientDescription { /// <summary> - /// A delegate that determines whether the callback is allowed. - /// </summary> - private readonly Func<Uri, bool> isCallbackAllowed; - - /// <summary> /// The client's secret, if any. /// </summary> private readonly string secret; @@ -32,13 +27,14 @@ namespace DotNetOpenAuth.OAuth2 { /// <param name="defaultCallback">The default callback.</param> /// <param name="clientType">Type of the client.</param> /// <param name="isCallbackAllowed">A delegate that determines whether the callback is allowed.</param> - public ClientDescription(string secret, Uri defaultCallback, ClientType clientType, Func<Uri, bool> isCallbackAllowed = null) { + public ClientDescription(string secret, Uri defaultCallback, ClientType clientType) { this.secret = secret; this.DefaultCallback = defaultCallback; this.ClientType = clientType; - this.isCallbackAllowed = isCallbackAllowed; } + #region IClientDescription Members + /// <summary> /// Gets the callback to use when an individual authorization request /// does not include an explicit callback URI. @@ -56,7 +52,7 @@ namespace DotNetOpenAuth.OAuth2 { /// <summary> /// Gets a value indicating whether a non-empty secret is registered for this client. /// </summary> - public bool HasNonEmptySecret { + public virtual bool HasNonEmptySecret { get { return !string.IsNullOrEmpty(this.secret); } } @@ -64,20 +60,17 @@ namespace DotNetOpenAuth.OAuth2 { /// Determines whether a callback URI included in a client's authorization request /// is among those allowed callbacks for the registered client. /// </summary> - /// <param name="callback">The absolute URI the client has requested the authorization result be received at.</param> + /// <param name="callback">The absolute URI the client has requested the authorization result be received at. Never null.</param> /// <returns> /// <c>true</c> if the callback URL is allowable for this client; otherwise, <c>false</c>. /// </returns> - public bool IsCallbackAllowed(Uri callback) { - if (this.isCallbackAllowed != null) { - return this.isCallbackAllowed(callback); - } - + /// <remarks> + /// This method may be overridden to allow for several callbacks to match. + /// </remarks> + public virtual bool IsCallbackAllowed(Uri callback) { return EqualityComparer<Uri>.Default.Equals(this.DefaultCallback, callback); } - #region IClientDescription Members - /// <summary> /// Checks whether the specified client secret is correct. /// </summary> @@ -87,7 +80,7 @@ namespace DotNetOpenAuth.OAuth2 { /// All string equality checks, whether checking secrets or their hashes, /// should be done using <see cref="MessagingUtilites.EqualsConstantTime"/> to mitigate timing attacks. /// </remarks> - public bool IsValidClientSecret(string secret) { + public virtual bool IsValidClientSecret(string secret) { Requires.NotNullOrEmpty(secret, "secret"); return MessagingUtilities.EqualsConstantTime(secret, this.secret); diff --git a/src/DotNetOpenAuth.OAuth2.ClientAuthorization/OAuth2/IClientDescription.cs b/src/DotNetOpenAuth.OAuth2.ClientAuthorization/OAuth2/IClientDescription.cs index bcef28b..ebbe1f2 100644 --- a/src/DotNetOpenAuth.OAuth2.ClientAuthorization/OAuth2/IClientDescription.cs +++ b/src/DotNetOpenAuth.OAuth2.ClientAuthorization/OAuth2/IClientDescription.cs @@ -35,7 +35,7 @@ namespace DotNetOpenAuth.OAuth2 { /// Determines whether a callback URI included in a client's authorization request /// is among those allowed callbacks for the registered client. /// </summary> - /// <param name="callback">The absolute URI the client has requested the authorization result be received at.</param> + /// <param name="callback">The absolute URI the client has requested the authorization result be received at. Never null.</param> /// <returns> /// <c>true</c> if the callback URL is allowable for this client; otherwise, <c>false</c>. /// </returns> |