diff options
Diffstat (limited to 'src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty')
15 files changed, 22 insertions, 152 deletions
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/AssociationManager.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/AssociationManager.cs index e6feac1..dfb307b 100644 --- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/AssociationManager.cs +++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/AssociationManager.cs @@ -7,7 +7,6 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { using System; using System.Collections.Generic; - using System.Diagnostics.Contracts; using System.Linq; using System.Net; using System.Security; @@ -15,6 +14,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OpenId.ChannelElements; using DotNetOpenAuth.OpenId.Messages; + using Validation; /// <summary> /// Manages the establishment, storage and retrieval of associations at the relying party. diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/Associations.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/Associations.cs index f315bf0..44d7d07 100644 --- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/Associations.cs +++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/Associations.cs @@ -13,6 +13,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { using System.Diagnostics.Contracts; using System.Linq; using DotNetOpenAuth.Messaging; + using Validation; /// <summary> /// A dictionary of handle/Association pairs. @@ -23,7 +24,6 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// can break if the collection is changed by another thread during enumeration. /// </remarks> [DebuggerDisplay("Count = {assocs.Count}")] - [ContractVerification(true)] internal class Associations { /// <summary> /// The lookup table where keys are the association handles and values are the associations themselves. @@ -47,8 +47,6 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// </remarks> public IEnumerable<Association> Best { get { - Contract.Ensures(Contract.Result<IEnumerable<Association>>() != null); - lock (this.associations) { return this.associations.OrderByDescending(assoc => assoc.Issued); } @@ -61,13 +59,12 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// <param name="association">The association to add to the collection.</param> public void Set(Association association) { Requires.NotNull(association, "association"); - Contract.Ensures(this.Get(association.Handle) == association); lock (this.associations) { this.associations.Remove(association.Handle); // just in case one already exists. this.associations.Add(association); } - Contract.Assume(this.Get(association.Handle) == association); + Assumes.True(this.Get(association.Handle) == association); } /// <summary> diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/AuthenticationRequest.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/AuthenticationRequest.cs index 8af817e..92af297 100644 --- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/AuthenticationRequest.cs +++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/AuthenticationRequest.cs @@ -8,7 +8,6 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { using System; using System.Collections.Generic; using System.Collections.Specialized; - using System.Diagnostics.Contracts; using System.Linq; using System.Text; using System.Threading; @@ -18,6 +17,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OpenId.ChannelElements; using DotNetOpenAuth.OpenId.Messages; + using Validation; /// <summary> /// Facilitates customization and creation and an authentication request @@ -322,7 +322,6 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { Requires.NotNull(userSuppliedIdentifier, "userSuppliedIdentifier"); Requires.NotNull(relyingParty, "relyingParty"); Requires.NotNull(realm, "realm"); - Contract.Ensures(Contract.Result<IEnumerable<AuthenticationRequest>>() != null); // Normalize the portion of the return_to path that correlates to the realm for capitalization. // (so that if a web app base path is /MyApp/, but the URL of this request happens to be @@ -430,8 +429,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { ErrorUtilities.VerifyArgumentNotNull(relyingParty, "relyingParty"); ErrorUtilities.VerifyArgumentNotNull(realm, "realm"); ErrorUtilities.VerifyArgumentNotNull(serviceEndpoints, "serviceEndpoints"); - ////Contract.Ensures(Contract.Result<IEnumerable<AuthenticationRequest>>() != null); - + //// // If shared associations are required, then we had better have an association store. ErrorUtilities.VerifyOperation(!relyingParty.SecuritySettings.RequireAssociation || relyingParty.AssociationManager.HasAssociationStore, OpenIdStrings.AssociationStoreRequired); diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/Behaviors/GsaIcamProfile.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/Behaviors/GsaIcamProfile.cs index f05d354..8deed09 100644 --- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/Behaviors/GsaIcamProfile.cs +++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/Behaviors/GsaIcamProfile.cs @@ -7,7 +7,6 @@ namespace DotNetOpenAuth.OpenId.RelyingParty.Behaviors { using System; using System.Diagnostics.CodeAnalysis; - using System.Diagnostics.Contracts; using System.Linq; using DotNetOpenAuth.Configuration; using DotNetOpenAuth.Messaging; diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/CryptoKeyStoreAsRelyingPartyAssociationStore.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/CryptoKeyStoreAsRelyingPartyAssociationStore.cs index 7ad1346..ba69838 100644 --- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/CryptoKeyStoreAsRelyingPartyAssociationStore.cs +++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/CryptoKeyStoreAsRelyingPartyAssociationStore.cs @@ -6,9 +6,9 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { using System; - using System.Diagnostics.Contracts; using System.Linq; using DotNetOpenAuth.Messaging.Bindings; + using Validation; /// <summary> /// Wraps a standard <see cref="ICryptoKeyStore"/> so that it behaves as an association store. @@ -25,7 +25,6 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// <param name="keyStore">The key store.</param> internal CryptoKeyStoreAsRelyingPartyAssociationStore(ICryptoKeyStore keyStore) { Requires.NotNull(keyStore, "keyStore"); - Contract.Ensures(this.keyStore == keyStore); this.keyStore = keyStore; } diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/Extensions/ExtensionsInteropHelper.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/Extensions/ExtensionsInteropHelper.cs index d57fede..fde1462 100644 --- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/Extensions/ExtensionsInteropHelper.cs +++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/Extensions/ExtensionsInteropHelper.cs @@ -8,13 +8,13 @@ namespace DotNetOpenAuth.OpenId.RelyingParty.Extensions { using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; - using System.Diagnostics.Contracts; using System.Linq; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OpenId.Extensions; using DotNetOpenAuth.OpenId.Extensions.AttributeExchange; using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration; using DotNetOpenAuth.OpenId.Messages; + using Validation; /// <summary> /// A set of methods designed to assist in improving interop across different diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/Extensions/UIUtilities.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/Extensions/UIUtilities.cs index 049430a..a5de08b 100644 --- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/Extensions/UIUtilities.cs +++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/Extensions/UIUtilities.cs @@ -6,10 +6,10 @@ namespace DotNetOpenAuth.OpenId.RelyingParty.Extensions.UI { using System; - using System.Diagnostics.Contracts; using System.Globalization; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OpenId.RelyingParty; + using Validation; /// <summary> /// Constants used in implementing support for the UI extension. diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/FailedAuthenticationResponse.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/FailedAuthenticationResponse.cs index 764062e..ef50d10 100644 --- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/FailedAuthenticationResponse.cs +++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/FailedAuthenticationResponse.cs @@ -8,7 +8,6 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { using System; using System.Collections.Generic; using System.Diagnostics; - using System.Diagnostics.Contracts; using System.Globalization; using System.Text; using System.Web; @@ -16,6 +15,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { using DotNetOpenAuth.OpenId; using DotNetOpenAuth.OpenId.Messages; using DotNetOpenAuth.OpenId.RelyingParty; + using Validation; /// <summary> /// Wraps a failed authentication response in an <see cref="IAuthenticationResponse"/> instance diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/IRelyingPartyAssociationStore.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/IRelyingPartyAssociationStore.cs index a97449e..96f613c 100644 --- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/IRelyingPartyAssociationStore.cs +++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/IRelyingPartyAssociationStore.cs @@ -6,7 +6,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { using System; - using System.Diagnostics.Contracts; + using Validation; /// <summary> /// Stores <see cref="Association"/>s for lookup by their handle, keeping @@ -18,7 +18,6 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// to not be a performance drain. Because this balance can vary by host, it is the /// responsibility of the host to initiate this cleaning. /// </remarks> - [ContractClass(typeof(IRelyingPartyAssociationStoreContract))] public interface IRelyingPartyAssociationStore { /// <summary> /// Saves an <see cref="Association"/> for later recall. @@ -71,83 +70,4 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// </remarks> bool RemoveAssociation(Uri providerEndpoint, string handle); } - - /// <summary> - /// Code Contract for the <see cref="IRelyingPartyAssociationStore"/> class. - /// </summary> - [ContractClassFor(typeof(IRelyingPartyAssociationStore))] - internal abstract class IRelyingPartyAssociationStoreContract : IRelyingPartyAssociationStore { - #region IAssociationStore Members - - /// <summary> - /// Saves an <see cref="Association"/> for later recall. - /// </summary> - /// <param name="providerEndpoint">The Uri (for relying parties) or Smart/Dumb (for providers).</param> - /// <param name="association">The association to store.</param> - /// <remarks> - /// TODO: what should implementations do on association handle conflict? - /// </remarks> - void IRelyingPartyAssociationStore.StoreAssociation(Uri providerEndpoint, Association association) { - Requires.NotNull(providerEndpoint, "providerEndpoint"); - Requires.NotNull(association, "association"); - throw new NotImplementedException(); - } - - /// <summary> - /// Gets the best association (the one with the longest remaining life) for a given key. - /// </summary> - /// <param name="providerEndpoint">The Uri (for relying parties) or Smart/Dumb (for Providers).</param> - /// <param name="securityRequirements">The security requirements that the returned association must meet.</param> - /// <returns> - /// The requested association, or null if no unexpired <see cref="Association"/>s exist for the given key. - /// </returns> - /// <remarks> - /// In the event that multiple associations exist for the given - /// <paramref name="providerEndpoint"/>, it is important for the - /// implementation for this method to use the <paramref name="securityRequirements"/> - /// to pick the best (highest grade or longest living as the host's policy may dictate) - /// association that fits the security requirements. - /// Associations that are returned that do not meet the security requirements will be - /// ignored and a new association created. - /// </remarks> - Association IRelyingPartyAssociationStore.GetAssociation(Uri providerEndpoint, SecuritySettings securityRequirements) { - Requires.NotNull(providerEndpoint, "providerEndpoint"); - Requires.NotNull(securityRequirements, "securityRequirements"); - throw new NotImplementedException(); - } - - /// <summary> - /// Gets the association for a given key and handle. - /// </summary> - /// <param name="providerEndpoint">The Uri (for relying parties) or Smart/Dumb (for Providers).</param> - /// <param name="handle">The handle of the specific association that must be recalled.</param> - /// <returns> - /// The requested association, or null if no unexpired <see cref="Association"/>s exist for the given key and handle. - /// </returns> - Association IRelyingPartyAssociationStore.GetAssociation(Uri providerEndpoint, string handle) { - Requires.NotNull(providerEndpoint, "providerEndpoint"); - Contract.Requires(!string.IsNullOrEmpty(handle)); - throw new NotImplementedException(); - } - - /// <summary> - /// Removes a specified handle that may exist in the store. - /// </summary> - /// <param name="providerEndpoint">The Uri (for relying parties) or Smart/Dumb (for Providers).</param> - /// <param name="handle">The handle of the specific association that must be deleted.</param> - /// <returns> - /// True if the association existed in this store previous to this call. - /// </returns> - /// <remarks> - /// No exception should be thrown if the association does not exist in the store - /// before this call. - /// </remarks> - bool IRelyingPartyAssociationStore.RemoveAssociation(Uri providerEndpoint, string handle) { - Requires.NotNull(providerEndpoint, "providerEndpoint"); - Contract.Requires(!string.IsNullOrEmpty(handle)); - throw new NotImplementedException(); - } - - #endregion - } } diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/ISetupRequiredAuthenticationResponse.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/ISetupRequiredAuthenticationResponse.cs index 2d23cfc..4fc459f 100644 --- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/ISetupRequiredAuthenticationResponse.cs +++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/ISetupRequiredAuthenticationResponse.cs @@ -6,14 +6,12 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { using System; - using System.Diagnostics.Contracts; /// <summary> /// An interface to expose useful properties and functionality for handling /// authentication responses that are returned from Immediate authentication /// requests that require a subsequent request to be made in non-immediate mode. /// </summary> - [ContractClass(typeof(ISetupRequiredAuthenticationResponseContract))] public interface ISetupRequiredAuthenticationResponse { /// <summary> /// Gets the <see cref="Identifier"/> to pass to <see cref="OpenIdRelyingParty.CreateRequest(Identifier)"/> @@ -21,31 +19,4 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// </summary> Identifier UserSuppliedIdentifier { get; } } - - /// <summary> - /// Code contract class for the <see cref="ISetupRequiredAuthenticationResponse"/> type. - /// </summary> - [ContractClassFor(typeof(ISetupRequiredAuthenticationResponse))] - internal abstract class ISetupRequiredAuthenticationResponseContract : ISetupRequiredAuthenticationResponse { - /// <summary> - /// Initializes a new instance of the <see cref="ISetupRequiredAuthenticationResponseContract"/> class. - /// </summary> - protected ISetupRequiredAuthenticationResponseContract() { - } - - #region ISetupRequiredAuthenticationResponse Members - - /// <summary> - /// Gets the <see cref="Identifier"/> to pass to <see cref="OpenIdRelyingParty.CreateRequest(Identifier)"/> - /// in a subsequent authentication attempt. - /// </summary> - Identifier ISetupRequiredAuthenticationResponse.UserSuppliedIdentifier { - get { - Requires.ValidState(((IAuthenticationResponse)this).Status == AuthenticationStatus.SetupRequired, OpenIdStrings.OperationOnlyValidForSetupRequiredState); - throw new System.NotImplementedException(); - } - } - - #endregion - } } diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/NegativeAuthenticationResponse.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/NegativeAuthenticationResponse.cs index 5837449..bf52060 100644 --- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/NegativeAuthenticationResponse.cs +++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/NegativeAuthenticationResponse.cs @@ -7,11 +7,11 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { using System; using System.Collections.Generic; - using System.Diagnostics.Contracts; using System.Linq; using System.Web; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OpenId.Messages; + using Validation; /// <summary> /// Wraps a negative assertion response in an <see cref="IAuthenticationResponse"/> instance diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/OpenIdRelyingParty.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/OpenIdRelyingParty.cs index 6264041..2177591 100644 --- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/OpenIdRelyingParty.cs +++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/OpenIdRelyingParty.cs @@ -11,7 +11,6 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { using System.Collections.Specialized; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; - using System.Diagnostics.Contracts; using System.Globalization; using System.Linq; using System.Net; @@ -24,6 +23,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { using DotNetOpenAuth.OpenId.ChannelElements; using DotNetOpenAuth.OpenId.Extensions; using DotNetOpenAuth.OpenId.Messages; + using Validation; /// <summary> /// A delegate that decides whether a given OpenID Provider endpoint may be @@ -40,7 +40,6 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// Provides the programmatic facilities to act as an OpenID relying party. /// </summary> [SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Justification = "Unavoidable")] - [ContractVerification(true)] public class OpenIdRelyingParty : IDisposable, IOpenIdHost { /// <summary> /// The name of the key to use in the HttpApplication cache to store the @@ -114,7 +113,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { // If we are a smart-mode RP (supporting associations), then we MUST also be // capable of storing nonces to prevent replay attacks. // If we're a dumb-mode RP, then 2.0 OPs are responsible for preventing replays. - Requires.True(cryptoKeyStore == null || nonceStore != null, null, OpenIdStrings.AssociationStoreRequiresNonceStore); + Requires.That(cryptoKeyStore == null || nonceStore != null, null, OpenIdStrings.AssociationStoreRequiresNonceStore); this.securitySettings = OpenIdElement.Configuration.RelyingParty.SecuritySettings.CreateSecuritySettings(); @@ -160,8 +159,6 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { [EditorBrowsable(EditorBrowsableState.Advanced)] public static IOpenIdApplicationStore HttpApplicationStore { get { - Contract.Ensures(Contract.Result<IOpenIdApplicationStore>() != null); - HttpContext context = HttpContext.Current; ErrorUtilities.VerifyOperation(context != null, Strings.StoreRequiredWhenNoHttpContextAvailable, typeof(IOpenIdApplicationStore).Name); var store = (IOpenIdApplicationStore)context.Application[ApplicationStoreKey]; @@ -200,7 +197,6 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// </summary> public RelyingPartySecuritySettings SecuritySettings { get { - Contract.Ensures(Contract.Result<RelyingPartySecuritySettings>() != null); return this.securitySettings; } @@ -347,7 +343,6 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { Requires.NotNull(userSuppliedIdentifier, "userSuppliedIdentifier"); Requires.NotNull(realm, "realm"); Requires.NotNull(returnToUrl, "returnToUrl"); - Contract.Ensures(Contract.Result<IAuthenticationRequest>() != null); try { return this.CreateRequests(userSuppliedIdentifier, realm, returnToUrl).First(); } catch (InvalidOperationException ex) { @@ -379,10 +374,9 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { public IAuthenticationRequest CreateRequest(Identifier userSuppliedIdentifier, Realm realm) { Requires.NotNull(userSuppliedIdentifier, "userSuppliedIdentifier"); Requires.NotNull(realm, "realm"); - Contract.Ensures(Contract.Result<IAuthenticationRequest>() != null); try { var result = this.CreateRequests(userSuppliedIdentifier, realm).First(); - Contract.Assume(result != null); + Assumes.True(result != null); return result; } catch (InvalidOperationException ex) { throw ErrorUtilities.Wrap(ex, OpenIdStrings.OpenIdEndpointNotFound); @@ -407,7 +401,6 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// <exception cref="InvalidOperationException">Thrown if <see cref="HttpContext.Current">HttpContext.Current</see> == <c>null</c>.</exception> public IAuthenticationRequest CreateRequest(Identifier userSuppliedIdentifier) { Requires.NotNull(userSuppliedIdentifier, "userSuppliedIdentifier"); - Contract.Ensures(Contract.Result<IAuthenticationRequest>() != null); try { return this.CreateRequests(userSuppliedIdentifier).First(); } catch (InvalidOperationException ex) { @@ -446,7 +439,6 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { Requires.NotNull(userSuppliedIdentifier, "userSuppliedIdentifier"); Requires.NotNull(realm, "realm"); Requires.NotNull(returnToUrl, "returnToUrl"); - Contract.Ensures(Contract.Result<IEnumerable<IAuthenticationRequest>>() != null); return AuthenticationRequest.Create(userSuppliedIdentifier, this, realm, returnToUrl, true).Cast<IAuthenticationRequest>().CacheGeneratedResults(); } @@ -477,15 +469,13 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// </remarks> /// <exception cref="InvalidOperationException">Thrown if <see cref="HttpContext.Current">HttpContext.Current</see> == <c>null</c>.</exception> public IEnumerable<IAuthenticationRequest> CreateRequests(Identifier userSuppliedIdentifier, Realm realm) { - Requires.ValidState(HttpContext.Current != null && HttpContext.Current.Request != null, MessagingStrings.HttpContextRequired); + RequiresEx.ValidState(HttpContext.Current != null && HttpContext.Current.Request != null, MessagingStrings.HttpContextRequired); Requires.NotNull(userSuppliedIdentifier, "userSuppliedIdentifier"); Requires.NotNull(realm, "realm"); - Contract.Ensures(Contract.Result<IEnumerable<IAuthenticationRequest>>() != null); // This next code contract is a BAD idea, because it causes each authentication request to be generated // at least an extra time. - ////Contract.Ensures(Contract.ForAll(Contract.Result<IEnumerable<IAuthenticationRequest>>(), el => el != null)); - + //// // Build the return_to URL UriBuilder returnTo = new UriBuilder(this.Channel.GetRequestFromContext().GetPublicFacingUrl()); @@ -526,8 +516,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// <exception cref="InvalidOperationException">Thrown if <see cref="HttpContext.Current">HttpContext.Current</see> == <c>null</c>.</exception> public IEnumerable<IAuthenticationRequest> CreateRequests(Identifier userSuppliedIdentifier) { Requires.NotNull(userSuppliedIdentifier, "userSuppliedIdentifier"); - Requires.ValidState(HttpContext.Current != null && HttpContext.Current.Request != null, MessagingStrings.HttpContextRequired); - Contract.Ensures(Contract.Result<IEnumerable<IAuthenticationRequest>>() != null); + RequiresEx.ValidState(HttpContext.Current != null && HttpContext.Current.Request != null, MessagingStrings.HttpContextRequired); return this.CreateRequests(userSuppliedIdentifier, Realm.AutoDetect); } @@ -540,7 +529,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// <para>Requires an <see cref="HttpContext.Current">HttpContext.Current</see> context.</para> /// </remarks> public IAuthenticationResponse GetResponse() { - Requires.ValidState(HttpContext.Current != null && HttpContext.Current.Request != null, MessagingStrings.HttpContextRequired); + RequiresEx.ValidState(HttpContext.Current != null && HttpContext.Current.Request != null, MessagingStrings.HttpContextRequired); return this.GetResponse(this.Channel.GetRequestFromContext()); } @@ -593,8 +582,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// <para>Requires an <see cref="HttpContext.Current">HttpContext.Current</see> context.</para> /// </remarks> public OutgoingWebResponse ProcessResponseFromPopup() { - Requires.ValidState(HttpContext.Current != null && HttpContext.Current.Request != null, MessagingStrings.HttpContextRequired); - Contract.Ensures(Contract.Result<OutgoingWebResponse>() != null); + RequiresEx.ValidState(HttpContext.Current != null && HttpContext.Current.Request != null, MessagingStrings.HttpContextRequired); return this.ProcessResponseFromPopup(this.Channel.GetRequestFromContext()); } @@ -606,7 +594,6 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { /// <returns>The HTTP response to send to this HTTP request.</returns> public OutgoingWebResponse ProcessResponseFromPopup(HttpRequestBase request) { Requires.NotNull(request, "request"); - Contract.Ensures(Contract.Result<OutgoingWebResponse>() != null); return this.ProcessResponseFromPopup(request, null); } @@ -693,7 +680,6 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "OpenID", Justification = "real word"), SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "iframe", Justification = "Code contracts")] internal OutgoingWebResponse ProcessResponseFromPopup(HttpRequestBase request, Action<AuthenticationStatus> callback) { Requires.NotNull(request, "request"); - Contract.Ensures(Contract.Result<OutgoingWebResponse>() != null); string extensionsJson = null; var authResponse = this.NonVerifyingRelyingParty.GetResponse(); diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/PositiveAnonymousResponse.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/PositiveAnonymousResponse.cs index 3f4692a..6ec7d04 100644 --- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/PositiveAnonymousResponse.cs +++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/PositiveAnonymousResponse.cs @@ -7,11 +7,11 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { using System; using System.Collections.Generic; - using System.Diagnostics.Contracts; using System.Linq; using System.Web; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OpenId.Messages; + using Validation; /// <summary> /// Wraps an extension-only response from the OP in an <see cref="IAuthenticationResponse"/> instance diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/PositiveAuthenticationResponse.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/PositiveAuthenticationResponse.cs index 2a06c9b..509eb60 100644 --- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/PositiveAuthenticationResponse.cs +++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/PositiveAuthenticationResponse.cs @@ -7,11 +7,11 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { using System; using System.Diagnostics; - using System.Diagnostics.Contracts; using System.Linq; using System.Web; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OpenId.Messages; + using Validation; /// <summary> /// Wraps a positive assertion response in an <see cref="IAuthenticationResponse"/> instance diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/PositiveAuthenticationResponseSnapshot.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/PositiveAuthenticationResponseSnapshot.cs index f5cf8ad..0e10087 100644 --- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/PositiveAuthenticationResponseSnapshot.cs +++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/PositiveAuthenticationResponseSnapshot.cs @@ -7,11 +7,11 @@ namespace DotNetOpenAuth.OpenId.RelyingParty { using System; using System.Collections.Generic; - using System.Diagnostics.Contracts; using System.Text; using System.Web; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OpenId.Messages; + using Validation; /// <summary> /// A serializable snapshot of a verified authentication message. |