diff options
Diffstat (limited to 'src/DotNetOpenAuth.OAuth')
17 files changed, 5 insertions, 260 deletions
diff --git a/src/DotNetOpenAuth.OAuth/Configuration/OAuthElement.cs b/src/DotNetOpenAuth.OAuth/Configuration/OAuthElement.cs index 3972e6f..8b34e49 100644 --- a/src/DotNetOpenAuth.OAuth/Configuration/OAuthElement.cs +++ b/src/DotNetOpenAuth.OAuth/Configuration/OAuthElement.cs @@ -6,7 +6,6 @@ namespace DotNetOpenAuth.Configuration { using System.Configuration; - using System.Diagnostics.Contracts; /// <summary> /// Represents the <oauth> element in the host's .config file. @@ -38,7 +37,6 @@ namespace DotNetOpenAuth.Configuration { /// </summary> public static OAuthElement Configuration { get { - Contract.Ensures(Contract.Result<OAuthElement>() != null); return (OAuthElement)ConfigurationManager.GetSection(SectionName) ?? new OAuthElement(); } } diff --git a/src/DotNetOpenAuth.OAuth/DotNetOpenAuth.OAuth.csproj b/src/DotNetOpenAuth.OAuth/DotNetOpenAuth.OAuth.csproj index 153fd88..d9d61ff 100644 --- a/src/DotNetOpenAuth.OAuth/DotNetOpenAuth.OAuth.csproj +++ b/src/DotNetOpenAuth.OAuth/DotNetOpenAuth.OAuth.csproj @@ -29,7 +29,6 @@ <Compile Include="OAuth\ChannelElements\OAuthHttpMethodBindingElement.cs" /> <Compile Include="OAuth\ChannelElements\PlaintextSigningBindingElement.cs" /> <Compile Include="OAuth\ChannelElements\HmacSha1SigningBindingElement.cs" /> - <Compile Include="OAuth\ChannelElements\SigningBindingElementBaseContract.cs" /> <Compile Include="OAuth\ChannelElements\SigningBindingElementChain.cs" /> <Compile Include="OAuth\ChannelElements\TokenType.cs" /> <Compile Include="OAuth\ChannelElements\UriOrOobEncoding.cs" /> diff --git a/src/DotNetOpenAuth.OAuth/Messaging/ITamperProtectionChannelBindingElement.cs b/src/DotNetOpenAuth.OAuth/Messaging/ITamperProtectionChannelBindingElement.cs index 66b82d4..1251472 100644 --- a/src/DotNetOpenAuth.OAuth/Messaging/ITamperProtectionChannelBindingElement.cs +++ b/src/DotNetOpenAuth.OAuth/Messaging/ITamperProtectionChannelBindingElement.cs @@ -6,14 +6,12 @@ namespace DotNetOpenAuth.Messaging { using System; - using System.Diagnostics.Contracts; using DotNetOpenAuth.OAuth.ChannelElements; /// <summary> /// An interface that must be implemented by message transforms/validators in order /// to be included in the channel stack. /// </summary> - [ContractClass(typeof(ITamperProtectionChannelBindingElementContract))] public interface ITamperProtectionChannelBindingElement : IChannelBindingElement { /// <summary> /// Gets or sets the delegate that will initialize the non-serialized properties necessary on a @@ -27,98 +25,4 @@ namespace DotNetOpenAuth.Messaging { /// <returns>The cloned instance.</returns> ITamperProtectionChannelBindingElement Clone(); } - - /// <summary> - /// Contract class for the <see cref="ITamperProtectionChannelBindingElement"/> interface. - /// </summary> - [ContractClassFor(typeof(ITamperProtectionChannelBindingElement))] - internal abstract class ITamperProtectionChannelBindingElementContract : ITamperProtectionChannelBindingElement { - #region ITamperProtectionChannelBindingElement Properties - - /// <summary> - /// Gets or sets the delegate that will initialize the non-serialized properties necessary on a - /// signable message so that its signature can be correctly calculated or verified. - /// </summary> - Action<ITamperResistantOAuthMessage> ITamperProtectionChannelBindingElement.SignatureCallback { - get { throw new NotImplementedException(); } - set { throw new NotImplementedException(); } - } - - #endregion - - #region IChannelBindingElement Members - - /// <summary> - /// Gets or sets the channel that this binding element belongs to. - /// </summary> - /// <remarks> - /// This property is set by the channel when it is first constructed. - /// </remarks> - Channel IChannelBindingElement.Channel { - get { throw new NotImplementedException(); } - set { throw new NotImplementedException(); } - } - - /// <summary> - /// Gets the protection commonly offered (if any) by this binding element. - /// </summary> - /// <remarks> - /// This value is used to assist in sorting binding elements in the channel stack. - /// </remarks> - MessageProtections IChannelBindingElement.Protection { - get { throw new NotImplementedException(); } - } - - /// <summary> - /// Prepares a message for sending based on the rules of this channel binding element. - /// </summary> - /// <param name="message">The message to prepare for sending.</param> - /// <returns> - /// The protections (if any) that this binding element applied to the message. - /// Null if this binding element did not even apply to this binding element. - /// </returns> - /// <remarks> - /// Implementations that provide message protection must honor the - /// <see cref="MessagePartAttribute.RequiredProtection"/> properties where applicable. - /// </remarks> - MessageProtections? IChannelBindingElement.ProcessOutgoingMessage(IProtocolMessage message) { - throw new NotImplementedException(); - } - - /// <summary> - /// Performs any transformation on an incoming message that may be necessary and/or - /// validates an incoming message based on the rules of this channel binding element. - /// </summary> - /// <param name="message">The incoming message to process.</param> - /// <returns> - /// The protections (if any) that this binding element applied to the message. - /// Null if this binding element did not even apply to this binding element. - /// </returns> - /// <exception cref="ProtocolException"> - /// Thrown when the binding element rules indicate that this message is invalid and should - /// NOT be processed. - /// </exception> - /// <remarks> - /// Implementations that provide message protection must honor the - /// <see cref="MessagePartAttribute.RequiredProtection"/> properties where applicable. - /// </remarks> - MessageProtections? IChannelBindingElement.ProcessIncomingMessage(IProtocolMessage message) { - throw new NotImplementedException(); - } - - #endregion - - #region ITamperProtectionChannelBindingElement Methods - - /// <summary> - /// Clones this instance. - /// </summary> - /// <returns>The cloned instance.</returns> - ITamperProtectionChannelBindingElement ITamperProtectionChannelBindingElement.Clone() { - Contract.Ensures(Contract.Result<ITamperProtectionChannelBindingElement>() != null); - throw new NotImplementedException(); - } - - #endregion - } } diff --git a/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/HmacSha1SigningBindingElement.cs b/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/HmacSha1SigningBindingElement.cs index ee05614..60fbdb9 100644 --- a/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/HmacSha1SigningBindingElement.cs +++ b/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/HmacSha1SigningBindingElement.cs @@ -7,7 +7,6 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { using System; using System.Diagnostics.CodeAnalysis; - using System.Diagnostics.Contracts; using System.Security.Cryptography; using System.Text; using DotNetOpenAuth.Messaging; diff --git a/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/ITokenManager.cs b/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/ITokenManager.cs index 18fa3c6..3749920 100644 --- a/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/ITokenManager.cs +++ b/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/ITokenManager.cs @@ -7,7 +7,6 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { using System; using System.Collections.Generic; - using System.Diagnostics.Contracts; using System.Linq; using System.Text; using DotNetOpenAuth.OAuth.Messages; @@ -18,7 +17,6 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { /// and recall of tokens and secrets for an individual OAuth consumer /// or service provider. /// </summary> - [ContractClass(typeof(ITokenManagerContract))] public interface ITokenManager { /// <summary> /// Gets the Token Secret given a request or access token. @@ -75,96 +73,4 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { /// <returns>Request or Access token, or invalid if the token is not recognized.</returns> TokenType GetTokenType(string token); } - - /// <summary> - /// The code contract class for the <see cref="ITokenManager"/> interface. - /// </summary> - [ContractClassFor(typeof(ITokenManager))] - internal abstract class ITokenManagerContract : ITokenManager { - /// <summary> - /// Prevents a default instance of the <see cref="ITokenManagerContract"/> class from being created. - /// </summary> - private ITokenManagerContract() { - } - - #region ITokenManager Members - - /// <summary> - /// Gets the Token Secret given a request or access token. - /// </summary> - /// <param name="token">The request or access token.</param> - /// <returns> - /// The secret associated with the given token. - /// </returns> - /// <exception cref="ArgumentException">Thrown if the secret cannot be found for the given token.</exception> - string ITokenManager.GetTokenSecret(string token) { - Requires.NotNullOrEmpty(token, "token"); - Contract.Ensures(Contract.Result<string>() != null); - throw new NotImplementedException(); - } - - /// <summary> - /// Stores a newly generated unauthorized request token, secret, and optional - /// application-specific parameters for later recall. - /// </summary> - /// <param name="request">The request message that resulted in the generation of a new unauthorized request token.</param> - /// <param name="response">The response message that includes the unauthorized request token.</param> - /// <exception cref="ArgumentException">Thrown if the consumer key is not registered, or a required parameter was not found in the parameters collection.</exception> - /// <remarks> - /// Request tokens stored by this method SHOULD NOT associate any user account with this token. - /// It usually opens up security holes in your application to do so. Instead, you associate a user - /// account with access tokens (not request tokens) in the <see cref="ITokenManager.ExpireRequestTokenAndStoreNewAccessToken"/> - /// method. - /// </remarks> - void ITokenManager.StoreNewRequestToken(UnauthorizedTokenRequest request, ITokenSecretContainingMessage response) { - Requires.NotNull(request, "request"); - Requires.NotNull(response, "response"); - throw new NotImplementedException(); - } - - /// <summary> - /// Deletes a request token and its associated secret and stores a new access token and secret. - /// </summary> - /// <param name="consumerKey">The Consumer that is exchanging its request token for an access token.</param> - /// <param name="requestToken">The Consumer's request token that should be deleted/expired.</param> - /// <param name="accessToken">The new access token that is being issued to the Consumer.</param> - /// <param name="accessTokenSecret">The secret associated with the newly issued access token.</param> - /// <remarks> - /// <para> - /// Any scope of granted privileges associated with the request token from the - /// original call to <see cref="ITokenManager.StoreNewRequestToken"/> should be carried over - /// to the new Access Token. - /// </para> - /// <para> - /// To associate a user account with the new access token, - /// <see cref="System.Web.HttpContext.User">HttpContext.Current.User</see> may be - /// useful in an ASP.NET web application within the implementation of this method. - /// Alternatively you may store the access token here without associating with a user account, - /// and wait until WebConsumer.ProcessUserAuthorization or - /// DesktopConsumer.ProcessUserAuthorization return the access - /// token to associate the access token with a user account at that point. - /// </para> - /// </remarks> - void ITokenManager.ExpireRequestTokenAndStoreNewAccessToken(string consumerKey, string requestToken, string accessToken, string accessTokenSecret) { - Requires.NotNullOrEmpty(consumerKey, "consumerKey"); - Requires.NotNullOrEmpty(requestToken, "requestToken"); - Requires.NotNullOrEmpty(accessToken, "accessToken"); - Requires.NotNull(accessTokenSecret, "accessTokenSecret"); - throw new NotImplementedException(); - } - - /// <summary> - /// Classifies a token as a request token or an access token. - /// </summary> - /// <param name="token">The token to classify.</param> - /// <returns> - /// Request or Access token, or invalid if the token is not recognized. - /// </returns> - TokenType ITokenManager.GetTokenType(string token) { - Requires.NotNullOrEmpty(token, "token"); - throw new NotImplementedException(); - } - - #endregion - } } diff --git a/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/OAuthChannel.cs b/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/OAuthChannel.cs index 3d61f66..1362ca9 100644 --- a/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/OAuthChannel.cs +++ b/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/OAuthChannel.cs @@ -9,7 +9,6 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; - using System.Diagnostics.Contracts; using System.Globalization; using System.IO; using System.Linq; diff --git a/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/RsaSha1SigningBindingElement.cs b/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/RsaSha1SigningBindingElement.cs index 01a5c53..55ce981 100644 --- a/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/RsaSha1SigningBindingElement.cs +++ b/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/RsaSha1SigningBindingElement.cs @@ -6,7 +6,6 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { using System; - using System.Diagnostics.Contracts; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; using System.Text; diff --git a/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/SigningBindingElementBase.cs b/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/SigningBindingElementBase.cs index cc9bc68..780afdc 100644 --- a/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/SigningBindingElementBase.cs +++ b/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/SigningBindingElementBase.cs @@ -9,7 +9,6 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { using System.Collections.Generic; using System.Collections.Specialized; using System.Diagnostics.CodeAnalysis; - using System.Diagnostics.Contracts; using System.Globalization; using System.Linq; using System.Text; @@ -22,7 +21,6 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { /// <summary> /// A binding element that signs outgoing messages and verifies the signature on incoming messages. /// </summary> - [ContractClass(typeof(SigningBindingElementBaseContract))] public abstract class SigningBindingElementBase : ITamperProtectionChannelBindingElement { /// <summary> /// The signature method this binding element uses. diff --git a/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/SigningBindingElementBaseContract.cs b/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/SigningBindingElementBaseContract.cs deleted file mode 100644 index 3648750..0000000 --- a/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/SigningBindingElementBaseContract.cs +++ /dev/null @@ -1,48 +0,0 @@ -//----------------------------------------------------------------------- -// <copyright file="SigningBindingElementBaseContract.cs" company="Outercurve Foundation"> -// Copyright (c) Outercurve Foundation. All rights reserved. -// </copyright> -//----------------------------------------------------------------------- - -namespace DotNetOpenAuth.OAuth.ChannelElements { - using System; - using System.Diagnostics.Contracts; - using DotNetOpenAuth.Messaging; - using Validation; - - /// <summary> - /// Code Contract for the <see cref="SigningBindingElementBase"/> class. - /// </summary> - [ContractClassFor(typeof(SigningBindingElementBase))] - internal abstract class SigningBindingElementBaseContract : SigningBindingElementBase { - /// <summary> - /// Prevents a default instance of the SigningBindingElementBaseContract class from being created. - /// </summary> - private SigningBindingElementBaseContract() - : base(string.Empty) { - } - - /// <summary> - /// Clones this instance. - /// </summary> - /// <returns>A new instance of the binding element.</returns> - /// <remarks> - /// Implementations of this method need not clone the SignatureVerificationCallback member, as the - /// <see cref="SigningBindingElementBase"/> class does this. - /// </remarks> - protected override ITamperProtectionChannelBindingElement Clone() { - throw new NotImplementedException(); - } - - /// <summary> - /// Calculates a signature for a given message. - /// </summary> - /// <param name="message">The message to sign.</param> - /// <returns>The signature for the message.</returns> - protected override string GetSignature(ITamperResistantOAuthMessage message) { - Requires.NotNull(message, "message"); - RequiresEx.ValidState(this.Channel != null); - throw new NotImplementedException(); - } - } -} diff --git a/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/SigningBindingElementChain.cs b/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/SigningBindingElementChain.cs index 242c1ac..2b25566 100644 --- a/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/SigningBindingElementChain.cs +++ b/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/SigningBindingElementChain.cs @@ -7,7 +7,6 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { using System; using System.Collections.Generic; - using System.Diagnostics.Contracts; using System.Linq; using System.Text; using DotNetOpenAuth.Messaging; diff --git a/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/UriOrOobEncoding.cs b/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/UriOrOobEncoding.cs index 639310d..60ec6c8 100644 --- a/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/UriOrOobEncoding.cs +++ b/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/UriOrOobEncoding.cs @@ -7,7 +7,6 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { using System; using System.Collections.Generic; - using System.Diagnostics.Contracts; using System.Linq; using System.Text; using DotNetOpenAuth.Messaging; diff --git a/src/DotNetOpenAuth.OAuth/OAuth/Messages/MessageBase.cs b/src/DotNetOpenAuth.OAuth/OAuth/Messages/MessageBase.cs index 43297cc..f2f087d 100644 --- a/src/DotNetOpenAuth.OAuth/OAuth/Messages/MessageBase.cs +++ b/src/DotNetOpenAuth.OAuth/OAuth/Messages/MessageBase.cs @@ -7,7 +7,6 @@ namespace DotNetOpenAuth.OAuth.Messages { using System; using System.Collections.Generic; - using System.Diagnostics.Contracts; using System.Globalization; using System.Text; using DotNetOpenAuth.Messaging; diff --git a/src/DotNetOpenAuth.OAuth/OAuth/Messages/UnauthorizedTokenResponse.cs b/src/DotNetOpenAuth.OAuth/OAuth/Messages/UnauthorizedTokenResponse.cs index 0ff12e5..9e879cd 100644 --- a/src/DotNetOpenAuth.OAuth/OAuth/Messages/UnauthorizedTokenResponse.cs +++ b/src/DotNetOpenAuth.OAuth/OAuth/Messages/UnauthorizedTokenResponse.cs @@ -8,7 +8,6 @@ namespace DotNetOpenAuth.OAuth.Messages { using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; - using System.Diagnostics.Contracts; using DotNetOpenAuth.Messaging; using Validation; diff --git a/src/DotNetOpenAuth.OAuth/OAuth/Protocol.cs b/src/DotNetOpenAuth.OAuth/OAuth/Protocol.cs index 9236681..72f0ff4 100644 --- a/src/DotNetOpenAuth.OAuth/OAuth/Protocol.cs +++ b/src/DotNetOpenAuth.OAuth/OAuth/Protocol.cs @@ -9,7 +9,6 @@ namespace DotNetOpenAuth.OAuth { using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; - using System.Diagnostics.Contracts; using System.Linq; using System.Text; using DotNetOpenAuth.Messaging; diff --git a/src/DotNetOpenAuth.OAuth/OAuth/ServiceProviderDescription.cs b/src/DotNetOpenAuth.OAuth/OAuth/ServiceProviderDescription.cs index 3f553a9..6dbe6ea 100644 --- a/src/DotNetOpenAuth.OAuth/OAuth/ServiceProviderDescription.cs +++ b/src/DotNetOpenAuth.OAuth/OAuth/ServiceProviderDescription.cs @@ -8,7 +8,6 @@ namespace DotNetOpenAuth.OAuth { using System; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; - using System.Diagnostics.Contracts; using System.Linq; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OAuth.ChannelElements; @@ -95,7 +94,7 @@ namespace DotNetOpenAuth.OAuth { /// </summary> /// <returns>The created signing element.</returns> internal ITamperProtectionChannelBindingElement CreateTamperProtectionElement() { - Contract.Requires(this.TamperProtectionElements != null); + RequiresEx.ValidState(this.TamperProtectionElements != null); return new SigningBindingElementChain(this.TamperProtectionElements.Select(el => (ITamperProtectionChannelBindingElement)el.Clone()).ToArray()); } } diff --git a/src/DotNetOpenAuth.OAuth/OAuthReporting.cs b/src/DotNetOpenAuth.OAuth/OAuthReporting.cs index 29a9adc..e2c0aab 100644 --- a/src/DotNetOpenAuth.OAuth/OAuthReporting.cs +++ b/src/DotNetOpenAuth.OAuth/OAuthReporting.cs @@ -7,12 +7,12 @@ namespace DotNetOpenAuth { using System; using System.Collections.Generic; - using System.Diagnostics.Contracts; using System.Linq; using System.Text; using DotNetOpenAuth.Messaging.Bindings; using DotNetOpenAuth.OAuth; using DotNetOpenAuth.OAuth.ChannelElements; + using Validation; /// <summary> /// Utility methods specific to OAuth feature reporting. @@ -26,9 +26,9 @@ namespace DotNetOpenAuth { /// <param name="tokenManager">The token manager.</param> /// <param name="nonceStore">The nonce store.</param> internal static void RecordFeatureAndDependencyUse(object value, ServiceProviderDescription service, ITokenManager tokenManager, INonceStore nonceStore) { - Contract.Requires(value != null); - Contract.Requires(service != null); - Contract.Requires(tokenManager != null); + Requires.NotNull(value, "value"); + Requires.NotNull(service, "service"); + Requires.NotNull(tokenManager, "tokenManager"); // In release builds, just quietly return. if (value == null || service == null || tokenManager == null) { diff --git a/src/DotNetOpenAuth.OAuth/Properties/AssemblyInfo.cs b/src/DotNetOpenAuth.OAuth/Properties/AssemblyInfo.cs index 465f646..85b5275 100644 --- a/src/DotNetOpenAuth.OAuth/Properties/AssemblyInfo.cs +++ b/src/DotNetOpenAuth.OAuth/Properties/AssemblyInfo.cs @@ -7,7 +7,6 @@ // We DON'T put an AssemblyVersionAttribute in here because it is generated in the build. using System; -using System.Diagnostics.Contracts; using System.Net; using System.Reflection; using System.Resources; @@ -33,8 +32,6 @@ using System.Web.UI; // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("7d73990c-47c0-4256-9f20-a893add9e289")] -[assembly: ContractVerification(true)] - #if StrongNameSigned // See comment at top of this file. We need this so that strong-naming doesn't // keep this assembly from being useful to shared host (medium trust) web sites. |