diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2010-07-12 22:00:46 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2010-07-12 22:00:46 -0700 |
commit | eea1b39e043cbd64bccda02e9c9da81aeb359ada (patch) | |
tree | 39f6a1ba996bb6ebf081d5a41b25d5ebebc3f6cd /projecttemplates/WebFormsRelyingParty/OAuthTokenEndpoint.ashx.cs | |
parent | 096a53e5a79cac2eecb1311661a255a5f4e6aa6e (diff) | |
download | DotNetOpenAuth-eea1b39e043cbd64bccda02e9c9da81aeb359ada.zip DotNetOpenAuth-eea1b39e043cbd64bccda02e9c9da81aeb359ada.tar.gz DotNetOpenAuth-eea1b39e043cbd64bccda02e9c9da81aeb359ada.tar.bz2 |
Work toward the WebFormsRelyingParty project template to use OAuth 2.0 instead of 1.0a.
It compiles now. (and the MVC one doesn't).
Diffstat (limited to 'projecttemplates/WebFormsRelyingParty/OAuthTokenEndpoint.ashx.cs')
-rw-r--r-- | projecttemplates/WebFormsRelyingParty/OAuthTokenEndpoint.ashx.cs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/projecttemplates/WebFormsRelyingParty/OAuthTokenEndpoint.ashx.cs b/projecttemplates/WebFormsRelyingParty/OAuthTokenEndpoint.ashx.cs new file mode 100644 index 0000000..ca9b399 --- /dev/null +++ b/projecttemplates/WebFormsRelyingParty/OAuthTokenEndpoint.ashx.cs @@ -0,0 +1,51 @@ +//----------------------------------------------------------------------- +// <copyright file="OAuthTokenEndpoint.ashx.cs" company="Andrew Arnott"> +// Copyright (c) Andrew Arnott. All rights reserved. +// </copyright> +//----------------------------------------------------------------------- + +namespace WebFormsRelyingParty { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Web; + using System.Web.SessionState; + using DotNetOpenAuth.Messaging; + using DotNetOpenAuth.OAuth2; + using RelyingPartyLogic; + + /// <summary> + /// An OAuth 2.0 token endpoint. + /// </summary> + public class OAuthTokenEndpoint : IHttpHandler, IRequiresSessionState { + /// <summary> + /// Initializes a new instance of the <see cref="OAuthTokenEndpoint"/> class. + /// </summary> + public OAuthTokenEndpoint() { + } + + /// <summary> + /// Gets a value indicating whether another request can use the <see cref="T:System.Web.IHttpHandler"/> instance. + /// </summary> + /// <returns> + /// true if the <see cref="T:System.Web.IHttpHandler"/> instance is reusable; otherwise, false. + /// </returns> + public bool IsReusable { + get { return true; } + } + + /// <summary> + /// Enables processing of HTTP Web requests by a custom HttpHandler that implements the <see cref="T:System.Web.IHttpHandler"/> interface. + /// </summary> + /// <param name="context">An <see cref="T:System.Web.HttpContext"/> object that provides references to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.</param> + public void ProcessRequest(HttpContext context) { + var serviceProvider = OAuthServiceProvider.AuthorizationServer; + IDirectResponseProtocolMessage response; + if (serviceProvider.TryPrepareAccessTokenResponse(new HttpRequestInfo(context.Request), out response)) { + serviceProvider.Channel.Send(response); + } else { + throw new InvalidOperationException(); + } + } + } +} |