summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.OpenId.Provider/OpenId
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.OpenId.Provider/OpenId')
-rw-r--r--src/DotNetOpenAuth.OpenId.Provider/OpenId/ChannelElements/ProviderSigningBindingElement.cs2
-rw-r--r--src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/AuthenticationRequest.cs24
-rw-r--r--src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Behaviors/AXFetchAsSregTransform.cs10
-rw-r--r--src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Behaviors/GsaIcamProfile.cs2
-rw-r--r--src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Behaviors/PpidGeneration.cs2
-rw-r--r--src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Extensions/ExtensionsInteropHelper.cs1
-rw-r--r--src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Extensions/UI/UIRequestTools.cs4
-rw-r--r--src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/HostProcessedRequest.cs2
-rw-r--r--src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/OpenIdProvider.cs69
-rw-r--r--src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Request.cs57
10 files changed, 97 insertions, 76 deletions
diff --git a/src/DotNetOpenAuth.OpenId.Provider/OpenId/ChannelElements/ProviderSigningBindingElement.cs b/src/DotNetOpenAuth.OpenId.Provider/OpenId/ChannelElements/ProviderSigningBindingElement.cs
index 520f41a..26d9133 100644
--- a/src/DotNetOpenAuth.OpenId.Provider/OpenId/ChannelElements/ProviderSigningBindingElement.cs
+++ b/src/DotNetOpenAuth.OpenId.Provider/OpenId/ChannelElements/ProviderSigningBindingElement.cs
@@ -58,6 +58,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements {
/// Prepares a message for sending based on the rules of this channel binding element.
/// </summary>
/// <param name="message">The message to prepare for sending.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// The protections (if any) that this binding element applied to the message.
/// Null if this binding element did not even apply to this binding element.
@@ -160,6 +161,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements {
/// <param name="message">The message.</param>
/// <param name="signedMessage">The signed message.</param>
/// <param name="protectionsApplied">The protections applied.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// The applied protections.
/// </returns>
diff --git a/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/AuthenticationRequest.cs b/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/AuthenticationRequest.cs
index a13cba1..80d8aeb 100644
--- a/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/AuthenticationRequest.cs
+++ b/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/AuthenticationRequest.cs
@@ -176,17 +176,6 @@ namespace DotNetOpenAuth.OpenId.Provider {
get { return (CheckIdRequest)base.RequestMessage; }
}
- /// <summary>
- /// Gets the response message, once <see cref="IsResponseReady"/> is <c>true</c>.
- /// </summary>
- protected override async Task<IProtocolMessage> GetResponseMessageAsync(CancellationToken cancellationToken) {
- if (this.IsAuthenticated.HasValue) {
- return this.IsAuthenticated.Value ? (IProtocolMessage)this.positiveResponse : (await this.GetNegativeResponseAsync());
- } else {
- return null;
- }
- }
-
#region IAuthenticationRequest Methods
/// <summary>
@@ -211,6 +200,8 @@ namespace DotNetOpenAuth.OpenId.Provider {
this.positiveResponse.ClaimedIdentifier = builder.Uri;
}
+ #endregion
+
/// <summary>
/// Sets the Claimed and Local identifiers even after they have been initially set.
/// </summary>
@@ -222,6 +213,15 @@ namespace DotNetOpenAuth.OpenId.Provider {
this.positiveResponse.LocalIdentifier = identifier;
}
- #endregion
+ /// <summary>
+ /// Gets the response message, once <see cref="IsResponseReady"/> is <c>true</c>.
+ /// </summary>
+ protected override async Task<IProtocolMessage> GetResponseMessageAsync(CancellationToken cancellationToken) {
+ if (this.IsAuthenticated.HasValue) {
+ return this.IsAuthenticated.Value ? (IProtocolMessage)this.positiveResponse : (await this.GetNegativeResponseAsync());
+ } else {
+ return null;
+ }
+ }
}
}
diff --git a/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Behaviors/AXFetchAsSregTransform.cs b/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Behaviors/AXFetchAsSregTransform.cs
index 721777f..17c9a1a 100644
--- a/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Behaviors/AXFetchAsSregTransform.cs
+++ b/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Behaviors/AXFetchAsSregTransform.cs
@@ -53,13 +53,14 @@ namespace DotNetOpenAuth.OpenId.Provider.Behaviors {
/// Called when a request is received by the Provider.
/// </summary>
/// <param name="request">The incoming request.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
- /// <c>true</c> if this behavior owns this request and wants to stop other behaviors
+ /// <c>true</c> if this behavior owns this request and wants to stop other behaviors
/// from handling it; <c>false</c> to allow other behaviors to process this request.
/// </returns>
/// <remarks>
- /// Implementations may set a new value to <see cref="IRequest.SecuritySettings"/> but
- /// should not change the properties on the instance of <see cref="ProviderSecuritySettings"/>
+ /// Implementations may set a new value to <see cref="IRequest.SecuritySettings" /> but
+ /// should not change the properties on the instance of <see cref="ProviderSecuritySettings" />
/// itself as that instance may be shared across many requests.
/// </remarks>
Task<bool> IProviderBehavior.OnIncomingRequestAsync(IRequest request, CancellationToken cancellationToken) {
@@ -75,8 +76,9 @@ namespace DotNetOpenAuth.OpenId.Provider.Behaviors {
/// Called when the Provider is preparing to send a response to an authentication request.
/// </summary>
/// <param name="request">The request that is configured to generate the outgoing response.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
- /// <c>true</c> if this behavior owns this request and wants to stop other behaviors
+ /// <c>true</c> if this behavior owns this request and wants to stop other behaviors
/// from handling it; <c>false</c> to allow other behaviors to process this request.
/// </returns>
async Task<bool> IProviderBehavior.OnOutgoingResponseAsync(Provider.IAuthenticationRequest request, CancellationToken cancellationToken) {
diff --git a/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Behaviors/GsaIcamProfile.cs b/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Behaviors/GsaIcamProfile.cs
index ab0cf53..0aa4642 100644
--- a/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Behaviors/GsaIcamProfile.cs
+++ b/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Behaviors/GsaIcamProfile.cs
@@ -71,6 +71,7 @@ namespace DotNetOpenAuth.OpenId.Provider.Behaviors {
/// Called when a request is received by the Provider.
/// </summary>
/// <param name="request">The incoming request.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// <c>true</c> if this behavior owns this request and wants to stop other behaviors
/// from handling it; <c>false</c> to allow other behaviors to process this request.
@@ -105,6 +106,7 @@ namespace DotNetOpenAuth.OpenId.Provider.Behaviors {
/// Called when the Provider is preparing to send a response to an authentication request.
/// </summary>
/// <param name="request">The request that is configured to generate the outgoing response.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// <c>true</c> if this behavior owns this request and wants to stop other behaviors
/// from handling it; <c>false</c> to allow other behaviors to process this request.
diff --git a/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Behaviors/PpidGeneration.cs b/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Behaviors/PpidGeneration.cs
index b6588a9..5acd4c9 100644
--- a/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Behaviors/PpidGeneration.cs
+++ b/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Behaviors/PpidGeneration.cs
@@ -54,6 +54,7 @@ namespace DotNetOpenAuth.OpenId.Provider.Behaviors {
/// Called when a request is received by the Provider.
/// </summary>
/// <param name="request">The incoming request.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// <c>true</c> if this behavior owns this request and wants to stop other behaviors
/// from handling it; <c>false</c> to allow other behaviors to process this request.
@@ -71,6 +72,7 @@ namespace DotNetOpenAuth.OpenId.Provider.Behaviors {
/// Called when the Provider is preparing to send a response to an authentication request.
/// </summary>
/// <param name="request">The request that is configured to generate the outgoing response.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// <c>true</c> if this behavior owns this request and wants to stop other behaviors
/// from handling it; <c>false</c> to allow other behaviors to process this request.
diff --git a/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Extensions/ExtensionsInteropHelper.cs b/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Extensions/ExtensionsInteropHelper.cs
index 26225b3..a275647 100644
--- a/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Extensions/ExtensionsInteropHelper.cs
+++ b/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Extensions/ExtensionsInteropHelper.cs
@@ -76,6 +76,7 @@ namespace DotNetOpenAuth.OpenId.Provider.Extensions {
/// attribute request extension came in.
/// </summary>
/// <param name="request">The authentication request with the response extensions already added.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
/// <remarks>
/// If the original attribute request came in as AX, the Simple Registration extension is converted
/// to an AX response and then the Simple Registration extension is removed from the response.
diff --git a/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Extensions/UI/UIRequestTools.cs b/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Extensions/UI/UIRequestTools.cs
index 09d0b21..c531ddd 100644
--- a/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Extensions/UI/UIRequestTools.cs
+++ b/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/Extensions/UI/UIRequestTools.cs
@@ -37,8 +37,8 @@ namespace DotNetOpenAuth.OpenId.Provider.Extensions.UI {
/// Gets the URL of the RP icon for the OP to display.
/// </summary>
/// <param name="realm">The realm of the RP where the authentication request originated.</param>
- /// <param name="webRequestHandler">The web request handler to use for discovery.
- /// Usually available via <see cref="Channel.WebRequestHandler">OpenIdProvider.Channel.WebRequestHandler</see>.</param>
+ /// <param name="hostFactories">The host factories.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// A sequence of the RP's icons it has available for the Provider to display, in decreasing preferred order.
/// </returns>
diff --git a/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/HostProcessedRequest.cs b/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/HostProcessedRequest.cs
index 85d111e..07807d2 100644
--- a/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/HostProcessedRequest.cs
+++ b/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/HostProcessedRequest.cs
@@ -101,6 +101,7 @@ namespace DotNetOpenAuth.OpenId.Provider {
/// succeeded.
/// </summary>
/// <param name="hostFactories">The host factories.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// Result of realm discovery.
/// </returns>
@@ -123,6 +124,7 @@ namespace DotNetOpenAuth.OpenId.Provider {
/// succeeded.
/// </summary>
/// <param name="hostFactories">The host factories.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// Result of realm discovery.
/// </returns>
diff --git a/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/OpenIdProvider.cs b/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/OpenIdProvider.cs
index 3b62482..0495299 100644
--- a/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/OpenIdProvider.cs
+++ b/src/DotNetOpenAuth.OpenId.Provider/OpenId/Provider/OpenIdProvider.cs
@@ -91,31 +91,6 @@ namespace DotNetOpenAuth.OpenId.Provider {
}
/// <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 StandardProviderApplicationStore();
- }
- } finally {
- context.Application.UnLock();
- }
- }
-
- return store;
- }
-
- /// <summary>
/// Gets the channel to use for sending/receiving messages.
/// </summary>
public Channel Channel { get; internal set; }
@@ -198,6 +173,31 @@ namespace DotNetOpenAuth.OpenId.Provider {
}
/// <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 StandardProviderApplicationStore();
+ }
+ } finally {
+ context.Application.UnLock();
+ }
+ }
+
+ return store;
+ }
+
+ /// <summary>
/// Gets the incoming OpenID request if there is one, or null if none was detected.
/// </summary>
/// <returns>The request that the hosting Provider should possibly process and then transmit the response for.</returns>
@@ -217,17 +217,18 @@ namespace DotNetOpenAuth.OpenId.Provider {
/// Gets the incoming OpenID request if there is one, or null if none was detected.
/// </summary>
/// <param name="httpRequestInfo">The incoming HTTP request to extract the message from.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// The request that the hosting Provider should process and then transmit the response for.
/// Null if no valid OpenID request was detected in the given HTTP request.
/// </returns>
+ /// <exception cref="ProtocolException">Thrown if the incoming message is recognized
+ /// but deviates from the protocol specification irrecoverably.</exception>
/// <remarks>
/// Requests may be infrastructural to OpenID and allow auto-responses, or they may
/// be authentication requests where the Provider site has to make decisions based
/// on its own user database and policies.
/// </remarks>
- /// <exception cref="ProtocolException">Thrown if the incoming message is recognized
- /// but deviates from the protocol specification irrecoverably.</exception>
public async Task<IRequest> GetRequestAsync(HttpRequestBase httpRequestInfo, CancellationToken cancellationToken) {
Requires.NotNull(httpRequestInfo, "httpRequestInfo");
IDirectedProtocolMessage incomingMessage = null;
@@ -299,8 +300,11 @@ namespace DotNetOpenAuth.OpenId.Provider {
/// Gets the response to a received request.
/// </summary>
/// <param name="request">The request.</param>
- /// <returns>The response that should be sent to the client.</returns>
- /// <exception cref="InvalidOperationException">Thrown if <see cref="IRequest.IsResponseReady"/> is <c>false</c>.</exception>
+ /// <param name="cancellationToken">The cancellation token.</param>
+ /// <returns>
+ /// The response that should be sent to the client.
+ /// </returns>
+ /// <exception cref="InvalidOperationException">Thrown if <see cref="IRequest.IsResponseReady" /> is <c>false</c>.</exception>
[SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily", Justification = "Code Contract requires that we cast early.")]
public async Task<HttpResponseMessage> PrepareResponseAsync(IRequest request, CancellationToken cancellationToken) {
Requires.NotNull(request, "request");
@@ -325,10 +329,11 @@ namespace DotNetOpenAuth.OpenId.Provider {
/// XRDS document that advertises its OpenID RP endpoint.</param>
/// <param name="claimedIdentifier">The Identifier you are asserting your member controls.</param>
/// <param name="localIdentifier">The Identifier you know your user by internally. This will typically
- /// be the same as <paramref name="claimedIdentifier"/>.</param>
+ /// be the same as <paramref name="claimedIdentifier" />.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
/// <param name="extensions">The extensions.</param>
/// <returns>
- /// A <see cref="OutgoingWebResponse"/> object describing the HTTP response to send
+ /// A <see cref="OutgoingWebResponse" /> object describing the HTTP response to send
/// the user agent to allow the redirect with assertion to happen.
/// </returns>
public async Task<HttpResponseMessage> PrepareUnsolicitedAssertionAsync(Uri providerEndpoint, Realm relyingPartyRealm, Identifier claimedIdentifier, Identifier localIdentifier, CancellationToken cancellationToken = default(CancellationToken), params IExtensionMessage[] extensions) {
@@ -415,6 +420,8 @@ namespace DotNetOpenAuth.OpenId.Provider {
/// Applies all behaviors to the response message.
/// </summary>
/// <param name="request">The request.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
+ /// <returns></returns>
private async Task ApplyBehaviorsToResponseAsync(IRequest request, CancellationToken cancellationToken) {
var authRequest = request as IAuthenticationRequest;
if (authRequest != null) {
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);
}
}