diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2013-03-02 08:59:34 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2013-03-02 08:59:34 -0800 |
commit | 1a1a37ebb26034d2f5470c3be2da18cefe5293da (patch) | |
tree | aeb0e2e6a5d7588a449a80881e477bc9b681ce7b /src/DotNetOpenAuth.AspNet/Clients/OAuth/DotNetOpenAuthWebConsumer.cs | |
parent | ffecd2bd3cd8e0f21d4156770afe5d84626ca6bc (diff) | |
download | DotNetOpenAuth-1a1a37ebb26034d2f5470c3be2da18cefe5293da.zip DotNetOpenAuth-1a1a37ebb26034d2f5470c3be2da18cefe5293da.tar.gz DotNetOpenAuth-1a1a37ebb26034d2f5470c3be2da18cefe5293da.tar.bz2 |
Fixes build breaks in DNOA.AspNet
Diffstat (limited to 'src/DotNetOpenAuth.AspNet/Clients/OAuth/DotNetOpenAuthWebConsumer.cs')
-rw-r--r-- | src/DotNetOpenAuth.AspNet/Clients/OAuth/DotNetOpenAuthWebConsumer.cs | 60 |
1 files changed, 21 insertions, 39 deletions
diff --git a/src/DotNetOpenAuth.AspNet/Clients/OAuth/DotNetOpenAuthWebConsumer.cs b/src/DotNetOpenAuth.AspNet/Clients/OAuth/DotNetOpenAuthWebConsumer.cs index cc35b76..1b6318f 100644 --- a/src/DotNetOpenAuth.AspNet/Clients/OAuth/DotNetOpenAuthWebConsumer.cs +++ b/src/DotNetOpenAuth.AspNet/Clients/OAuth/DotNetOpenAuthWebConsumer.cs @@ -11,6 +11,7 @@ namespace DotNetOpenAuth.AspNet.Clients { using System.Net.Http; using System.Threading; using System.Threading.Tasks; + using System.Web; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OAuth; using DotNetOpenAuth.OAuth.ChannelElements; @@ -20,13 +21,13 @@ namespace DotNetOpenAuth.AspNet.Clients { /// <summary> /// The dot net open auth web consumer. /// </summary> - public class DotNetOpenAuthWebConsumer : IOAuthWebWorker, IDisposable { + public class DotNetOpenAuthWebConsumer : IOAuthWebWorker { #region Constants and Fields /// <summary> /// The _web consumer. /// </summary> - private readonly WebConsumer webConsumer; + private readonly Consumer webConsumer; #endregion @@ -41,11 +42,15 @@ namespace DotNetOpenAuth.AspNet.Clients { /// <param name="tokenManager"> /// The token manager. /// </param> - public DotNetOpenAuthWebConsumer(ServiceProviderDescription serviceDescription, IConsumerTokenManager tokenManager) { + public DotNetOpenAuthWebConsumer(ServiceProviderDescription serviceDescription, string consumerKey, string consumerSecret) { Requires.NotNull(serviceDescription, "serviceDescription"); - Requires.NotNull(tokenManager, "tokenManager"); - this.webConsumer = new WebConsumer(serviceDescription, tokenManager); + this.webConsumer = new Consumer { + ServiceProvider = serviceDescription, + ConsumerKey = consumerKey, + ConsumerSecret = consumerSecret, + TemporaryCredentialStorage = new CookieTemporaryCredentialStorage(), + }; } #endregion @@ -53,7 +58,7 @@ namespace DotNetOpenAuth.AspNet.Clients { /// <summary> /// Gets the DotNetOpenAuth <see cref="WebConsumer"/> instance that can be used to make OAuth 1.0 authorized HTTP requests. /// </summary> - public WebConsumer Consumer { + public Consumer Consumer { get { return this.webConsumer; } } @@ -63,8 +68,8 @@ namespace DotNetOpenAuth.AspNet.Clients { /// Creates an HTTP message handler that authorizes outgoing web requests. /// </summary> /// <param name="accessToken">The access token.</param> - public HttpMessageHandler CreateMessageHandler(string accessToken) { - Requires.NotNullOrEmpty(accessToken, "accessToken"); + public HttpMessageHandler CreateMessageHandler(AccessToken accessToken) { + Requires.NotNullOrEmpty(accessToken.Token, "accessToken"); return this.Consumer.CreateMessageHandler(accessToken); } @@ -76,8 +81,12 @@ namespace DotNetOpenAuth.AspNet.Clients { /// <returns> /// The response message. /// </returns> - public Task<AuthorizedTokenResponse> ProcessUserAuthorizationAsync(CancellationToken cancellationToken = default(CancellationToken)) { - return this.webConsumer.ProcessUserAuthorizationAsync(cancellationToken: cancellationToken); + public Task<AccessTokenResponse> ProcessUserAuthorizationAsync(HttpContextBase context = null, CancellationToken cancellationToken = default(CancellationToken)) { + if (context == null) { + context = new HttpContextWrapper(HttpContext.Current); + } + + return this.webConsumer.ProcessUserAuthorizationAsync(context.Request.Url, cancellationToken: cancellationToken); } /// <summary> @@ -88,37 +97,10 @@ namespace DotNetOpenAuth.AspNet.Clients { /// <returns> /// The response message. /// </returns> - public async Task<HttpResponseMessage> RequestAuthenticationAsync(Uri callback, CancellationToken cancellationToken = default(CancellationToken)) { - var redirectParameters = new Dictionary<string, string>(); - UserAuthorizationRequest request = await this.webConsumer.PrepareRequestUserAuthorizationAsync( - callback, null, redirectParameters, cancellationToken); - var response = await this.webConsumer.Channel.PrepareResponseAsync(request, cancellationToken); - return response; - } - - #endregion - - #region IDisposable members - - /// <summary> - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// </summary> - /// <filterpriority>2</filterpriority> - public void Dispose() { - this.Dispose(true); - GC.SuppressFinalize(this); + public Task<Uri> RequestAuthenticationAsync(Uri callback, CancellationToken cancellationToken = default(CancellationToken)) { + return this.webConsumer.RequestUserAuthorizationAsync(callback, cancellationToken: cancellationToken); } #endregion - - /// <summary> - /// Releases unmanaged and - optionally - managed resources - /// </summary> - /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> - protected virtual void Dispose(bool disposing) { - if (disposing) { - this.webConsumer.Dispose(); - } - } } } |