diff options
Diffstat (limited to 'src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty')
4 files changed, 70 insertions, 46 deletions
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/AssociationManager.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/AssociationManager.cs index 14566e1..367c146 100644 --- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/AssociationManager.cs +++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/AssociationManager.cs @@ -132,6 +132,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// a new association of one does not already exist. /// </summary> /// <param name="provider">The provider to get an association for.</param> + /// <param name="cancellationToken">The cancellation token.</param> /// <returns>The existing or new association; <c>null</c> if none existed and one could not be created.</returns> internal async Task<Association> GetOrCreateAssociationAsync(IProviderEndpoint provider, CancellationToken cancellationToken) { return this.GetExistingAssociation(provider) ?? await this.CreateNewAssociationAsync(provider, cancellationToken); @@ -141,6 +142,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// Creates a new association with a given Provider. /// </summary> /// <param name="provider">The provider to create an association with.</param> + /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// The newly created association, or null if no association can be created with /// the given Provider given the current security settings. @@ -148,7 +150,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// <remarks> /// A new association is created and returned even if one already exists in the /// association store. - /// Any new association is automatically added to the <see cref="associationStore"/>. + /// Any new association is automatically added to the <see cref="associationStore" />. /// </remarks> private async Task<Association> CreateNewAssociationAsync(IProviderEndpoint provider, CancellationToken cancellationToken) { Requires.NotNull(provider, "provider"); @@ -180,10 +182,12 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// <param name="provider">The provider to create an association with.</param> /// <param name="associateRequest">The associate request. May be <c>null</c>, which will always result in a <c>null</c> return value..</param> /// <param name="retriesRemaining">The number of times to try the associate request again if the Provider suggests it.</param> + /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// The newly created association, or null if no association can be created with /// the given Provider given the current security settings. /// </returns> + /// <exception cref="ProtocolException"></exception> private async Task<Association> CreateNewAssociationAsync(IProviderEndpoint provider, AssociateRequest associateRequest, int retriesRemaining, CancellationToken cancellationToken) { Requires.NotNull(provider, "provider"); diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/AuthenticationRequest.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/AuthenticationRequest.cs index 0fb5b4a..a26b49e 100644 --- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/AuthenticationRequest.cs +++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/AuthenticationRequest.cs @@ -93,20 +93,6 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { public AuthenticationRequestMode Mode { get; set; } /// <summary> - /// Gets the HTTP response the relying party should send to the user agent - /// to redirect it to the OpenID Provider to start the OpenID authentication process. - /// </summary> - /// <value></value> - public async Task<HttpResponseMessage> GetRedirectingResponseAsync(CancellationToken cancellationToken) { - foreach (var behavior in this.RelyingParty.Behaviors) { - behavior.OnOutgoingAuthenticationRequest(this); - } - - var request = await this.CreateRequestMessageAsync(cancellationToken); - return await this.RelyingParty.Channel.PrepareResponseAsync(request, cancellationToken); - } - - /// <summary> /// Gets the URL that the user agent will return to after authentication /// completes or fails at the Provider. /// </summary> @@ -199,6 +185,20 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { #region IAuthenticationRequest methods /// <summary> + /// Gets the HTTP response the relying party should send to the user agent + /// to redirect it to the OpenID Provider to start the OpenID authentication process. + /// </summary> + /// <param name="cancellationToken">The cancellation token.</param> + public async Task<HttpResponseMessage> GetRedirectingResponseAsync(CancellationToken cancellationToken) { + foreach (var behavior in this.RelyingParty.Behaviors) { + behavior.OnOutgoingAuthenticationRequest(this); + } + + var request = await this.CreateRequestMessageAsync(cancellationToken); + return await this.RelyingParty.Channel.PrepareResponseAsync(request, cancellationToken); + } + + /// <summary> /// Makes a dictionary of key/value pairs available when the authentication is completed. /// </summary> /// <param name="arguments">The arguments to add to the request's return_to URI.</param> @@ -305,6 +305,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// <param name="realm">The realm.</param> /// <param name="returnToUrl">The return_to base URL.</param> /// <param name="createNewAssociationsAsNeeded">if set to <c>true</c>, associations that do not exist between this Relying Party and the asserting Providers are created before the authentication request is created.</param> + /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// A sequence of authentication requests, any of which constitutes a valid identity assertion on the Claimed Identifier. /// Never null, but may be empty. @@ -391,13 +392,16 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// Creates the request message to send to the Provider, /// based on the properties in this instance. /// </summary> - /// <returns>The message to send to the Provider.</returns> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns> + /// The message to send to the Provider. + /// </returns> internal Task<SignedResponseRequest> CreateRequestMessageTestHookAsync(CancellationToken cancellationToken) { return this.CreateRequestMessageAsync(cancellationToken); } /// <summary> - /// Performs deferred request generation for the <see cref="Create"/> method. + /// Performs deferred request generation for the <see cref="Create" /> method. /// </summary> /// <param name="userSuppliedIdentifier">The user supplied identifier.</param> /// <param name="relyingParty">The relying party.</param> @@ -405,6 +409,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// <param name="returnToUrl">The return_to base URL.</param> /// <param name="serviceEndpoints">The discovered service endpoints on the Claimed Identifier.</param> /// <param name="createNewAssociationsAsNeeded">if set to <c>true</c>, associations that do not exist between this Relying Party and the asserting Providers are created before the authentication request is created.</param> + /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// A sequence of authentication requests, any of which constitutes a valid identity assertion on the Claimed Identifier. /// Never null, but may be empty. diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/Extensions/UIUtilities.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/Extensions/UIUtilities.cs index 80bfe65..4e138ee 100644 --- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/Extensions/UIUtilities.cs +++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/Extensions/UIUtilities.cs @@ -24,7 +24,10 @@ using Validation; /// <param name="relyingParty">The relying party.</param> /// <param name="request">The authentication request to place in the window.</param> /// <param name="windowName">The name to assign to the popup window.</param> - /// <returns>A string starting with 'window.open' and forming just that one method call.</returns> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns> + /// A string starting with 'window.open' and forming just that one method call. + /// </returns> internal static async Task<string> GetWindowPopupScriptAsync(OpenIdRelyingParty relyingParty, IAuthenticationRequest request, string windowName, CancellationToken cancellationToken) { Requires.NotNull(relyingParty, "relyingParty"); Requires.NotNull(request, "request"); diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/OpenIdRelyingParty.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/OpenIdRelyingParty.cs index a129334..b190ce3 100644 --- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/OpenIdRelyingParty.cs +++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/OpenIdRelyingParty.cs @@ -157,31 +157,6 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { } /// <summary> - /// Gets the standard state storage mechanism that uses ASP.NET's - /// HttpApplication state dictionary to store associations and nonces. - /// </summary> - public static IOpenIdApplicationStore GetHttpApplicationStore(HttpContextBase context = null) { - if (context == null) { - ErrorUtilities.VerifyOperation(HttpContext.Current != null, Strings.StoreRequiredWhenNoHttpContextAvailable, typeof(IOpenIdApplicationStore).Name); - context = new HttpContextWrapper(HttpContext.Current); - } - - var store = (IOpenIdApplicationStore)context.Application[ApplicationStoreKey]; - if (store == null) { - context.Application.Lock(); - try { - if ((store = (IOpenIdApplicationStore)context.Application[ApplicationStoreKey]) == null) { - context.Application[ApplicationStoreKey] = store = new StandardRelyingPartyApplicationStore(); - } - } finally { - context.Application.UnLock(); - } - } - - return store; - } - - /// <summary> /// Gets or sets the channel to use for sending/receiving messages. /// </summary> public Channel Channel { @@ -314,6 +289,33 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { } /// <summary> + /// Gets the standard state storage mechanism that uses ASP.NET's + /// HttpApplication state dictionary to store associations and nonces. + /// </summary> + /// <param name="context">The context.</param> + /// <returns>The application store.</returns> + public static IOpenIdApplicationStore GetHttpApplicationStore(HttpContextBase context = null) { + if (context == null) { + ErrorUtilities.VerifyOperation(HttpContext.Current != null, Strings.StoreRequiredWhenNoHttpContextAvailable, typeof(IOpenIdApplicationStore).Name); + context = new HttpContextWrapper(HttpContext.Current); + } + + var store = (IOpenIdApplicationStore)context.Application[ApplicationStoreKey]; + if (store == null) { + context.Application.Lock(); + try { + if ((store = (IOpenIdApplicationStore)context.Application[ApplicationStoreKey]) == null) { + context.Application[ApplicationStoreKey] = store = new StandardRelyingPartyApplicationStore(); + } + } finally { + context.Application.UnLock(); + } + } + + return store; + } + + /// <summary> /// Creates an authentication request to verify that a user controls /// some given Identifier. /// </summary> @@ -520,7 +522,10 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// Gets an authentication response from a Provider. /// </summary> /// <param name="httpRequestInfo">The HTTP request that may be carrying an authentication response from the Provider.</param> - /// <returns>The processed authentication response if there is any; <c>null</c> otherwise.</returns> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns> + /// The processed authentication response if there is any; <c>null</c> otherwise. + /// </returns> public async Task<IAuthenticationResponse> GetResponseAsync(HttpRequestBase httpRequestInfo, CancellationToken cancellationToken) { Requires.NotNull(httpRequestInfo, "httpRequestInfo"); try { @@ -574,7 +579,10 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// Processes the response received in a popup window or iframe to an AJAX-directed OpenID authentication. /// </summary> /// <param name="request">The incoming HTTP request that is expected to carry an OpenID authentication response.</param> - /// <returns>The HTTP response to send to this HTTP request.</returns> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns> + /// The HTTP response to send to this HTTP request. + /// </returns> public Task<HttpResponseMessage> ProcessResponseFromPopupAsync(HttpRequestBase request, CancellationToken cancellationToken) { Requires.NotNull(request, "request"); @@ -657,6 +665,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// </summary> /// <param name="request">The incoming HTTP request that is expected to carry an OpenID authentication response.</param> /// <param name="callback">The callback fired after the response status has been determined but before the Javascript response is formulated.</param> + /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// The HTTP response to send to this HTTP request. /// </returns> @@ -716,7 +725,10 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// Performs discovery on the specified identifier. /// </summary> /// <param name="identifier">The identifier to discover services for.</param> - /// <returns>A non-null sequence of services discovered for the identifier.</returns> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns> + /// A non-null sequence of services discovered for the identifier. + /// </returns> internal Task<IEnumerable<IdentifierDiscoveryResult>> DiscoverAsync(Identifier identifier, CancellationToken cancellationToken) { return this.discoveryServices.DiscoverAsync(identifier, cancellationToken); } |