diff options
Diffstat (limited to 'src/DotNetOpenAuth.OAuth2.ResourceServer')
8 files changed, 16 insertions, 38 deletions
diff --git a/src/DotNetOpenAuth.OAuth2.ResourceServer/Configuration/OAuth2ResourceServerSection.cs b/src/DotNetOpenAuth.OAuth2.ResourceServer/Configuration/OAuth2ResourceServerSection.cs index 3e37018..5f6cc3c 100644 --- a/src/DotNetOpenAuth.OAuth2.ResourceServer/Configuration/OAuth2ResourceServerSection.cs +++ b/src/DotNetOpenAuth.OAuth2.ResourceServer/Configuration/OAuth2ResourceServerSection.cs @@ -6,7 +6,6 @@ namespace DotNetOpenAuth.Configuration { using System.Configuration; - using System.Diagnostics.Contracts; /// <summary> /// Represents the <oauth2/resourceServer> section in the host's .config file. @@ -28,7 +27,6 @@ namespace DotNetOpenAuth.Configuration { /// </summary> internal static OAuth2ResourceServerSection Configuration { get { - Contract.Ensures(Contract.Result<OAuth2ResourceServerSection>() != null); return (OAuth2ResourceServerSection)ConfigurationManager.GetSection(SectionName) ?? new OAuth2ResourceServerSection(); } } diff --git a/src/DotNetOpenAuth.OAuth2.ResourceServer/DotNetOpenAuth.OAuth2.ResourceServer.csproj b/src/DotNetOpenAuth.OAuth2.ResourceServer/DotNetOpenAuth.OAuth2.ResourceServer.csproj index eb54fee..c36a789 100644 --- a/src/DotNetOpenAuth.OAuth2.ResourceServer/DotNetOpenAuth.OAuth2.ResourceServer.csproj +++ b/src/DotNetOpenAuth.OAuth2.ResourceServer/DotNetOpenAuth.OAuth2.ResourceServer.csproj @@ -50,6 +50,12 @@ <LastGenOutput>ResourceServerStrings.Designer.cs</LastGenOutput> </EmbeddedResource> </ItemGroup> + <ItemGroup> + <Reference Include="Validation, Version=2.0.0.0, Culture=neutral, PublicKeyToken=2fc06f0d701809a7, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\packages\Validation.2.0.0.12319\lib\portable-windows8+net40+sl5+windowsphone8\Validation.dll</HintPath> + </Reference> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(ProjectRoot)tools\DotNetOpenAuth.targets" /> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> diff --git a/src/DotNetOpenAuth.OAuth2.ResourceServer/OAuth2/ChannelElements/OAuth2ResourceServerChannel.cs b/src/DotNetOpenAuth.OAuth2.ResourceServer/OAuth2/ChannelElements/OAuth2ResourceServerChannel.cs index e9d596a..8cf7eeb 100644 --- a/src/DotNetOpenAuth.OAuth2.ResourceServer/OAuth2/ChannelElements/OAuth2ResourceServerChannel.cs +++ b/src/DotNetOpenAuth.OAuth2.ResourceServer/OAuth2/ChannelElements/OAuth2ResourceServerChannel.cs @@ -7,7 +7,6 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements { using System; using System.Collections.Generic; - using System.Diagnostics.Contracts; using System.Linq; using System.Net; using System.Net.Mime; @@ -16,6 +15,7 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements { using DotNetOpenAuth.Messaging; using DotNetOpenAuth.Messaging.Reflection; using DotNetOpenAuth.OAuth2.Messages; + using Validation; /// <summary> /// The channel for the OAuth protocol. diff --git a/src/DotNetOpenAuth.OAuth2.ResourceServer/OAuth2/IAccessTokenAnalyzer.cs b/src/DotNetOpenAuth.OAuth2.ResourceServer/OAuth2/IAccessTokenAnalyzer.cs index 5c5a526..a86b26d 100644 --- a/src/DotNetOpenAuth.OAuth2.ResourceServer/OAuth2/IAccessTokenAnalyzer.cs +++ b/src/DotNetOpenAuth.OAuth2.ResourceServer/OAuth2/IAccessTokenAnalyzer.cs @@ -8,16 +8,15 @@ namespace DotNetOpenAuth.OAuth2 { using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; - using System.Diagnostics.Contracts; using System.Linq; using System.Text; using DotNetOpenAuth.Messaging; + using Validation; /// <summary> /// An interface that resource server hosts should implement if they accept access tokens /// issued by non-DotNetOpenAuth authorization servers. /// </summary> - [ContractClass((typeof(IAccessTokenAnalyzerContract)))] public interface IAccessTokenAnalyzer { /// <summary> /// Reads an access token to find out what data it authorizes access to. @@ -28,30 +27,4 @@ namespace DotNetOpenAuth.OAuth2 { /// <exception cref="ProtocolException">Thrown if the access token is expired, invalid, or from an untrusted authorization server.</exception> AccessToken DeserializeAccessToken(IDirectedProtocolMessage message, string accessToken); } - - /// <summary> - /// Code contract for the <see cref="IAccessTokenAnalyzer"/> interface. - /// </summary> - [ContractClassFor(typeof(IAccessTokenAnalyzer))] - internal abstract class IAccessTokenAnalyzerContract : IAccessTokenAnalyzer { - /// <summary> - /// Prevents a default instance of the <see cref="IAccessTokenAnalyzerContract"/> class from being created. - /// </summary> - private IAccessTokenAnalyzerContract() { - } - - /// <summary> - /// Reads an access token to find out what data it authorizes access to. - /// </summary> - /// <param name="message">The message carrying the access token.</param> - /// <param name="accessToken">The access token's serialized representation.</param> - /// <returns>The deserialized, validated token.</returns> - /// <exception cref="ProtocolException">Thrown if the access token is expired, invalid, or from an untrusted authorization server.</exception> - AccessToken IAccessTokenAnalyzer.DeserializeAccessToken(IDirectedProtocolMessage message, string accessToken) { - Requires.NotNull(message, "message"); - Requires.NotNullOrEmpty(accessToken, "accessToken"); - Contract.Ensures(Contract.Result<AccessToken>() != null); - throw new NotImplementedException(); - } - } } diff --git a/src/DotNetOpenAuth.OAuth2.ResourceServer/OAuth2/ResourceServer.cs b/src/DotNetOpenAuth.OAuth2.ResourceServer/OAuth2/ResourceServer.cs index 896588f..540773f 100644 --- a/src/DotNetOpenAuth.OAuth2.ResourceServer/OAuth2/ResourceServer.cs +++ b/src/DotNetOpenAuth.OAuth2.ResourceServer/OAuth2/ResourceServer.cs @@ -8,7 +8,6 @@ namespace DotNetOpenAuth.OAuth2 { using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; - using System.Diagnostics.Contracts; using System.Linq; using System.Net; #if CLR4 @@ -23,6 +22,7 @@ namespace DotNetOpenAuth.OAuth2 { using DotNetOpenAuth.OAuth.ChannelElements; using Messages; using Messaging; + using Validation; /// <summary> /// Provides services for validating OAuth access tokens. @@ -90,7 +90,7 @@ namespace DotNetOpenAuth.OAuth2 { /// </exception> public virtual AccessToken GetAccessToken(HttpRequestBase httpRequestInfo = null, params string[] requiredScopes) { Requires.NotNull(requiredScopes, "requiredScopes"); - Requires.ValidState(this.ScopeSatisfiedCheck != null, Strings.RequiredPropertyNotYetPreset); + RequiresEx.ValidState(this.ScopeSatisfiedCheck != null, Strings.RequiredPropertyNotYetPreset); if (httpRequestInfo == null) { httpRequestInfo = this.Channel.GetRequestFromContext(); } diff --git a/src/DotNetOpenAuth.OAuth2.ResourceServer/OAuth2/StandardAccessTokenAnalyzer.cs b/src/DotNetOpenAuth.OAuth2.ResourceServer/OAuth2/StandardAccessTokenAnalyzer.cs index 62436ec..32f10ba 100644 --- a/src/DotNetOpenAuth.OAuth2.ResourceServer/OAuth2/StandardAccessTokenAnalyzer.cs +++ b/src/DotNetOpenAuth.OAuth2.ResourceServer/OAuth2/StandardAccessTokenAnalyzer.cs @@ -7,11 +7,11 @@ namespace DotNetOpenAuth.OAuth2 { using System; using System.Collections.Generic; - using System.Diagnostics.Contracts; using System.IO; using System.Security.Cryptography; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OAuth2.ChannelElements; + using Validation; /// <summary> /// An access token reader that understands DotNetOpenAuth authorization server issued tokens. @@ -24,7 +24,7 @@ namespace DotNetOpenAuth.OAuth2 { /// <param name="resourceServerPrivateEncryptionKey">The crypto service provider with the resource server private encryption key.</param> public StandardAccessTokenAnalyzer(RSACryptoServiceProvider authorizationServerPublicSigningKey, RSACryptoServiceProvider resourceServerPrivateEncryptionKey) { Requires.NotNull(authorizationServerPublicSigningKey, "authorizationServerPublicSigningKey"); - Requires.True(resourceServerPrivateEncryptionKey == null || !resourceServerPrivateEncryptionKey.PublicOnly, "resourceServerPrivateEncryptionKey"); + Requires.That(resourceServerPrivateEncryptionKey == null || !resourceServerPrivateEncryptionKey.PublicOnly, "resourceServerPrivateEncryptionKey", "Private key required when encrypting."); this.AuthorizationServerPublicSigningKey = authorizationServerPublicSigningKey; this.ResourceServerPrivateEncryptionKey = resourceServerPrivateEncryptionKey; } diff --git a/src/DotNetOpenAuth.OAuth2.ResourceServer/Properties/AssemblyInfo.cs b/src/DotNetOpenAuth.OAuth2.ResourceServer/Properties/AssemblyInfo.cs index 397b35d..29900ab 100644 --- a/src/DotNetOpenAuth.OAuth2.ResourceServer/Properties/AssemblyInfo.cs +++ b/src/DotNetOpenAuth.OAuth2.ResourceServer/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; @@ -31,8 +30,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. diff --git a/src/DotNetOpenAuth.OAuth2.ResourceServer/packages.config b/src/DotNetOpenAuth.OAuth2.ResourceServer/packages.config new file mode 100644 index 0000000..67054af --- /dev/null +++ b/src/DotNetOpenAuth.OAuth2.ResourceServer/packages.config @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="Microsoft.IdentityModel" version="6.1.7600.16394" targetFramework="net40" /> +</packages>
\ No newline at end of file |