diff options
Diffstat (limited to 'src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Request.cs')
-rw-r--r-- | src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Request.cs | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Request.cs b/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Request.cs index 93f8107..cc44338 100644 --- a/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Request.cs +++ b/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Request.cs @@ -16,7 +16,7 @@ using DotNetOpenAuth.OpenId.Messages; using Validation; /// <summary> - /// Implements the <see cref="IRequest"/> interface for all incoming + /// Implements the <see cref="IRequest" /> interface for all incoming /// request messages to an OpenID Provider. /// </summary> [Serializable] @@ -93,32 +93,6 @@ using Validation; /// <value>Defaults to the <see cref="OpenIdProvider.SecuritySettings"/> on the <see cref="OpenIdProvider"/>.</value> public ProviderSecuritySettings SecuritySettings { get; set; } - /// <summary> - /// Gets the response to send to the user agent. - /// </summary> - /// <exception cref="InvalidOperationException">Thrown if <see cref="IsResponseReady"/> is <c>false</c>.</exception> - internal async Task<IProtocolMessage> GetResponseAsync(CancellationToken cancellationToken) { - RequiresEx.ValidState(this.IsResponseReady, OpenIdStrings.ResponseNotReady); - - if (this.responseExtensions.Count > 0) { - var responseMessage = await this.GetResponseMessageAsync(cancellationToken); - var extensibleResponse = responseMessage as IProtocolMessageWithExtensions; - ErrorUtilities.VerifyOperation(extensibleResponse != null, MessagingStrings.MessageNotExtensible, responseMessage.GetType().Name); - foreach (var extension in this.responseExtensions) { - // It's possible that a prior call to this property - // has already added some/all of the extensions to the message. - // We don't have to worry about deleting old ones because - // this class provides no facility for removing extensions - // that are previously added. - if (!extensibleResponse.Extensions.Contains(extension)) { - extensibleResponse.Extensions.Add(extension); - } - } - } - - return await this.GetResponseMessageAsync(cancellationToken); - } - #endregion /// <summary> @@ -201,8 +175,37 @@ using Validation; #endregion /// <summary> + /// Gets the response to send to the user agent. + /// </summary> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns>The response.</returns> + /// <exception cref="InvalidOperationException">Thrown if <see cref="IsResponseReady" /> is <c>false</c>.</exception> + internal async Task<IProtocolMessage> GetResponseAsync(CancellationToken cancellationToken) { + RequiresEx.ValidState(this.IsResponseReady, OpenIdStrings.ResponseNotReady); + + if (this.responseExtensions.Count > 0) { + var responseMessage = await this.GetResponseMessageAsync(cancellationToken); + var extensibleResponse = responseMessage as IProtocolMessageWithExtensions; + ErrorUtilities.VerifyOperation(extensibleResponse != null, MessagingStrings.MessageNotExtensible, responseMessage.GetType().Name); + foreach (var extension in this.responseExtensions) { + // It's possible that a prior call to this property + // has already added some/all of the extensions to the message. + // We don't have to worry about deleting old ones because + // this class provides no facility for removing extensions + // that are previously added. + if (!extensibleResponse.Extensions.Contains(extension)) { + extensibleResponse.Extensions.Add(extension); + } + } + } + + return await this.GetResponseMessageAsync(cancellationToken); + } + + /// <summary> /// Gets the response message, once <see cref="IsResponseReady"/> is <c>true</c>. /// </summary> + /// <param name="cancellationToken">The cancellation token.</param> protected abstract Task<IProtocolMessage> GetResponseMessageAsync(CancellationToken cancellationToken); } } |