summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2009-06-02 19:33:48 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2009-06-02 19:33:48 -0700
commit073ae9e3b22b6e37990e276ff1d5206edbc23551 (patch)
treed511dc5bec940e5c36967aa2ebbca289b7a5a3c1 /src
parent507fe96dc2835078ac649bcc36395275f4736217 (diff)
downloadDotNetOpenAuth-073ae9e3b22b6e37990e276ff1d5206edbc23551.zip
DotNetOpenAuth-073ae9e3b22b6e37990e276ff1d5206edbc23551.tar.gz
DotNetOpenAuth-073ae9e3b22b6e37990e276ff1d5206edbc23551.tar.bz2
Added RelyingParty.IAuthenticationResponse.Provider property.
Resolves Trac ticket 71.
Diffstat (limited to 'src')
-rw-r--r--src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj1
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/ProviderEndpointDescriptionTests.cs62
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAnonymousResponseTests.cs14
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/RelyingParty/ServiceEndpointTests.cs40
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/UriIdentifierTests.cs2
-rw-r--r--src/DotNetOpenAuth/OpenId/ProviderEndpointDescription.cs107
-rw-r--r--src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationResponseSnapshot.cs8
-rw-r--r--src/DotNetOpenAuth/OpenId/RelyingParty/FailedAuthenticationResponse.cs9
-rw-r--r--src/DotNetOpenAuth/OpenId/RelyingParty/IAuthenticationRequest.cs2
-rw-r--r--src/DotNetOpenAuth/OpenId/RelyingParty/IAuthenticationResponse.cs7
-rw-r--r--src/DotNetOpenAuth/OpenId/RelyingParty/NegativeAuthenticationResponse.cs9
-rw-r--r--src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAnonymousResponse.cs17
-rw-r--r--src/DotNetOpenAuth/OpenId/RelyingParty/ServiceEndpoint.cs82
13 files changed, 252 insertions, 108 deletions
diff --git a/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj b/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj
index 32e0acc..3957cfa 100644
--- a/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj
+++ b/src/DotNetOpenAuth.Test/DotNetOpenAuth.Test.csproj
@@ -211,6 +211,7 @@
<Compile Include="OpenId\OpenIdCoordinator.cs" />
<Compile Include="OpenId\AssociationHandshakeTests.cs" />
<Compile Include="OpenId\OpenIdTestBase.cs" />
+ <Compile Include="OpenId\ProviderEndpointDescriptionTests.cs" />
<Compile Include="OpenId\Provider\AnonymousRequestTests.cs" />
<Compile Include="OpenId\Provider\AuthenticationRequestTest.cs" />
<Compile Include="OpenId\Provider\HostProcessedRequestTests.cs" />
diff --git a/src/DotNetOpenAuth.Test/OpenId/ProviderEndpointDescriptionTests.cs b/src/DotNetOpenAuth.Test/OpenId/ProviderEndpointDescriptionTests.cs
new file mode 100644
index 0000000..005b8a0
--- /dev/null
+++ b/src/DotNetOpenAuth.Test/OpenId/ProviderEndpointDescriptionTests.cs
@@ -0,0 +1,62 @@
+//-----------------------------------------------------------------------
+// <copyright file="ProviderEndpointDescriptionTests.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.Test.OpenId {
+ using System;
+ using DotNetOpenAuth.OpenId;
+ using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration;
+ using DotNetOpenAuth.OpenId.Messages;
+ using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+ [TestClass]
+ public class ProviderEndpointDescriptionTests : OpenIdTestBase {
+ private ProviderEndpointDescription se;
+
+ private string[] v20TypeUris = { Protocol.V20.ClaimedIdentifierServiceTypeURI };
+
+ [TestInitialize]
+ public override void SetUp() {
+ base.SetUp();
+
+ this.se = new ProviderEndpointDescription(OPUri, Protocol.V20.Version);
+ }
+
+ [TestMethod, ExpectedException(typeof(ArgumentNullException))]
+ public void IsExtensionSupportedNullType() {
+ this.se.IsExtensionSupported((Type)null);
+ }
+
+ [TestMethod, ExpectedException(typeof(ArgumentNullException))]
+ public void IsExtensionSupportedNullString() {
+ this.se.IsExtensionSupported((string)null);
+ }
+
+ [TestMethod, ExpectedException(typeof(ArgumentException))]
+ public void IsExtensionSupportedEmptyString() {
+ this.se.IsExtensionSupported(string.Empty);
+ }
+
+ [TestMethod, ExpectedException(typeof(ArgumentNullException))]
+ public void IsExtensionSupportedNullExtension() {
+ this.se.IsExtensionSupported((IOpenIdMessageExtension)null);
+ }
+
+ [TestMethod]
+ public void IsExtensionSupported() {
+ this.se = new ProviderEndpointDescription(OPUri, this.v20TypeUris);
+ Assert.IsFalse(this.se.IsExtensionSupported<ClaimsRequest>());
+ Assert.IsFalse(this.se.IsExtensionSupported(new ClaimsRequest()));
+ Assert.IsFalse(this.se.IsExtensionSupported("http://someextension/typeuri"));
+
+ this.se = new ProviderEndpointDescription(
+ OPUri,
+ new[] { Protocol.V20.ClaimedIdentifierServiceTypeURI, "http://someextension", Constants.sreg_ns });
+ Assert.IsTrue(this.se.IsExtensionSupported<ClaimsRequest>());
+ Assert.IsTrue(this.se.IsExtensionSupported(new ClaimsRequest()));
+ Assert.IsTrue(this.se.IsExtensionSupported("http://someextension"));
+ }
+ }
+}
diff --git a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAnonymousResponseTests.cs b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAnonymousResponseTests.cs
index 6452420..1418513 100644
--- a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAnonymousResponseTests.cs
+++ b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAnonymousResponseTests.cs
@@ -36,7 +36,21 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty {
Assert.IsNull(response.ClaimedIdentifier);
Assert.IsNull(response.FriendlyIdentifierForDisplay);
Assert.IsNull(response.Exception);
+ Assert.IsNull(response.Provider);
Assert.AreSame(ext, response.GetUntrustedExtension<ClaimsResponse>());
}
+
+ /// <summary>
+ /// Verifies the Provider property.
+ /// </summary>
+ [TestMethod]
+ public void ProviderTest() {
+ var responseMessage = new IndirectSignedResponse(Protocol.V20.Version, this.returnTo);
+ responseMessage.ProviderEndpoint = OPUri;
+ var response = new PositiveAnonymousResponse(responseMessage);
+ Assert.IsNotNull(response.Provider);
+ Assert.AreEqual(OPUri, response.Provider.Uri);
+ Assert.AreEqual(responseMessage.Version, response.Provider.Version);
+ }
}
}
diff --git a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/ServiceEndpointTests.cs b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/ServiceEndpointTests.cs
index 7b71eef..bd09bc9 100644
--- a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/ServiceEndpointTests.cs
+++ b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/ServiceEndpointTests.cs
@@ -173,46 +173,6 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty {
Assert.AreEqual("=!9B72.7DD1.50A9.5CCD", se.FriendlyIdentifierForDisplay);
}
- [TestMethod, ExpectedException(typeof(ArgumentNullException))]
- public void IsExtensionSupportedNullType() {
- ServiceEndpoint se = ServiceEndpoint.CreateForClaimedIdentifier(this.claimedXri, this.userSuppliedXri, this.localId, new ProviderEndpointDescription(this.providerEndpoint, this.v20TypeUris), this.servicePriority, this.uriPriority);
- se.IsExtensionSupported((Type)null);
- }
-
- [TestMethod, ExpectedException(typeof(ArgumentNullException))]
- public void IsExtensionSupportedNullString() {
- ServiceEndpoint se = ServiceEndpoint.CreateForClaimedIdentifier(this.claimedXri, this.userSuppliedXri, this.localId, new ProviderEndpointDescription(this.providerEndpoint, this.v20TypeUris), this.servicePriority, this.uriPriority);
- se.IsExtensionSupported((string)null);
- }
-
- [TestMethod, ExpectedException(typeof(ArgumentException))]
- public void IsExtensionSupportedEmptyString() {
- ServiceEndpoint se = ServiceEndpoint.CreateForClaimedIdentifier(this.claimedXri, this.userSuppliedXri, this.localId, new ProviderEndpointDescription(this.providerEndpoint, this.v20TypeUris), this.servicePriority, this.uriPriority);
- se.IsExtensionSupported(string.Empty);
- }
-
- [TestMethod, ExpectedException(typeof(ArgumentNullException))]
- public void IsExtensionSupportedNullExtension() {
- ServiceEndpoint se = ServiceEndpoint.CreateForClaimedIdentifier(this.claimedXri, this.userSuppliedXri, this.localId, new ProviderEndpointDescription(this.providerEndpoint, this.v20TypeUris), this.servicePriority, this.uriPriority);
- se.IsExtensionSupported((IOpenIdMessageExtension)null);
- }
-
- [TestMethod]
- public void IsExtensionSupported() {
- ServiceEndpoint se = ServiceEndpoint.CreateForClaimedIdentifier(this.claimedXri, this.userSuppliedXri, this.localId, new ProviderEndpointDescription(this.providerEndpoint, this.v20TypeUris), this.servicePriority, this.uriPriority);
- Assert.IsFalse(se.IsExtensionSupported<ClaimsRequest>());
- Assert.IsFalse(se.IsExtensionSupported(new ClaimsRequest()));
- Assert.IsFalse(se.IsExtensionSupported("http://someextension/typeuri"));
-
- ProviderEndpointDescription ped = new ProviderEndpointDescription(
- OPUri,
- new[] { Protocol.V20.ClaimedIdentifierServiceTypeURI, "http://someextension", Constants.sreg_ns });
- se = ServiceEndpoint.CreateForClaimedIdentifier(this.claimedXri, this.userSuppliedXri, this.localId, ped, this.servicePriority, this.uriPriority);
- Assert.IsTrue(se.IsExtensionSupported<ClaimsRequest>());
- Assert.IsTrue(se.IsExtensionSupported(new ClaimsRequest()));
- Assert.IsTrue(se.IsExtensionSupported("http://someextension"));
- }
-
[TestMethod]
public void IsTypeUriPresent() {
ServiceEndpoint se = ServiceEndpoint.CreateForClaimedIdentifier(this.claimedXri, this.userSuppliedXri, this.localId, new ProviderEndpointDescription(this.providerEndpoint, this.v20TypeUris), this.servicePriority, this.uriPriority);
diff --git a/src/DotNetOpenAuth.Test/OpenId/UriIdentifierTests.cs b/src/DotNetOpenAuth.Test/OpenId/UriIdentifierTests.cs
index 3b3f985..f1823e6 100644
--- a/src/DotNetOpenAuth.Test/OpenId/UriIdentifierTests.cs
+++ b/src/DotNetOpenAuth.Test/OpenId/UriIdentifierTests.cs
@@ -391,7 +391,7 @@ namespace DotNetOpenAuth.Test.OpenId {
// the ServiceEndpoint.Equals method.
Assert.AreEqual(expectSreg ? 2 : 1, se.ProviderSupportedServiceTypeUris.Count);
Assert.IsTrue(se.ProviderSupportedServiceTypeUris.Contains(protocol.ClaimedIdentifierServiceTypeURI));
- Assert.AreEqual(expectSreg, se.IsExtensionSupported(new ClaimsRequest()));
+ Assert.AreEqual(expectSreg, se.IsExtensionSupported<ClaimsRequest>());
}
private void DiscoverXrds(string page, ProtocolVersion version, Identifier expectedLocalId, string providerEndpoint) {
diff --git a/src/DotNetOpenAuth/OpenId/ProviderEndpointDescription.cs b/src/DotNetOpenAuth/OpenId/ProviderEndpointDescription.cs
index 29d04ba..0751f51 100644
--- a/src/DotNetOpenAuth/OpenId/ProviderEndpointDescription.cs
+++ b/src/DotNetOpenAuth/OpenId/ProviderEndpointDescription.cs
@@ -10,6 +10,8 @@ namespace DotNetOpenAuth.OpenId {
using System.Collections.ObjectModel;
using System.Linq;
using DotNetOpenAuth.Messaging;
+ using DotNetOpenAuth.OpenId.Messages;
+ using DotNetOpenAuth.OpenId.RelyingParty;
/// <summary>
/// Describes some OpenID Provider endpoint and its capabilities.
@@ -17,7 +19,8 @@ namespace DotNetOpenAuth.OpenId {
/// <remarks>
/// This is an immutable type.
/// </remarks>
- internal class ProviderEndpointDescription {
+ [Serializable]
+ internal class ProviderEndpointDescription : IProviderEndpoint {
/// <summary>
/// Initializes a new instance of the <see cref="ProviderEndpointDescription"/> class.
/// </summary>
@@ -54,6 +57,24 @@ namespace DotNetOpenAuth.OpenId {
ErrorUtilities.VerifyProtocol(this.ProtocolVersion != null, OpenIdStrings.ProviderVersionUnrecognized, this.Endpoint);
}
+ #region IProviderEndpoint Properties
+
+ /// <summary>
+ /// Gets the detected version of OpenID implemented by the Provider.
+ /// </summary>
+ Version IProviderEndpoint.Version {
+ get { return this.ProtocolVersion; }
+ }
+
+ /// <summary>
+ /// Gets the URL that the OpenID Provider receives authentication requests at.
+ /// </summary>
+ Uri IProviderEndpoint.Uri {
+ get { return this.Endpoint; }
+ }
+
+ #endregion
+
/// <summary>
/// Gets the URL that the OpenID Provider listens for incoming OpenID messages on.
/// </summary>
@@ -71,6 +92,88 @@ namespace DotNetOpenAuth.OpenId {
/// <summary>
/// Gets the collection of service type URIs found in the XRDS document describing this Provider.
/// </summary>
- internal ReadOnlyCollection<string> Capabilities { get; private set; }
+ internal ReadOnlyCollection<string> Capabilities { get; private set; }
+
+ #region IProviderEndpoint Methods
+
+ /// <summary>
+ /// Checks whether the OpenId Identifier claims support for a given extension.
+ /// </summary>
+ /// <typeparam name="T">The extension whose support is being queried.</typeparam>
+ /// <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 bool IsExtensionSupported<T>() where T : IOpenIdMessageExtension, new() {
+ T extension = new T();
+ return this.IsExtensionSupported(extension);
+ }
+
+ /// <summary>
+ /// Checks whether the OpenId Identifier claims support for a given extension.
+ /// </summary>
+ /// <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 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);
+ }
+
+ #endregion
+
+ /// <summary>
+ /// Determines whether some extension is supported by the Provider.
+ /// </summary>
+ /// <param name="extensionUri">The extension URI.</param>
+ /// <returns>
+ /// <c>true</c> if the extension is supported; otherwise, <c>false</c>.
+ /// </returns>
+ protected internal bool IsExtensionSupported(string extensionUri) {
+ ErrorUtilities.VerifyNonZeroLength(extensionUri, "extensionUri");
+ ErrorUtilities.VerifyOperation(this.Capabilities != null, OpenIdStrings.ExtensionLookupSupportUnavailable);
+ return this.Capabilities.Contains(extensionUri);
+ }
+
+ /// <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>
+ protected internal 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;
+ }
}
}
diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationResponseSnapshot.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationResponseSnapshot.cs
index 5ab7ec4..5bf60d6 100644
--- a/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationResponseSnapshot.cs
+++ b/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationResponseSnapshot.cs
@@ -32,6 +32,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
this.ClaimedIdentifier = copyFrom.ClaimedIdentifier;
this.FriendlyIdentifierForDisplay = copyFrom.FriendlyIdentifierForDisplay;
this.Status = copyFrom.Status;
+ this.Provider = copyFrom.Provider;
this.callbackArguments = copyFrom.GetCallbackArguments();
}
@@ -94,6 +95,13 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
public AuthenticationStatus Status { get; private set; }
/// <summary>
+ /// Gets information about the OpenId Provider, as advertised by the
+ /// OpenID discovery documents found at the <see cref="ClaimedIdentifier"/>
+ /// location.
+ /// </summary>
+ public IProviderEndpoint Provider { get; private set; }
+
+ /// <summary>
/// Gets the details regarding a failed authentication attempt, if available.
/// This will be set if and only if <see cref="Status"/> is <see cref="AuthenticationStatus.Failed"/>.
/// </summary>
diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/FailedAuthenticationResponse.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/FailedAuthenticationResponse.cs
index 0dc21bb..b01761a 100644
--- a/src/DotNetOpenAuth/OpenId/RelyingParty/FailedAuthenticationResponse.cs
+++ b/src/DotNetOpenAuth/OpenId/RelyingParty/FailedAuthenticationResponse.cs
@@ -97,6 +97,15 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
}
/// <summary>
+ /// Gets information about the OpenId Provider, as advertised by the
+ /// OpenID discovery documents found at the <see cref="ClaimedIdentifier"/>
+ /// location.
+ /// </summary>
+ public IProviderEndpoint Provider {
+ get { throw new NotSupportedException(); }
+ }
+
+ /// <summary>
/// Gets the details regarding a failed authentication attempt, if available.
/// This will be set if and only if <see cref="Status"/> is <see cref="AuthenticationStatus.Failed"/>.
/// </summary>
diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/IAuthenticationRequest.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/IAuthenticationRequest.cs
index 0bfcaf5..8414031 100644
--- a/src/DotNetOpenAuth/OpenId/RelyingParty/IAuthenticationRequest.cs
+++ b/src/DotNetOpenAuth/OpenId/RelyingParty/IAuthenticationRequest.cs
@@ -88,7 +88,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// <summary>
/// Gets information about the OpenId Provider, as advertised by the
- /// OpenId discovery documents found at the <see cref="ClaimedIdentifier"/>
+ /// OpenID discovery documents found at the <see cref="ClaimedIdentifier"/>
/// location.
/// </summary>
IProviderEndpoint Provider { get; }
diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/IAuthenticationResponse.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/IAuthenticationResponse.cs
index afca13d..0bb05e1 100644
--- a/src/DotNetOpenAuth/OpenId/RelyingParty/IAuthenticationResponse.cs
+++ b/src/DotNetOpenAuth/OpenId/RelyingParty/IAuthenticationResponse.cs
@@ -79,6 +79,13 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
AuthenticationStatus Status { get; }
/// <summary>
+ /// Gets information about the OpenId Provider, as advertised by the
+ /// OpenID discovery documents found at the <see cref="ClaimedIdentifier"/>
+ /// location.
+ /// </summary>
+ IProviderEndpoint Provider { get; }
+
+ /// <summary>
/// Gets the details regarding a failed authentication attempt, if available.
/// This will be set if and only if <see cref="Status"/> is <see cref="AuthenticationStatus.Failed"/>.
/// </summary>
diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/NegativeAuthenticationResponse.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/NegativeAuthenticationResponse.cs
index cd68a81..2a934e3 100644
--- a/src/DotNetOpenAuth/OpenId/RelyingParty/NegativeAuthenticationResponse.cs
+++ b/src/DotNetOpenAuth/OpenId/RelyingParty/NegativeAuthenticationResponse.cs
@@ -96,6 +96,15 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
}
/// <summary>
+ /// Gets information about the OpenId Provider, as advertised by the
+ /// OpenID discovery documents found at the <see cref="ClaimedIdentifier"/>
+ /// location.
+ /// </summary>
+ public IProviderEndpoint Provider {
+ get { throw new NotSupportedException(); }
+ }
+
+ /// <summary>
/// Gets the details regarding a failed authentication attempt, if available.
/// This will be set if and only if <see cref="Status"/> is <see cref="AuthenticationStatus.Failed"/>.
/// </summary>
diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAnonymousResponse.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAnonymousResponse.cs
index a28de12..6a5e971 100644
--- a/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAnonymousResponse.cs
+++ b/src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAnonymousResponse.cs
@@ -24,6 +24,11 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
private readonly IndirectSignedResponse response;
/// <summary>
+ /// Information about the OP endpoint that issued this assertion.
+ /// </summary>
+ private readonly ProviderEndpointDescription provider;
+
+ /// <summary>
/// Initializes a new instance of the <see cref="PositiveAnonymousResponse"/> class.
/// </summary>
/// <param name="response">The response message.</param>
@@ -32,6 +37,9 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
ErrorUtilities.VerifyArgumentNotNull(response, "response");
this.response = response;
+ if (response.ProviderEndpoint != null && response.Version != null) {
+ this.provider = new ProviderEndpointDescription(response.ProviderEndpoint, response.Version);
+ }
}
#region IAuthenticationResponse Properties
@@ -97,6 +105,15 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
}
/// <summary>
+ /// Gets information about the OpenId Provider, as advertised by the
+ /// OpenID discovery documents found at the <see cref="ClaimedIdentifier"/>
+ /// location.
+ /// </summary>
+ public IProviderEndpoint Provider {
+ get { return this.provider; }
+ }
+
+ /// <summary>
/// Gets the details regarding a failed authentication attempt, if available.
/// This will be set if and only if <see cref="Status"/> is <see cref="AuthenticationStatus.Failed"/>.
/// </summary>
diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/ServiceEndpoint.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/ServiceEndpoint.cs
index a56d4e7..88264f5 100644
--- a/src/DotNetOpenAuth/OpenId/RelyingParty/ServiceEndpoint.cs
+++ b/src/DotNetOpenAuth/OpenId/RelyingParty/ServiceEndpoint.cs
@@ -94,26 +94,10 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// <summary>
/// Gets the URL that the OpenID Provider receives authentication requests at.
/// </summary>
- Uri IProviderEndpoint.Uri { get { return this.ProviderEndpoint; } }
-
- /// <summary>
- /// Gets the URL which accepts OpenID Authentication protocol messages.
- /// </summary>
- /// <remarks>
- /// Obtained by performing discovery on the User-Supplied Identifier.
- /// This value MUST be an absolute HTTP or HTTPS URL.
- /// </remarks>
- public Uri ProviderEndpoint {
+ Uri IProviderEndpoint.Uri {
get { return this.ProviderDescription.Endpoint; }
}
- /*
- /// <summary>
- /// An Identifier for an OpenID Provider.
- /// </summary>
- public Identifier ProviderIdentifier { get; private set; }
- */
-
/// <summary>
/// Gets the Identifier that was presented by the end user to the Relying Party,
/// or selected by the user at the OpenID Provider.
@@ -224,7 +208,9 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// <summary>
/// Gets the detected version of OpenID implemented by the Provider.
/// </summary>
- Version IProviderEndpoint.Version { get { return Protocol.Version; } }
+ Version IProviderEndpoint.Version {
+ get { return this.ProviderDescription.ProtocolVersion; }
+ }
/// <summary>
/// Gets an XRDS sorting routine that uses the XRDS Service/@Priority
@@ -279,6 +265,17 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
}
/// <summary>
+ /// Gets the URL which accepts OpenID Authentication protocol messages.
+ /// </summary>
+ /// <remarks>
+ /// Obtained by performing discovery on the User-Supplied Identifier.
+ /// This value MUST be an absolute HTTP or HTTPS URL.
+ /// </remarks>
+ internal Uri ProviderEndpoint {
+ get { return this.ProviderDescription.Endpoint; }
+ }
+
+ /// <summary>
/// Gets a value indicating whether the <see cref="ProviderEndpoint"/> is using an encrypted channel.
/// </summary>
internal bool IsSecure {
@@ -318,46 +315,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// <c>true</c> if the service type uri is present; <c>false</c> otherwise.
/// </returns>
public bool IsTypeUriPresent(string typeUri) {
- return this.IsExtensionSupported(typeUri);
- }
-
- /// <summary>
- /// Determines whether some extension is supported by the Provider.
- /// </summary>
- /// <param name="extensionUri">The extension URI.</param>
- /// <returns>
- /// <c>true</c> if the extension is supported; otherwise, <c>false</c>.
- /// </returns>
- public bool IsExtensionSupported(string extensionUri) {
- ErrorUtilities.VerifyNonZeroLength(extensionUri, "extensionUri");
-
- ErrorUtilities.VerifyOperation(this.ProviderSupportedServiceTypeUris != null, OpenIdStrings.ExtensionLookupSupportUnavailable);
- return this.ProviderSupportedServiceTypeUris.Contains(extensionUri);
- }
-
- /// <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;
+ return this.ProviderDescription.IsExtensionSupported(typeUri);
}
/// <summary>
@@ -368,8 +326,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// <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);
+ return this.ProviderDescription.IsExtensionSupported<T>();
}
/// <summary>
@@ -380,10 +337,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// <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);
+ return this.ProviderDescription.IsExtensionSupported(extensionType);
}
/// <summary>