diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2009-01-09 20:55:37 -0800 |
---|---|---|
committer | Andrew <andrewarnott@gmail.com> | 2009-01-09 20:55:37 -0800 |
commit | 588d1384431e23827921124bd438569231cbdfa7 (patch) | |
tree | 0b485c38e844d9dc68ec15ba09cd80383cd024ea | |
parent | 5e7ae77ffe5db726f5c5e78a969e6f92eb028d48 (diff) | |
download | DotNetOpenAuth-588d1384431e23827921124bd438569231cbdfa7.zip DotNetOpenAuth-588d1384431e23827921124bd438569231cbdfa7.tar.gz DotNetOpenAuth-588d1384431e23827921124bd438569231cbdfa7.tar.bz2 |
StyleCop work.
8 files changed, 160 insertions, 20 deletions
diff --git a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseTests.cs b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseTests.cs index f849a7d..7a194b7 100644 --- a/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/RelyingParty/PositiveAuthenticationResponseTests.cs @@ -6,18 +6,11 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty {
using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
+ using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.OpenId;
using DotNetOpenAuth.OpenId.Messages;
using DotNetOpenAuth.OpenId.RelyingParty;
using Microsoft.VisualStudio.TestTools.UnitTesting;
- using DotNetOpenAuth.OpenId.Provider;
- using RPAuthRequest = DotNetOpenAuth.OpenId.RelyingParty.IAuthenticationRequest;
- using OPAuthRequest = DotNetOpenAuth.OpenId.Provider.IAuthenticationRequest;
- using DotNetOpenAuth.Messaging;
- using DotNetOpenAuth.Test.Mocks;
[TestClass]
public class PositiveAuthenticationResponseTests : OpenIdTestBase {
@@ -34,7 +27,7 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty { /// </summary>
[TestMethod]
public void Valid() {
- PositiveAssertionResponse assertion = GetPositiveAssertion();
+ PositiveAssertionResponse assertion = this.GetPositiveAssertion();
var rp = CreateRelyingParty();
var authResponse = new PositiveAuthenticationResponse(assertion, rp);
Assert.AreEqual(AuthenticationStatus.Authenticated, authResponse.Status);
@@ -47,7 +40,7 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty { /// </summary>
[TestMethod, ExpectedException(typeof(ProtocolException))]
public void SpoofedClaimedIdDetectionSolicited() {
- PositiveAssertionResponse assertion = GetPositiveAssertion();
+ PositiveAssertionResponse assertion = this.GetPositiveAssertion();
assertion.ProviderEndpoint = new Uri("http://rogueOP");
var rp = CreateRelyingParty();
var authResponse = new PositiveAuthenticationResponse(assertion, rp);
@@ -56,10 +49,10 @@ namespace DotNetOpenAuth.Test.OpenId.RelyingParty { private PositiveAssertionResponse GetPositiveAssertion() {
Protocol protocol = Protocol.Default;
- PositiveAssertionResponse assertion = new PositiveAssertionResponse(protocol.Version, returnTo);
+ PositiveAssertionResponse assertion = new PositiveAssertionResponse(protocol.Version, this.returnTo);
assertion.ClaimedIdentifier = TestSupport.GetMockIdentifier(TestSupport.Scenarios.AutoApproval, this.MockResponder, protocol.ProtocolVersion);
assertion.LocalIdentifier = TestSupport.GetDelegateUrl(TestSupport.Scenarios.AutoApproval);
- assertion.ReturnTo = returnTo;
+ assertion.ReturnTo = this.returnTo;
assertion.ProviderEndpoint = TestSupport.GetFullUrl("/" + TestSupport.ProviderPage, null, false);
return assertion;
}
diff --git a/src/DotNetOpenAuth/OpenId/Messages/IndirectSignedResponse.cs b/src/DotNetOpenAuth/OpenId/Messages/IndirectSignedResponse.cs index 11a3c44..fdd2400 100644 --- a/src/DotNetOpenAuth/OpenId/Messages/IndirectSignedResponse.cs +++ b/src/DotNetOpenAuth/OpenId/Messages/IndirectSignedResponse.cs @@ -349,7 +349,7 @@ namespace DotNetOpenAuth.OpenId.Messages { string.Equals(this.Recipient.Scheme, this.ReturnTo.Scheme, StringComparison.OrdinalIgnoreCase) && string.Equals(this.Recipient.Authority, this.ReturnTo.Authority, StringComparison.OrdinalIgnoreCase) && string.Equals(this.Recipient.AbsolutePath, this.ReturnTo.AbsolutePath, StringComparison.Ordinal) && - IsQuerySubsetOf(this.Recipient.Query, this.ReturnTo.Query), + this.IsQuerySubsetOf(this.Recipient.Query, this.ReturnTo.Query), OpenIdStrings.ReturnToParamDoesNotMatchRequestUrl, Protocol.openid.return_to, this.ReturnTo, diff --git a/src/DotNetOpenAuth/OpenId/OpenIdXrdsHelper.cs b/src/DotNetOpenAuth/OpenId/OpenIdXrdsHelper.cs index b8cd802..935b369 100644 --- a/src/DotNetOpenAuth/OpenId/OpenIdXrdsHelper.cs +++ b/src/DotNetOpenAuth/OpenId/OpenIdXrdsHelper.cs @@ -36,6 +36,7 @@ namespace DotNetOpenAuth.OpenId { /// </summary> /// <param name="xrds">The XrdsDocument instance to use in this process.</param> /// <param name="claimedIdentifier">The claimed identifier that was used to discover this XRDS document.</param> + /// <param name="userSuppliedIdentifier">The user supplied identifier.</param> /// <returns> /// A sequence of OpenID Providers that can assert ownership of the <paramref name="claimedIdentifier"/>. /// </returns> @@ -94,7 +95,10 @@ namespace DotNetOpenAuth.OpenId { /// </summary> /// <param name="xrds">The XrdsDocument instance to use in this process.</param> /// <param name="claimedIdentifier">The claimed identifier.</param> - /// <returns>A sequence of the providers that can assert ownership of the given identifier.</returns> + /// <param name="userSuppliedIdentifier">The user supplied identifier.</param> + /// <returns> + /// A sequence of the providers that can assert ownership of the given identifier. + /// </returns> private static IEnumerable<ServiceEndpoint> GenerateClaimedIdentifierServiceEndpoints(this XrdsDocument xrds, UriIdentifier claimedIdentifier, UriIdentifier userSuppliedIdentifier) { return from service in xrds.FindClaimedIdentifierServices() from uri in service.UriElements diff --git a/src/DotNetOpenAuth/OpenId/Provider/AuthenticationRequest.cs b/src/DotNetOpenAuth/OpenId/Provider/AuthenticationRequest.cs index a77a8d7..96dcf1d 100644 --- a/src/DotNetOpenAuth/OpenId/Provider/AuthenticationRequest.cs +++ b/src/DotNetOpenAuth/OpenId/Provider/AuthenticationRequest.cs @@ -65,6 +65,9 @@ namespace DotNetOpenAuth.OpenId.Provider { this.IsDelegatedIdentifier = this.ClaimedIdentifier != null && this.ClaimedIdentifier != this.LocalIdentifier; } + /// <summary> + /// Gets a value indicating whether the response is ready to be created and sent. + /// </summary> public override bool IsResponseReady { get { // The null checks on the identifiers is to make sure that an identifier_select @@ -76,18 +79,39 @@ namespace DotNetOpenAuth.OpenId.Provider { #region IAuthenticationRequest Properties + /// <summary> + /// Gets the version of OpenID being used by the relying party that sent the request. + /// </summary> public ProtocolVersion RelyingPartyVersion { get { return Protocol.Lookup(this.RequestMessage.Version).ProtocolVersion; } } + /// <summary> + /// Gets a value indicating whether the consumer demands an immediate response. + /// If false, the consumer is willing to wait for the identity provider + /// to authenticate the user. + /// </summary> public bool Immediate { get { return this.RequestMessage.Immediate; } } + /// <summary> + /// Gets the URL the consumer site claims to use as its 'base' address. + /// </summary> public Realm Realm { get { return this.RequestMessage.Realm; } } + /// <summary> + /// Gets a value indicating whether verification of the return URL claimed by the Relying Party + /// succeeded. + /// </summary> + /// <remarks> + /// Return URL verification is only attempted if this property is queried. + /// The result of the verification is cached per request so calling this + /// property getter multiple times in one request is not a performance hit. + /// See OpenID Authentication 2.0 spec section 9.2.1. + /// </remarks> public bool IsReturnUrlDiscoverable { get { ErrorUtilities.VerifyInternal(Realm != null, "Realm should have been read or derived by now."); @@ -124,10 +148,37 @@ namespace DotNetOpenAuth.OpenId.Provider { } } + /// <summary> + /// Gets a value indicating whether the Provider should help the user + /// select a Claimed Identifier to send back to the relying party. + /// </summary> public bool IsDirectedIdentity { get; private set; } + /// <summary> + /// Gets a value indicating whether the requesting Relying Party is using a delegated URL. + /// </summary> + /// <remarks> + /// When delegated identifiers are used, the <see cref="ClaimedIdentifier"/> should not + /// be changed at the Provider during authentication. + /// Delegation is only detectable on requests originating from OpenID 2.0 relying parties. + /// A relying party implementing only OpenID 1.x may use delegation and this property will + /// return false anyway. + /// </remarks> public bool IsDelegatedIdentifier { get; private set; } + /// <summary> + /// Gets or sets the Local Identifier to this OpenID Provider of the user attempting + /// to authenticate. Check <see cref="IsDirectedIdentity"/> to see if + /// this value is valid. + /// </summary> + /// <remarks> + /// This may or may not be the same as the Claimed Identifier that the user agent + /// originally supplied to the relying party. The Claimed Identifier + /// endpoint may be delegating authentication to this provider using + /// this provider's local id, which is what this property contains. + /// Use this identifier when looking up this user in the provider's user account + /// list. + /// </remarks> public Identifier LocalIdentifier { get { return this.positiveResponse.LocalIdentifier; @@ -148,6 +199,21 @@ namespace DotNetOpenAuth.OpenId.Provider { } } + /// <summary> + /// Gets or sets the identifier that the user agent is claiming at the relying party site. + /// Check <see cref="IsDirectedIdentity"/> to see if this value is valid. + /// </summary> + /// <remarks> + /// <para>This property can only be set if <see cref="IsDelegatedIdentifier"/> is + /// false, to prevent breaking URL delegation.</para> + /// <para>This will not be the same as this provider's local identifier for the user + /// if the user has set up his/her own identity page that points to this + /// provider for authentication.</para> + /// <para>The provider may use this identifier for displaying to the user when + /// asking for the user's permission to authenticate to the relying party.</para> + /// </remarks> + /// <exception cref="InvalidOperationException">Thrown from the setter + /// if <see cref="IsDelegatedIdentifier"/> is true.</exception> public Identifier ClaimedIdentifier { get { return this.positiveResponse.ClaimedIdentifier; @@ -166,6 +232,11 @@ namespace DotNetOpenAuth.OpenId.Provider { } } + /// <summary> + /// Gets or sets a value indicating whether the provider has determined that the + /// <see cref="ClaimedIdentifier"/> belongs to the currently logged in user + /// and wishes to share this information with the consumer. + /// </summary> public bool? IsAuthenticated { get { return this.isAuthenticated; @@ -179,10 +250,16 @@ namespace DotNetOpenAuth.OpenId.Provider { #endregion + /// <summary> + /// Gets the original request message. + /// </summary> protected new CheckIdRequest RequestMessage { get { return (CheckIdRequest)base.RequestMessage; } } + /// <summary> + /// Gets the response message, once <see cref="IsResponseReady"/> is <c>true</c>. + /// </summary> protected override IProtocolMessage ResponseMessage { get { if (this.isAuthenticated.HasValue) { @@ -195,6 +272,22 @@ namespace DotNetOpenAuth.OpenId.Provider { #region IAuthenticationRequest Methods + /// <summary> + /// Adds an optional fragment (#fragment) portion to the ClaimedIdentifier. + /// Useful for identifier recycling. + /// </summary> + /// <param name="fragment">Should not include the # prefix character as that will be added internally. + /// May be null or the empty string to clear a previously set fragment.</param> + /// <remarks> + /// <para>Unlike the <see cref="ClaimedIdentifier"/> property, which can only be set if + /// using directed identity, this method can be called on any URI claimed identifier.</para> + /// <para>Because XRI claimed identifiers (the canonical IDs) are never recycled, + /// this method should<i>not</i> be called for XRIs.</para> + /// </remarks> + /// <exception cref="InvalidOperationException"> + /// Thrown when this method is called on an XRI, or on a directed identity + /// request before the <see cref="ClaimedIdentifier"/> property is set. + /// </exception> public void SetClaimedIdentifierFragment(string fragment) { ErrorUtilities.VerifyOperation(!(this.IsDirectedIdentity && this.ClaimedIdentifier == null), OpenIdStrings.ClaimedIdentifierMustBeSetFirst); ErrorUtilities.VerifyOperation(!(this.ClaimedIdentifier is XriIdentifier), OpenIdStrings.FragmentNotAllowedOnXRIs); diff --git a/src/DotNetOpenAuth/OpenId/Provider/AutoResponsiveRequest.cs b/src/DotNetOpenAuth/OpenId/Provider/AutoResponsiveRequest.cs index fe4debe..53998dc 100644 --- a/src/DotNetOpenAuth/OpenId/Provider/AutoResponsiveRequest.cs +++ b/src/DotNetOpenAuth/OpenId/Provider/AutoResponsiveRequest.cs @@ -35,10 +35,20 @@ namespace DotNetOpenAuth.OpenId.Provider { this.response = response; } + /// <summary> + /// Gets a value indicating whether the response is ready to be sent to the user agent. + /// </summary> + /// <remarks> + /// This property returns false if there are properties that must be set on this + /// request instance before the response can be sent. + /// </remarks> public override bool IsResponseReady { get { return true; } } + /// <summary> + /// Gets the response message, once <see cref="IsResponseReady"/> is <c>true</c>. + /// </summary> protected override IProtocolMessage ResponseMessage { get { return this.response; } } diff --git a/src/DotNetOpenAuth/OpenId/Provider/Request.cs b/src/DotNetOpenAuth/OpenId/Provider/Request.cs index 0d64c2e..6344f03 100644 --- a/src/DotNetOpenAuth/OpenId/Provider/Request.cs +++ b/src/DotNetOpenAuth/OpenId/Provider/Request.cs @@ -60,8 +60,19 @@ namespace DotNetOpenAuth.OpenId.Provider { #region IRequest Members + /// <summary> + /// Gets a value indicating whether the response is ready to be sent to the user agent. + /// </summary> + /// <value></value> + /// <remarks> + /// This property returns false if there are properties that must be set on this + /// request instance before the response can be sent. + /// </remarks> public abstract bool IsResponseReady { get; } + /// <summary> + /// Gets the response to send to the user agent. + /// </summary> public UserAgentResponse Response { get { if (this.cachedUserAgentResponse == null && this.IsResponseReady) { @@ -89,22 +100,38 @@ namespace DotNetOpenAuth.OpenId.Provider { #endregion + /// <summary> + /// Gets the instance of the hosting <see cref="OpenIdProvider"/>. + /// </summary> protected OpenIdProvider Provider { get { return this.provider; } } + /// <summary> + /// Gets the original request message. + /// </summary> protected IDirectedProtocolMessage RequestMessage { get { return this.request; } } + /// <summary> + /// Gets the response message, once <see cref="IsResponseReady"/> is <c>true</c>. + /// </summary> protected abstract IProtocolMessage ResponseMessage { get; } + /// <summary> + /// Gets the protocol version used in the request.. + /// </summary> protected Protocol Protocol { get { return Protocol.Lookup(this.RequestMessage.Version); } } #region IRequest Methods + /// <summary> + /// Adds an extension to the response to send to the relying party. + /// </summary> + /// <param name="extension">The extension to add to the response message.</param> public void AddResponseExtension(IOpenIdMessageExtension extension) { ErrorUtilities.VerifyArgumentNotNull(extension, "extension"); @@ -117,6 +144,13 @@ namespace DotNetOpenAuth.OpenId.Provider { this.ResetUserAgentResponse(); } + /// <summary> + /// Gets an extension sent from the relying party. + /// </summary> + /// <typeparam name="T">The type of the extension.</typeparam> + /// <returns> + /// An instance of the extension initialized with values passed in with the request. + /// </returns> public T GetExtension<T>() where T : IOpenIdMessageExtension, new() { if (this.extensibleMessage != null) { return this.extensibleMessage.Extensions.OfType<T>().SingleOrDefault(); @@ -125,6 +159,13 @@ namespace DotNetOpenAuth.OpenId.Provider { } } + /// <summary> + /// Gets an extension sent from the relying party. + /// </summary> + /// <param name="extensionType">The type of the extension.</param> + /// <returns> + /// An instance of the extension initialized with values passed in with the request. + /// </returns> public IOpenIdMessageExtension GetExtension(Type extensionType) { ErrorUtilities.VerifyArgumentNotNull(extensionType, "extensionType"); if (this.extensibleMessage != null) { diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/ServiceEndpoint.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/ServiceEndpoint.cs index 804a5ea..5c757e4 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/ServiceEndpoint.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/ServiceEndpoint.cs @@ -125,7 +125,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { public Identifier UserSuppliedIdentifier { get; private set; } /// <summary> - /// Gets the Identifier that the end user claims to own. + /// Gets or sets the Identifier that the end user claims to own. /// </summary> public Identifier ClaimedIdentifier { get { diff --git a/src/DotNetOpenAuth/OpenId/UriIdentifier.cs b/src/DotNetOpenAuth/OpenId/UriIdentifier.cs index 40d5549..b03963e 100644 --- a/src/DotNetOpenAuth/OpenId/UriIdentifier.cs +++ b/src/DotNetOpenAuth/OpenId/UriIdentifier.cs @@ -307,11 +307,10 @@ namespace DotNetOpenAuth.OpenId { /// <summary> /// Searches HTML for the HEAD META tags that describe OpenID provider services. /// </summary> - /// <param name="claimedIdentifier"> - /// The final URL that provided this HTML document. - /// This may not be the same as (this) userSuppliedIdentifier if the - /// userSuppliedIdentifier pointed to a 301 Redirect. - /// </param> + /// <param name="claimedIdentifier">The final URL that provided this HTML document. + /// This may not be the same as (this) userSuppliedIdentifier if the + /// userSuppliedIdentifier pointed to a 301 Redirect.</param> + /// <param name="userSuppliedIdentifier">The user supplied identifier.</param> /// <param name="html">The HTML that was downloaded and should be searched.</param> /// <returns> /// An initialized ServiceEndpoint if the OpenID Provider information was |