diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2008-11-20 06:54:14 -0800 |
---|---|---|
committer | Andrew <andrewarnott@gmail.com> | 2008-11-20 06:54:14 -0800 |
commit | 1a882368e2e99e9360cfd1f4f23f5acb70306436 (patch) | |
tree | ab0d370a8b8b9d5b638524f189a39991970834bb /samples/ServiceProvider | |
parent | d51be63270463542a308a9a2cef992b7d55baaa6 (diff) | |
download | DotNetOpenAuth-1a882368e2e99e9360cfd1f4f23f5acb70306436.zip DotNetOpenAuth-1a882368e2e99e9360cfd1f4f23f5acb70306436.tar.gz DotNetOpenAuth-1a882368e2e99e9360cfd1f4f23f5acb70306436.tar.bz2 |
Reworked the way messages are instantiated and deserialized.
This was a whole lot of work to just get multi-version capability added to message types so that OpenID could handle its few versions.
Diffstat (limited to 'samples/ServiceProvider')
-rw-r--r-- | samples/ServiceProvider/App_Code/CustomOAuthTypeProvider.cs | 17 | ||||
-rw-r--r-- | samples/ServiceProvider/OAuth.ashx | 2 |
2 files changed, 10 insertions, 9 deletions
diff --git a/samples/ServiceProvider/App_Code/CustomOAuthTypeProvider.cs b/samples/ServiceProvider/App_Code/CustomOAuthTypeProvider.cs index 0fd1ed5..a4397c1 100644 --- a/samples/ServiceProvider/App_Code/CustomOAuthTypeProvider.cs +++ b/samples/ServiceProvider/App_Code/CustomOAuthTypeProvider.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Web; +using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OAuth.ChannelElements; using DotNetOpenAuth.OAuth.Messages; @@ -9,22 +10,22 @@ using DotNetOpenAuth.OAuth.Messages; /// A custom class that will cause the OAuth library to use our custom message types /// where we have them. /// </summary> -public class CustomOAuthTypeProvider : OAuthServiceProviderMessageTypeProvider { +public class CustomOAuthMessageFactory : OAuthServiceProviderMessageFactory { /// <summary> - /// Initializes a new instance of the <see cref="CustomOAuthTypeProvider"/> class. + /// Initializes a new instance of the <see cref="CustomOAuthMessageFactory"/> class. /// </summary> /// <param name="tokenManager">The token manager instance to use.</param> - public CustomOAuthTypeProvider(ITokenManager tokenManager) : base(tokenManager) { + public CustomOAuthMessageFactory(ITokenManager tokenManager) : base(tokenManager) { } - public override Type GetRequestMessageType(IDictionary<string, string> fields) { - Type type = base.GetRequestMessageType(fields); + public override IDirectedProtocolMessage GetNewRequestMessage(MessageReceivingEndpoint recipient, IDictionary<string, string> fields) { + var message = base.GetNewRequestMessage(recipient, fields); // inject our own type here to replace the standard one - if (type == typeof(UnauthorizedTokenRequest)) { - type = typeof(RequestScopedTokenMessage); + if (message is UnauthorizedTokenRequest) { + message = new RequestScopedTokenMessage(recipient); } - return type; + return message; } } diff --git a/samples/ServiceProvider/OAuth.ashx b/samples/ServiceProvider/OAuth.ashx index f2100c6..506b900 100644 --- a/samples/ServiceProvider/OAuth.ashx +++ b/samples/ServiceProvider/OAuth.ashx @@ -13,7 +13,7 @@ public class OAuth : IHttpHandler, IRequiresSessionState { ServiceProvider sp; public OAuth() { - sp = new ServiceProvider(Constants.SelfDescription, Global.TokenManager, new CustomOAuthTypeProvider(Global.TokenManager)); + sp = new ServiceProvider(Constants.SelfDescription, Global.TokenManager, new CustomOAuthMessageFactory(Global.TokenManager)); } public void ProcessRequest(HttpContext context) { |