using Microsoft.AspNet.Http; using System; namespace OAuth.AspNet.AuthServer { /// /// Contains data about the OAuth client redirect URI /// public class OAuthValidateClientRedirectUriContext : BaseValidatingClientContext { /// /// Initializes a new instance of the class /// /// /// /// /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "3#", Justification = "redirect_uri is a string parameter")] public OAuthValidateClientRedirectUriContext(HttpContext context, OAuthAuthorizationServerOptions options, string clientId, string redirectUri) : base(context, options, clientId) { RedirectUri = redirectUri; } /// /// Gets the client redirect URI /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Justification = "redirect_uri is a string parameter")] public string RedirectUri { get; private set; } /// /// Marks this context as validated by the application. IsValidated becomes true and HasError becomes false as a result of calling. /// /// public override bool Validated() { if (string.IsNullOrEmpty(RedirectUri)) { // Don't allow default validation when redirect_uri not provided with request return false; } return base.Validated(); } /// /// Checks the redirect URI to determine whether it equals . /// /// /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "0#", Justification = "redirect_uri is a string parameter")] public bool Validated(string redirectUri) { if (redirectUri == null) { throw new ArgumentNullException("redirectUri"); } if (!string.IsNullOrEmpty(RedirectUri) && !string.Equals(RedirectUri, redirectUri, StringComparison.Ordinal)) { // Don't allow validation to alter redirect_uri provided with request return false; } RedirectUri = redirectUri; return Validated(); } } }