diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2008-09-13 17:20:53 -0700 |
---|---|---|
committer | Andrew <andrewarnott@gmail.com> | 2008-09-13 17:20:53 -0700 |
commit | 09722c436047dccfb6b6294906013786f78d5d53 (patch) | |
tree | b266c794ee5662235063e0ec37d6b938674084f6 /src | |
parent | f665e1e639319918385fcc8397f8c0d5009e3bdd (diff) | |
download | DotNetOpenAuth-09722c436047dccfb6b6294906013786f78d5d53.zip DotNetOpenAuth-09722c436047dccfb6b6294906013786f78d5d53.tar.gz DotNetOpenAuth-09722c436047dccfb6b6294906013786f78d5d53.tar.bz2 |
Refactored several Messaging classes into the Messaging.Bindings namespace.
Diffstat (limited to 'src')
32 files changed, 301 insertions, 83 deletions
diff --git a/src/DotNetOAuth.Test/DotNetOAuth.Test.csproj b/src/DotNetOAuth.Test/DotNetOAuth.Test.csproj index 32e17aa..7d6c942 100644 --- a/src/DotNetOAuth.Test/DotNetOAuth.Test.csproj +++ b/src/DotNetOAuth.Test/DotNetOAuth.Test.csproj @@ -64,7 +64,7 @@ <Compile Include="Messaging\DictionaryXmlReaderTests.cs" />
<Compile Include="Messaging\HttpRequestInfoTests.cs" />
<Compile Include="Messaging\ProtocolExceptionTests.cs" />
- <Compile Include="Messaging\StandardMessageExpirationBindingElementTests.cs" />
+ <Compile Include="Messaging\StandardExpirationBindingElementTests.cs" />
<Compile Include="Mocks\MockTransformationBindingElement.cs" />
<Compile Include="Mocks\MockReplayProtectionBindingElement.cs" />
<Compile Include="Mocks\TestBaseMessage.cs" />
diff --git a/src/DotNetOAuth.Test/Messaging/ChannelTests.cs b/src/DotNetOAuth.Test/Messaging/ChannelTests.cs index 6f58133..e4381a6 100644 --- a/src/DotNetOAuth.Test/Messaging/ChannelTests.cs +++ b/src/DotNetOAuth.Test/Messaging/ChannelTests.cs @@ -11,6 +11,7 @@ namespace DotNetOAuth.Test.Messaging { using System.Net;
using System.Web;
using DotNetOAuth.Messaging;
+ using DotNetOAuth.Messaging.Bindings;
using DotNetOAuth.Test.Mocks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -222,26 +223,26 @@ namespace DotNetOAuth.Test.Messaging { TestReplayProtectedMessage message = new TestReplayProtectedMessage(MessageTransport.Indirect);
message.Recipient = new Uri("http://localtest");
- this.Channel = CreateChannel(ChannelProtection.ReplayProtection, ChannelProtection.ReplayProtection);
+ this.Channel = CreateChannel(MessageProtection.ReplayProtection, MessageProtection.ReplayProtection);
this.Channel.Send(message);
Assert.IsNotNull(((IReplayProtectedProtocolMessage)message).Nonce);
}
[TestMethod, ExpectedException(typeof(InvalidSignatureException))]
public void ReceivedInvalidSignature() {
- this.Channel = CreateChannel(ChannelProtection.TamperProtection, ChannelProtection.TamperProtection);
+ this.Channel = CreateChannel(MessageProtection.TamperProtection, MessageProtection.TamperProtection);
this.ParameterizedReceiveProtectedTest(DateTime.UtcNow, true);
}
[TestMethod]
public void ReceivedReplayProtectedMessageJustOnce() {
- this.Channel = CreateChannel(ChannelProtection.ReplayProtection, ChannelProtection.ReplayProtection);
+ this.Channel = CreateChannel(MessageProtection.ReplayProtection, MessageProtection.ReplayProtection);
this.ParameterizedReceiveProtectedTest(DateTime.UtcNow, false);
}
[TestMethod, ExpectedException(typeof(ReplayedMessageException))]
public void ReceivedReplayProtectedMessageTwice() {
- this.Channel = CreateChannel(ChannelProtection.ReplayProtection, ChannelProtection.ReplayProtection);
+ this.Channel = CreateChannel(MessageProtection.ReplayProtection, MessageProtection.ReplayProtection);
this.ParameterizedReceiveProtectedTest(DateTime.UtcNow, false);
this.ParameterizedReceiveProtectedTest(DateTime.UtcNow, false);
}
@@ -250,7 +251,7 @@ namespace DotNetOAuth.Test.Messaging { public void MessageExpirationWithoutTamperResistance() {
new TestChannel(
new TestMessageTypeProvider(),
- new StandardMessageExpirationBindingElement());
+ new StandardExpirationBindingElement());
}
[TestMethod, ExpectedException(typeof(ProtocolException))]
@@ -267,7 +268,7 @@ namespace DotNetOAuth.Test.Messaging { IChannelBindingElement transformB = new MockTransformationBindingElement("b");
IChannelBindingElement sign = new MockSigningBindingElement();
IChannelBindingElement replay = new MockReplayProtectionBindingElement();
- IChannelBindingElement expire = new StandardMessageExpirationBindingElement();
+ IChannelBindingElement expire = new StandardExpirationBindingElement();
Channel channel = new TestChannel(
new TestMessageTypeProvider(),
diff --git a/src/DotNetOAuth.Test/Messaging/MessagingTestBase.cs b/src/DotNetOAuth.Test/Messaging/MessagingTestBase.cs index 61be6a7..b0b4eba 100644 --- a/src/DotNetOAuth.Test/Messaging/MessagingTestBase.cs +++ b/src/DotNetOAuth.Test/Messaging/MessagingTestBase.cs @@ -11,6 +11,7 @@ namespace DotNetOAuth.Test { using System.Net;
using System.Xml;
using DotNetOAuth.Messaging;
+ using DotNetOAuth.Messaging.Bindings;
using DotNetOAuth.Test.Mocks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -53,22 +54,22 @@ namespace DotNetOAuth.Test { return request;
}
- internal static Channel CreateChannel(ChannelProtection capabilityAndRecognition) {
+ internal static Channel CreateChannel(MessageProtection capabilityAndRecognition) {
return CreateChannel(capabilityAndRecognition, capabilityAndRecognition);
}
- internal static Channel CreateChannel(ChannelProtection capability, ChannelProtection recognition) {
+ internal static Channel CreateChannel(MessageProtection capability, MessageProtection recognition) {
bool signing = false, expiration = false, replay = false;
var bindingElements = new List<IChannelBindingElement>();
- if (capability >= ChannelProtection.TamperProtection) {
+ if (capability >= MessageProtection.TamperProtection) {
bindingElements.Add(new MockSigningBindingElement());
signing = true;
}
- if (capability >= ChannelProtection.Expiration) {
- bindingElements.Add(new StandardMessageExpirationBindingElement());
+ if (capability >= MessageProtection.Expiration) {
+ bindingElements.Add(new StandardExpirationBindingElement());
expiration = true;
}
- if (capability >= ChannelProtection.ReplayProtection) {
+ if (capability >= MessageProtection.ReplayProtection) {
bindingElements.Add(new MockReplayProtectionBindingElement());
replay = true;
}
diff --git a/src/DotNetOAuth.Test/Messaging/ProtocolExceptionTests.cs b/src/DotNetOAuth.Test/Messaging/ProtocolExceptionTests.cs index 072b57c..0e01e33 100644 --- a/src/DotNetOAuth.Test/Messaging/ProtocolExceptionTests.cs +++ b/src/DotNetOAuth.Test/Messaging/ProtocolExceptionTests.cs @@ -38,7 +38,7 @@ namespace DotNetOAuth.Test.Messaging { IDirectedProtocolMessage msg = (IDirectedProtocolMessage)ex;
Assert.AreEqual("some error occurred", ex.Message);
Assert.AreSame(receiver, msg.Recipient);
- Assert.AreEqual(request.Protocol, msg.Protocol);
+ Assert.AreEqual(request.ProtocolVersion, msg.ProtocolVersion);
Assert.AreEqual(request.Transport, msg.Transport);
msg.EnsureValidMessage();
}
@@ -62,15 +62,15 @@ namespace DotNetOAuth.Test.Messaging { ProtocolException ex = new ProtocolException("message", request, null);
IDirectedProtocolMessage msg = (IDirectedProtocolMessage)ex;
Assert.IsNull(msg.Recipient);
- Assert.AreEqual(request.Protocol, msg.Protocol);
+ Assert.AreEqual(request.ProtocolVersion, msg.ProtocolVersion);
Assert.AreEqual(request.Transport, msg.Transport);
}
[TestMethod, ExpectedException(typeof(InvalidOperationException))]
- public void ProtocolWithoutMessage() {
+ public void ProtocolVersionWithoutMessage() {
ProtocolException ex = new ProtocolException();
IDirectedProtocolMessage msg = (IDirectedProtocolMessage)ex;
- var temp = msg.Protocol;
+ var temp = msg.ProtocolVersion;
}
[TestMethod, ExpectedException(typeof(InvalidOperationException))]
diff --git a/src/DotNetOAuth.Test/Messaging/StandardMessageExpirationBindingElementTests.cs b/src/DotNetOAuth.Test/Messaging/StandardExpirationBindingElementTests.cs index 5a664a4..84b12c6 100644 --- a/src/DotNetOAuth.Test/Messaging/StandardMessageExpirationBindingElementTests.cs +++ b/src/DotNetOAuth.Test/Messaging/StandardExpirationBindingElementTests.cs @@ -1,5 +1,5 @@ //-----------------------------------------------------------------------
-// <copyright file="StandardMessageExpirationBindingElementTests.cs" company="Andrew Arnott">
+// <copyright file="StandardExpirationBindingElementTests.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
@@ -7,32 +7,33 @@ namespace DotNetOAuth.Test.Messaging {
using System;
using DotNetOAuth.Messaging;
+ using DotNetOAuth.Messaging.Bindings;
using DotNetOAuth.Test.Mocks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
- public class StandardMessageExpirationBindingElementTests : MessagingTestBase {
+ public class StandardExpirationBindingElementTests : MessagingTestBase {
[TestMethod]
public void SendSetsTimestamp() {
TestExpiringMessage message = new TestExpiringMessage(MessageTransport.Indirect);
message.Recipient = new Uri("http://localtest");
((IExpiringProtocolMessage)message).UtcCreationDate = DateTime.Parse("1/1/1990");
- Channel channel = CreateChannel(ChannelProtection.Expiration, ChannelProtection.Expiration);
+ Channel channel = CreateChannel(MessageProtection.Expiration, MessageProtection.Expiration);
channel.Send(message);
Assert.IsTrue(DateTime.UtcNow - ((IExpiringProtocolMessage)message).UtcCreationDate < TimeSpan.FromSeconds(3), "The timestamp on the message was not set on send.");
}
[TestMethod]
public void VerifyGoodTimestampIsAccepted() {
- this.Channel = CreateChannel(ChannelProtection.Expiration, ChannelProtection.Expiration);
+ this.Channel = CreateChannel(MessageProtection.Expiration, MessageProtection.Expiration);
this.ParameterizedReceiveProtectedTest(DateTime.UtcNow, false);
}
[TestMethod, ExpectedException(typeof(ExpiredMessageException))]
public void VerifyBadTimestampIsRejected() {
- this.Channel = CreateChannel(ChannelProtection.Expiration, ChannelProtection.Expiration);
- this.ParameterizedReceiveProtectedTest(DateTime.UtcNow - StandardMessageExpirationBindingElement.DefaultMaximumMessageAge - TimeSpan.FromSeconds(1), false);
+ this.Channel = CreateChannel(MessageProtection.Expiration, MessageProtection.Expiration);
+ this.ParameterizedReceiveProtectedTest(DateTime.UtcNow - StandardExpirationBindingElement.DefaultMaximumMessageAge - TimeSpan.FromSeconds(1), false);
}
}
}
diff --git a/src/DotNetOAuth.Test/Mocks/MockReplayProtectionBindingElement.cs b/src/DotNetOAuth.Test/Mocks/MockReplayProtectionBindingElement.cs index ff1d709..1b80b5b 100644 --- a/src/DotNetOAuth.Test/Mocks/MockReplayProtectionBindingElement.cs +++ b/src/DotNetOAuth.Test/Mocks/MockReplayProtectionBindingElement.cs @@ -5,11 +5,8 @@ //-----------------------------------------------------------------------
namespace DotNetOAuth.Test.Mocks {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
using DotNetOAuth.Messaging;
+ using DotNetOAuth.Messaging.Bindings;
using Microsoft.VisualStudio.TestTools.UnitTesting;
internal class MockReplayProtectionBindingElement : IChannelBindingElement {
@@ -17,8 +14,8 @@ namespace DotNetOAuth.Test.Mocks { #region IChannelBindingElement Members
- ChannelProtection IChannelBindingElement.Protection {
- get { return ChannelProtection.ReplayProtection; }
+ MessageProtection IChannelBindingElement.Protection {
+ get { return MessageProtection.ReplayProtection; }
}
void IChannelBindingElement.PrepareMessageForSending(IProtocolMessage message) {
diff --git a/src/DotNetOAuth.Test/Mocks/MockSigningBindingElement.cs b/src/DotNetOAuth.Test/Mocks/MockSigningBindingElement.cs index 5cf8be6..8aa8020 100644 --- a/src/DotNetOAuth.Test/Mocks/MockSigningBindingElement.cs +++ b/src/DotNetOAuth.Test/Mocks/MockSigningBindingElement.cs @@ -10,25 +10,26 @@ namespace DotNetOAuth.Test.Mocks { using System.Linq;
using System.Text;
using DotNetOAuth.Messaging;
+ using DotNetOAuth.Messaging.Bindings;
internal class MockSigningBindingElement : IChannelBindingElement {
internal const string MessageSignature = "mocksignature";
#region IChannelBindingElement Members
- ChannelProtection IChannelBindingElement.Protection {
- get { return ChannelProtection.TamperProtection; }
+ MessageProtection IChannelBindingElement.Protection {
+ get { return MessageProtection.TamperProtection; }
}
void IChannelBindingElement.PrepareMessageForSending(IProtocolMessage message) {
- ISignedProtocolMessage signedMessage = message as ISignedProtocolMessage;
+ ISignedOAuthMessage signedMessage = message as ISignedOAuthMessage;
if (signedMessage != null) {
signedMessage.Signature = MessageSignature;
}
}
void IChannelBindingElement.PrepareMessageForReceiving(IProtocolMessage message) {
- ISignedProtocolMessage signedMessage = message as ISignedProtocolMessage;
+ ISignedOAuthMessage signedMessage = message as ISignedOAuthMessage;
if (signedMessage != null) {
if (signedMessage.Signature != MessageSignature) {
throw new InvalidSignatureException(message);
diff --git a/src/DotNetOAuth.Test/Mocks/MockTransformationBindingElement.cs b/src/DotNetOAuth.Test/Mocks/MockTransformationBindingElement.cs index 7a1320b..cd75e34 100644 --- a/src/DotNetOAuth.Test/Mocks/MockTransformationBindingElement.cs +++ b/src/DotNetOAuth.Test/Mocks/MockTransformationBindingElement.cs @@ -25,8 +25,8 @@ namespace DotNetOAuth.Test.Mocks { #region IChannelBindingElement Members
- ChannelProtection IChannelBindingElement.Protection {
- get { return ChannelProtection.None; }
+ MessageProtection IChannelBindingElement.Protection {
+ get { return MessageProtection.None; }
}
void IChannelBindingElement.PrepareMessageForSending(IProtocolMessage message) {
diff --git a/src/DotNetOAuth.Test/Mocks/TestBaseMessage.cs b/src/DotNetOAuth.Test/Mocks/TestBaseMessage.cs index 7841357..29e2809 100644 --- a/src/DotNetOAuth.Test/Mocks/TestBaseMessage.cs +++ b/src/DotNetOAuth.Test/Mocks/TestBaseMessage.cs @@ -5,6 +5,7 @@ //-----------------------------------------------------------------------
namespace DotNetOAuth.Test.Mocks {
+ using System;
using System.Runtime.Serialization;
using DotNetOAuth.Messaging;
@@ -23,8 +24,12 @@ namespace DotNetOAuth.Test.Mocks { [DataMember(Name = "explicit")]
string IBaseMessageExplicitMembers.ExplicitProperty { get; set; }
- Protocol IProtocolMessage.Protocol {
- get { return Protocol.V10; }
+ Version IProtocolMessage.ProtocolVersion {
+ get { return new Version(1, 0); }
+ }
+
+ MessageProtection IProtocolMessage.RequiredProtection {
+ get { return MessageProtection.None; }
}
MessageTransport IProtocolMessage.Transport {
diff --git a/src/DotNetOAuth.Test/Mocks/TestDirectedMessage.cs b/src/DotNetOAuth.Test/Mocks/TestDirectedMessage.cs index 0e600b5..9e4cd38 100644 --- a/src/DotNetOAuth.Test/Mocks/TestDirectedMessage.cs +++ b/src/DotNetOAuth.Test/Mocks/TestDirectedMessage.cs @@ -34,8 +34,12 @@ namespace DotNetOAuth.Test.Mocks { #region IProtocolMessage Members
- Protocol IProtocolMessage.Protocol {
- get { return Protocol.V10; }
+ Version IProtocolMessage.ProtocolVersion {
+ get { return new Version(1, 0); }
+ }
+
+ MessageProtection IProtocolMessage.RequiredProtection {
+ get { return MessageProtection.None; }
}
MessageTransport IProtocolMessage.Transport {
diff --git a/src/DotNetOAuth.Test/Mocks/TestExpiringMessage.cs b/src/DotNetOAuth.Test/Mocks/TestExpiringMessage.cs index cd6f986..d51e8ee 100644 --- a/src/DotNetOAuth.Test/Mocks/TestExpiringMessage.cs +++ b/src/DotNetOAuth.Test/Mocks/TestExpiringMessage.cs @@ -9,6 +9,7 @@ namespace DotNetOAuth.Test.Mocks { using System.Diagnostics;
using System.Runtime.Serialization;
using DotNetOAuth.Messaging;
+ using DotNetOAuth.Messaging.Bindings;
[DataContract(Namespace = Protocol.DataContractNamespaceV10)]
internal class TestExpiringMessage : TestSignedDirectedMessage, IExpiringProtocolMessage {
diff --git a/src/DotNetOAuth.Test/Mocks/TestMessage.cs b/src/DotNetOAuth.Test/Mocks/TestMessage.cs index 7e0def7..e67b582 100644 --- a/src/DotNetOAuth.Test/Mocks/TestMessage.cs +++ b/src/DotNetOAuth.Test/Mocks/TestMessage.cs @@ -33,8 +33,12 @@ namespace DotNetOAuth.Test.Mocks { #region IProtocolMessage Members
- Protocol IProtocolMessage.Protocol {
- get { return Protocol.V10; }
+ Version IProtocolMessage.ProtocolVersion {
+ get { return new Version(1, 0); }
+ }
+
+ MessageProtection IProtocolMessage.RequiredProtection {
+ get { return MessageProtection.None; }
}
MessageTransport IProtocolMessage.Transport {
diff --git a/src/DotNetOAuth.Test/Mocks/TestReplayProtectedMessage.cs b/src/DotNetOAuth.Test/Mocks/TestReplayProtectedMessage.cs index e9b1984..b62957b 100644 --- a/src/DotNetOAuth.Test/Mocks/TestReplayProtectedMessage.cs +++ b/src/DotNetOAuth.Test/Mocks/TestReplayProtectedMessage.cs @@ -7,6 +7,7 @@ namespace DotNetOAuth.Test.Mocks {
using System.Runtime.Serialization;
using DotNetOAuth.Messaging;
+ using DotNetOAuth.Messaging.Bindings;
[DataContract(Namespace = Protocol.DataContractNamespaceV10)]
internal class TestReplayProtectedMessage : TestExpiringMessage, IReplayProtectedProtocolMessage {
diff --git a/src/DotNetOAuth.Test/Mocks/TestSignedDirectedMessage.cs b/src/DotNetOAuth.Test/Mocks/TestSignedDirectedMessage.cs index b00d385..81cae4f 100644 --- a/src/DotNetOAuth.Test/Mocks/TestSignedDirectedMessage.cs +++ b/src/DotNetOAuth.Test/Mocks/TestSignedDirectedMessage.cs @@ -7,9 +7,10 @@ namespace DotNetOAuth.Test.Mocks {
using System.Runtime.Serialization;
using DotNetOAuth.Messaging;
+ using DotNetOAuth.Messaging.Bindings;
[DataContract(Namespace = Protocol.DataContractNamespaceV10)]
- internal class TestSignedDirectedMessage : TestDirectedMessage, ISignedProtocolMessage {
+ internal class TestSignedDirectedMessage : TestDirectedMessage, ISignedOAuthMessage {
internal TestSignedDirectedMessage(MessageTransport transport)
: base(transport) {
}
diff --git a/src/DotNetOAuth/DotNetOAuth.csproj b/src/DotNetOAuth/DotNetOAuth.csproj index 253d4df..69b1186 100644 --- a/src/DotNetOAuth/DotNetOAuth.csproj +++ b/src/DotNetOAuth/DotNetOAuth.csproj @@ -68,28 +68,28 @@ <ItemGroup>
<Compile Include="Consumer.cs" />
<Compile Include="IWebRequestHandler.cs" />
- <Compile Include="Messaging\ChannelProtection.cs" />
+ <Compile Include="Messaging\MessageProtection.cs" />
<Compile Include="Messaging\IChannelBindingElement.cs" />
- <Compile Include="Messaging\ReplayedMessageException.cs" />
- <Compile Include="Messaging\ExpiredMessageException.cs" />
+ <Compile Include="Messaging\Bindings\ReplayedMessageException.cs" />
+ <Compile Include="Messaging\Bindings\ExpiredMessageException.cs" />
<Compile Include="Messaging\DataContractMemberComparer.cs" />
- <Compile Include="Messaging\InvalidSignatureException.cs" />
- <Compile Include="Messaging\IReplayProtectedProtocolMessage.cs" />
- <Compile Include="Messaging\IExpiringProtocolMessage.cs" />
+ <Compile Include="Messaging\Bindings\InvalidSignatureException.cs" />
+ <Compile Include="Messaging\Bindings\IReplayProtectedProtocolMessage.cs" />
+ <Compile Include="Messaging\Bindings\IExpiringProtocolMessage.cs" />
<Compile Include="Messaging\DictionaryXmlReader.cs" />
<Compile Include="Messaging\DictionaryXmlWriter.cs" />
<Compile Include="Messaging\Channel.cs" />
<Compile Include="Messaging\HttpRequestInfo.cs" />
<Compile Include="Messaging\IDirectedProtocolMessage.cs" />
<Compile Include="Messaging\IMessageTypeProvider.cs" />
- <Compile Include="Messaging\ISignedProtocolMessage.cs" />
+ <Compile Include="Messaging\Bindings\ISignedOAuthMessage.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\StandardMessageExpirationBindingElement.cs" />
+ <Compile Include="Messaging\Bindings\StandardExpirationBindingElement.cs" />
<Compile Include="OAuthChannel.cs" />
<Compile Include="Messaging\Response.cs" />
<Compile Include="Messaging\IProtocolMessage.cs" />
@@ -117,6 +117,9 @@ </ItemGroup>
<ItemGroup>
<None Include="ClassDiagram.cd" />
+ <None Include="Messaging\Bindings\Bindings.cd" />
+ <None Include="Messaging\Exceptions.cd" />
+ <None Include="Messaging\Messaging.cd" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Messaging\MessagingStrings.resx">
diff --git a/src/DotNetOAuth/Messaging/Bindings/Bindings.cd b/src/DotNetOAuth/Messaging/Bindings/Bindings.cd new file mode 100644 index 0000000..c663332 --- /dev/null +++ b/src/DotNetOAuth/Messaging/Bindings/Bindings.cd @@ -0,0 +1,76 @@ +<?xml version="1.0" encoding="utf-8"?>
+<ClassDiagram MajorVersion="1" MinorVersion="1">
+ <Class Name="DotNetOAuth.Messaging.Bindings.InvalidSignatureException" Collapsed="true">
+ <Position X="8.25" Y="2" Width="1.5" />
+ <TypeIdentifier>
+ <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
+ <FileName>Messaging\Bindings\InvalidSignatureException.cs</FileName>
+ </TypeIdentifier>
+ </Class>
+ <Class Name="DotNetOAuth.Messaging.Bindings.ReplayedMessageException" Collapsed="true">
+ <Position X="6" Y="2" Width="1.5" />
+ <TypeIdentifier>
+ <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
+ <FileName>Messaging\Bindings\ReplayedMessageException.cs</FileName>
+ </TypeIdentifier>
+ </Class>
+ <Class Name="DotNetOAuth.Messaging.Bindings.ExpiredMessageException" Collapsed="true">
+ <Position X="3.75" Y="2" Width="1.5" />
+ <TypeIdentifier>
+ <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
+ <FileName>Messaging\Bindings\ExpiredMessageException.cs</FileName>
+ </TypeIdentifier>
+ </Class>
+ <Class Name="DotNetOAuth.Messaging.ProtocolException" Collapsed="true">
+ <Position X="6" Y="0.5" Width="1.5" />
+ <TypeIdentifier>
+ <HashCode>AAAKAAAAAAAAAAAAAIBAAAAACAQAIAAAAACAAAAAAAA=</HashCode>
+ <FileName>Messaging\ProtocolException.cs</FileName>
+ </TypeIdentifier>
+ <Lollipop Position="0.2" />
+ </Class>
+ <Class Name="DotNetOAuth.Messaging.Bindings.StandardExpirationBindingElement" Collapsed="true">
+ <Position X="1" Y="3" Width="2.75" />
+ <TypeIdentifier>
+ <HashCode>AAAQAAAAAAAARAAAAAAAEAAAAAIAAAAAAAAAAAAAAAA=</HashCode>
+ <FileName>Messaging\Bindings\StandardExpirationBindingElement.cs</FileName>
+ </TypeIdentifier>
+ <Lollipop Position="0.2" />
+ </Class>
+ <Interface Name="DotNetOAuth.Messaging.IProtocolMessage" Collapsed="true">
+ <Position X="6" Y="3.5" Width="1.5" />
+ <TypeIdentifier>
+ <HashCode>AAAAAAAAQAAAAAAAAAAAAAYAAAAAAAAAAAACAAAAAAA=</HashCode>
+ <FileName>Messaging\IProtocolMessage.cs</FileName>
+ </TypeIdentifier>
+ </Interface>
+ <Interface Name="DotNetOAuth.Messaging.Bindings.IExpiringProtocolMessage" Collapsed="true">
+ <Position X="3.75" Y="4.75" Width="1.5" />
+ <TypeIdentifier>
+ <HashCode>AAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAA=</HashCode>
+ <FileName>Messaging\Bindings\IExpiringProtocolMessage.cs</FileName>
+ </TypeIdentifier>
+ </Interface>
+ <Interface Name="DotNetOAuth.Messaging.Bindings.IReplayProtectedProtocolMessage" Collapsed="true">
+ <Position X="6" Y="4.75" Width="1.5" />
+ <TypeIdentifier>
+ <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAA=</HashCode>
+ <FileName>Messaging\Bindings\IReplayProtectedProtocolMessage.cs</FileName>
+ </TypeIdentifier>
+ </Interface>
+ <Interface Name="DotNetOAuth.Messaging.Bindings.ISignedOAuthMessage" Collapsed="true">
+ <Position X="8.25" Y="4.75" Width="1.5" />
+ <TypeIdentifier>
+ <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAE=</HashCode>
+ <FileName>Messaging\Bindings\ISignedOAuthMessage.cs</FileName>
+ </TypeIdentifier>
+ </Interface>
+ <Interface Name="DotNetOAuth.Messaging.IChannelBindingElement">
+ <Position X="0.5" Y="0.5" Width="2" />
+ <TypeIdentifier>
+ <HashCode>BAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAEAAAAAAAAA=</HashCode>
+ <FileName>Messaging\IChannelBindingElement.cs</FileName>
+ </TypeIdentifier>
+ </Interface>
+ <Font Name="Segoe UI" Size="9" />
+</ClassDiagram>
\ No newline at end of file diff --git a/src/DotNetOAuth/Messaging/ExpiredMessageException.cs b/src/DotNetOAuth/Messaging/Bindings/ExpiredMessageException.cs index fe37b07..df4c446 100644 --- a/src/DotNetOAuth/Messaging/ExpiredMessageException.cs +++ b/src/DotNetOAuth/Messaging/Bindings/ExpiredMessageException.cs @@ -4,7 +4,7 @@ // </copyright>
//-----------------------------------------------------------------------
-namespace DotNetOAuth.Messaging {
+namespace DotNetOAuth.Messaging.Bindings {
using System;
/// <summary>
diff --git a/src/DotNetOAuth/Messaging/IExpiringProtocolMessage.cs b/src/DotNetOAuth/Messaging/Bindings/IExpiringProtocolMessage.cs index 3867369..39c4f97 100644 --- a/src/DotNetOAuth/Messaging/IExpiringProtocolMessage.cs +++ b/src/DotNetOAuth/Messaging/Bindings/IExpiringProtocolMessage.cs @@ -4,7 +4,7 @@ // </copyright>
//-----------------------------------------------------------------------
-namespace DotNetOAuth.Messaging {
+namespace DotNetOAuth.Messaging.Bindings {
using System;
/// <summary>
@@ -13,7 +13,7 @@ namespace DotNetOAuth.Messaging { /// <remarks>
/// All expiring messages must also be signed to prevent tampering with the creation date.
/// </remarks>
- internal interface IExpiringProtocolMessage : ISignedProtocolMessage {
+ internal interface IExpiringProtocolMessage : IProtocolMessage {
/// <summary>
/// Gets or sets the UTC date/time the message was originally sent onto the network.
/// </summary>
diff --git a/src/DotNetOAuth/Messaging/IReplayProtectedProtocolMessage.cs b/src/DotNetOAuth/Messaging/Bindings/IReplayProtectedProtocolMessage.cs index bc6cd7b..e1a5674 100644 --- a/src/DotNetOAuth/Messaging/IReplayProtectedProtocolMessage.cs +++ b/src/DotNetOAuth/Messaging/Bindings/IReplayProtectedProtocolMessage.cs @@ -4,8 +4,9 @@ // </copyright>
//-----------------------------------------------------------------------
-namespace DotNetOAuth.Messaging {
+namespace DotNetOAuth.Messaging.Bindings {
using System;
+ using DotNetOAuth.Messaging;
/// <summary>
/// The contract a message that has an allowable time window for processing must implement.
@@ -14,7 +15,7 @@ namespace DotNetOAuth.Messaging { /// All replay-protected messages must also be set to expire so the nonces do not have
/// to be stored indefinitely.
/// </remarks>
- internal interface IReplayProtectedProtocolMessage : IExpiringProtocolMessage {
+ internal interface IReplayProtectedProtocolMessage : IProtocolMessage {
/// <summary>
/// Gets or sets the nonce that will protect the message from replay attacks.
/// </summary>
diff --git a/src/DotNetOAuth/Messaging/ISignedProtocolMessage.cs b/src/DotNetOAuth/Messaging/Bindings/ISignedOAuthMessage.cs index c3aae98..7ee83ff 100644 --- a/src/DotNetOAuth/Messaging/ISignedProtocolMessage.cs +++ b/src/DotNetOAuth/Messaging/Bindings/ISignedOAuthMessage.cs @@ -1,14 +1,14 @@ //-----------------------------------------------------------------------
-// <copyright file="ISignedProtocolMessage.cs" company="Andrew Arnott">
+// <copyright file="ISignedOAuthMessage.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
-namespace DotNetOAuth.Messaging {
+namespace DotNetOAuth.Messaging.Bindings {
/// <summary>
/// The contract a message that is signed must implement.
/// </summary>
- internal interface ISignedProtocolMessage : IProtocolMessage {
+ internal interface ISignedOAuthMessage : IProtocolMessage {
/// <summary>
/// Gets or sets the message signature.
/// </summary>
diff --git a/src/DotNetOAuth/Messaging/InvalidSignatureException.cs b/src/DotNetOAuth/Messaging/Bindings/InvalidSignatureException.cs index 7b65f2d..89fa938 100644 --- a/src/DotNetOAuth/Messaging/InvalidSignatureException.cs +++ b/src/DotNetOAuth/Messaging/Bindings/InvalidSignatureException.cs @@ -4,7 +4,7 @@ // </copyright>
//-----------------------------------------------------------------------
-namespace DotNetOAuth.Messaging {
+namespace DotNetOAuth.Messaging.Bindings {
using System;
/// <summary>
diff --git a/src/DotNetOAuth/Messaging/ReplayedMessageException.cs b/src/DotNetOAuth/Messaging/Bindings/ReplayedMessageException.cs index 2c4e5cb..11cf096 100644 --- a/src/DotNetOAuth/Messaging/ReplayedMessageException.cs +++ b/src/DotNetOAuth/Messaging/Bindings/ReplayedMessageException.cs @@ -4,7 +4,7 @@ // </copyright>
//-----------------------------------------------------------------------
-namespace DotNetOAuth.Messaging {
+namespace DotNetOAuth.Messaging.Bindings {
using System;
/// <summary>
diff --git a/src/DotNetOAuth/Messaging/StandardMessageExpirationBindingElement.cs b/src/DotNetOAuth/Messaging/Bindings/StandardExpirationBindingElement.cs index cfa0d31..154ea13 100644 --- a/src/DotNetOAuth/Messaging/StandardMessageExpirationBindingElement.cs +++ b/src/DotNetOAuth/Messaging/Bindings/StandardExpirationBindingElement.cs @@ -1,32 +1,32 @@ //-----------------------------------------------------------------------
-// <copyright file="StandardMessageExpirationBindingElement.cs" company="Andrew Arnott">
+// <copyright file="StandardExpirationBindingElement.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
-namespace DotNetOAuth.Messaging {
+namespace DotNetOAuth.Messaging.Bindings {
using System;
/// <summary>
/// A message expiration enforcing binding element that supports messages
/// implementing the <see cref="IExpiringProtocolMessage"/> interface.
/// </summary>
- internal class StandardMessageExpirationBindingElement : IChannelBindingElement {
+ internal class StandardExpirationBindingElement : IChannelBindingElement {
/// <summary>
/// The default maximum message age to use if the default constructor is called.
/// </summary>
internal static readonly TimeSpan DefaultMaximumMessageAge = TimeSpan.FromMinutes(13);
/// <summary>
- /// Initializes a new instance of the <see cref="StandardMessageExpirationBindingElement"/> class
+ /// Initializes a new instance of the <see cref="StandardExpirationBindingElement"/> class
/// with a default maximum message lifetime of 13 minutes.
/// </summary>
- internal StandardMessageExpirationBindingElement()
+ internal StandardExpirationBindingElement()
: this(DefaultMaximumMessageAge) {
}
/// <summary>
- /// Initializes a new instance of the <see cref="StandardMessageExpirationBindingElement"/> class.
+ /// Initializes a new instance of the <see cref="StandardExpirationBindingElement"/> class.
/// </summary>
/// <param name="maximumAge">
/// <para>The maximum age a message implementing the
@@ -39,7 +39,7 @@ namespace DotNetOAuth.Messaging { /// If a message should live for at least t = 3 minutes,
/// this property should be set to (2*d + t) = 13 minutes.</para>
/// </param>
- internal StandardMessageExpirationBindingElement(TimeSpan maximumAge) {
+ internal StandardExpirationBindingElement(TimeSpan maximumAge) {
this.MaximumMessageAge = maximumAge;
}
@@ -48,9 +48,9 @@ namespace DotNetOAuth.Messaging { /// <summary>
/// Gets the protection offered by this binding element.
/// </summary>
- /// <value><see cref="ChannelProtection.Expiration"/></value>
- ChannelProtection IChannelBindingElement.Protection {
- get { return ChannelProtection.Expiration; }
+ /// <value><see cref="MessageProtection.Expiration"/></value>
+ MessageProtection IChannelBindingElement.Protection {
+ get { return MessageProtection.Expiration; }
}
#endregion
diff --git a/src/DotNetOAuth/Messaging/Channel.cs b/src/DotNetOAuth/Messaging/Channel.cs index 5d52b23..3c91b25 100644 --- a/src/DotNetOAuth/Messaging/Channel.cs +++ b/src/DotNetOAuth/Messaging/Channel.cs @@ -64,6 +64,7 @@ namespace DotNetOAuth.Messaging { /// <remarks>
/// Incoming messages should have the binding elements applied in reverse order.
/// </remarks>
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
private List<IChannelBindingElement> bindingElements = new List<IChannelBindingElement>();
/// <summary>
@@ -412,13 +413,13 @@ namespace DotNetOAuth.Messaging { private static IEnumerable<IChannelBindingElement> ValidateAndPrepareBindingElements(IEnumerable<IChannelBindingElement> elements) {
// Filter the elements between the mere transforming ones and the protection ones.
var transformationElements = new List<IChannelBindingElement>(
- elements.Where(element => element.Protection == ChannelProtection.None));
+ elements.Where(element => element.Protection == MessageProtection.None));
var protectionElements = new List<IChannelBindingElement>(
- elements.Where(element => element.Protection != ChannelProtection.None));
+ elements.Where(element => element.Protection != MessageProtection.None));
bool wasLastProtectionPresent = true;
- foreach (ChannelProtection protectionKind in Enum.GetValues(typeof(ChannelProtection))) {
- if (protectionKind == ChannelProtection.None) {
+ foreach (MessageProtection protectionKind in Enum.GetValues(typeof(MessageProtection))) {
+ if (protectionKind == MessageProtection.None) {
continue;
}
@@ -464,8 +465,8 @@ namespace DotNetOAuth.Messaging { /// 1 if <paramref name="element2"/> should be applied to an outgoing message before <paramref name="element1"/>.
/// 0 if it doesn't matter.
/// </returns>
- private static int BindingElementOutgoingMessageApplicationOrder(ChannelProtection protection1, ChannelProtection protection2) {
- Debug.Assert(protection1 != ChannelProtection.None && protection2 != ChannelProtection.None, "This comparison function should only be used to compare protection binding elements. Otherwise we change the order of user-defined message transformations.");
+ private static int BindingElementOutgoingMessageApplicationOrder(MessageProtection protection1, MessageProtection protection2) {
+ Debug.Assert(protection1 != MessageProtection.None && protection2 != MessageProtection.None, "This comparison function should only be used to compare protection binding elements. Otherwise we change the order of user-defined message transformations.");
// Now put the protection ones in the right order.
return -((int)protection1).CompareTo((int)protection2); // descending flag ordinal order
diff --git a/src/DotNetOAuth/Messaging/Exceptions.cd b/src/DotNetOAuth/Messaging/Exceptions.cd new file mode 100644 index 0000000..f0e527b --- /dev/null +++ b/src/DotNetOAuth/Messaging/Exceptions.cd @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="utf-8"?>
+<ClassDiagram MajorVersion="1" MinorVersion="1">
+ <Class Name="DotNetOAuth.Messaging.ExpiredMessageException">
+ <Position X="7.25" Y="2.25" Width="2" />
+ <TypeIdentifier>
+ <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
+ <FileName>Messaging\ExpiredMessageException.cs</FileName>
+ </TypeIdentifier>
+ </Class>
+ <Class Name="DotNetOAuth.Messaging.ProtocolException" Collapsed="true">
+ <Position X="9.75" Y="0.75" Width="1.5" />
+ <TypeIdentifier>
+ <HashCode>AAAKAAAAAAAAQAAAAIBAAAAACAAAAAAAAACAAAAAAAA=</HashCode>
+ <FileName>Messaging\ProtocolException.cs</FileName>
+ </TypeIdentifier>
+ <Lollipop Position="0.2" />
+ </Class>
+ <Class Name="DotNetOAuth.Messaging.InvalidSignatureException" Collapsed="true">
+ <Position X="9.5" Y="2.25" Width="2" />
+ <TypeIdentifier>
+ <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
+ <FileName>Messaging\InvalidSignatureException.cs</FileName>
+ </TypeIdentifier>
+ </Class>
+ <Class Name="DotNetOAuth.Messaging.ReplayedMessageException" Collapsed="true">
+ <Position X="11.75" Y="2.25" Width="2.25" />
+ <TypeIdentifier>
+ <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
+ <FileName>Messaging\ReplayedMessageException.cs</FileName>
+ </TypeIdentifier>
+ </Class>
+ <Font Name="Segoe UI" Size="9" />
+</ClassDiagram>
\ No newline at end of file diff --git a/src/DotNetOAuth/Messaging/IChannelBindingElement.cs b/src/DotNetOAuth/Messaging/IChannelBindingElement.cs index 5e72d36..b9f41f8 100644 --- a/src/DotNetOAuth/Messaging/IChannelBindingElement.cs +++ b/src/DotNetOAuth/Messaging/IChannelBindingElement.cs @@ -18,7 +18,7 @@ namespace DotNetOAuth.Messaging { /// <summary>
/// Gets the protection offered (if any) by this binding element.
/// </summary>
- ChannelProtection Protection { get; }
+ MessageProtection Protection { get; }
/// <summary>
/// Prepares a message for sending based on the rules of this channel binding element.
diff --git a/src/DotNetOAuth/Messaging/IProtocolMessage.cs b/src/DotNetOAuth/Messaging/IProtocolMessage.cs index 76079c0..61df813 100644 --- a/src/DotNetOAuth/Messaging/IProtocolMessage.cs +++ b/src/DotNetOAuth/Messaging/IProtocolMessage.cs @@ -17,7 +17,12 @@ namespace DotNetOAuth.Messaging { /// <summary>
/// Gets the version of the protocol this message is prepared to implement.
/// </summary>
- Protocol Protocol { get; }
+ Version ProtocolVersion { get; }
+
+ /// <summary>
+ /// Gets the level of protection this message requires.
+ /// </summary>
+ MessageProtection RequiredProtection { get; }
/// <summary>
/// Gets whether this is a direct or indirect message.
diff --git a/src/DotNetOAuth/Messaging/ChannelProtection.cs b/src/DotNetOAuth/Messaging/MessageProtection.cs index bbc619c..b87c12d 100644 --- a/src/DotNetOAuth/Messaging/ChannelProtection.cs +++ b/src/DotNetOAuth/Messaging/MessageProtection.cs @@ -1,5 +1,5 @@ //-----------------------------------------------------------------------
-// <copyright file="ChannelProtection.cs" company="Andrew Arnott">
+// <copyright file="MessageProtection.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
@@ -17,7 +17,7 @@ namespace DotNetOAuth.Messaging { /// tamper protection to prevent a user from changing the timestamp on a message.
/// </remarks>
[Flags]
- internal enum ChannelProtection {
+ internal enum MessageProtection {
/// <summary>
/// No protection.
/// </summary>
diff --git a/src/DotNetOAuth/Messaging/Messaging.cd b/src/DotNetOAuth/Messaging/Messaging.cd new file mode 100644 index 0000000..48106a8 --- /dev/null +++ b/src/DotNetOAuth/Messaging/Messaging.cd @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="utf-8"?>
+<ClassDiagram MajorVersion="1" MinorVersion="1" GroupingSetting="Access">
+ <Class Name="DotNetOAuth.Messaging.Channel">
+ <Position X="5.25" Y="0.75" Width="1.75" />
+ <Compartments>
+ <Compartment Name="Protected" Collapsed="true" />
+ <Compartment Name="Internal" Collapsed="true" />
+ <Compartment Name="Private" Collapsed="true" />
+ <Compartment Name="Fields" Collapsed="true" />
+ </Compartments>
+ <TypeIdentifier>
+ <HashCode>gBgQgAIAAQAEAIgAAEAAAARBIAAQgAAQEEAAAABAMAA=</HashCode>
+ <FileName>Messaging\Channel.cs</FileName>
+ </TypeIdentifier>
+ <ShowAsCollectionAssociation>
+ <Property Name="BindingElements" />
+ </ShowAsCollectionAssociation>
+ </Class>
+ <Interface Name="DotNetOAuth.Messaging.IChannelBindingElement">
+ <Position X="1.75" Y="1.5" Width="2.25" />
+ <TypeIdentifier>
+ <HashCode>BAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAEAAAAAAAAA=</HashCode>
+ <FileName>Messaging\IChannelBindingElement.cs</FileName>
+ </TypeIdentifier>
+ <ShowAsAssociation>
+ <Property Name="Protection" />
+ </ShowAsAssociation>
+ </Interface>
+ <Interface Name="DotNetOAuth.Messaging.IProtocolMessage">
+ <Position X="5.25" Y="3.5" Width="1.75" />
+ <TypeIdentifier>
+ <HashCode>AAAAAAAAQAAAAAAAAAAAAAYAAAAAAAAAAAACAAAAAAA=</HashCode>
+ <FileName>Messaging\IProtocolMessage.cs</FileName>
+ </TypeIdentifier>
+ <ShowAsAssociation>
+ <Property Name="RequiredProtection" />
+ <Property Name="Transport" />
+ </ShowAsAssociation>
+ </Interface>
+ <Interface Name="DotNetOAuth.Messaging.IDirectedProtocolMessage">
+ <Position X="5" Y="5.25" Width="2.25" />
+ <TypeIdentifier>
+ <HashCode>AAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
+ <FileName>Messaging\IDirectedProtocolMessage.cs</FileName>
+ </TypeIdentifier>
+ </Interface>
+ <Enum Name="DotNetOAuth.Messaging.MessageProtection">
+ <Position X="2" Y="3.5" Width="1.75" />
+ <TypeIdentifier>
+ <HashCode>AIAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAEAAAA=</HashCode>
+ <FileName>Messaging\MessageProtection.cs</FileName>
+ </TypeIdentifier>
+ </Enum>
+ <Enum Name="DotNetOAuth.Messaging.MessageTransport">
+ <Position X="8" Y="3.5" Width="1.5" />
+ <TypeIdentifier>
+ <HashCode>AAACAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
+ <FileName>Messaging\MessageTransport.cs</FileName>
+ </TypeIdentifier>
+ </Enum>
+ <Font Name="Segoe UI" Size="9" />
+</ClassDiagram>
\ No newline at end of file diff --git a/src/DotNetOAuth/Messaging/ProtocolException.cs b/src/DotNetOAuth/Messaging/ProtocolException.cs index d7c3675..05ff340 100644 --- a/src/DotNetOAuth/Messaging/ProtocolException.cs +++ b/src/DotNetOAuth/Messaging/ProtocolException.cs @@ -120,16 +120,23 @@ namespace DotNetOAuth.Messaging { /// <summary>
/// Gets the version of the protocol this message is prepared to implement.
/// </summary>
- Protocol IProtocolMessage.Protocol {
+ Version IProtocolMessage.ProtocolVersion {
get {
if (this.inResponseTo == null) {
throw new InvalidOperationException(MessagingStrings.ExceptionNotConstructedForTransit);
}
- return this.inResponseTo.Protocol;
+ return this.inResponseTo.ProtocolVersion;
}
}
/// <summary>
+ /// Gets the level of protection this exception requires when transmitted as a message.
+ /// </summary>
+ MessageProtection IProtocolMessage.RequiredProtection {
+ get { return MessageProtection.None; }
+ }
+
+ /// <summary>
/// Gets whether this is a direct or indirect message.
/// </summary>
MessageTransport IProtocolMessage.Transport {
diff --git a/src/DotNetOAuth/OAuthChannel.cs b/src/DotNetOAuth/OAuthChannel.cs index 5ca973e..47f445f 100644 --- a/src/DotNetOAuth/OAuthChannel.cs +++ b/src/DotNetOAuth/OAuthChannel.cs @@ -195,11 +195,12 @@ namespace DotNetOAuth { private HttpWebRequest InitializeRequestAsAuthHeader(IDirectedProtocolMessage requestMessage) {
var serializer = MessageSerializer.Get(requestMessage.GetType());
var fields = serializer.Serialize(requestMessage);
+ var protocol = Protocol.Lookup(requestMessage.ProtocolVersion);
HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(requestMessage.Recipient);
StringBuilder authorization = new StringBuilder();
- authorization.Append(requestMessage.Protocol.AuthorizationHeaderScheme);
+ authorization.Append(protocol.AuthorizationHeaderScheme);
authorization.Append(" ");
foreach (var pair in fields) {
string key = Uri.EscapeDataString(pair.Key);
diff --git a/src/DotNetOAuth/Protocol.cs b/src/DotNetOAuth/Protocol.cs index f3dc3b6..7d91b6c 100644 --- a/src/DotNetOAuth/Protocol.cs +++ b/src/DotNetOAuth/Protocol.cs @@ -71,5 +71,17 @@ namespace DotNetOAuth { internal string AuthorizationHeaderScheme {
get { return this.authorizationHeaderScheme; }
}
+
+ /// <summary>
+ /// Gets an instance of <see cref="Protocol"/> given a <see cref="Version"/>.
+ /// </summary>
+ /// <param name="version">The version of the protocol that is desired.</param>
+ /// <returns>The <see cref="Protocol"/> instance representing the requested version.</returns>
+ internal static Protocol Lookup(Version version) {
+ switch (version.Major) {
+ case 1: return Protocol.V10;
+ default: throw new ArgumentOutOfRangeException("version");
+ }
+ }
}
}
|