diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2009-04-10 21:19:09 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2009-04-10 21:19:09 -0700 |
commit | 5cb3aa5dda4d090400e6561c6ec64999ed5fca4c (patch) | |
tree | 0cf5633163de5d2f4e61c4e4a1c1d3783f234e5f /samples/DotNetOpenAuth.ApplicationBlock/GoogleConsumer.cs | |
parent | 8254a5ca1ced42181eb33e1282cfab5e429b0243 (diff) | |
parent | 3588b38fff5216468485d75642f91d283208c5c8 (diff) | |
download | DotNetOpenAuth-5cb3aa5dda4d090400e6561c6ec64999ed5fca4c.zip DotNetOpenAuth-5cb3aa5dda4d090400e6561c6ec64999ed5fca4c.tar.gz DotNetOpenAuth-5cb3aa5dda4d090400e6561c6ec64999ed5fca4c.tar.bz2 |
Merge commit 'v3.0'
Diffstat (limited to 'samples/DotNetOpenAuth.ApplicationBlock/GoogleConsumer.cs')
-rw-r--r-- | samples/DotNetOpenAuth.ApplicationBlock/GoogleConsumer.cs | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/samples/DotNetOpenAuth.ApplicationBlock/GoogleConsumer.cs b/samples/DotNetOpenAuth.ApplicationBlock/GoogleConsumer.cs index c6f2b89..f0a4c03 100644 --- a/samples/DotNetOpenAuth.ApplicationBlock/GoogleConsumer.cs +++ b/samples/DotNetOpenAuth.ApplicationBlock/GoogleConsumer.cs @@ -11,6 +11,7 @@ namespace DotNetOpenAuth.ApplicationBlock { using System.IO; using System.Linq; using System.Net; + using System.Security.Cryptography.X509Certificates; using System.Text; using System.Text.RegularExpressions; using System.Xml; @@ -26,7 +27,7 @@ namespace DotNetOpenAuth.ApplicationBlock { /// <summary> /// The Consumer to use for accessing Google data APIs. /// </summary> - private static readonly ServiceProviderDescription GoogleDescription = new ServiceProviderDescription { + public static readonly ServiceProviderDescription ServiceDescription = new ServiceProviderDescription { RequestTokenEndpoint = new MessageReceivingEndpoint("https://www.google.com/accounts/OAuthGetRequestToken", HttpDeliveryMethods.AuthorizationHeaderRequest | HttpDeliveryMethods.GetRequest), UserAuthorizationEndpoint = new MessageReceivingEndpoint("https://www.google.com/accounts/OAuthAuthorizeToken", HttpDeliveryMethods.AuthorizationHeaderRequest | HttpDeliveryMethods.GetRequest), AccessTokenEndpoint = new MessageReceivingEndpoint("https://www.google.com/accounts/OAuthGetAccessToken", HttpDeliveryMethods.AuthorizationHeaderRequest | HttpDeliveryMethods.GetRequest), @@ -69,26 +70,21 @@ namespace DotNetOpenAuth.ApplicationBlock { } /// <summary> - /// Initializes a new instance of the <see cref="WebConsumer"/> class that is prepared to communicate with Google. + /// The service description to use for accessing Google data APIs using an X509 certificate. /// </summary> - /// <param name="tokenManager">The token manager.</param> - /// <param name="consumerKey">The consumer key.</param> - /// <returns>The newly instantiated <see cref="WebConsumer"/>.</returns> - public static WebConsumer CreateWebConsumer(ITokenManager tokenManager, string consumerKey) { - return new WebConsumer(GoogleDescription, tokenManager) { - ConsumerKey = consumerKey, - }; - } + /// <param name="signingCertificate">The signing certificate.</param> + /// <returns>A service description that can be used to create an instance of + /// <see cref="DesktopConsumer"/> or <see cref="WebConsumer"/>. </returns> + public static ServiceProviderDescription CreateRsaSha1ServiceDescription(X509Certificate2 signingCertificate) { + if (signingCertificate == null) { + throw new ArgumentNullException("signingCertificate"); + } - /// <summary> - /// Initializes a new instance of the <see cref="DesktopConsumer"/> class that is prepared to communicate with Google. - /// </summary> - /// <param name="tokenManager">The token manager.</param> - /// <param name="consumerKey">The consumer key.</param> - /// <returns>The newly instantiated <see cref="DesktopConsumer"/>.</returns> - public static DesktopConsumer CreateDesktopConsumer(ITokenManager tokenManager, string consumerKey) { - return new DesktopConsumer(GoogleDescription, tokenManager) { - ConsumerKey = consumerKey, + return new ServiceProviderDescription { + RequestTokenEndpoint = new MessageReceivingEndpoint("https://www.google.com/accounts/OAuthGetRequestToken", HttpDeliveryMethods.AuthorizationHeaderRequest | HttpDeliveryMethods.GetRequest), + UserAuthorizationEndpoint = new MessageReceivingEndpoint("https://www.google.com/accounts/OAuthAuthorizeToken", HttpDeliveryMethods.AuthorizationHeaderRequest | HttpDeliveryMethods.GetRequest), + AccessTokenEndpoint = new MessageReceivingEndpoint("https://www.google.com/accounts/OAuthGetAccessToken", HttpDeliveryMethods.AuthorizationHeaderRequest | HttpDeliveryMethods.GetRequest), + TamperProtectionElements = new ITamperProtectionChannelBindingElement[] { new RsaSha1SigningBindingElement(signingCertificate) }, }; } |