diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2009-11-22 14:00:43 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2009-11-22 14:00:43 -0800 |
commit | d97cc88a29d869f5a1f505e9b24e9321b6a7b8fb (patch) | |
tree | 6147c49395c30d4ce73d7cf3f3edb47a54d39de1 | |
parent | 9a1fd377901eb3f84a05216abab1e5727620f9a9 (diff) | |
download | DotNetOpenAuth-d97cc88a29d869f5a1f505e9b24e9321b6a7b8fb.zip DotNetOpenAuth-d97cc88a29d869f5a1f505e9b24e9321b6a7b8fb.tar.gz DotNetOpenAuth-d97cc88a29d869f5a1f505e9b24e9321b6a7b8fb.tar.bz2 |
StyleCop fixes.
17 files changed, 163 insertions, 126 deletions
diff --git a/src/DotNetOpenAuth.Test/Mocks/MockHttpRequest.cs b/src/DotNetOpenAuth.Test/Mocks/MockHttpRequest.cs index bd10f54..b10da88 100644 --- a/src/DotNetOpenAuth.Test/Mocks/MockHttpRequest.cs +++ b/src/DotNetOpenAuth.Test/Mocks/MockHttpRequest.cs @@ -15,10 +15,10 @@ namespace DotNetOpenAuth.Test.Mocks { using System.Web; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OpenId; + using DotNetOpenAuth.OpenId.DiscoveryServices; using DotNetOpenAuth.OpenId.RelyingParty; using DotNetOpenAuth.Test.OpenId; using DotNetOpenAuth.Yadis; - using DotNetOpenAuth.OpenId.DiscoveryServices; internal class MockHttpRequest { private readonly Dictionary<Uri, IncomingWebResponse> registeredMockResponses = new Dictionary<Uri, IncomingWebResponse>(); diff --git a/src/DotNetOpenAuth.Test/Mocks/MockIdentifier.cs b/src/DotNetOpenAuth.Test/Mocks/MockIdentifier.cs index d03582d..862a05e 100644 --- a/src/DotNetOpenAuth.Test/Mocks/MockIdentifier.cs +++ b/src/DotNetOpenAuth.Test/Mocks/MockIdentifier.cs @@ -10,8 +10,8 @@ namespace DotNetOpenAuth.Test.Mocks { using System.Diagnostics.Contracts; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OpenId; - using DotNetOpenAuth.OpenId.RelyingParty; using DotNetOpenAuth.OpenId.DiscoveryServices; + using DotNetOpenAuth.OpenId.RelyingParty; /// <summary> /// Performs similar to an ordinary <see cref="Identifier"/>, but when called upon diff --git a/src/DotNetOpenAuth.Test/OpenId/DiscoveryServices/UriDiscoveryServiceTests.cs b/src/DotNetOpenAuth.Test/OpenId/DiscoveryServices/UriDiscoveryServiceTests.cs index 38c39aa..9c68daa 100644 --- a/src/DotNetOpenAuth.Test/OpenId/DiscoveryServices/UriDiscoveryServiceTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/DiscoveryServices/UriDiscoveryServiceTests.cs @@ -13,10 +13,10 @@ namespace DotNetOpenAuth.Test.OpenId.DiscoveryServices { using System.Web; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OpenId; + using DotNetOpenAuth.OpenId.DiscoveryServices; using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration; using DotNetOpenAuth.OpenId.RelyingParty; using Microsoft.VisualStudio.TestTools.UnitTesting; - using DotNetOpenAuth.OpenId.DiscoveryServices; [TestClass] public class UriDiscoveryServiceTests : OpenIdTestBase { diff --git a/src/DotNetOpenAuth.Test/OpenId/DiscoveryServices/XriDiscoveryProxyServiceTests.cs b/src/DotNetOpenAuth.Test/OpenId/DiscoveryServices/XriDiscoveryProxyServiceTests.cs index 90ccc06..b3383a4 100644 --- a/src/DotNetOpenAuth.Test/OpenId/DiscoveryServices/XriDiscoveryProxyServiceTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/DiscoveryServices/XriDiscoveryProxyServiceTests.cs @@ -10,9 +10,9 @@ namespace DotNetOpenAuth.Test.OpenId.DiscoveryServices { using System.Linq; using System.Text; using DotNetOpenAuth.OpenId; + using DotNetOpenAuth.OpenId.DiscoveryServices; using DotNetOpenAuth.OpenId.RelyingParty; using Microsoft.VisualStudio.TestTools.UnitTesting; - using DotNetOpenAuth.OpenId.DiscoveryServices; [TestClass] public class XriDiscoveryProxyServiceTests : OpenIdTestBase { diff --git a/src/DotNetOpenAuth.Test/OpenId/Extensions/ExtensionsInteropHelperRPRequestTests.cs b/src/DotNetOpenAuth.Test/OpenId/Extensions/ExtensionsInteropHelperRPRequestTests.cs index 3e0b72a..73dc2b3 100644 --- a/src/DotNetOpenAuth.Test/OpenId/Extensions/ExtensionsInteropHelperRPRequestTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/Extensions/ExtensionsInteropHelperRPRequestTests.cs @@ -5,6 +5,7 @@ //----------------------------------------------------------------------- namespace DotNetOpenAuth.Test.OpenId { + using System.Collections.ObjectModel; using System.Linq; using DotNetOpenAuth.OpenId; using DotNetOpenAuth.OpenId.Extensions; @@ -12,7 +13,6 @@ namespace DotNetOpenAuth.Test.OpenId { using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration; using DotNetOpenAuth.OpenId.RelyingParty; using Microsoft.VisualStudio.TestTools.UnitTesting; - using System.Collections.ObjectModel; [TestClass] public class ExtensionsInteropHelperRPRequestTests : OpenIdTestBase { diff --git a/src/DotNetOpenAuth.Test/OpenId/OpenIdUtilitiesTests.cs b/src/DotNetOpenAuth.Test/OpenId/OpenIdUtilitiesTests.cs index 539a931..1a68d0a 100644 --- a/src/DotNetOpenAuth.Test/OpenId/OpenIdUtilitiesTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/OpenIdUtilitiesTests.cs @@ -9,10 +9,10 @@ namespace DotNetOpenAuth.Test.OpenId { using System.Collections.Generic; using System.Linq; using System.Text; - using Microsoft.VisualStudio.TestTools.UnitTesting; using DotNetOpenAuth.OpenId; using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration; using DotNetOpenAuth.OpenId.Messages; + using Microsoft.VisualStudio.TestTools.UnitTesting; [TestClass] public class OpenIdUtilitiesTests : OpenIdTestBase { diff --git a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs index 4ec650c..fea672d 100644 --- a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/AuthenticationRequestTests.cs @@ -13,11 +13,11 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty { using System.Web; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OpenId; + using DotNetOpenAuth.OpenId.DiscoveryServices; using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration; using DotNetOpenAuth.OpenId.Messages; using DotNetOpenAuth.OpenId.RelyingParty; using Microsoft.VisualStudio.TestTools.UnitTesting; - using DotNetOpenAuth.OpenId.DiscoveryServices; [TestClass] public class AuthenticationRequestTests : OpenIdTestBase { diff --git a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/ServiceEndpointTests.cs b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/ServiceEndpointTests.cs index e8c9f68..6718213 100644 --- a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/ServiceEndpointTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/ServiceEndpointTests.cs @@ -12,12 +12,12 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty { using System.Text; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OpenId; + using DotNetOpenAuth.OpenId.DiscoveryServices; using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration; using DotNetOpenAuth.OpenId.Messages; using DotNetOpenAuth.OpenId.RelyingParty; using DotNetOpenAuth.Test.Messaging; using Microsoft.VisualStudio.TestTools.UnitTesting; - using DotNetOpenAuth.OpenId.DiscoveryServices; [TestClass] public class ServiceEndpointTests : OpenIdTestBase { diff --git a/src/DotNetOpenAuth/OpenId/DiscoveryServices/IIdentifierDiscoveryResult.cs b/src/DotNetOpenAuth/OpenId/DiscoveryServices/IIdentifierDiscoveryResult.cs index 6ee27f1..4ac6dab 100644 --- a/src/DotNetOpenAuth/OpenId/DiscoveryServices/IIdentifierDiscoveryResult.cs +++ b/src/DotNetOpenAuth/OpenId/DiscoveryServices/IIdentifierDiscoveryResult.cs @@ -7,30 +7,58 @@ namespace DotNetOpenAuth.OpenId.DiscoveryServices { using System; using System.Collections.Generic; + using System.Diagnostics.Contracts; using System.Linq; using System.Text; using DotNetOpenAuth.OpenId.RelyingParty; - using System.Diagnostics.Contracts; + /// <summary> + /// An self-describing result of discovery on some identifier; perhaps one of many. + /// </summary> [ContractClass(typeof(IIdentifierDiscoveryResultContract))] - interface IIdentifierDiscoveryResult { + internal interface IIdentifierDiscoveryResult { /// <summary> /// Gets the provider endpoint. /// </summary> /// <value>The discovered provider endpoint. May optionally implement <see cref="IXrdsProviderEndpoint"/>.</value> IProviderEndpoint ProviderEndpoint { get; } + /// <summary> + /// Gets the Identifier that the end user claims to control. + /// </summary> Identifier ClaimedIdentifier { get; } + /// <summary> + /// Gets an alternate Identifier for an end user that is local to a + /// particular OP and thus not necessarily under the end user's + /// control. + /// </summary> Identifier ProviderLocalIdentifier { get; } + /// <summary> + /// Gets the Identifier that was presented by the end user to the Relying Party, + /// or selected by the user at the OpenID Provider. + /// During the initiation phase of the protocol, an end user may enter + /// either their own Identifier or an OP Identifier. If an OP Identifier + /// is used, the OP may then assist the end user in selecting an Identifier + /// to share with the Relying Party. + /// </summary> Identifier UserSuppliedIdentifier { get; } } + /// <summary> + /// Code contract class for the <see cref="IIdentifierDiscoveryResult"/> interface. + /// </summary> [ContractClassFor(typeof(IIdentifierDiscoveryResult))] internal class IIdentifierDiscoveryResultContract : IIdentifierDiscoveryResult { #region IIdentifierDiscoveryResult Members + /// <summary> + /// Gets the provider endpoint. + /// </summary> + /// <value> + /// The discovered provider endpoint. May optionally implement <see cref="IXrdsProviderEndpoint"/>. + /// </value> IProviderEndpoint IIdentifierDiscoveryResult.ProviderEndpoint { get { Contract.Ensures(Contract.Result<IProviderEndpoint>() != null); @@ -38,6 +66,9 @@ namespace DotNetOpenAuth.OpenId.DiscoveryServices { } } + /// <summary> + /// Gets the Identifier that the end user claims to control. + /// </summary> Identifier IIdentifierDiscoveryResult.ClaimedIdentifier { get { Contract.Ensures(Contract.Result<Identifier>() != null); @@ -45,6 +76,14 @@ namespace DotNetOpenAuth.OpenId.DiscoveryServices { } } + /// <summary> + /// Gets the Identifier that was presented by the end user to the Relying Party, + /// or selected by the user at the OpenID Provider. + /// During the initiation phase of the protocol, an end user may enter + /// either their own Identifier or an OP Identifier. If an OP Identifier + /// is used, the OP may then assist the end user in selecting an Identifier + /// to share with the Relying Party. + /// </summary> Identifier IIdentifierDiscoveryResult.UserSuppliedIdentifier { get { Contract.Ensures(Contract.Result<Identifier>() != null); @@ -52,6 +91,11 @@ namespace DotNetOpenAuth.OpenId.DiscoveryServices { } } + /// <summary> + /// Gets an alternate Identifier for an end user that is local to a + /// particular OP and thus not necessarily under the end user's + /// control. + /// </summary> Identifier IIdentifierDiscoveryResult.ProviderLocalIdentifier { get { Contract.Ensures(Contract.Result<Identifier>() != null); @@ -61,5 +105,4 @@ namespace DotNetOpenAuth.OpenId.DiscoveryServices { #endregion } - } diff --git a/src/DotNetOpenAuth/OpenId/DiscoveryServices/IdentifierDiscoveryResult.cs b/src/DotNetOpenAuth/OpenId/DiscoveryServices/IdentifierDiscoveryResult.cs index 0b4312a..ad77c17 100644 --- a/src/DotNetOpenAuth/OpenId/DiscoveryServices/IdentifierDiscoveryResult.cs +++ b/src/DotNetOpenAuth/OpenId/DiscoveryServices/IdentifierDiscoveryResult.cs @@ -14,8 +14,8 @@ namespace DotNetOpenAuth.OpenId.DiscoveryServices { using System.Linq; using System.Text; using DotNetOpenAuth.Messaging; - using DotNetOpenAuth.OpenId.Messages; using DotNetOpenAuth.OpenId.DiscoveryServices; + using DotNetOpenAuth.OpenId.Messages; using DotNetOpenAuth.OpenId.RelyingParty; /// <summary> @@ -40,7 +40,7 @@ namespace DotNetOpenAuth.OpenId.DiscoveryServices { private int? servicePriority; /// <summary> - /// Initializes a new instance of the <see cref="ServiceEndpoint"/> class. + /// Initializes a new instance of the <see cref="IdentifierDiscoveryResult"/> class. /// </summary> /// <param name="providerEndpoint">The provider endpoint.</param> /// <param name="claimedIdentifier">The Claimed Identifier.</param> @@ -60,29 +60,6 @@ namespace DotNetOpenAuth.OpenId.DiscoveryServices { } /// <summary> - /// Initializes a new instance of the <see cref="ServiceEndpoint"/> class. - /// </summary> - /// <param name="providerEndpoint">The provider endpoint.</param> - /// <param name="claimedIdentifier">The Claimed Identifier.</param> - /// <param name="userSuppliedIdentifier">The User-supplied Identifier.</param> - /// <param name="providerLocalIdentifier">The Provider Local Identifier.</param> - /// <param name="protocol">The protocol.</param> - /// <remarks> - /// Used for deserializing <see cref="ServiceEndpoint"/> from authentication responses. - /// </remarks> - private IdentifierDiscoveryResult(Uri providerEndpoint, Identifier claimedIdentifier, Identifier userSuppliedIdentifier, Identifier providerLocalIdentifier, Protocol protocol) { - Contract.Requires<ArgumentNullException>(providerEndpoint != null); - Contract.Requires<ArgumentNullException>(claimedIdentifier != null); - Contract.Requires<ArgumentNullException>(providerLocalIdentifier != null); - Contract.Requires<ArgumentNullException>(protocol != null); - - this.ClaimedIdentifier = claimedIdentifier; - this.UserSuppliedIdentifier = userSuppliedIdentifier; - this.ProviderEndpoint = new ProviderEndpointDescription(providerEndpoint, protocol.Version); - this.ProviderLocalIdentifier = providerLocalIdentifier ?? claimedIdentifier; - } - - /// <summary> /// Gets the Identifier that was presented by the end user to the Relying Party, /// or selected by the user at the OpenID Provider. /// During the initiation phase of the protocol, an end user may enter @@ -93,7 +70,7 @@ namespace DotNetOpenAuth.OpenId.DiscoveryServices { public Identifier UserSuppliedIdentifier { get; private set; } /// <summary> - /// Gets or sets the Identifier that the end user claims to own. + /// Gets or sets the Identifier that the end user claims to control. /// </summary> public Identifier ClaimedIdentifier { get { @@ -116,6 +93,12 @@ namespace DotNetOpenAuth.OpenId.DiscoveryServices { /// </summary> public Identifier ProviderLocalIdentifier { get; private set; } + /// <summary> + /// Gets the provider endpoint. + /// </summary> + /// <value> + /// The discovered provider endpoint. May optionally implement <see cref="IXrdsProviderEndpoint"/>. + /// </value> public IProviderEndpoint ProviderEndpoint { get; private set; } /// <summary> @@ -249,13 +232,13 @@ namespace DotNetOpenAuth.OpenId.DiscoveryServices { } /// <summary> - /// Creates a <see cref="ServiceEndpoint"/> instance to represent some OP Identifier. + /// Creates a <see cref="IIdentifierDiscoveryResult"/> instance to represent some OP Identifier. /// </summary> /// <param name="providerIdentifier">The provider identifier (actually the user-supplied identifier).</param> /// <param name="providerEndpoint">The provider endpoint.</param> /// <param name="servicePriority">The service priority.</param> /// <param name="uriPriority">The URI priority.</param> - /// <returns>The created <see cref="ServiceEndpoint"/> instance</returns> + /// <returns>The created <see cref="IIdentifierDiscoveryResult"/> instance</returns> internal static IIdentifierDiscoveryResult CreateForProviderIdentifier(Identifier providerIdentifier, ProviderEndpointDescription providerEndpoint, int? servicePriority, int? uriPriority) { Contract.Requires<ArgumentNullException>(providerEndpoint != null); @@ -271,20 +254,20 @@ namespace DotNetOpenAuth.OpenId.DiscoveryServices { } /// <summary> - /// Creates a <see cref="ServiceEndpoint"/> instance to represent some Claimed Identifier. + /// Creates a <see cref="IIdentifierDiscoveryResult"/> instance to represent some Claimed Identifier. /// </summary> /// <param name="claimedIdentifier">The claimed identifier.</param> /// <param name="providerLocalIdentifier">The provider local identifier.</param> /// <param name="providerEndpoint">The provider endpoint.</param> /// <param name="servicePriority">The service priority.</param> /// <param name="uriPriority">The URI priority.</param> - /// <returns>The created <see cref="ServiceEndpoint"/> instance</returns> + /// <returns>The created <see cref="IIdentifierDiscoveryResult"/> instance</returns> internal static IIdentifierDiscoveryResult CreateForClaimedIdentifier(Identifier claimedIdentifier, Identifier providerLocalIdentifier, IProviderEndpoint providerEndpoint, int? servicePriority, int? uriPriority) { return CreateForClaimedIdentifier(claimedIdentifier, null, providerLocalIdentifier, providerEndpoint, servicePriority, uriPriority); } /// <summary> - /// Creates a <see cref="ServiceEndpoint"/> instance to represent some Claimed Identifier. + /// Creates a <see cref="IIdentifierDiscoveryResult"/> instance to represent some Claimed Identifier. /// </summary> /// <param name="claimedIdentifier">The claimed identifier.</param> /// <param name="userSuppliedIdentifier">The user supplied identifier.</param> @@ -292,7 +275,7 @@ namespace DotNetOpenAuth.OpenId.DiscoveryServices { /// <param name="providerEndpoint">The provider endpoint.</param> /// <param name="servicePriority">The service priority.</param> /// <param name="uriPriority">The URI priority.</param> - /// <returns>The created <see cref="ServiceEndpoint"/> instance</returns> + /// <returns>The created <see cref="IdentifierDiscoveryResult"/> instance</returns> internal static IIdentifierDiscoveryResult CreateForClaimedIdentifier(Identifier claimedIdentifier, Identifier userSuppliedIdentifier, Identifier providerLocalIdentifier, IProviderEndpoint providerEndpoint, int? servicePriority, int? uriPriority) { return new IdentifierDiscoveryResult(providerEndpoint, claimedIdentifier, userSuppliedIdentifier, providerLocalIdentifier, servicePriority, uriPriority); } diff --git a/src/DotNetOpenAuth/OpenId/Extensions/UI/UIRequest.cs b/src/DotNetOpenAuth/OpenId/Extensions/UI/UIRequest.cs index 61e6f85..dddb1a6 100644 --- a/src/DotNetOpenAuth/OpenId/Extensions/UI/UIRequest.cs +++ b/src/DotNetOpenAuth/OpenId/Extensions/UI/UIRequest.cs @@ -28,8 +28,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.UI { /// <see cref="UIModes.Popup"/>. </para> /// <para>An RP may determine whether an arbitrary OP supports this extension (and thereby determine /// whether to use a standard full window redirect or a popup) via the - /// <see cref="IProviderEndpoint.IsExtensionSupported"/> method on the <see cref="DotNetOpenAuth.OpenId.RelyingParty.IAuthenticationRequest.Provider"/> - /// object.</para> + /// <see cref="OpenIdUtilities.IsExtensionSupported<T>(IProviderEndpoint)"/> method.</para> /// </remarks> public sealed class UIRequest : IOpenIdMessageExtension, IMessageWithEvents { /// <summary> diff --git a/src/DotNetOpenAuth/OpenId/OpenIdUtilities.cs b/src/DotNetOpenAuth/OpenId/OpenIdUtilities.cs index 9c7754a..4845c17 100644 --- a/src/DotNetOpenAuth/OpenId/OpenIdUtilities.cs +++ b/src/DotNetOpenAuth/OpenId/OpenIdUtilities.cs @@ -15,22 +15,94 @@ namespace DotNetOpenAuth.OpenId { using System.Web.UI; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OpenId.ChannelElements; + using DotNetOpenAuth.OpenId.DiscoveryServices; using DotNetOpenAuth.OpenId.Extensions; + using DotNetOpenAuth.OpenId.Messages; using DotNetOpenAuth.OpenId.Provider; using DotNetOpenAuth.OpenId.RelyingParty; -using DotNetOpenAuth.OpenId.DiscoveryServices; - using DotNetOpenAuth.OpenId.Messages; /// <summary> /// A set of utilities especially useful to OpenID. /// </summary> - internal static class OpenIdUtilities { + public static class OpenIdUtilities { /// <summary> /// The prefix to designate this library's proprietary parameters added to the protocol. /// </summary> internal const string CustomParameterPrefix = "dnoa."; /// <summary> + /// Checks whether the OpenId Identifier claims support for a given extension. + /// </summary> + /// <typeparam name="T">The extension whose support is being queried.</typeparam> + /// <param name="providerEndpoint">The provider endpoint.</param> + /// <returns> + /// True if support for the extension is advertised. False otherwise. + /// </returns> + /// <remarks> + /// Note that a true or false return value is no guarantee of a Provider's + /// support for or lack of support for an extension. The return value is + /// determined by how the authenticating user filled out his/her XRDS document only. + /// The only way to be sure of support for a given extension is to include + /// the extension in the request and see if a response comes back for that extension. + /// </remarks> + [SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "No parameter at all.")] + public static bool IsExtensionSupported<T>(this IProviderEndpoint providerEndpoint) where T : IOpenIdMessageExtension, new() { + Contract.Requires(providerEndpoint != null); + T extension = new T(); + return IsExtensionSupported(providerEndpoint, extension); + } + + /// <summary> + /// Checks whether the OpenId Identifier claims support for a given extension. + /// </summary> + /// <param name="providerEndpoint">The provider endpoint.</param> + /// <param name="extensionType">The extension whose support is being queried.</param> + /// <returns> + /// True if support for the extension is advertised. False otherwise. + /// </returns> + /// <remarks> + /// Note that a true or false return value is no guarantee of a Provider's + /// support for or lack of support for an extension. The return value is + /// determined by how the authenticating user filled out his/her XRDS document only. + /// The only way to be sure of support for a given extension is to include + /// the extension in the request and see if a response comes back for that extension. + /// </remarks> + public static bool IsExtensionSupported(this IProviderEndpoint providerEndpoint, Type extensionType) { + Contract.Requires(providerEndpoint != null); + Contract.Requires(extensionType != null); + Contract.Requires<ArgumentException>(typeof(IOpenIdMessageExtension).IsAssignableFrom(extensionType)); + var extension = (IOpenIdMessageExtension)Activator.CreateInstance(extensionType); + return IsExtensionSupported(providerEndpoint, extension); + } + + /// <summary> + /// Determines whether a given extension is supported by this endpoint. + /// </summary> + /// <param name="providerEndpoint">The provider endpoint.</param> + /// <param name="extension">An instance of the extension to check support for.</param> + /// <returns> + /// <c>true</c> if the extension is supported by this endpoint; otherwise, <c>false</c>. + /// </returns> + public static bool IsExtensionSupported(this IProviderEndpoint providerEndpoint, IOpenIdMessageExtension extension) { + Contract.Requires(providerEndpoint != null); + Contract.Requires<ArgumentNullException>(extension != null); + + // Consider the primary case. + if (providerEndpoint.IsTypeUriPresent(extension.TypeUri)) { + return true; + } + + // Consider the secondary cases. + if (extension.AdditionalSupportedTypeUris != null) { + if (extension.AdditionalSupportedTypeUris.Any(typeUri => providerEndpoint.IsTypeUriPresent(typeUri))) { + return true; + } + } + + return false; + } + + /// <summary> /// Gets the OpenID protocol instance for the version in a message. /// </summary> /// <param name="message">The message.</param> @@ -161,6 +233,8 @@ using DotNetOpenAuth.OpenId.DiscoveryServices; /// <summary> /// Gets the OpenID protocol used by the Provider. /// </summary> + /// <param name="providerDescription">The provider description.</param> + /// <returns>The OpenID protocol.</returns> internal static Protocol GetProtocol(this IProviderEndpoint providerDescription) { return Protocol.Lookup(providerDescription.Version); } @@ -168,6 +242,8 @@ using DotNetOpenAuth.OpenId.DiscoveryServices; /// <summary> /// Gets the value for the <see cref="IAuthenticationResponse.FriendlyIdentifierForDisplay"/> property. /// </summary> + /// <param name="discoveryResult">The discovery result.</param> + /// <returns>A human-readable, abbreviated (but not secure) identifier the user MAY recognize as his own.</returns> internal static string GetFriendlyIdentifierForDisplay(this IIdentifierDiscoveryResult discoveryResult) { Contract.Requires(discoveryResult != null); XriIdentifier xri = discoveryResult.ClaimedIdentifier as XriIdentifier; @@ -196,51 +272,6 @@ using DotNetOpenAuth.OpenId.DiscoveryServices; } /// <summary> - /// Checks whether the OpenId Identifier claims support for a given extension. - /// </summary> - /// <typeparam name="T">The extension whose support is being queried.</typeparam> - /// <param name="providerEndpoint">The provider endpoint.</param> - /// <returns> - /// True if support for the extension is advertised. False otherwise. - /// </returns> - /// <remarks> - /// Note that a true or false return value is no guarantee of a Provider's - /// support for or lack of support for an extension. The return value is - /// determined by how the authenticating user filled out his/her XRDS document only. - /// The only way to be sure of support for a given extension is to include - /// the extension in the request and see if a response comes back for that extension. - /// </remarks> - [SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "No parameter at all.")] - public static bool IsExtensionSupported<T>(this IProviderEndpoint providerEndpoint) where T : IOpenIdMessageExtension, new() { - Contract.Requires(providerEndpoint != null); - T extension = new T(); - return IsExtensionSupported(providerEndpoint, extension); - } - - /// <summary> - /// Checks whether the OpenId Identifier claims support for a given extension. - /// </summary> - /// <param name="providerEndpoint">The provider endpoint.</param> - /// <param name="extensionType">The extension whose support is being queried.</param> - /// <returns> - /// True if support for the extension is advertised. False otherwise. - /// </returns> - /// <remarks> - /// Note that a true or false return value is no guarantee of a Provider's - /// support for or lack of support for an extension. The return value is - /// determined by how the authenticating user filled out his/her XRDS document only. - /// The only way to be sure of support for a given extension is to include - /// the extension in the request and see if a response comes back for that extension. - /// </remarks> - public static bool IsExtensionSupported(this IProviderEndpoint providerEndpoint, Type extensionType) { - Contract.Requires(providerEndpoint != null); - Contract.Requires(extensionType != null); - Contract.Requires<ArgumentException>(typeof(IOpenIdMessageExtension).IsAssignableFrom(extensionType)); - var extension = (IOpenIdMessageExtension)Activator.CreateInstance(extensionType); - return IsExtensionSupported(providerEndpoint, extension); - } - - /// <summary> /// Determines whether a given type URI is present on the specified provider endpoint. /// </summary> /// <param name="providerEndpoint">The provider endpoint.</param> @@ -253,32 +284,5 @@ using DotNetOpenAuth.OpenId.DiscoveryServices; Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(typeUri)); return providerEndpoint.Capabilities.Contains(typeUri); } - - /// <summary> - /// Determines whether a given extension is supported by this endpoint. - /// </summary> - /// <param name="providerEndpoint">The provider endpoint.</param> - /// <param name="extension">An instance of the extension to check support for.</param> - /// <returns> - /// <c>true</c> if the extension is supported by this endpoint; otherwise, <c>false</c>. - /// </returns> - internal static bool IsExtensionSupported(this IProviderEndpoint providerEndpoint, IOpenIdMessageExtension extension) { - Contract.Requires(providerEndpoint != null); - Contract.Requires<ArgumentNullException>(extension != null); - - // Consider the primary case. - if (providerEndpoint.IsTypeUriPresent(extension.TypeUri)) { - return true; - } - - // Consider the secondary cases. - if (extension.AdditionalSupportedTypeUris != null) { - if (extension.AdditionalSupportedTypeUris.Any(typeUri => providerEndpoint.IsTypeUriPresent(typeUri))) { - return true; - } - } - - return false; - } } } diff --git a/src/DotNetOpenAuth/OpenId/OpenIdXrdsHelper.cs b/src/DotNetOpenAuth/OpenId/OpenIdXrdsHelper.cs index 0dfbe3c..e84035a 100644 --- a/src/DotNetOpenAuth/OpenId/OpenIdXrdsHelper.cs +++ b/src/DotNetOpenAuth/OpenId/OpenIdXrdsHelper.cs @@ -10,9 +10,9 @@ namespace DotNetOpenAuth.OpenId { using System.Diagnostics.Contracts; using System.Linq; using DotNetOpenAuth.Messaging; + using DotNetOpenAuth.OpenId.DiscoveryServices; using DotNetOpenAuth.OpenId.RelyingParty; using DotNetOpenAuth.Xrds; - using DotNetOpenAuth.OpenId.DiscoveryServices; /// <summary> /// Adds OpenID-specific extension methods to the XrdsDocument class. diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs index 78db244..467bed1 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs @@ -14,8 +14,8 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { using System.Web; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OpenId.ChannelElements; - using DotNetOpenAuth.OpenId.Messages; using DotNetOpenAuth.OpenId.DiscoveryServices; + using DotNetOpenAuth.OpenId.Messages; /// <summary> /// Facilitates customization and creation and an authentication request @@ -373,6 +373,14 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { return CreateInternal(userSuppliedIdentifier, relyingParty, realm, returnToUrl, serviceEndpoints, createNewAssociationsAsNeeded); } + /// <summary> + /// Creates an instance of <see cref="AuthenticationRequest"/> FOR TESTING PURPOSES ONLY. + /// </summary> + /// <param name="discoveryResult">The discovery result.</param> + /// <param name="realm">The realm.</param> + /// <param name="returnTo">The return to.</param> + /// <param name="rp">The relying party.</param> + /// <returns>The instantiated <see cref="AuthenticationRequest"/>.</returns> internal static AuthenticationRequest CreateForTest(IIdentifierDiscoveryResult discoveryResult, Realm realm, Uri returnTo, OpenIdRelyingParty rp) { return new AuthenticationRequest(discoveryResult, realm, returnTo, rp); } diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/IProviderEndpoint.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/IProviderEndpoint.cs index 930ef66..79b5055 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/IProviderEndpoint.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/IProviderEndpoint.cs @@ -49,7 +49,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { [ContractClassFor(typeof(IProviderEndpoint))] internal abstract class IProviderEndpointContract : IProviderEndpoint { /// <summary> - /// Initializes a new instance of the <see cref="IProviderEndpointContract"/> class. + /// Prevents a default instance of the <see cref="IProviderEndpointContract"/> class from being created. /// </summary> private IProviderEndpointContract() { } diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAuthenticationResponse.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAuthenticationResponse.cs index 4ce4935..657768b 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAuthenticationResponse.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAuthenticationResponse.cs @@ -11,8 +11,8 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { using System.Linq; using System.Web; using DotNetOpenAuth.Messaging; - using DotNetOpenAuth.OpenId.Messages; using DotNetOpenAuth.OpenId.DiscoveryServices; + using DotNetOpenAuth.OpenId.Messages; /// <summary> /// Wraps a positive assertion response in an <see cref="IAuthenticationResponse"/> instance diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/SimpleXrdsProviderEndpoint.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/SimpleXrdsProviderEndpoint.cs index b67d12b..1b8ce75 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/SimpleXrdsProviderEndpoint.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/SimpleXrdsProviderEndpoint.cs @@ -6,9 +6,9 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { using System; - using DotNetOpenAuth.OpenId.Messages; -using System.Collections.ObjectModel; + using System.Collections.ObjectModel; using DotNetOpenAuth.Messaging; + using DotNetOpenAuth.OpenId.Messages; /// <summary> /// A very simple IXrdsProviderEndpoint implementation for verifying that all positive |