summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2008-12-26 12:59:20 -0800
committerAndrew <andrewarnott@gmail.com>2008-12-26 12:59:20 -0800
commit095f0d7bb1625c0710701d64d55fc631e66f5220 (patch)
treed56c2cc892d27d80e0a25e64644e958c704581dd
parentf22a1abb889539fa2943349b9cf1ed2bad7d8143 (diff)
downloadDotNetOpenAuth-095f0d7bb1625c0710701d64d55fc631e66f5220.zip
DotNetOpenAuth-095f0d7bb1625c0710701d64d55fc631e66f5220.tar.gz
DotNetOpenAuth-095f0d7bb1625c0710701d64d55fc631e66f5220.tar.bz2
Enabled the extension methods in the ServiceEndpoint class.
-rw-r--r--src/DotNetOpenAuth/DotNetOpenAuth.csproj1
-rw-r--r--src/DotNetOpenAuth/OpenId/Extensions/IExtension.cs60
-rw-r--r--src/DotNetOpenAuth/OpenId/OpenIdStrings.Designer.cs9
-rw-r--r--src/DotNetOpenAuth/OpenId/OpenIdStrings.resx3
-rw-r--r--src/DotNetOpenAuth/OpenId/RelyingParty/ServiceEndpoint.cs85
5 files changed, 65 insertions, 93 deletions
diff --git a/src/DotNetOpenAuth/DotNetOpenAuth.csproj b/src/DotNetOpenAuth/DotNetOpenAuth.csproj
index 583abd2..ecf4e77 100644
--- a/src/DotNetOpenAuth/DotNetOpenAuth.csproj
+++ b/src/DotNetOpenAuth/DotNetOpenAuth.csproj
@@ -178,7 +178,6 @@
<Compile Include="OpenId\Extensions\AliasManager.cs" />
<Compile Include="OpenId\Extensions\ExtensionBase.cs" />
<Compile Include="OpenId\Extensions\ExtensionArgumentsManager.cs" />
- <None Include="OpenId\Extensions\IExtension.cs" />
<Compile Include="OpenId\Extensions\OpenIdExtensionFactory.cs" />
<Compile Include="OpenId\Extensions\SimpleRegistration\ClaimsRequest.cs" />
<Compile Include="OpenId\Extensions\SimpleRegistration\ClaimsResponse.cs" />
diff --git a/src/DotNetOpenAuth/OpenId/Extensions/IExtension.cs b/src/DotNetOpenAuth/OpenId/Extensions/IExtension.cs
deleted file mode 100644
index bc4acda..0000000
--- a/src/DotNetOpenAuth/OpenId/Extensions/IExtension.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="IExtension.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace DotNetOpenAuth.OpenId.Extensions {
- using System;
- using System.Collections.Generic;
- using System.Text;
- using DotNetOpenAuth.OpenId.Messages;
-
- /// <summary>
- /// The contract an OpenID extension can implement for messages from relying party to provider
- /// to make handling extensions generally easier.
- /// Extensions are not required to implement this interface, however.
- /// </summary>
- internal interface IExtensionRequest : IOpenIdProtocolMessageExtension {
- /// <summary>
- /// Returns the fields this extension should add to an authentication request.
- /// </summary>
- IDictionary<string, string> Serialize(RelyingParty.IAuthenticationRequest authenticationRequest);
-
- /// <summary>
- /// Reads the extension information on an authentication request to the provider.
- /// </summary>
- /// <param name="fields">The fields belonging to the extension.</param>
- /// <param name="request">The incoming OpenID request carrying the extension.</param>
- /// <param name="typeUri">The actual extension TypeUri that was recognized in the message.</param>
- /// <returns>
- /// True if the extension found a valid set of recognized parameters in the request,
- /// false otherwise.
- /// </returns>
- bool Deserialize(IDictionary<string, string> fields, Provider.IRequest request, string typeUri);
- }
-
- /// <summary>
- /// The contract an OpenID extension can implement for messages from provider to relying party
- /// to make handling extensions generally easier.
- /// Extensions are not required to implement this interface, however.
- /// </summary>
- internal interface IExtensionResponse : IOpenIdProtocolMessageExtension {
- /// <summary>
- /// Returns the fields this extension should add to an authentication response.
- /// </summary>
- IDictionary<string, string> Serialize(Provider.IRequest authenticationRequest);
-
- /// <summary>
- /// Reads a Provider's response for extension values.
- /// </summary>
- /// <param name="fields">The fields belonging to the extension.</param>
- /// <param name="response">The incoming OpenID response carrying the extension.</param>
- /// <param name="typeUri">The actual extension TypeUri that was recognized in the message.</param>
- /// <returns>
- /// True if the extension found a valid set of recognized parameters in the response,
- /// false otherwise.
- /// </returns>
- bool Deserialize(IDictionary<string, string> fields, RelyingParty.IAuthenticationResponse response, string typeUri);
- }
-}
diff --git a/src/DotNetOpenAuth/OpenId/OpenIdStrings.Designer.cs b/src/DotNetOpenAuth/OpenId/OpenIdStrings.Designer.cs
index 7769455..ad62c27 100644
--- a/src/DotNetOpenAuth/OpenId/OpenIdStrings.Designer.cs
+++ b/src/DotNetOpenAuth/OpenId/OpenIdStrings.Designer.cs
@@ -295,6 +295,15 @@ namespace DotNetOpenAuth.OpenId {
}
/// <summary>
+ /// Looks up a localized string similar to The type must implement {0}..
+ /// </summary>
+ internal static string TypeMustImplementX {
+ get {
+ return ResourceManager.GetString("TypeMustImplementX", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Unsolicited assertions are not allowed from 1.0 OpenID Providers..
/// </summary>
internal static string UnsolicitedAssertionsNotAllowedFrom1xOPs {
diff --git a/src/DotNetOpenAuth/OpenId/OpenIdStrings.resx b/src/DotNetOpenAuth/OpenId/OpenIdStrings.resx
index e896fcf..c1d755b 100644
--- a/src/DotNetOpenAuth/OpenId/OpenIdStrings.resx
+++ b/src/DotNetOpenAuth/OpenId/OpenIdStrings.resx
@@ -195,6 +195,9 @@
<data name="SregInvalidBirthdate" xml:space="preserve">
<value>Invalid birthdate value. Must be in the form yyyy-MM-dd.</value>
</data>
+ <data name="TypeMustImplementX" xml:space="preserve">
+ <value>The type must implement {0}.</value>
+ </data>
<data name="UnsolicitedAssertionsNotAllowedFrom1xOPs" xml:space="preserve">
<value>Unsolicited assertions are not allowed from 1.0 OpenID Providers.</value>
</data>
diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/ServiceEndpoint.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/ServiceEndpoint.cs
index 25a77d5..15fa3bd 100644
--- a/src/DotNetOpenAuth/OpenId/RelyingParty/ServiceEndpoint.cs
+++ b/src/DotNetOpenAuth/OpenId/RelyingParty/ServiceEndpoint.cs
@@ -8,9 +8,12 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
using System;
using System.Collections.ObjectModel;
using System.Diagnostics;
+ using System.Globalization;
using System.IO;
+ using System.Linq;
using System.Text;
using DotNetOpenAuth.Messaging;
+ using DotNetOpenAuth.OpenId.Messages;
/// <summary>
/// Represents a single OP endpoint from discovery on some OpenID Identifier.
@@ -260,38 +263,56 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
return this.ProviderSupportedServiceTypeUris.Contains(extensionUri);
}
- ////public bool IsExtensionSupported(IExtension extension) {
- //// if (extension == null) throw new ArgumentNullException("extension");
-
- //// // Consider the primary case.
- //// if (IsExtensionSupported(extension.TypeUri)) {
- //// return true;
- //// }
- //// // Consider the secondary cases.
- //// if (extension.AdditionalSupportedTypeUris != null) {
- //// foreach (string extensionTypeUri in extension.AdditionalSupportedTypeUris) {
- //// if (IsExtensionSupported(extensionTypeUri)) {
- //// return true;
- //// }
- //// }
- //// }
- //// return false;
- ////}
-
- ////public bool IsExtensionSupported<T>() where T : Extensions.IExtension, new() {
- //// T extension = new T();
- //// return IsExtensionSupported(extension);
- ////}
-
- ////public bool IsExtensionSupported(Type extensionType) {
- //// if (extensionType == null) throw new ArgumentNullException("extensionType");
- //// if (!typeof(Extensions.IExtension).IsAssignableFrom(extensionType))
- //// throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
- //// Strings.TypeMustImplementX, typeof(Extensions.IExtension).FullName),
- //// "extensionType");
- //// var extension = (Extensions.IExtension)Activator.CreateInstance(extensionType);
- //// return IsExtensionSupported(extension);
- ////}
+ /// <summary>
+ /// Determines whether a given extension is supported by this endpoint.
+ /// </summary>
+ /// <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 bool IsExtensionSupported(IOpenIdMessageExtension extension) {
+ ErrorUtilities.VerifyArgumentNotNull(extension, "extension");
+
+ // Consider the primary case.
+ if (this.IsExtensionSupported(extension.TypeUri)) {
+ return true;
+ }
+
+ // Consider the secondary cases.
+ if (extension.AdditionalSupportedTypeUris != null) {
+ if (extension.AdditionalSupportedTypeUris.Any(typeUri => this.IsExtensionSupported(typeUri))) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /// <summary>
+ /// Determines whether a given extension is supported by this endpoint.
+ /// </summary>
+ /// <typeparam name="T">The type of extension to check support for on this endpoint.</typeparam>
+ /// <returns>
+ /// <c>true</c> if the extension is supported by this endpoint; otherwise, <c>false</c>.
+ /// </returns>
+ public bool IsExtensionSupported<T>() where T : IOpenIdMessageExtension, new() {
+ T extension = new T();
+ return this.IsExtensionSupported(extension);
+ }
+
+ /// <summary>
+ /// Determines whether a given extension is supported by this endpoint.
+ /// </summary>
+ /// <param name="extensionType">The type of extension to check support for on this endpoint.</param>
+ /// <returns>
+ /// <c>true</c> if the extension is supported by this endpoint; otherwise, <c>false</c>.
+ /// </returns>
+ public bool IsExtensionSupported(Type extensionType) {
+ ErrorUtilities.VerifyArgumentNotNull(extensionType, "extensionType");
+ ErrorUtilities.VerifyArgument(typeof(IOpenIdMessageExtension).IsAssignableFrom(extensionType), OpenIdStrings.TypeMustImplementX, typeof(IOpenIdMessageExtension).FullName);
+ var extension = (IOpenIdMessageExtension)Activator.CreateInstance(extensionType);
+ return this.IsExtensionSupported(extension);
+ }
/// <summary>
/// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.