summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2008-11-18 07:33:29 -0800
committerAndrew <andrewarnott@gmail.com>2008-11-18 07:33:29 -0800
commit587c9b421f3f0b3607662050c1b1546f203cc8f9 (patch)
tree896aa100bd0fdc00f9f7891cc53d8192247d85f1
parent6c26c72a01e8ae62474f78e1d44b849c673f8e4e (diff)
downloadDotNetOpenAuth-587c9b421f3f0b3607662050c1b1546f203cc8f9.zip
DotNetOpenAuth-587c9b421f3f0b3607662050c1b1546f203cc8f9.tar.gz
DotNetOpenAuth-587c9b421f3f0b3607662050c1b1546f203cc8f9.tar.bz2
Moved association creation logic from test assembly to library.
-rw-r--r--src/DotNetOpenAuth.Test/CoordinatorBase.cs4
-rw-r--r--src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs26
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/OpenIdCoordinator.cs4
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/ScenarioTests.cs16
-rw-r--r--src/DotNetOpenAuth/DotNetOpenAuth.csproj484
-rw-r--r--src/DotNetOpenAuth/Messaging/Channel.cs21
-rw-r--r--src/DotNetOpenAuth/Messaging/ErrorUtilities.cs12
-rw-r--r--src/DotNetOpenAuth/Messaging/MessagingStrings.Designer.cs11
-rw-r--r--src/DotNetOpenAuth/Messaging/MessagingStrings.resx5
-rw-r--r--src/DotNetOpenAuth/OpenId/Messages/AssociateDiffieHellmanResponse.cs22
-rw-r--r--src/DotNetOpenAuth/OpenId/Messages/AssociateRequest.cs22
-rw-r--r--src/DotNetOpenAuth/OpenId/Messages/AssociateSuccessfulResponse.cs13
-rw-r--r--src/DotNetOpenAuth/OpenId/Messages/AssociateUnencryptedResponse.cs17
-rw-r--r--src/DotNetOpenAuth/OpenId/OpenIdRelyingParty.cs24
-rw-r--r--src/DotNetOpenAuth/OpenId/ProviderDescription.cs48
-rw-r--r--src/DotNetOpenAuth/OpenId/RelyingPartyDescription.cs18
16 files changed, 476 insertions, 271 deletions
diff --git a/src/DotNetOpenAuth.Test/CoordinatorBase.cs b/src/DotNetOpenAuth.Test/CoordinatorBase.cs
index 9c16eac..4463dde 100644
--- a/src/DotNetOpenAuth.Test/CoordinatorBase.cs
+++ b/src/DotNetOpenAuth.Test/CoordinatorBase.cs
@@ -22,6 +22,10 @@ namespace DotNetOpenAuth.Test {
this.party2Action = party2Action;
}
+ protected internal Action<IProtocolMessage> IncomingMessageFilter { get; set; }
+
+ protected internal Action<IProtocolMessage> OutgoingMessageFilter { get; set; }
+
internal abstract void Run();
protected void RunCore(T1 party1Object, T2 party2Object) {
diff --git a/src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs b/src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs
index bba9285..bb094af 100644
--- a/src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs
+++ b/src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs
@@ -17,12 +17,16 @@ namespace DotNetOpenAuth.Test.Mocks {
private EventWaitHandle incomingMessageSignal = new AutoResetEvent(false);
private IProtocolMessage incomingMessage;
private Response incomingRawResponse;
+ private Action<IProtocolMessage> incomingMessageFilter;
+ private Action<IProtocolMessage> outgoingMessageFilter;
- internal CoordinatingChannel(Channel wrappedChannel)
+ internal CoordinatingChannel(Channel wrappedChannel, Action<IProtocolMessage> incomingMessageFilter, Action<IProtocolMessage> outgoingMessageFilter)
: base(GetMessageTypeProvider(wrappedChannel), wrappedChannel.BindingElements.ToArray()) {
ErrorUtilities.VerifyArgumentNotNull(wrappedChannel, "wrappedChannel");
this.wrappedChannel = wrappedChannel;
+ this.incomingMessageFilter = incomingMessageFilter;
+ this.outgoingMessageFilter = outgoingMessageFilter;
}
/// <summary>
@@ -35,26 +39,32 @@ namespace DotNetOpenAuth.Test.Mocks {
}
protected override IProtocolMessage RequestInternal(IDirectedProtocolMessage request) {
+ this.ProcessMessageFilter(request, true);
HttpRequestInfo requestInfo = this.SpoofHttpMethod(request);
// Drop the outgoing message in the other channel's in-slot and let them know it's there.
this.RemoteChannel.incomingMessage = requestInfo.Message;
this.RemoteChannel.incomingMessageSignal.Set();
// Now wait for a response...
- return this.AwaitIncomingMessage();
+ IProtocolMessage response = this.AwaitIncomingMessage();
+ this.ProcessMessageFilter(response, false);
+ return response;
}
protected override Response SendDirectMessageResponse(IProtocolMessage response) {
+ this.ProcessMessageFilter(response, true);
this.RemoteChannel.incomingMessage = CloneSerializedParts(response, null);
this.RemoteChannel.incomingMessageSignal.Set();
return null;
}
protected override Response SendIndirectMessage(IDirectedProtocolMessage message) {
+ this.ProcessMessageFilter(message, true);
// In this mock transport, direct and indirect messages are the same.
return this.SendDirectMessageResponse(message);
}
protected override IDirectedProtocolMessage ReadFromRequestInternal(HttpRequestInfo request) {
+ this.ProcessMessageFilter(request.Message, false);
return request.Message;
}
@@ -104,5 +114,17 @@ namespace DotNetOpenAuth.Test.Mocks {
this.incomingMessage = null;
return response;
}
+
+ private void ProcessMessageFilter(IProtocolMessage message, bool outgoing) {
+ if (outgoing) {
+ if (this.outgoingMessageFilter != null) {
+ this.outgoingMessageFilter(message);
+ }
+ } else {
+ if (this.incomingMessageFilter != null) {
+ this.incomingMessageFilter(message);
+ }
+ }
+ }
}
}
diff --git a/src/DotNetOpenAuth.Test/OpenId/OpenIdCoordinator.cs b/src/DotNetOpenAuth.Test/OpenId/OpenIdCoordinator.cs
index 78fb921..6ec2f38 100644
--- a/src/DotNetOpenAuth.Test/OpenId/OpenIdCoordinator.cs
+++ b/src/DotNetOpenAuth.Test/OpenId/OpenIdCoordinator.cs
@@ -21,8 +21,8 @@ namespace DotNetOpenAuth.Test.OpenId {
OpenIdRelyingParty rp = new OpenIdRelyingParty();
OpenIdProvider op = new OpenIdProvider();
- var rpCoordinatingChannel = new CoordinatingChannel(rp.Channel);
- var opCoordinatingChannel = new CoordinatingChannel(op.Channel);
+ var rpCoordinatingChannel = new CoordinatingChannel(rp.Channel, this.IncomingMessageFilter, this.OutgoingMessageFilter);
+ var opCoordinatingChannel = new CoordinatingChannel(op.Channel, this.IncomingMessageFilter, this.OutgoingMessageFilter);
rpCoordinatingChannel.RemoteChannel = opCoordinatingChannel;
opCoordinatingChannel.RemoteChannel = rpCoordinatingChannel;
diff --git a/src/DotNetOpenAuth.Test/OpenId/ScenarioTests.cs b/src/DotNetOpenAuth.Test/OpenId/ScenarioTests.cs
index f3d78e8..ddcae42 100644
--- a/src/DotNetOpenAuth.Test/OpenId/ScenarioTests.cs
+++ b/src/DotNetOpenAuth.Test/OpenId/ScenarioTests.cs
@@ -21,14 +21,11 @@ namespace DotNetOpenAuth.Test.OpenId {
[TestMethod]
public void AssociateDiffieHellmanMessages() {
Association rpAssociation = null, opAssociation = null;
+ AssociateDiffieHellmanResponse associateResponse = null;
OpenIdCoordinator coordinator = new OpenIdCoordinator(
rp => {
- var associateRequest = new AssociateDiffieHellmanRequest(new Uri("http://host"));
- associateRequest.AssociationType = Protocol.Args.SignatureAlgorithm.HMAC_SHA1;
- associateRequest.SessionType = Protocol.Args.SessionType.DH_SHA1;
- associateRequest.InitializeRequest();
- var associateResponse = rp.Channel.Request<AssociateDiffieHellmanResponse>(associateRequest);
- rpAssociation = associateResponse.CreateAssociation(associateRequest);
+ var op = new ProviderEndpointDescription(new Uri("http://host"), Protocol);
+ rpAssociation = rp.GetAssociation(op);
Assert.IsNotNull(rpAssociation);
Assert.IsFalse(MessagingUtilities.AreEquivalent(associateResponse.EncodedMacKey, rpAssociation.SecretKey), "Key should have been encrypted.");
},
@@ -39,6 +36,13 @@ namespace DotNetOpenAuth.Test.OpenId {
opAssociation = response.CreateAssociation(associateRequest);
op.Channel.Send(response);
});
+ coordinator.IncomingMessageFilter = (message) => {
+ var associateResponseMessage = message as AssociateDiffieHellmanResponse;
+ if (associateResponseMessage != null) {
+ // capture this message so we can analyze it later
+ associateResponse = associateResponseMessage;
+ }
+ };
coordinator.Run();
Assert.AreEqual(opAssociation.Handle, rpAssociation.Handle);
Assert.IsTrue(Math.Abs(opAssociation.SecondsTillExpiration - rpAssociation.SecondsTillExpiration) < 60);
diff --git a/src/DotNetOpenAuth/DotNetOpenAuth.csproj b/src/DotNetOpenAuth/DotNetOpenAuth.csproj
index 5c74ae3..8e94b2d 100644
--- a/src/DotNetOpenAuth/DotNetOpenAuth.csproj
+++ b/src/DotNetOpenAuth/DotNetOpenAuth.csproj
@@ -1,242 +1,244 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.30729</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{3191B653-F76D-4C1A-9A5A-347BC3AAAAB7}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>DotNetOpenAuth</RootNamespace>
- <AssemblyName>DotNetOpenAuth</AssemblyName>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>..\..\bin\Debug\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
- <DocumentationFile>..\..\bin\Debug\DotNetOpenAuth.xml</DocumentationFile>
- <RunCodeAnalysis>false</RunCodeAnalysis>
- <CodeAnalysisRules>-Microsoft.Design#CA1054;-Microsoft.Design#CA1056;-Microsoft.Design#CA1055</CodeAnalysisRules>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>..\..\bin\Release\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
- <DocumentationFile>..\..\bin\debug\DotNetOpenAuth.xml</DocumentationFile>
- <RunCodeAnalysis>true</RunCodeAnalysis>
- <CodeAnalysisRules>-Microsoft.Design#CA1054;-Microsoft.Design#CA1056;-Microsoft.Design#CA1055</CodeAnalysisRules>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Sign)' == 'true' ">
- <SignAssembly>true</SignAssembly>
- <AssemblyOriginatorKeyFile>..\official-build-key.pfx</AssemblyOriginatorKeyFile>
- <DefineConstants>$(DefineConstants);StrongNameSigned</DefineConstants>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\lib\log4net.dll</HintPath>
- </Reference>
- <Reference Include="System" />
- <Reference Include="System.configuration" />
- <Reference Include="System.Core">
- <RequiredTargetFramework>3.5</RequiredTargetFramework>
- </Reference>
- <Reference Include="System.Data" />
- <Reference Include="System.ServiceModel">
- <RequiredTargetFramework>3.0</RequiredTargetFramework>
- </Reference>
- <Reference Include="System.Web" />
- <Reference Include="System.XML" />
- <Reference Include="System.Xml.Linq">
- <RequiredTargetFramework>3.5</RequiredTargetFramework>
- </Reference>
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Configuration\ProviderSection.cs" />
- <Compile Include="Configuration\ProviderSecuritySettingsElement.cs" />
- <Compile Include="Configuration\RelyingPartySection.cs" />
- <Compile Include="Configuration\RelyingPartySecuritySettingsElement.cs" />
- <Compile Include="Configuration\TypeConfigurationElement.cs" />
- <Compile Include="Configuration\UntrustedWebRequestSection.cs" />
- <Compile Include="Configuration\HostNameOrRegexCollection.cs" />
- <Compile Include="Configuration\HostNameElement.cs" />
- <Compile Include="Messaging\EmptyDictionary.cs" />
- <Compile Include="Messaging\EmptyEnumerator.cs" />
- <Compile Include="Messaging\EmptyList.cs" />
- <Compile Include="Messaging\ErrorUtilities.cs" />
- <Compile Include="Messaging\Reflection\IMessagePartEncoder.cs" />
- <Compile Include="OAuth\ChannelElements\OAuthConsumerMessageTypeProvider.cs" />
- <Compile Include="OAuth\ChannelElements\ITokenGenerator.cs" />
- <Compile Include="OAuth\ChannelElements\ITokenManager.cs" />
- <Compile Include="OAuth\ChannelElements\OAuthHttpMethodBindingElement.cs" />
- <Compile Include="OAuth\ChannelElements\PlaintextSigningBindingElement.cs" />
- <Compile Include="OAuth\ChannelElements\HmacSha1SigningBindingElement.cs" />
- <Compile Include="OAuth\ChannelElements\SigningBindingElementChain.cs" />
- <Compile Include="OAuth\ChannelElements\StandardTokenGenerator.cs" />
- <Compile Include="OAuth\ChannelElements\TokenType.cs" />
- <Compile Include="OAuth\ConsumerBase.cs" />
- <Compile Include="OAuth\DesktopConsumer.cs" />
- <Compile Include="GlobalSuppressions.cs" />
- <Compile Include="OAuth\Messages\ITokenSecretContainingMessage.cs" />
- <Compile Include="Messaging\ChannelEventArgs.cs" />
- <Compile Include="Messaging\ITamperProtectionChannelBindingElement.cs" />
- <Compile Include="OAuth\OAuthStrings.Designer.cs">
- <AutoGen>True</AutoGen>
- <DesignTime>True</DesignTime>
- <DependentUpon>OAuthStrings.resx</DependentUpon>
- </Compile>
- <Compile Include="OAuth\ServiceProviderDescription.cs" />
- <Compile Include="OAuth\Messages\ITokenContainingMessage.cs" />
- <Compile Include="OAuth\Messages\SignedMessageBase.cs" />
- <Compile Include="Messaging\Bindings\NonceMemoryStore.cs" />
- <Compile Include="OAuth\ChannelElements\SigningBindingElementBase.cs" />
- <Compile Include="OAuth\WebConsumer.cs" />
- <Compile Include="Messaging\IWebRequestHandler.cs" />
- <Compile Include="OAuth\ChannelElements\ITamperResistantOAuthMessage.cs" />
- <Compile Include="OAuth\Messages\MessageBase.cs" />
- <Compile Include="OAuth\Messages\AuthorizedTokenRequest.cs" />
- <Compile Include="Messaging\Bindings\INonceStore.cs" />
- <Compile Include="Messaging\Bindings\StandardReplayProtectionBindingElement.cs" />
- <Compile Include="Messaging\MessagePartAttribute.cs" />
- <Compile Include="Messaging\MessageProtections.cs" />
- <Compile Include="Messaging\IChannelBindingElement.cs" />
- <Compile Include="Messaging\Bindings\ReplayedMessageException.cs" />
- <Compile Include="Messaging\Bindings\ExpiredMessageException.cs" />
- <Compile Include="Messaging\Bindings\InvalidSignatureException.cs" />
- <Compile Include="Messaging\Bindings\IReplayProtectedProtocolMessage.cs" />
- <Compile Include="Messaging\Bindings\IExpiringProtocolMessage.cs" />
- <Compile Include="OAuth\Messages\AccessProtectedResourceRequest.cs" />
- <Compile Include="OAuth\Messages\AuthorizedTokenResponse.cs" />
- <Compile Include="OAuth\Messages\UserAuthorizationResponse.cs" />
- <Compile Include="OAuth\Messages\UserAuthorizationRequest.cs" />
- <Compile Include="OAuth\Messages\UnauthorizedTokenResponse.cs" />
- <Compile Include="Messaging\Channel.cs" />
- <Compile Include="Messaging\HttpRequestInfo.cs" />
- <Compile Include="Messaging\IDirectedProtocolMessage.cs" />
- <Compile Include="Messaging\IMessageTypeProvider.cs" />
- <Compile Include="Messaging\ITamperResistantProtocolMessage.cs" />
- <Compile Include="Messaging\MessageSerializer.cs" />
- <Compile Include="Messaging\MessagingStrings.Designer.cs">
- <AutoGen>True</AutoGen>
- <DesignTime>True</DesignTime>
- <DependentUpon>MessagingStrings.resx</DependentUpon>
- </Compile>
- <Compile Include="Messaging\MessagingUtilities.cs" />
- <Compile Include="Messaging\Bindings\StandardExpirationBindingElement.cs" />
- <Compile Include="Messaging\Reflection\ValueMapping.cs" />
- <Compile Include="Messaging\Reflection\MessageDescription.cs" />
- <Compile Include="Messaging\Reflection\MessageDictionary.cs" />
- <Compile Include="Messaging\Reflection\MessagePart.cs" />
- <Compile Include="Messaging\UnprotectedMessageException.cs" />
- <Compile Include="OAuth\ChannelElements\OAuthChannel.cs" />
- <Compile Include="Messaging\Response.cs" />
- <Compile Include="Messaging\IProtocolMessage.cs" />
- <Compile Include="Logger.cs" />
- <Compile Include="Loggers\ILog.cs" />
- <Compile Include="Loggers\Log4NetLogger.cs" />
- <Compile Include="Loggers\NoOpLogger.cs" />
- <Compile Include="Loggers\TraceLogger.cs" />
- <Compile Include="Messaging\HttpDeliveryMethods.cs" />
- <Compile Include="Messaging\MessageTransport.cs" />
- <Compile Include="OAuth\ChannelElements\OAuthServiceProviderMessageTypeProvider.cs" />
- <Compile Include="Messaging\ProtocolException.cs" />
- <Compile Include="OpenId\Association.cs" />
- <Compile Include="OpenId\AssociationMemoryStore.cs" />
- <Compile Include="OpenId\Associations.cs" />
- <Compile Include="OpenId\ChannelElements\ITamperResistantOpenIdMessage.cs" />
- <Compile Include="OpenId\ChannelElements\SigningBindingElement.cs" />
- <Compile Include="OpenId\ChannelElements\KeyValueFormEncoding.cs" />
- <Compile Include="OpenId\ChannelElements\OpenIdChannel.cs" />
- <Compile Include="OpenId\ChannelElements\OpenIdMessageTypeProvider.cs" />
- <Compile Include="OpenId\Configuration.cs" />
- <Compile Include="OpenId\DiffieHellmanUtilities.cs" />
- <Compile Include="OpenId\DiffieHellman\DHKeyGeneration.cs" />
- <Compile Include="OpenId\DiffieHellman\DHParameters.cs" />
- <Compile Include="OpenId\DiffieHellman\DiffieHellman.cs" />
- <Compile Include="OpenId\DiffieHellman\DiffieHellmanManaged.cs" />
- <Compile Include="OpenId\DiffieHellman\mono\BigInteger.cs" />
- <Compile Include="OpenId\DiffieHellman\mono\ConfidenceFactor.cs" />
- <Compile Include="OpenId\DiffieHellman\mono\NextPrimeFinder.cs" />
- <Compile Include="OpenId\DiffieHellman\mono\PrimalityTests.cs" />
- <Compile Include="OpenId\DiffieHellman\mono\PrimeGeneratorBase.cs" />
- <Compile Include="OpenId\DiffieHellman\mono\SequentialSearchPrimeGeneratorBase.cs" />
- <Compile Include="OpenId\HmacShaAssociation.cs" />
- <Compile Include="OpenId\IAssociationStore.cs" />
- <Compile Include="OpenId\Messages\AssociateUnencryptedRequest.cs" />
- <Compile Include="OpenId\OpenIdProvider.cs" />
- <Compile Include="OpenId\Messages\AssociateDiffieHellmanRequest.cs" />
- <Compile Include="OpenId\Messages\AssociateDiffieHellmanResponse.cs" />
- <Compile Include="OpenId\Messages\AssociateRequest.cs" />
- <Compile Include="OpenId\Messages\AssociateSuccessfulResponse.cs" />
- <Compile Include="OpenId\Messages\AssociateUnencryptedResponse.cs" />
- <Compile Include="OpenId\Messages\AssociateUnsuccessfulResponse.cs" />
- <Compile Include="OpenId\Messages\IndirectErrorResponse.cs" />
- <Compile Include="OpenId\Messages\DirectErrorResponse.cs" />
- <Compile Include="OpenId\Messages\RequestBase.cs" />
- <Compile Include="OpenId\Messages\DirectResponseBase.cs" />
- <Compile Include="OpenId\OpenIdRelyingParty.cs" />
- <Compile Include="OpenId\OpenIdStrings.Designer.cs">
- <DependentUpon>OpenIdStrings.resx</DependentUpon>
- <DesignTime>True</DesignTime>
- <AutoGen>True</AutoGen>
- </Compile>
- <Compile Include="OpenId\Protocol.cs" />
- <Compile Include="OpenId\Provider\ProviderSecuritySettings.cs" />
- <Compile Include="OpenId\RelyingParty\RelyingPartySecuritySettings.cs" />
- <Compile Include="OpenId\SecuritySettings.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="OAuth\Messages\UnauthorizedTokenRequest.cs" />
- <Compile Include="OAuth\ChannelElements\RsaSha1SigningBindingElement.cs" />
- <Compile Include="Messaging\StandardWebRequestHandler.cs" />
- <Compile Include="Messaging\MessageReceivingEndpoint.cs" />
- <Compile Include="Util.cs" />
- <Compile Include="OAuth\Protocol.cs" />
- <Compile Include="OAuth\ServiceProvider.cs" />
- <Compile Include="Strings.Designer.cs">
- <AutoGen>True</AutoGen>
- <DesignTime>True</DesignTime>
- <DependentUpon>Strings.resx</DependentUpon>
- </Compile>
- <Compile Include="UriUtil.cs" />
- </ItemGroup>
- <ItemGroup>
- <None Include="ClassDiagram.cd" />
- <None Include="OAuth\Messages\OAuth Messages.cd" />
- <None Include="Messaging\Bindings\Bindings.cd" />
- <None Include="Messaging\Exceptions.cd" />
- <None Include="Messaging\Messaging.cd" />
- </ItemGroup>
- <ItemGroup>
- <EmbeddedResource Include="Messaging\MessagingStrings.resx">
- <Generator>ResXFileCodeGenerator</Generator>
- <LastGenOutput>MessagingStrings.Designer.cs</LastGenOutput>
- </EmbeddedResource>
- <EmbeddedResource Include="OAuth\OAuthStrings.resx">
- <Generator>ResXFileCodeGenerator</Generator>
- <LastGenOutput>OAuthStrings.Designer.cs</LastGenOutput>
- </EmbeddedResource>
- <EmbeddedResource Include="OpenId\OpenIdStrings.resx">
- <Generator>ResXFileCodeGenerator</Generator>
- <LastGenOutput>OpenIdStrings.Designer.cs</LastGenOutput>
- </EmbeddedResource>
- <EmbeddedResource Include="Strings.resx">
- <Generator>ResXFileCodeGenerator</Generator>
- <LastGenOutput>Strings.Designer.cs</LastGenOutput>
- <SubType>Designer</SubType>
- </EmbeddedResource>
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <Import Project="..\..\tools\DotNetOpenAuth.Versioning.targets" />
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{3191B653-F76D-4C1A-9A5A-347BC3AAAAB7}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>DotNetOpenAuth</RootNamespace>
+ <AssemblyName>DotNetOpenAuth</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>..\..\bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+ <DocumentationFile>..\..\bin\Debug\DotNetOpenAuth.xml</DocumentationFile>
+ <RunCodeAnalysis>false</RunCodeAnalysis>
+ <CodeAnalysisRules>-Microsoft.Design#CA1054;-Microsoft.Design#CA1056;-Microsoft.Design#CA1055</CodeAnalysisRules>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>..\..\bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+ <DocumentationFile>..\..\bin\debug\DotNetOpenAuth.xml</DocumentationFile>
+ <RunCodeAnalysis>true</RunCodeAnalysis>
+ <CodeAnalysisRules>-Microsoft.Design#CA1054;-Microsoft.Design#CA1056;-Microsoft.Design#CA1055</CodeAnalysisRules>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Sign)' == 'true' ">
+ <SignAssembly>true</SignAssembly>
+ <AssemblyOriginatorKeyFile>..\official-build-key.pfx</AssemblyOriginatorKeyFile>
+ <DefineConstants>$(DefineConstants);StrongNameSigned</DefineConstants>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\lib\log4net.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.configuration" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.ServiceModel">
+ <RequiredTargetFramework>3.0</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Web" />
+ <Reference Include="System.XML" />
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Configuration\ProviderSection.cs" />
+ <Compile Include="Configuration\ProviderSecuritySettingsElement.cs" />
+ <Compile Include="Configuration\RelyingPartySection.cs" />
+ <Compile Include="Configuration\RelyingPartySecuritySettingsElement.cs" />
+ <Compile Include="Configuration\TypeConfigurationElement.cs" />
+ <Compile Include="Configuration\UntrustedWebRequestSection.cs" />
+ <Compile Include="Configuration\HostNameOrRegexCollection.cs" />
+ <Compile Include="Configuration\HostNameElement.cs" />
+ <Compile Include="Messaging\EmptyDictionary.cs" />
+ <Compile Include="Messaging\EmptyEnumerator.cs" />
+ <Compile Include="Messaging\EmptyList.cs" />
+ <Compile Include="Messaging\ErrorUtilities.cs" />
+ <Compile Include="Messaging\Reflection\IMessagePartEncoder.cs" />
+ <Compile Include="OAuth\ChannelElements\OAuthConsumerMessageTypeProvider.cs" />
+ <Compile Include="OAuth\ChannelElements\ITokenGenerator.cs" />
+ <Compile Include="OAuth\ChannelElements\ITokenManager.cs" />
+ <Compile Include="OAuth\ChannelElements\OAuthHttpMethodBindingElement.cs" />
+ <Compile Include="OAuth\ChannelElements\PlaintextSigningBindingElement.cs" />
+ <Compile Include="OAuth\ChannelElements\HmacSha1SigningBindingElement.cs" />
+ <Compile Include="OAuth\ChannelElements\SigningBindingElementChain.cs" />
+ <Compile Include="OAuth\ChannelElements\StandardTokenGenerator.cs" />
+ <Compile Include="OAuth\ChannelElements\TokenType.cs" />
+ <Compile Include="OAuth\ConsumerBase.cs" />
+ <Compile Include="OAuth\DesktopConsumer.cs" />
+ <Compile Include="GlobalSuppressions.cs" />
+ <Compile Include="OAuth\Messages\ITokenSecretContainingMessage.cs" />
+ <Compile Include="Messaging\ChannelEventArgs.cs" />
+ <Compile Include="Messaging\ITamperProtectionChannelBindingElement.cs" />
+ <Compile Include="OAuth\OAuthStrings.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DesignTime>True</DesignTime>
+ <DependentUpon>OAuthStrings.resx</DependentUpon>
+ </Compile>
+ <Compile Include="OAuth\ServiceProviderDescription.cs" />
+ <Compile Include="OAuth\Messages\ITokenContainingMessage.cs" />
+ <Compile Include="OAuth\Messages\SignedMessageBase.cs" />
+ <Compile Include="Messaging\Bindings\NonceMemoryStore.cs" />
+ <Compile Include="OAuth\ChannelElements\SigningBindingElementBase.cs" />
+ <Compile Include="OAuth\WebConsumer.cs" />
+ <Compile Include="Messaging\IWebRequestHandler.cs" />
+ <Compile Include="OAuth\ChannelElements\ITamperResistantOAuthMessage.cs" />
+ <Compile Include="OAuth\Messages\MessageBase.cs" />
+ <Compile Include="OAuth\Messages\AuthorizedTokenRequest.cs" />
+ <Compile Include="Messaging\Bindings\INonceStore.cs" />
+ <Compile Include="Messaging\Bindings\StandardReplayProtectionBindingElement.cs" />
+ <Compile Include="Messaging\MessagePartAttribute.cs" />
+ <Compile Include="Messaging\MessageProtections.cs" />
+ <Compile Include="Messaging\IChannelBindingElement.cs" />
+ <Compile Include="Messaging\Bindings\ReplayedMessageException.cs" />
+ <Compile Include="Messaging\Bindings\ExpiredMessageException.cs" />
+ <Compile Include="Messaging\Bindings\InvalidSignatureException.cs" />
+ <Compile Include="Messaging\Bindings\IReplayProtectedProtocolMessage.cs" />
+ <Compile Include="Messaging\Bindings\IExpiringProtocolMessage.cs" />
+ <Compile Include="OAuth\Messages\AccessProtectedResourceRequest.cs" />
+ <Compile Include="OAuth\Messages\AuthorizedTokenResponse.cs" />
+ <Compile Include="OAuth\Messages\UserAuthorizationResponse.cs" />
+ <Compile Include="OAuth\Messages\UserAuthorizationRequest.cs" />
+ <Compile Include="OAuth\Messages\UnauthorizedTokenResponse.cs" />
+ <Compile Include="Messaging\Channel.cs" />
+ <Compile Include="Messaging\HttpRequestInfo.cs" />
+ <Compile Include="Messaging\IDirectedProtocolMessage.cs" />
+ <Compile Include="Messaging\IMessageTypeProvider.cs" />
+ <Compile Include="Messaging\ITamperResistantProtocolMessage.cs" />
+ <Compile Include="Messaging\MessageSerializer.cs" />
+ <Compile Include="Messaging\MessagingStrings.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DesignTime>True</DesignTime>
+ <DependentUpon>MessagingStrings.resx</DependentUpon>
+ </Compile>
+ <Compile Include="Messaging\MessagingUtilities.cs" />
+ <Compile Include="Messaging\Bindings\StandardExpirationBindingElement.cs" />
+ <Compile Include="Messaging\Reflection\ValueMapping.cs" />
+ <Compile Include="Messaging\Reflection\MessageDescription.cs" />
+ <Compile Include="Messaging\Reflection\MessageDictionary.cs" />
+ <Compile Include="Messaging\Reflection\MessagePart.cs" />
+ <Compile Include="Messaging\UnprotectedMessageException.cs" />
+ <Compile Include="OAuth\ChannelElements\OAuthChannel.cs" />
+ <Compile Include="Messaging\Response.cs" />
+ <Compile Include="Messaging\IProtocolMessage.cs" />
+ <Compile Include="Logger.cs" />
+ <Compile Include="Loggers\ILog.cs" />
+ <Compile Include="Loggers\Log4NetLogger.cs" />
+ <Compile Include="Loggers\NoOpLogger.cs" />
+ <Compile Include="Loggers\TraceLogger.cs" />
+ <Compile Include="Messaging\HttpDeliveryMethods.cs" />
+ <Compile Include="Messaging\MessageTransport.cs" />
+ <Compile Include="OAuth\ChannelElements\OAuthServiceProviderMessageTypeProvider.cs" />
+ <Compile Include="Messaging\ProtocolException.cs" />
+ <Compile Include="OpenId\Association.cs" />
+ <Compile Include="OpenId\AssociationMemoryStore.cs" />
+ <Compile Include="OpenId\Associations.cs" />
+ <Compile Include="OpenId\ChannelElements\ITamperResistantOpenIdMessage.cs" />
+ <Compile Include="OpenId\ChannelElements\SigningBindingElement.cs" />
+ <Compile Include="OpenId\ChannelElements\KeyValueFormEncoding.cs" />
+ <Compile Include="OpenId\ChannelElements\OpenIdChannel.cs" />
+ <Compile Include="OpenId\ChannelElements\OpenIdMessageTypeProvider.cs" />
+ <Compile Include="OpenId\Configuration.cs" />
+ <Compile Include="OpenId\RelyingPartyDescription.cs" />
+ <Compile Include="OpenId\DiffieHellmanUtilities.cs" />
+ <Compile Include="OpenId\DiffieHellman\DHKeyGeneration.cs" />
+ <Compile Include="OpenId\DiffieHellman\DHParameters.cs" />
+ <Compile Include="OpenId\DiffieHellman\DiffieHellman.cs" />
+ <Compile Include="OpenId\DiffieHellman\DiffieHellmanManaged.cs" />
+ <Compile Include="OpenId\DiffieHellman\mono\BigInteger.cs" />
+ <Compile Include="OpenId\DiffieHellman\mono\ConfidenceFactor.cs" />
+ <Compile Include="OpenId\DiffieHellman\mono\NextPrimeFinder.cs" />
+ <Compile Include="OpenId\DiffieHellman\mono\PrimalityTests.cs" />
+ <Compile Include="OpenId\DiffieHellman\mono\PrimeGeneratorBase.cs" />
+ <Compile Include="OpenId\DiffieHellman\mono\SequentialSearchPrimeGeneratorBase.cs" />
+ <Compile Include="OpenId\HmacShaAssociation.cs" />
+ <Compile Include="OpenId\IAssociationStore.cs" />
+ <Compile Include="OpenId\Messages\AssociateUnencryptedRequest.cs" />
+ <Compile Include="OpenId\OpenIdProvider.cs" />
+ <Compile Include="OpenId\Messages\AssociateDiffieHellmanRequest.cs" />
+ <Compile Include="OpenId\Messages\AssociateDiffieHellmanResponse.cs" />
+ <Compile Include="OpenId\Messages\AssociateRequest.cs" />
+ <Compile Include="OpenId\Messages\AssociateSuccessfulResponse.cs" />
+ <Compile Include="OpenId\Messages\AssociateUnencryptedResponse.cs" />
+ <Compile Include="OpenId\Messages\AssociateUnsuccessfulResponse.cs" />
+ <Compile Include="OpenId\Messages\IndirectErrorResponse.cs" />
+ <Compile Include="OpenId\Messages\DirectErrorResponse.cs" />
+ <Compile Include="OpenId\Messages\RequestBase.cs" />
+ <Compile Include="OpenId\Messages\DirectResponseBase.cs" />
+ <Compile Include="OpenId\OpenIdRelyingParty.cs" />
+ <Compile Include="OpenId\OpenIdStrings.Designer.cs">
+ <DependentUpon>OpenIdStrings.resx</DependentUpon>
+ <DesignTime>True</DesignTime>
+ <AutoGen>True</AutoGen>
+ </Compile>
+ <Compile Include="OpenId\Protocol.cs" />
+ <Compile Include="OpenId\ProviderDescription.cs" />
+ <Compile Include="OpenId\Provider\ProviderSecuritySettings.cs" />
+ <Compile Include="OpenId\RelyingParty\RelyingPartySecuritySettings.cs" />
+ <Compile Include="OpenId\SecuritySettings.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="OAuth\Messages\UnauthorizedTokenRequest.cs" />
+ <Compile Include="OAuth\ChannelElements\RsaSha1SigningBindingElement.cs" />
+ <Compile Include="Messaging\StandardWebRequestHandler.cs" />
+ <Compile Include="Messaging\MessageReceivingEndpoint.cs" />
+ <Compile Include="Util.cs" />
+ <Compile Include="OAuth\Protocol.cs" />
+ <Compile Include="OAuth\ServiceProvider.cs" />
+ <Compile Include="Strings.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DesignTime>True</DesignTime>
+ <DependentUpon>Strings.resx</DependentUpon>
+ </Compile>
+ <Compile Include="UriUtil.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="ClassDiagram.cd" />
+ <None Include="OAuth\Messages\OAuth Messages.cd" />
+ <None Include="Messaging\Bindings\Bindings.cd" />
+ <None Include="Messaging\Exceptions.cd" />
+ <None Include="Messaging\Messaging.cd" />
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Messaging\MessagingStrings.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>MessagingStrings.Designer.cs</LastGenOutput>
+ </EmbeddedResource>
+ <EmbeddedResource Include="OAuth\OAuthStrings.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>OAuthStrings.Designer.cs</LastGenOutput>
+ </EmbeddedResource>
+ <EmbeddedResource Include="OpenId\OpenIdStrings.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>OpenIdStrings.Designer.cs</LastGenOutput>
+ </EmbeddedResource>
+ <EmbeddedResource Include="Strings.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>Strings.Designer.cs</LastGenOutput>
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <Import Project="..\..\tools\DotNetOpenAuth.Versioning.targets" />
</Project> \ No newline at end of file
diff --git a/src/DotNetOpenAuth/Messaging/Channel.cs b/src/DotNetOpenAuth/Messaging/Channel.cs
index 6fbd909..73dddb1 100644
--- a/src/DotNetOpenAuth/Messaging/Channel.cs
+++ b/src/DotNetOpenAuth/Messaging/Channel.cs
@@ -280,23 +280,10 @@ namespace DotNetOpenAuth.Messaging {
public TRESPONSE Request<TRESPONSE>(IDirectedProtocolMessage request)
where TRESPONSE : class, IProtocolMessage {
IProtocolMessage response = this.Request(request);
- if (response == null) {
- throw new ProtocolException(
- string.Format(
- CultureInfo.CurrentCulture,
- MessagingStrings.ExpectedMessageNotReceived,
- typeof(TRESPONSE)));
- }
+ ErrorUtilities.Verify(response != null, MessagingStrings.ExpectedMessageNotReceived, typeof(TRESPONSE));
var expectedResponse = response as TRESPONSE;
- if (expectedResponse == null) {
- throw new ProtocolException(
- string.Format(
- CultureInfo.CurrentCulture,
- MessagingStrings.UnexpectedMessageReceived,
- typeof(TRESPONSE),
- response.GetType()));
- }
+ ErrorUtilities.Verify(expectedResponse != null, MessagingStrings.UnexpectedMessageReceived, typeof(TRESPONSE), response.GetType());
return expectedResponse;
}
@@ -305,7 +292,8 @@ namespace DotNetOpenAuth.Messaging {
/// Sends a direct message to a remote party and waits for the response.
/// </summary>
/// <param name="request">The message to send.</param>
- /// <returns>The remote party's response.</returns>
+ /// <returns>The remote party's response. Guaranteed to never be null.</returns>
+ /// <exception cref="ProtocolException">Thrown if the response does not include a protocol message.</exception>
public IProtocolMessage Request(IDirectedProtocolMessage request) {
if (request == null) {
throw new ArgumentNullException("request");
@@ -314,6 +302,7 @@ namespace DotNetOpenAuth.Messaging {
this.PrepareMessageForSending(request);
Logger.DebugFormat("Sending request: {0}", request);
var responseMessage = this.RequestInternal(request);
+ ErrorUtilities.Verify(responseMessage != null, MessagingStrings.ExpectedMessageNotReceived, typeof(IProtocolMessage).Name);
Logger.DebugFormat("Received message response: {0}", responseMessage);
this.VerifyMessageAfterReceiving(responseMessage);
diff --git a/src/DotNetOpenAuth/Messaging/ErrorUtilities.cs b/src/DotNetOpenAuth/Messaging/ErrorUtilities.cs
index 8464066..fb62c76 100644
--- a/src/DotNetOpenAuth/Messaging/ErrorUtilities.cs
+++ b/src/DotNetOpenAuth/Messaging/ErrorUtilities.cs
@@ -52,6 +52,18 @@ namespace DotNetOpenAuth.Messaging {
}
/// <summary>
+ /// Verifies something about the argument supplied to a method.
+ /// </summary>
+ /// <param name="condition">The condition that must evaluate to true to avoid an exception.</param>
+ /// <param name="message">The message to use in the exception if the condition is false.</param>
+ /// <param name="args">The string formatting arguments, if any.</param>
+ internal static void VerifyArgument(bool condition, string message, params string[] args) {
+ if (!condition) {
+ throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, message, args));
+ }
+ }
+
+ /// <summary>
/// Verifies that some given value is not null.
/// </summary>
/// <param name="value">The value to check.</param>
diff --git a/src/DotNetOpenAuth/Messaging/MessagingStrings.Designer.cs b/src/DotNetOpenAuth/Messaging/MessagingStrings.Designer.cs
index eb6e4f8..dcd8f4e 100644
--- a/src/DotNetOpenAuth/Messaging/MessagingStrings.Designer.cs
+++ b/src/DotNetOpenAuth/Messaging/MessagingStrings.Designer.cs
@@ -142,7 +142,7 @@ namespace DotNetOpenAuth.Messaging {
}
/// <summary>
- /// Looks up a localized string similar to Expected message {0} but received no recognizable message..
+ /// Looks up a localized string similar to Expected {0} message but received no recognizable message..
/// </summary>
internal static string ExpectedMessageNotReceived {
get {
@@ -421,6 +421,15 @@ namespace DotNetOpenAuth.Messaging {
}
/// <summary>
+ /// Looks up a localized string similar to Unexpected message type received..
+ /// </summary>
+ internal static string UnexpectedMessageReceivedOfMany {
+ get {
+ return ResourceManager.GetString("UnexpectedMessageReceivedOfMany", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to The type {0} or a derived type was expected, but {1} was given..
/// </summary>
internal static string UnexpectedType {
diff --git a/src/DotNetOpenAuth/Messaging/MessagingStrings.resx b/src/DotNetOpenAuth/Messaging/MessagingStrings.resx
index 406e0ff..aa0d9d0 100644
--- a/src/DotNetOpenAuth/Messaging/MessagingStrings.resx
+++ b/src/DotNetOpenAuth/Messaging/MessagingStrings.resx
@@ -145,7 +145,7 @@
<value>This exception was not constructed with a root request message that caused it.</value>
</data>
<data name="ExpectedMessageNotReceived" xml:space="preserve">
- <value>Expected message {0} but received no recognizable message.</value>
+ <value>Expected {0} message but received no recognizable message.</value>
</data>
<data name="ExpiredMessage" xml:space="preserve">
<value>The message expired at {0} and it is now {1}.</value>
@@ -237,6 +237,9 @@
<data name="UnexpectedMessageReceived" xml:space="preserve">
<value>Expected message {0} but received {1} instead.</value>
</data>
+ <data name="UnexpectedMessageReceivedOfMany" xml:space="preserve">
+ <value>Unexpected message type received.</value>
+ </data>
<data name="UnexpectedType" xml:space="preserve">
<value>The type {0} or a derived type was expected, but {1} was given.</value>
</data>
diff --git a/src/DotNetOpenAuth/OpenId/Messages/AssociateDiffieHellmanResponse.cs b/src/DotNetOpenAuth/OpenId/Messages/AssociateDiffieHellmanResponse.cs
index 7c3a07d..39b7516 100644
--- a/src/DotNetOpenAuth/OpenId/Messages/AssociateDiffieHellmanResponse.cs
+++ b/src/DotNetOpenAuth/OpenId/Messages/AssociateDiffieHellmanResponse.cs
@@ -33,7 +33,25 @@ namespace DotNetOpenAuth.OpenId.Messages {
internal byte[] EncodedMacKey { get; set; }
/// <summary>
- /// Called to create the Association based on a provided request previously given by the Relying Party.
+ /// Called to create the Association based on a request previously given by the Relying Party.
+ /// </summary>
+ /// <param name="request">The prior request for an association.</param>
+ /// <returns>The created association.</returns>
+ /// <remarks>
+ /// <para>The response message is updated to include the details of the created association by this method,
+ /// but the resulting association is <i>not</i> added to the association store and must be done by the caller.</para>
+ /// <para>This method is called by both the Provider and the Relying Party, but actually performs
+ /// quite different operations in either scenario.</para>
+ /// </remarks>
+ protected internal override Association CreateAssociation(AssociateRequest request) {
+ ErrorUtilities.VerifyArgumentNotNull(request, "request");
+ ErrorUtilities.VerifyArgument(request is AssociateDiffieHellmanRequest, "request");
+
+ return this.CreateAssociation((AssociateDiffieHellmanRequest)request);
+ }
+
+ /// <summary>
+ /// Called to create the Association based on a request previously given by the Relying Party.
/// </summary>
/// <param name="request">The request for an association.</param>
/// <returns>The created association.</returns>
@@ -43,7 +61,7 @@ namespace DotNetOpenAuth.OpenId.Messages {
/// <para>This method is called by both the Provider and the Relying Party, but actually performs
/// quite different operations in either scenario.</para>
/// </remarks>
- internal Association CreateAssociation(AssociateDiffieHellmanRequest request) {
+ private Association CreateAssociation(AssociateDiffieHellmanRequest request) {
// If the encoded mac key is already set, then this is an incoming message at the Relying Party.
if (this.EncodedMacKey == null) {
return this.CreateAssociationAtProvider(request);
diff --git a/src/DotNetOpenAuth/OpenId/Messages/AssociateRequest.cs b/src/DotNetOpenAuth/OpenId/Messages/AssociateRequest.cs
index c5adb7e..9e4c533 100644
--- a/src/DotNetOpenAuth/OpenId/Messages/AssociateRequest.cs
+++ b/src/DotNetOpenAuth/OpenId/Messages/AssociateRequest.cs
@@ -60,5 +60,27 @@ namespace DotNetOpenAuth.OpenId.Messages {
OpenIdStrings.NoEncryptionSessionRequiresHttps,
this);
}
+
+ /// <summary>
+ /// Creates an association request message that is appropriate for a given Provider.
+ /// </summary>
+ /// <param name="provider">The provider to create an association with.</param>
+ /// <returns>The message to send to the Provider to request an association.</returns>
+ internal static AssociateRequest Create(ProviderEndpointDescription provider) {
+ AssociateRequest associateRequest;
+ if (provider.Endpoint.IsTransportSecure()) {
+ associateRequest = new AssociateUnencryptedRequest(provider.Endpoint);
+ } else {
+ // TODO: apply security policies and our knowledge of the provider's OpenID version
+ // to select the right association here.
+ var diffieHellmanAssociateRequest = new AssociateDiffieHellmanRequest(provider.Endpoint);
+ diffieHellmanAssociateRequest.AssociationType = provider.Protocol.Args.SignatureAlgorithm.HMAC_SHA1;
+ diffieHellmanAssociateRequest.SessionType = provider.Protocol.Args.SessionType.DH_SHA1;
+ diffieHellmanAssociateRequest.InitializeRequest();
+ associateRequest = diffieHellmanAssociateRequest;
+ }
+
+ return associateRequest;
+ }
}
}
diff --git a/src/DotNetOpenAuth/OpenId/Messages/AssociateSuccessfulResponse.cs b/src/DotNetOpenAuth/OpenId/Messages/AssociateSuccessfulResponse.cs
index 5968171..8c6d39d 100644
--- a/src/DotNetOpenAuth/OpenId/Messages/AssociateSuccessfulResponse.cs
+++ b/src/DotNetOpenAuth/OpenId/Messages/AssociateSuccessfulResponse.cs
@@ -50,5 +50,18 @@ namespace DotNetOpenAuth.OpenId.Messages {
/// <value>An integer, represented in base 10 ASCII. </value>
[MessagePart("expires_in", IsRequired = true)]
internal long ExpiresIn { get; set; }
+
+ /// <summary>
+ /// Called to create the Association based on a request previously given by the Relying Party.
+ /// </summary>
+ /// <param name="request">The prior request for an association.</param>
+ /// <returns>The created association.</returns>
+ /// <remarks>
+ /// <para>The response message is updated to include the details of the created association by this method,
+ /// but the resulting association is <i>not</i> added to the association store and must be done by the caller.</para>
+ /// <para>This method is called by both the Provider and the Relying Party, but actually performs
+ /// quite different operations in either scenario.</para>
+ /// </remarks>
+ protected internal abstract Association CreateAssociation(AssociateRequest request);
}
}
diff --git a/src/DotNetOpenAuth/OpenId/Messages/AssociateUnencryptedResponse.cs b/src/DotNetOpenAuth/OpenId/Messages/AssociateUnencryptedResponse.cs
index 4d0a341..3790963 100644
--- a/src/DotNetOpenAuth/OpenId/Messages/AssociateUnencryptedResponse.cs
+++ b/src/DotNetOpenAuth/OpenId/Messages/AssociateUnencryptedResponse.cs
@@ -5,6 +5,7 @@
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.OpenId.Messages {
+ using System;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.Messaging.Reflection;
@@ -27,5 +28,21 @@ namespace DotNetOpenAuth.OpenId.Messages {
/// </summary>
[MessagePart("mac_key", IsRequired = true, AllowEmpty = false)]
internal byte[] MacKey { get; set; }
+
+ /// <summary>
+ /// Called to create the Association based on a request previously given by the Relying Party.
+ /// </summary>
+ /// <param name="request">The prior request for an association.</param>
+ /// <returns>The created association.</returns>
+ /// <remarks>
+ /// <para>The response message is updated to include the details of the created association by this method,
+ /// but the resulting association is <i>not</i> added to the association store and must be done by the caller.</para>
+ /// <para>This method is called by both the Provider and the Relying Party, but actually performs
+ /// quite different operations in either scenario.</para>
+ /// </remarks>
+ protected internal override Association CreateAssociation(AssociateRequest request) {
+ ////return HmacShaAssociation.Create(Protocol, this.AssociationType, AssociationRelyingPartyType.
+ throw new NotImplementedException();
+ }
}
}
diff --git a/src/DotNetOpenAuth/OpenId/OpenIdRelyingParty.cs b/src/DotNetOpenAuth/OpenId/OpenIdRelyingParty.cs
index f25bcaa..f5e2d9c 100644
--- a/src/DotNetOpenAuth/OpenId/OpenIdRelyingParty.cs
+++ b/src/DotNetOpenAuth/OpenId/OpenIdRelyingParty.cs
@@ -11,6 +11,7 @@ namespace DotNetOpenAuth.OpenId {
using System.Text;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.OpenId.ChannelElements;
+ using DotNetOpenAuth.OpenId.Messages;
/// <summary>
/// Provides the programmatic facilities to act as an OpenId consumer.
@@ -27,5 +28,28 @@ namespace DotNetOpenAuth.OpenId {
/// Gets the channel to use for sending/receiving messages.
/// </summary>
public Channel Channel { get; internal set; }
+
+ /// <summary>
+ /// Gets an association between this Relying Party and a given Provider.
+ /// A new association is created if necessary and possible.
+ /// </summary>
+ /// <param name="provider">The provider to create an association with.</param>
+ /// <returns>The association if one exists and/or could be created. Null otherwise.</returns>
+ internal Association GetAssociation(ProviderEndpointDescription provider) {
+ ErrorUtilities.VerifyArgumentNotNull(provider, "provider");
+
+ var associateRequest = AssociateRequest.Create(provider);
+ var associateResponse = this.Channel.Request(associateRequest);
+ var associateSuccessfulResponse = associateResponse as AssociateSuccessfulResponse;
+ var associateUnsuccessfulResponse = associateResponse as AssociateUnsuccessfulResponse;
+ if (associateSuccessfulResponse != null) {
+ return associateSuccessfulResponse.CreateAssociation(associateRequest);
+ } else if (associateUnsuccessfulResponse != null) {
+ // TODO: code here
+ throw new NotImplementedException();
+ } else {
+ throw new ProtocolException(MessagingStrings.UnexpectedMessageReceivedOfMany);
+ }
+ }
}
}
diff --git a/src/DotNetOpenAuth/OpenId/ProviderDescription.cs b/src/DotNetOpenAuth/OpenId/ProviderDescription.cs
new file mode 100644
index 0000000..99faad1
--- /dev/null
+++ b/src/DotNetOpenAuth/OpenId/ProviderDescription.cs
@@ -0,0 +1,48 @@
+//-----------------------------------------------------------------------
+// <copyright file="ProviderDescription.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.OpenId {
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+ using DotNetOpenAuth.Messaging;
+
+ /// <summary>
+ /// Describes some OpenID Provider endpoint and its capabilities.
+ /// </summary>
+ /// <remarks>
+ /// This is an immutable type.
+ /// </remarks>
+ internal class ProviderEndpointDescription {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ProviderEndpointDescription"/> class.
+ /// </summary>
+ /// <param name="providerEndpoint">The OpenID Provider endpoint URL.</param>
+ /// <param name="version">The OpenID version supported by this particular endpoint.</param>
+ internal ProviderEndpointDescription(Uri providerEndpoint, Protocol version) {
+ ErrorUtilities.VerifyArgumentNotNull(providerEndpoint, "providerEndpoint");
+ ErrorUtilities.VerifyArgumentNotNull(version, "version");
+
+ this.Endpoint = providerEndpoint;
+ this.Protocol = version;
+ }
+
+ /// <summary>
+ /// Gets the URL that the OpenID Provider listens for incoming OpenID messages on.
+ /// </summary>
+ internal Uri Endpoint { get; private set; }
+
+ /// <summary>
+ /// Gets the OpenID protocol version this endpoint supports.
+ /// </summary>
+ /// <remarks>
+ /// If an endpoint supports multiple versions, each version must be represented
+ /// by its own <see cref="ProviderEndpointDescription"/> object.
+ /// </remarks>
+ internal Protocol Protocol { get; private set; }
+ }
+}
diff --git a/src/DotNetOpenAuth/OpenId/RelyingPartyDescription.cs b/src/DotNetOpenAuth/OpenId/RelyingPartyDescription.cs
new file mode 100644
index 0000000..263daac
--- /dev/null
+++ b/src/DotNetOpenAuth/OpenId/RelyingPartyDescription.cs
@@ -0,0 +1,18 @@
+//-----------------------------------------------------------------------
+// <copyright file="RelyingPartyDescription.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.OpenId {
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+
+ /// <summary>
+ /// A description of some OpenID Relying Party endpoint.
+ /// </summary>
+ internal class RelyingPartyEndpointDescription {
+ }
+}