diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2012-03-30 22:56:11 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2012-03-30 22:56:11 -0700 |
commit | 12ff0dc0fa007968813675a2e0d447389a5c1bd3 (patch) | |
tree | e4cc68fd05e24143bcbea3b4073fd289ffe62c01 /src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/AuthServerUtilities.cs | |
parent | 9ee48d7fa3d6d62807b854030b8303719e6f0a6f (diff) | |
download | DotNetOpenAuth-12ff0dc0fa007968813675a2e0d447389a5c1bd3.zip DotNetOpenAuth-12ff0dc0fa007968813675a2e0d447389a5c1bd3.tar.gz DotNetOpenAuth-12ff0dc0fa007968813675a2e0d447389a5c1bd3.tar.bz2 |
Fixed up an authorization server's token endpoint to generate more accurate error messages.
Diffstat (limited to 'src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/AuthServerUtilities.cs')
-rw-r--r-- | src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/AuthServerUtilities.cs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/AuthServerUtilities.cs b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/AuthServerUtilities.cs index 75b21c8..a59eaa7 100644 --- a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/AuthServerUtilities.cs +++ b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/AuthServerUtilities.cs @@ -8,6 +8,7 @@ namespace DotNetOpenAuth.OAuth2 { using System; using System.Collections.Generic; using System.Diagnostics.Contracts; + using System.Globalization; using System.Linq; using System.Text; using DotNetOpenAuth.Messaging; @@ -36,5 +37,19 @@ namespace DotNetOpenAuth.OAuth2 { throw ErrorUtilities.Wrap(ex, OAuthStrings.ClientOrTokenSecretNotFound); } } + + /// <summary> + /// Verifies a condition is true or throws an exception describing the problem. + /// </summary> + /// <param name="condition">The condition that evaluates to true to avoid an exception.</param> + /// <param name="error">A single error code from <see cref="Protocol.AccessTokenRequestErrorCodes"/>.</param> + /// <param name="unformattedDescription">A human-readable UTF-8 encoded text providing additional information, used to assist the client developer in understanding the error that occurred.</param> + /// <param name="args">The formatting arguments to generate the actual description.</param> + internal static void TokenEndpointVerify(bool condition, string error, string unformattedDescription = null, params object[] args) { + if (!condition) { + string description = unformattedDescription != null ? string.Format(CultureInfo.CurrentCulture, unformattedDescription, args) : null; + throw new TokenEndpointProtocolException(error, description); + } + } } } |