diff options
Diffstat (limited to 'samples/OAuthServiceProvider/OAuth.ashx')
-rw-r--r-- | samples/OAuthServiceProvider/OAuth.ashx | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/samples/OAuthServiceProvider/OAuth.ashx b/samples/OAuthServiceProvider/OAuth.ashx index 8a74926..7b3dc75 100644 --- a/samples/OAuthServiceProvider/OAuth.ashx +++ b/samples/OAuthServiceProvider/OAuth.ashx @@ -2,41 +2,45 @@ using System; using System.Linq; +using System.Threading.Tasks; using System.Web; using System.Web.SessionState; +using DotNetOpenAuth.ApplicationBlock; using DotNetOpenAuth.OAuth; using DotNetOpenAuth.OAuth.ChannelElements; using DotNetOpenAuth.OAuth.Messages; using DotNetOpenAuth.Messaging; using OAuthServiceProvider.Code; -public class OAuth : IHttpHandler, IRequiresSessionState { +public class OAuth : HttpAsyncHandlerBase, IRequiresSessionState { ServiceProvider sp; public OAuth() { sp = new ServiceProvider(Constants.SelfDescription, Global.TokenManager, new CustomOAuthMessageFactory(Global.TokenManager)); } - public void ProcessRequest(HttpContext context) { - IProtocolMessage request = sp.ReadRequest(); + public override bool IsReusable { + get { return true; } + } + + protected override async Task ProcessRequestAsync(HttpContext context) { + IProtocolMessage request = await sp.ReadRequestAsync(); RequestScopedTokenMessage requestToken; UserAuthorizationRequest requestAuth; AuthorizedTokenRequest requestAccessToken; if ((requestToken = request as RequestScopedTokenMessage) != null) { var response = sp.PrepareUnauthorizedTokenMessage(requestToken); - sp.Channel.Send(response); + var responseMessage = await sp.Channel.PrepareResponseAsync(response); + await responseMessage.SendAsync(new HttpResponseWrapper(context.Response)); } else if ((requestAuth = request as UserAuthorizationRequest) != null) { Global.PendingOAuthAuthorization = requestAuth; HttpContext.Current.Response.Redirect("~/Members/Authorize.aspx"); } else if ((requestAccessToken = request as AuthorizedTokenRequest) != null) { var response = sp.PrepareAccessTokenMessage(requestAccessToken); - sp.Channel.Send(response); + var responseMessage = await sp.Channel.PrepareResponseAsync(response); + await responseMessage.SendAsync(new HttpResponseWrapper(context.Response)); } else { throw new InvalidOperationException(); } } - - public bool IsReusable { - get { return true; } - } } |