diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2009-05-20 21:15:28 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2009-05-20 21:15:28 -0700 |
commit | 72172af6db41a234731c8fe13e25b55b0ceaf7d1 (patch) | |
tree | ecde234adb248b5d550c2b2db1377af512050ddb /src | |
parent | 83fb6d3b6a8397799b2e57b142b5b161568a0b5d (diff) | |
download | DotNetOpenAuth-72172af6db41a234731c8fe13e25b55b0ceaf7d1.zip DotNetOpenAuth-72172af6db41a234731c8fe13e25b55b0ceaf7d1.tar.gz DotNetOpenAuth-72172af6db41a234731c8fe13e25b55b0ceaf7d1.tar.bz2 |
Promoted OpenIdRelyingParty.CreateRequests methods from internal to public.
No implementation change. Just reordering of methods for StyleCop and changed a few doc comments.
Diffstat (limited to 'src')
-rw-r--r-- | src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs | 6 | ||||
-rw-r--r-- | src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs | 178 |
2 files changed, 94 insertions, 90 deletions
diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs index 5ed57ce..d806eeb 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs @@ -242,7 +242,10 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// <param name="realm">The realm.</param> /// <param name="returnToUrl">The return_to base URL.</param> /// <param name="createNewAssociationsAsNeeded">if set to <c>true</c>, associations that do not exist between this Relying Party and the asserting Providers are created before the authentication request is created.</param> - /// <returns>A sequence of authentication requests, any of which constitutes a valid identity assertion on the Claimed Identifier.</returns> + /// <returns> + /// A sequence of authentication requests, any of which constitutes a valid identity assertion on the Claimed Identifier. + /// Never null, but may be empty. + /// </returns> internal static IEnumerable<AuthenticationRequest> Create(Identifier userSuppliedIdentifier, OpenIdRelyingParty relyingParty, Realm realm, Uri returnToUrl, bool createNewAssociationsAsNeeded) { Contract.Requires(userSuppliedIdentifier != null); Contract.Requires(relyingParty != null); @@ -313,6 +316,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// <param name="createNewAssociationsAsNeeded">if set to <c>true</c>, associations that do not exist between this Relying Party and the asserting Providers are created before the authentication request is created.</param> /// <returns> /// A sequence of authentication requests, any of which constitutes a valid identity assertion on the Claimed Identifier. + /// Never null, but may be empty. /// </returns> /// <remarks> /// All data validation and cleansing steps must have ALREADY taken place diff --git a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs index 3762602..0b400da 100644 --- a/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs +++ b/src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingParty.cs @@ -321,86 +321,6 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { } /// <summary> - /// Gets an authentication response from a Provider. - /// </summary> - /// <returns>The processed authentication response if there is any; <c>null</c> otherwise.</returns> - /// <remarks> - /// <para>Requires an <see cref="HttpContext.Current">HttpContext.Current</see> context.</para> - /// </remarks> - public IAuthenticationResponse GetResponse() { - return this.GetResponse(this.Channel.GetRequestFromContext()); - } - - /// <summary> - /// Gets an authentication response from a Provider. - /// </summary> - /// <param name="httpRequestInfo">The HTTP request that may be carrying an authentication response from the Provider.</param> - /// <returns>The processed authentication response if there is any; <c>null</c> otherwise.</returns> - public IAuthenticationResponse GetResponse(HttpRequestInfo httpRequestInfo) { - Contract.Requires(httpRequestInfo != null); - try { - var message = this.Channel.ReadFromRequest(httpRequestInfo); - PositiveAssertionResponse positiveAssertion; - NegativeAssertionResponse negativeAssertion; - IndirectSignedResponse positiveExtensionOnly; - if ((positiveAssertion = message as PositiveAssertionResponse) != null) { - return new PositiveAuthenticationResponse(positiveAssertion, this); - } else if ((positiveExtensionOnly = message as IndirectSignedResponse) != null) { - return new PositiveAnonymousResponse(positiveExtensionOnly); - } else if ((negativeAssertion = message as NegativeAssertionResponse) != null) { - return new NegativeAuthenticationResponse(negativeAssertion); - } else if (message != null) { - Logger.OpenId.WarnFormat("Received unexpected message type {0} when expecting an assertion message.", message.GetType().Name); - } - - return null; - } catch (ProtocolException ex) { - return new FailedAuthenticationResponse(ex); - } - } - - #region IDisposable Members - - /// <summary> - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// </summary> - public void Dispose() { - this.Dispose(true); - GC.SuppressFinalize(this); - } - - #endregion - - /// <summary> - /// Determines whether some parameter name belongs to OpenID or this library - /// as a protocol or internal parameter name. - /// </summary> - /// <param name="parameterName">Name of the parameter.</param> - /// <returns> - /// <c>true</c> if the named parameter is a library- or protocol-specific parameter; otherwise, <c>false</c>. - /// </returns> - internal static bool IsOpenIdSupportingParameter(string parameterName) { - Protocol protocol = Protocol.Default; - return parameterName.StartsWith(protocol.openid.Prefix, StringComparison.OrdinalIgnoreCase) - || parameterName.StartsWith("dnoi.", StringComparison.Ordinal); - } - - /// <summary> - /// Creates a relying party that does not verify incoming messages against - /// nonce or association stores. - /// </summary> - /// <returns>The instantiated <see cref="OpenIdRelyingParty"/>.</returns> - /// <remarks> - /// Useful for previewing messages while - /// allowing them to be fully processed and verified later. - /// </remarks> - internal static OpenIdRelyingParty CreateNonVerifying() { - OpenIdRelyingParty rp = new OpenIdRelyingParty(); - rp.Channel = OpenIdChannel.CreateNonVerifyingChannel(); - return rp; - } - - /// <summary> /// Generates the authentication requests that can satisfy the requirements of some OpenID Identifier. /// </summary> /// <param name="userSuppliedIdentifier"> @@ -416,8 +336,8 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// responses from the OpenID Provider. /// </param> /// <returns> - /// An authentication request object that describes the HTTP response to - /// send to the user agent to initiate the authentication. + /// A sequence of authentication requests, any of which constitutes a valid identity assertion on the Claimed Identifier. + /// Never null, but may be empty. /// </returns> /// <remarks> /// <para>Any individual generated request can satisfy the authentication. @@ -427,7 +347,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// <para>No exception is thrown if no OpenID endpoints were discovered. /// An empty enumerable is returned instead.</para> /// </remarks> - internal IEnumerable<IAuthenticationRequest> CreateRequests(Identifier userSuppliedIdentifier, Realm realm, Uri returnToUrl) { + public IEnumerable<IAuthenticationRequest> CreateRequests(Identifier userSuppliedIdentifier, Realm realm, Uri returnToUrl) { Contract.Requires(userSuppliedIdentifier != null); Contract.Requires(realm != null); Contract.Requires(returnToUrl != null); @@ -450,8 +370,8 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// your realm would typically be https://www.example.com/. /// </param> /// <returns> - /// An authentication request object that describes the HTTP response to - /// send to the user agent to initiate the authentication. + /// A sequence of authentication requests, any of which constitutes a valid identity assertion on the Claimed Identifier. + /// Never null, but may be empty. /// </returns> /// <remarks> /// <para>Any individual generated request can satisfy the authentication. @@ -463,7 +383,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// <para>Requires an <see cref="HttpContext.Current">HttpContext.Current</see> context.</para> /// </remarks> /// <exception cref="InvalidOperationException">Thrown if <see cref="HttpContext.Current">HttpContext.Current</see> == <c>null</c>.</exception> - internal IEnumerable<IAuthenticationRequest> CreateRequests(Identifier userSuppliedIdentifier, Realm realm) { + public IEnumerable<IAuthenticationRequest> CreateRequests(Identifier userSuppliedIdentifier, Realm realm) { Contract.Requires(userSuppliedIdentifier != null); Contract.Requires(realm != null); Contract.Ensures(Contract.Result<IEnumerable<IAuthenticationRequest>>() != null); @@ -494,8 +414,8 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// The Identifier supplied by the user. This may be a URL, an XRI or i-name. /// </param> /// <returns> - /// An authentication request object that describes the HTTP response to - /// send to the user agent to initiate the authentication. + /// A sequence of authentication requests, any of which constitutes a valid identity assertion on the Claimed Identifier. + /// Never null, but may be empty. /// </returns> /// <remarks> /// <para>Any individual generated request can satisfy the authentication. @@ -507,7 +427,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// <para>Requires an <see cref="HttpContext.Current">HttpContext.Current</see> context.</para> /// </remarks> /// <exception cref="InvalidOperationException">Thrown if <see cref="HttpContext.Current">HttpContext.Current</see> == <c>null</c>.</exception> - internal IEnumerable<IAuthenticationRequest> CreateRequests(Identifier userSuppliedIdentifier) { + public IEnumerable<IAuthenticationRequest> CreateRequests(Identifier userSuppliedIdentifier) { Contract.Requires(userSuppliedIdentifier != null); Contract.Ensures(Contract.Result<IEnumerable<IAuthenticationRequest>>() != null); ErrorUtilities.VerifyHttpContext(); @@ -530,6 +450,86 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { } /// <summary> + /// Gets an authentication response from a Provider. + /// </summary> + /// <returns>The processed authentication response if there is any; <c>null</c> otherwise.</returns> + /// <remarks> + /// <para>Requires an <see cref="HttpContext.Current">HttpContext.Current</see> context.</para> + /// </remarks> + public IAuthenticationResponse GetResponse() { + return this.GetResponse(this.Channel.GetRequestFromContext()); + } + + /// <summary> + /// Gets an authentication response from a Provider. + /// </summary> + /// <param name="httpRequestInfo">The HTTP request that may be carrying an authentication response from the Provider.</param> + /// <returns>The processed authentication response if there is any; <c>null</c> otherwise.</returns> + public IAuthenticationResponse GetResponse(HttpRequestInfo httpRequestInfo) { + Contract.Requires(httpRequestInfo != null); + try { + var message = this.Channel.ReadFromRequest(httpRequestInfo); + PositiveAssertionResponse positiveAssertion; + NegativeAssertionResponse negativeAssertion; + IndirectSignedResponse positiveExtensionOnly; + if ((positiveAssertion = message as PositiveAssertionResponse) != null) { + return new PositiveAuthenticationResponse(positiveAssertion, this); + } else if ((positiveExtensionOnly = message as IndirectSignedResponse) != null) { + return new PositiveAnonymousResponse(positiveExtensionOnly); + } else if ((negativeAssertion = message as NegativeAssertionResponse) != null) { + return new NegativeAuthenticationResponse(negativeAssertion); + } else if (message != null) { + Logger.OpenId.WarnFormat("Received unexpected message type {0} when expecting an assertion message.", message.GetType().Name); + } + + return null; + } catch (ProtocolException ex) { + return new FailedAuthenticationResponse(ex); + } + } + + #region IDisposable Members + + /// <summary> + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// </summary> + public void Dispose() { + this.Dispose(true); + GC.SuppressFinalize(this); + } + + #endregion + + /// <summary> + /// Determines whether some parameter name belongs to OpenID or this library + /// as a protocol or internal parameter name. + /// </summary> + /// <param name="parameterName">Name of the parameter.</param> + /// <returns> + /// <c>true</c> if the named parameter is a library- or protocol-specific parameter; otherwise, <c>false</c>. + /// </returns> + internal static bool IsOpenIdSupportingParameter(string parameterName) { + Protocol protocol = Protocol.Default; + return parameterName.StartsWith(protocol.openid.Prefix, StringComparison.OrdinalIgnoreCase) + || parameterName.StartsWith("dnoi.", StringComparison.Ordinal); + } + + /// <summary> + /// Creates a relying party that does not verify incoming messages against + /// nonce or association stores. + /// </summary> + /// <returns>The instantiated <see cref="OpenIdRelyingParty"/>.</returns> + /// <remarks> + /// Useful for previewing messages while + /// allowing them to be fully processed and verified later. + /// </remarks> + internal static OpenIdRelyingParty CreateNonVerifying() { + OpenIdRelyingParty rp = new OpenIdRelyingParty(); + rp.Channel = OpenIdChannel.CreateNonVerifyingChannel(); + return rp; + } + + /// <summary> /// Releases unmanaged and - optionally - managed resources /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> |