summaryrefslogtreecommitdiffstats
path: root/samples/OAuthServiceProvider/OAuth.ashx
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2009-03-26 16:01:37 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2009-03-26 16:01:37 -0700
commitfc29aefdf4fe9fb1081ee21c01f5ba3963904be6 (patch)
tree74e1cb88f7a600f446df513a3a15a0104d7ff7e7 /samples/OAuthServiceProvider/OAuth.ashx
parentd18ea6028e8c6cadbf99e2c4529350c26224c6ff (diff)
parentad95a2e4ab219a246a2288c62452b0d920a7cdc2 (diff)
downloadDotNetOpenAuth-fc29aefdf4fe9fb1081ee21c01f5ba3963904be6.zip
DotNetOpenAuth-fc29aefdf4fe9fb1081ee21c01f5ba3963904be6.tar.gz
DotNetOpenAuth-fc29aefdf4fe9fb1081ee21c01f5ba3963904be6.tar.bz2
Merge branch 'samplerename'
Diffstat (limited to 'samples/OAuthServiceProvider/OAuth.ashx')
-rw-r--r--samples/OAuthServiceProvider/OAuth.ashx41
1 files changed, 41 insertions, 0 deletions
diff --git a/samples/OAuthServiceProvider/OAuth.ashx b/samples/OAuthServiceProvider/OAuth.ashx
new file mode 100644
index 0000000..46a516f
--- /dev/null
+++ b/samples/OAuthServiceProvider/OAuth.ashx
@@ -0,0 +1,41 @@
+<%@ WebHandler Language="C#" Class="OAuth" %>
+
+using System;
+using System.Linq;
+using System.Web;
+using System.Web.SessionState;
+using DotNetOpenAuth.OAuth;
+using DotNetOpenAuth.OAuth.ChannelElements;
+using DotNetOpenAuth.OAuth.Messages;
+using DotNetOpenAuth.Messaging;
+
+public class OAuth : IHttpHandler, 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();
+ RequestScopedTokenMessage requestToken;
+ UserAuthorizationRequest requestAuth;
+ AuthorizedTokenRequest requestAccessToken;
+ if ((requestToken = request as RequestScopedTokenMessage) != null) {
+ var response = sp.PrepareUnauthorizedTokenMessage(requestToken);
+ sp.Channel.Send(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);
+ } else {
+ throw new InvalidOperationException();
+ }
+ }
+
+ public bool IsReusable {
+ get { return true; }
+ }
+}