Skip to content
This repository has been archived by the owner on Mar 20, 2019. It is now read-only.

Commit

Permalink
More warning fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
AArnott committed Feb 11, 2013
1 parent 938a79f commit 04426df
Show file tree
Hide file tree
Showing 45 changed files with 221 additions and 66 deletions.
Expand Up @@ -210,6 +210,9 @@ public AuthController()
/// <summary>
/// Preloads discovery results for the OP buttons we display on the selector in the ViewData.
/// </summary>
/// <returns>
/// A task that completes with the asynchronous operation.
/// </returns>
private async Task PreloadDiscoveryResultsAsync() {
this.ViewData["PreloadedDiscoveryResults"] = this.RelyingParty.PreloadDiscoveryResultsAsync(
Realm.AutoDetect,
Expand Down
6 changes: 5 additions & 1 deletion samples/DotNetOpenAuth.ApplicationBlock/GoogleConsumer.cs
Expand Up @@ -177,9 +177,13 @@ public enum Applications : long
/// <summary>
/// Requests authorization from Google to access data from a set of Google applications.
/// </summary>
/// <param name="consumer">The Google consumer previously constructed using <see cref="CreateWebConsumer"/> or <see cref="CreateDesktopConsumer"/>.</param>
/// <param name="consumer">The Google consumer previously constructed using <see cref="CreateWebConsumer" /> or <see cref="CreateDesktopConsumer" />.</param>
/// <param name="requestedAccessScope">The requested access scope.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// A task that completes with the asynchronous operation.
/// </returns>
/// <exception cref="System.ArgumentNullException">consumer</exception>
public static async Task RequestAuthorizationAsync(WebConsumer consumer, Applications requestedAccessScope, CancellationToken cancellationToken = default(CancellationToken)) {
if (consumer == null) {
throw new ArgumentNullException("consumer");
Expand Down
3 changes: 3 additions & 0 deletions samples/OpenIdOfflineProvider/CheckIdWindow.xaml.cs
Expand Up @@ -55,6 +55,9 @@ public partial class CheckIdWindow : Window {
/// </summary>
/// <param name="provider">The OpenID Provider host.</param>
/// <param name="request">The incoming authentication request.</param>
/// <returns>
/// A task that completes with the asynchronous operation.
/// </returns>
internal static async Task ProcessAuthenticationAsync(HostedProvider provider, IAuthenticationRequest request) {
Requires.NotNull(provider, "provider");
Requires.NotNull(request, "request");
Expand Down
3 changes: 3 additions & 0 deletions samples/OpenIdOfflineProvider/HostedProvider.cs
Expand Up @@ -210,6 +210,9 @@ internal class HostedProvider : IDisposable {
/// Handles incoming HTTP requests.
/// </summary>
/// <param name="context">The HttpListener context.</param>
/// <returns>
/// A task that completes with the asynchronous operation.
/// </returns>
private async Task RequestHandlerAsync(HttpListenerContext context) {
Requires.NotNull(context, "context");
Requires.NotNull(context.Response.OutputStream, "context.Response.OutputStream");
Expand Down
4 changes: 4 additions & 0 deletions samples/OpenIdOfflineProvider/HttpHost.cs
Expand Up @@ -65,6 +65,7 @@ internal class HttpHost : IDisposable {
/// The request handler delegate.
/// </summary>
/// <param name="context">Information on the incoming HTTP request.</param>
/// <returns>A task that completes with the async operation.</returns>
internal delegate Task RequestHandlerAsync(HttpListenerContext context);

/// <summary>
Expand Down Expand Up @@ -117,6 +118,9 @@ internal class HttpHost : IDisposable {
/// <summary>
/// The HTTP listener thread body.
/// </summary>
/// <returns>
/// A task that completes with the asynchronous operation.
/// </returns>
private async Task ProcessRequestsAsync() {
Assumes.True(this.listener != null);

Expand Down
3 changes: 3 additions & 0 deletions samples/OpenIdOfflineProvider/MainWindow.xaml.cs
Expand Up @@ -128,6 +128,9 @@ public partial class MainWindow : Window, IDisposable {
/// </summary>
/// <param name="requestInfo">The request info.</param>
/// <param name="response">The response.</param>
/// <returns>
/// A task that completes with the asynchronous operation.
/// </returns>
private async Task ProcessRequestAsync(HttpRequestBase requestInfo, HttpListenerResponse response) {
IRequest request = await this.hostedProvider.Provider.GetRequestAsync(requestInfo, CancellationToken.None);
if (request == null) {
Expand Down
Expand Up @@ -68,17 +68,22 @@ public class DotNetOpenAuthWebConsumer : IOAuthWebWorker, IDisposable {
/// <summary>
/// The process user authorization.
/// </summary>
/// <returns>The response message.</returns>
/// <param name="cancellationToken"></param>
/// <returns>
/// The response message.
/// </returns>
public Task<AuthorizedTokenResponse> ProcessUserAuthorizationAsync(CancellationToken cancellationToken = default(CancellationToken)) {
return this.webConsumer.ProcessUserAuthorizationAsync(cancellationToken: cancellationToken);
}

/// <summary>
/// The request authentication.
/// </summary>
/// <param name="callback">
/// The callback.
/// </param>
/// <param name="callback">The callback.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <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(
Expand Down
6 changes: 5 additions & 1 deletion src/DotNetOpenAuth.AspNet/Clients/OAuth/IOAuthWebWorker.cs
Expand Up @@ -33,14 +33,18 @@ public interface IOAuthWebWorker {
/// <summary>
/// The process user authorization.
/// </summary>
/// <returns>The response message.</returns>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// The response message.
/// </returns>
Task<AuthorizedTokenResponse> ProcessUserAuthorizationAsync(CancellationToken cancellationToken = default(CancellationToken));

/// <summary>
/// The request authentication.
/// </summary>
/// <param name="callback">The callback.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The response message</returns>
Task<HttpResponseMessage> RequestAuthenticationAsync(Uri callback, CancellationToken cancellationToken = default(CancellationToken));

#endregion
Expand Down
Expand Up @@ -92,9 +92,9 @@ public sealed class InMemoryOAuthTokenManager : IConsumerTokenManager {
/// useful in an ASP.NET web application within the implementation of this method.
/// Alternatively you may store the access token here without associating with a user account,
/// and wait until
/// <see cref="WebConsumer.ProcessUserAuthorization()"/>
/// <see cref="WebConsumer.ProcessUserAuthorizationAsync()"/>
/// or
/// <see cref="DesktopConsumer.ProcessUserAuthorization(string, string)"/>
/// <see cref="DesktopConsumer.ProcessUserAuthorizationAsync(string, string)"/>
/// return the access
/// token to associate the access token with a user account at that point.
/// </para>
Expand Down
7 changes: 3 additions & 4 deletions src/DotNetOpenAuth.AspNet/Clients/OAuth/LinkedInClient.cs
Expand Up @@ -82,11 +82,10 @@ public LinkedInClient(string consumerKey, string consumerSecret, IOAuthTokenMana
/// <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>
/// <param name="response">The response token returned from service provider</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// Authentication result.
/// Authentication result.
/// </returns>
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
Justification = "We don't care if the request fails.")]
Expand Down
3 changes: 3 additions & 0 deletions src/DotNetOpenAuth.AspNet/Clients/OAuth/OAuthClient.cs
Expand Up @@ -108,6 +108,9 @@ public abstract class OAuthClient : IAuthenticationClient {
/// <param name="context">The context.</param>
/// <param name="returnUrl">The return url after users have completed authenticating against external website.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// A task that completes with the asynchronous operation.
/// </returns>
public virtual Task RequestAuthenticationAsync(HttpContextBase context, Uri returnUrl, CancellationToken cancellationToken = default(CancellationToken)) {
Requires.NotNull(returnUrl, "returnUrl");
Requires.NotNull(context, "context");
Expand Down
5 changes: 4 additions & 1 deletion src/DotNetOpenAuth.AspNet/Clients/OAuth2/OAuth2Client.cs
Expand Up @@ -62,6 +62,9 @@ public abstract class OAuth2Client : IAuthenticationClient {
/// <param name="context">The context.</param>
/// <param name="returnUrl">The return url after users have completed authenticating against external website.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// A task that completes with the asynchronous operation.
/// </returns>
public virtual async Task RequestAuthenticationAsync(HttpContextBase context, Uri returnUrl, CancellationToken cancellationToken = default(CancellationToken)) {
Requires.NotNull(context, "context");
Requires.NotNull(returnUrl, "returnUrl");
Expand Down Expand Up @@ -90,7 +93,7 @@ public abstract class OAuth2Client : IAuthenticationClient {
/// <param name="returnPageUrl">The return URL which should match the value passed to RequestAuthentication() method.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// An instance of <see cref="AuthenticationResult"/> containing authentication result.
/// An instance of <see cref="AuthenticationResult" /> containing authentication result.
/// </returns>
public virtual async Task<AuthenticationResult> VerifyAuthenticationAsync(HttpContextBase context, Uri returnPageUrl, CancellationToken cancellationToken = default(CancellationToken)) {
Requires.NotNull(context, "context");
Expand Down
11 changes: 5 additions & 6 deletions src/DotNetOpenAuth.AspNet/Clients/OpenID/OpenIDClient.cs
Expand Up @@ -81,13 +81,12 @@ public class OpenIdClient : IAuthenticationClient {
/// <summary>
/// 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="context">
/// The context of the current request.
/// </param>
/// <param name="returnUrl">
/// The return url after users have completed authenticating against external website.
/// </param>
/// <param name="context">The context of the current request.</param>
/// <param name="returnUrl">The return url after users have completed authenticating against external website.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// A task that completes with the asynchronous operation.
/// </returns>
[SuppressMessage("Microsoft.Usage", "CA2234:PassSystemUriObjectsInsteadOfStrings",
Justification = "We don't have a Uri object handy.")]
public virtual async Task RequestAuthenticationAsync(HttpContextBase context, Uri returnUrl, CancellationToken cancellationToken = default(CancellationToken)) {
Expand Down
15 changes: 9 additions & 6 deletions src/DotNetOpenAuth.AspNet/OpenAuthSecurityManager.cs
Expand Up @@ -143,9 +143,11 @@ public class OpenAuthSecurityManager {
/// <summary>
/// Requests the specified provider to start the authentication by directing users to an external website
/// </summary>
/// <param name="returnUrl">
/// The return url after user is authenticated.
/// </param>
/// <param name="returnUrl">The return url after user is authenticated.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// A task that completes with the asynchronous operation.
/// </returns>
public async Task RequestAuthenticationAsync(string returnUrl, CancellationToken cancellationToken = default(CancellationToken)) {
// convert returnUrl to an absolute path
Uri uri;
Expand Down Expand Up @@ -185,12 +187,13 @@ public class OpenAuthSecurityManager {
/// Checks if user is successfully authenticated when user is redirected back to this user.
/// </summary>
/// <param name="returnUrl">The return Url which must match exactly the Url passed into RequestAuthentication() earlier.</param>
/// <remarks>
/// This returnUrl parameter only applies to OAuth2 providers. For other providers, it ignores the returnUrl parameter.
/// </remarks>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// The result of the authentication.
/// </returns>
/// <remarks>
/// This returnUrl parameter only applies to OAuth2 providers. For other providers, it ignores the returnUrl parameter.
/// </remarks>
public async Task<AuthenticationResult> VerifyAuthenticationAsync(string returnUrl, CancellationToken cancellationToken = default(CancellationToken)) {
// check for XSRF attack
string sessionId;
Expand Down
32 changes: 21 additions & 11 deletions src/DotNetOpenAuth.Core/Messaging/Channel.cs
Expand Up @@ -387,7 +387,10 @@ public async Task<TRequest> ReadFromRequestAsync<TRequest>(CancellationToken can
/// Gets the protocol message that may be embedded in the given HTTP request.
/// </summary>
/// <param name="httpRequest">The request to search for an embedded message.</param>
/// <returns>The deserialized message, if one is found. Null otherwise.</returns>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// The deserialized message, if one is found. Null otherwise.
/// </returns>
public async Task<IDirectedProtocolMessage> ReadFromRequestAsync(HttpRequestBase httpRequest, CancellationToken cancellationToken) {
Requires.NotNull(httpRequest, "httpRequest");

Expand Down Expand Up @@ -476,10 +479,11 @@ public async Task<TResponse> RequestAsync<TResponse>(IDirectedProtocolMessage re
/// </summary>
/// <param name="message">The message just received.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <exception cref="ProtocolException">
/// Thrown when the message is somehow invalid.
/// This can be due to tampering, replay attack or expiration, among other things.
/// </exception>
/// <returns>
/// A task that completes with the asynchronous operation.
/// </returns>
/// <exception cref="ProtocolException">Thrown when the message is somehow invalid.
/// This can be due to tampering, replay attack or expiration, among other things.</exception>
internal Task ProcessIncomingMessageTestHookAsync(IProtocolMessage message, CancellationToken cancellationToken) {
return this.ProcessIncomingMessageAsync(message, cancellationToken);
}
Expand Down Expand Up @@ -525,7 +529,9 @@ public async Task<TResponse> RequestAsync<TResponse>(IDirectedProtocolMessage re
/// </summary>
/// <param name="message">The message to prepare for sending.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <returns>
/// A task that completes with the asynchronous operation.
/// </returns>
/// <remarks>
/// This method should NOT be called by derived types
/// except when sending ONE WAY request messages.
Expand Down Expand Up @@ -962,7 +968,9 @@ public async Task<TResponse> RequestAsync<TResponse>(IDirectedProtocolMessage re
/// </summary>
/// <param name="message">The message to prepare for sending.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <returns>
/// A task that completes with the asynchronous operation.
/// </returns>
/// <exception cref="UnprotectedMessageException"></exception>
/// <remarks>
/// This method should NOT be called by derived types
Expand Down Expand Up @@ -1134,10 +1142,12 @@ public async Task<TResponse> RequestAsync<TResponse>(IDirectedProtocolMessage re
/// </summary>
/// <param name="message">The message just received.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <exception cref="ProtocolException">
/// Thrown when the message is somehow invalid.
/// This can be due to tampering, replay attack or expiration, among other things.
/// </exception>
/// <returns>
/// A task that completes with the asynchronous operation.
/// </returns>
/// <exception cref="UnprotectedMessageException"></exception>
/// <exception cref="ProtocolException">Thrown when the message is somehow invalid.
/// This can be due to tampering, replay attack or expiration, among other things.</exception>
protected virtual async Task ProcessIncomingMessageAsync(IProtocolMessage message, CancellationToken cancellationToken) {
Requires.NotNull(message, "message");

Expand Down
1 change: 1 addition & 0 deletions src/DotNetOpenAuth.Core/Reporting.cs
Expand Up @@ -370,6 +370,7 @@ public class Reporting {
/// <summary>
/// Creates an HTTP client that can be used for outbound HTTP requests.
/// </summary>
/// <returns>The HTTP client to use.</returns>
private static HttpClient CreateHttpClient() {
var channel = new HttpClientHandler();
channel.AllowAutoRedirect = false;
Expand Down
2 changes: 1 addition & 1 deletion src/DotNetOpenAuth.Core/Util.cs
Expand Up @@ -235,7 +235,7 @@ internal static class Util {
/// <typeparam name="TResult">The type of the result.</typeparam>
/// <param name="source">The source.</param>
/// <param name="transform">The transform.</param>
/// <returns></returns>
/// <returns>A dictionary populated with the results of the transforms.</returns>
internal static async Task<Dictionary<TSource, TResult>> ToDictionaryAsync<TSource, TResult>(
this IEnumerable<TSource> source, Func<TSource, Task<TResult>> transform) {
var taskResults = source.ToDictionary(s => s, transform);
Expand Down
@@ -1,4 +1,10 @@
namespace DotNetOpenAuth.OAuth {
//-----------------------------------------------------------------------
// <copyright file="OAuth1HttpMessageHandler.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace DotNetOpenAuth.OAuth {
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -11,6 +17,9 @@

using Validation;

/// <summary>
/// A delegated HTTP handler that automatically signs outgoing requests.
/// </summary>
public class OAuth1HttpMessageHandler : DelegatingHandler {
/// <summary>
/// Initializes a new instance of the <see cref="OAuth1HttpMessageHandler" /> class.
Expand All @@ -34,10 +43,30 @@ public OAuth1HttpMessageHandler(HttpMessageHandler innerHandler, ConsumerBase co
this.AccessToken = accessToken;
}

/// <summary>
/// Gets or sets the access token.
/// </summary>
/// <value>
/// The access token.
/// </value>
public string AccessToken { get; set; }

/// <summary>
/// Gets or sets the consumer.
/// </summary>
/// <value>
/// The consumer.
/// </value>
public ConsumerBase Consumer { get; set; }

/// <summary>
/// Sends an HTTP request to the inner handler to send to the server as an asynchronous operation.
/// </summary>
/// <param name="request">The HTTP request message to send to the server.</param>
/// <param name="cancellationToken">A cancellation token to cancel operation.</param>
/// <returns>
/// Returns <see cref="T:System.Threading.Tasks.Task`1" />. The task object representing the asynchronous operation.
/// </returns>
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) {
Verify.Operation(this.Consumer != null, Strings.RequiredPropertyNotYetPreset, "Consumer");
Verify.Operation(!string.IsNullOrEmpty(this.AccessToken), Strings.RequiredPropertyNotYetPreset, "AccessToken");
Expand Down
Expand Up @@ -151,6 +151,8 @@ public ServiceProvider(ServiceProviderDescription serviceDescription, IServicePr
/// Gets the standard state storage mechanism that uses ASP.NET's
/// HttpApplication state dictionary to store associations and nonces.
/// </summary>
/// <param name="context">The HTTP context. If <c>null</c>, this method must be called while <see cref="HttpContext.Current"/> is non-null.</param>
/// <returns>The nonce store.</returns>
public static INonceStore GetHttpApplicationStore(HttpContextBase context = null) {
if (context == null) {
ErrorUtilities.VerifyOperation(HttpContext.Current != null, Strings.StoreRequiredWhenNoHttpContextAvailable, typeof(INonceStore).Name);
Expand Down Expand Up @@ -203,7 +205,11 @@ public ServiceProvider(ServiceProviderDescription serviceDescription, IServicePr
/// <summary>
/// Reads any incoming OAuth message.
/// </summary>
/// <returns>The deserialized message.</returns>
/// <param name="request">The request.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// The deserialized message.
/// </returns>
/// <remarks>
/// Requires HttpContext.Current.
/// </remarks>
Expand Down

0 comments on commit 04426df

Please sign in to comment.