diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2012-03-01 22:55:03 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2012-03-01 23:19:26 -0800 |
commit | 198bffe042a3650095b27bed29d0f8c98bc5c926 (patch) | |
tree | bc1b2178b73d4303221ac48d320c758751abe5e9 /src/DotNetOpenAuth.AspNet/Clients/OAuth/OAuthClient.cs | |
parent | 6bc4c6db7529501e8a2c0b7fa54a24fb8e4dbf42 (diff) | |
download | DotNetOpenAuth-198bffe042a3650095b27bed29d0f8c98bc5c926.zip DotNetOpenAuth-198bffe042a3650095b27bed29d0f8c98bc5c926.tar.gz DotNetOpenAuth-198bffe042a3650095b27bed29d0f8c98bc5c926.tar.bz2 |
ReSharper code cleanup to help get this AspNet contribution into StyleCop compliance.
Diffstat (limited to 'src/DotNetOpenAuth.AspNet/Clients/OAuth/OAuthClient.cs')
-rw-r--r-- | src/DotNetOpenAuth.AspNet/Clients/OAuth/OAuthClient.cs | 121 |
1 files changed, 86 insertions, 35 deletions
diff --git a/src/DotNetOpenAuth.AspNet/Clients/OAuth/OAuthClient.cs b/src/DotNetOpenAuth.AspNet/Clients/OAuth/OAuthClient.cs index 5908225..56e046e 100644 --- a/src/DotNetOpenAuth.AspNet/Clients/OAuth/OAuthClient.cs +++ b/src/DotNetOpenAuth.AspNet/Clients/OAuth/OAuthClient.cs @@ -16,25 +16,56 @@ namespace DotNetOpenAuth.AspNet.Clients { /// Represents base class for OAuth 1.0 clients /// </summary> public abstract class OAuthClient : IAuthenticationClient { + #region Constructors and Destructors + /// <summary> /// Initializes a new instance of the <see cref="OAuthClient"/> class. /// </summary> - /// <param name="providerName">Name of the provider.</param> - /// <param name="serviceDescription">The service description.</param> - /// <param name="consumerKey">The consumer key.</param> - /// <param name="consumerSecret">The consumer secret.</param> - protected OAuthClient(string providerName, ServiceProviderDescription serviceDescription, string consumerKey, string consumerSecret) : - this(providerName, serviceDescription, new InMemoryOAuthTokenManager(consumerKey, consumerSecret)) { - } + /// <param name="providerName"> + /// Name of the provider. + /// </param> + /// <param name="serviceDescription"> + /// The service description. + /// </param> + /// <param name="consumerKey"> + /// The consumer key. + /// </param> + /// <param name="consumerSecret"> + /// The consumer secret. + /// </param> + protected OAuthClient( + string providerName, ServiceProviderDescription serviceDescription, string consumerKey, string consumerSecret) + : this(providerName, serviceDescription, new InMemoryOAuthTokenManager(consumerKey, consumerSecret)) {} /// <summary> /// Initializes a new instance of the <see cref="OAuthClient"/> class. /// </summary> - /// <param name="providerName">Name of the provider.</param> - protected OAuthClient(string providerName, ServiceProviderDescription serviceDescription, IConsumerTokenManager tokenManager) : - this(providerName, new DotNetOpenAuthWebConsumer(serviceDescription, tokenManager)) { - } + /// <param name="providerName"> + /// Name of the provider. + /// </param> + /// <param name="serviceDescription"> + /// The service Description. + /// </param> + /// <param name="tokenManager"> + /// The token Manager. + /// </param> + protected OAuthClient( + string providerName, ServiceProviderDescription serviceDescription, IConsumerTokenManager tokenManager) + : this(providerName, new DotNetOpenAuthWebConsumer(serviceDescription, tokenManager)) {} + /// <summary> + /// Initializes a new instance of the <see cref="OAuthClient"/> class. + /// </summary> + /// <param name="providerName"> + /// The provider name. + /// </param> + /// <param name="webWorker"> + /// The web worker. + /// </param> + /// <exception cref="ArgumentNullException"> + /// </exception> + /// <exception cref="ArgumentNullException"> + /// </exception> protected OAuthClient(string providerName, IOAuthWebWorker webWorker) { if (providerName == null) { throw new ArgumentNullException("providerName"); @@ -44,32 +75,41 @@ namespace DotNetOpenAuth.AspNet.Clients { throw new ArgumentNullException("webWorker"); } - ProviderName = providerName; - WebWorker = webWorker; + this.ProviderName = providerName; + this.WebWorker = webWorker; } + #endregion + + #region Public Properties + /// <summary> /// Gets the name of the provider which provides authentication service. /// </summary> - public string ProviderName { - get; - private set; - } + public string ProviderName { get; private set; } + + #endregion + + #region Properties /// <summary> - /// Gets the <see cref="OAuthWebConsumer"/> instance which handles constructing requests - /// to the OAuth providers. + /// Gets the <see cref="OAuthWebConsumer" /> instance which handles constructing requests to the OAuth providers. /// </summary> - protected IOAuthWebWorker WebWorker { - get; - private set; - } + protected IOAuthWebWorker WebWorker { get; private set; } + + #endregion + + #region Public Methods and Operators /// <summary> - /// Attempts to authenticate users by forwarding them to an external website, and - /// upon succcess or failure, redirect users back to the specified url. + /// Attempts to authenticate users by forwarding them to an external website, and upon succcess or failure, redirect users back to the specified url. /// </summary> - /// <param name="returnUrl">The return url after users have completed authenticating against external website.</param> + /// <param name="context"> + /// The context. + /// </param> + /// <param name="returnUrl"> + /// The return url after users have completed authenticating against external website. + /// </param> public virtual void RequestAuthentication(HttpContextBase context, Uri returnUrl) { if (returnUrl == null) { throw new ArgumentNullException("returnUrl"); @@ -80,36 +120,47 @@ namespace DotNetOpenAuth.AspNet.Clients { } Uri callback = returnUrl.StripQueryArgumentsWithPrefix("oauth_"); - WebWorker.RequestAuthentication(callback); + this.WebWorker.RequestAuthentication(callback); } /// <summary> /// Check if authentication succeeded after user is redirected back from the service provider. /// </summary> + /// <param name="context"> + /// The context. + /// </param> /// <returns> - /// An instance of <see cref="AuthenticationResult"/> containing authentication result. + /// An instance of <see cref="AuthenticationResult"/> containing authentication result. /// </returns> public virtual AuthenticationResult VerifyAuthentication(HttpContextBase context) { - AuthorizedTokenResponse response = WebWorker.ProcessUserAuthorization(); + AuthorizedTokenResponse response = this.WebWorker.ProcessUserAuthorization(); if (response == null) { return AuthenticationResult.Failed; } // add the access token to the user data dictionary just in case page developers want to use it - AuthenticationResult result = VerifyAuthenticationCore(response); - if (result.IsSuccessful && result.ExtraData != null) - { + AuthenticationResult result = this.VerifyAuthenticationCore(response); + if (result.IsSuccessful && result.ExtraData != null) { result.ExtraData["accesstoken"] = response.AccessToken; } return result; } + #endregion + + #region Methods + /// <summary> /// Check if authentication succeeded after user is redirected back from the service provider. /// </summary> - /// <param name="response">The response token returned from service provider</param> - /// <returns>Authentication result</returns> + /// <param name="response"> + /// The response token returned from service provider + /// </param> + /// <returns> + /// Authentication result + /// </returns> protected abstract AuthenticationResult VerifyAuthenticationCore(AuthorizedTokenResponse response); + #endregion } -}
\ No newline at end of file +} |