diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2008-10-23 19:52:59 -0700 |
---|---|---|
committer | Andrew <andrewarnott@gmail.com> | 2008-10-23 19:52:59 -0700 |
commit | 38c7d25878550429583558f5c907e34fb094fb68 (patch) | |
tree | c6edc9ee32d6d2031202040ac18cd2d288b3bb83 /src | |
parent | 7ba9649126a7b802e348fbe210383fabc2898659 (diff) | |
download | DotNetOpenAuth-38c7d25878550429583558f5c907e34fb094fb68.zip DotNetOpenAuth-38c7d25878550429583558f5c907e34fb094fb68.tar.gz DotNetOpenAuth-38c7d25878550429583558f5c907e34fb094fb68.tar.bz2 |
Applied FxCop fixes.
Diffstat (limited to 'src')
58 files changed, 488 insertions, 254 deletions
diff --git a/src/DotNetOAuth.Test/ChannelElements/OAuthChannelTests.cs b/src/DotNetOAuth.Test/ChannelElements/OAuthChannelTests.cs index d847726..7a03859 100644 --- a/src/DotNetOAuth.Test/ChannelElements/OAuthChannelTests.cs +++ b/src/DotNetOAuth.Test/ChannelElements/OAuthChannelTests.cs @@ -68,17 +68,17 @@ namespace DotNetOAuth.Test.ChannelElements { [TestMethod]
public void ReadFromRequestAuthorization() {
- this.ParameterizedReceiveTest(HttpDeliveryMethod.AuthorizationHeaderRequest);
+ this.ParameterizedReceiveTest(HttpDeliveryMethods.AuthorizationHeaderRequest);
}
[TestMethod]
public void ReadFromRequestForm() {
- this.ParameterizedReceiveTest(HttpDeliveryMethod.PostRequest);
+ this.ParameterizedReceiveTest(HttpDeliveryMethods.PostRequest);
}
[TestMethod]
public void ReadFromRequestQueryString() {
- this.ParameterizedReceiveTest(HttpDeliveryMethod.GetRequest);
+ this.ParameterizedReceiveTest(HttpDeliveryMethods.GetRequest);
}
[TestMethod]
@@ -144,23 +144,23 @@ namespace DotNetOAuth.Test.ChannelElements { public void RequestBadPreferredScheme() {
TestDirectedMessage message = new TestDirectedMessage(MessageTransport.Direct);
message.Recipient = new Uri("http://localtest");
- message.HttpMethods = HttpDeliveryMethod.None;
+ message.HttpMethods = HttpDeliveryMethods.None;
this.channel.Request(message);
}
[TestMethod]
public void RequestUsingAuthorizationHeader() {
- this.ParameterizedRequestTest(HttpDeliveryMethod.AuthorizationHeaderRequest);
+ this.ParameterizedRequestTest(HttpDeliveryMethods.AuthorizationHeaderRequest);
}
[TestMethod]
public void RequestUsingGet() {
- this.ParameterizedRequestTest(HttpDeliveryMethod.GetRequest);
+ this.ParameterizedRequestTest(HttpDeliveryMethods.GetRequest);
}
[TestMethod]
public void RequestUsingPost() {
- this.ParameterizedRequestTest(HttpDeliveryMethod.PostRequest);
+ this.ParameterizedRequestTest(HttpDeliveryMethods.PostRequest);
}
private static string CreateAuthorizationHeader(IDictionary<string, string> fields) {
@@ -183,14 +183,14 @@ namespace DotNetOAuth.Test.ChannelElements { return authorization.ToString();
}
- private static HttpRequestInfo CreateHttpRequestInfo(HttpDeliveryMethod scheme, IDictionary<string, string> fields) {
+ private static HttpRequestInfo CreateHttpRequestInfo(HttpDeliveryMethods scheme, IDictionary<string, string> fields) {
string query = MessagingUtilities.CreateQueryString(fields);
UriBuilder requestUri = new UriBuilder("http://localhost/path");
WebHeaderCollection headers = new WebHeaderCollection();
MemoryStream ms = new MemoryStream();
string method;
switch (scheme) {
- case HttpDeliveryMethod.PostRequest:
+ case HttpDeliveryMethods.PostRequest:
method = "POST";
headers.Add(HttpRequestHeader.ContentType, "application/x-www-form-urlencoded");
StreamWriter sw = new StreamWriter(ms);
@@ -198,11 +198,11 @@ namespace DotNetOAuth.Test.ChannelElements { sw.Flush();
ms.Position = 0;
break;
- case HttpDeliveryMethod.GetRequest:
+ case HttpDeliveryMethods.GetRequest:
method = "GET";
requestUri.Query = query;
break;
- case HttpDeliveryMethod.AuthorizationHeaderRequest:
+ case HttpDeliveryMethods.AuthorizationHeaderRequest:
method = "GET";
headers.Add(HttpRequestHeader.Authorization, CreateAuthorizationHeader(fields));
break;
@@ -229,7 +229,7 @@ namespace DotNetOAuth.Test.ChannelElements { return info;
}
- private void ParameterizedRequestTest(HttpDeliveryMethod scheme) {
+ private void ParameterizedRequestTest(HttpDeliveryMethods scheme) {
TestDirectedMessage request = new TestDirectedMessage(MessageTransport.Direct) {
Age = 15,
Name = "Andrew",
@@ -243,7 +243,7 @@ namespace DotNetOAuth.Test.ChannelElements { this.webRequestHandler.Callback = (req) => {
Assert.IsNotNull(req);
HttpRequestInfo reqInfo = ConvertToRequestInfo(req, this.webRequestHandler.RequestEntityStream);
- Assert.AreEqual(scheme == HttpDeliveryMethod.PostRequest ? "POST" : "GET", reqInfo.HttpMethod);
+ Assert.AreEqual(scheme == HttpDeliveryMethods.PostRequest ? "POST" : "GET", reqInfo.HttpMethod);
var incomingMessage = this.channel.ReadFromRequest(reqInfo) as TestMessage;
Assert.IsNotNull(incomingMessage);
Assert.AreEqual(request.Age, incomingMessage.Age);
@@ -272,7 +272,7 @@ namespace DotNetOAuth.Test.ChannelElements { Assert.AreEqual(request.Location, responseMessage.Location);
}
- private void ParameterizedReceiveTest(HttpDeliveryMethod scheme) {
+ private void ParameterizedReceiveTest(HttpDeliveryMethods scheme) {
var fields = new Dictionary<string, string> {
{ "age", "15" },
{ "Name", "Andrew" },
diff --git a/src/DotNetOAuth.Test/ChannelElements/PlainTextSigningBindingElementTest.cs b/src/DotNetOAuth.Test/ChannelElements/PlaintextSigningBindingElementTest.cs index ef27e94..7bf9e63 100644 --- a/src/DotNetOAuth.Test/ChannelElements/PlainTextSigningBindingElementTest.cs +++ b/src/DotNetOAuth.Test/ChannelElements/PlaintextSigningBindingElementTest.cs @@ -1,5 +1,5 @@ //-----------------------------------------------------------------------
-// <copyright file="PlainTextSigningBindingElementTest.cs" company="Andrew Arnott">
+// <copyright file="PlaintextSigningBindingElementTest.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
@@ -12,11 +12,11 @@ namespace DotNetOAuth.Test.ChannelElements using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
- public class PlainTextSigningBindingElementTest {
+ public class PlaintextSigningBindingElementTest {
[TestMethod]
public void HttpsSignatureGeneration() {
- SigningBindingElementBase target = new PlainTextSigningBindingElement();
- MessageReceivingEndpoint endpoint = new MessageReceivingEndpoint("https://localtest", HttpDeliveryMethod.GetRequest);
+ SigningBindingElementBase target = new PlaintextSigningBindingElement();
+ MessageReceivingEndpoint endpoint = new MessageReceivingEndpoint("https://localtest", HttpDeliveryMethods.GetRequest);
ITamperResistantOAuthMessage message = new GetRequestTokenMessage(endpoint);
message.ConsumerSecret = "cs";
message.TokenSecret = "ts";
@@ -27,8 +27,8 @@ namespace DotNetOAuth.Test.ChannelElements [TestMethod]
public void HttpsSignatureVerification() {
- MessageReceivingEndpoint endpoint = new MessageReceivingEndpoint("https://localtest", HttpDeliveryMethod.GetRequest);
- ITamperProtectionChannelBindingElement target = new PlainTextSigningBindingElement();
+ MessageReceivingEndpoint endpoint = new MessageReceivingEndpoint("https://localtest", HttpDeliveryMethods.GetRequest);
+ ITamperProtectionChannelBindingElement target = new PlaintextSigningBindingElement();
ITamperResistantOAuthMessage message = new GetRequestTokenMessage(endpoint);
message.ConsumerSecret = "cs";
message.TokenSecret = "ts";
@@ -39,8 +39,8 @@ namespace DotNetOAuth.Test.ChannelElements [TestMethod]
public void HttpsSignatureVerificationNotApplicable() {
- SigningBindingElementBase target = new PlainTextSigningBindingElement();
- MessageReceivingEndpoint endpoint = new MessageReceivingEndpoint("https://localtest", HttpDeliveryMethod.GetRequest);
+ SigningBindingElementBase target = new PlaintextSigningBindingElement();
+ MessageReceivingEndpoint endpoint = new MessageReceivingEndpoint("https://localtest", HttpDeliveryMethods.GetRequest);
ITamperResistantOAuthMessage message = new GetRequestTokenMessage(endpoint);
message.ConsumerSecret = "cs";
message.TokenSecret = "ts";
@@ -51,8 +51,8 @@ namespace DotNetOAuth.Test.ChannelElements [TestMethod]
public void HttpSignatureGeneration() {
- SigningBindingElementBase target = new PlainTextSigningBindingElement();
- MessageReceivingEndpoint endpoint = new MessageReceivingEndpoint("http://localtest", HttpDeliveryMethod.GetRequest);
+ SigningBindingElementBase target = new PlaintextSigningBindingElement();
+ MessageReceivingEndpoint endpoint = new MessageReceivingEndpoint("http://localtest", HttpDeliveryMethods.GetRequest);
ITamperResistantOAuthMessage message = new GetRequestTokenMessage(endpoint);
message.ConsumerSecret = "cs";
message.TokenSecret = "ts";
@@ -65,8 +65,8 @@ namespace DotNetOAuth.Test.ChannelElements [TestMethod]
public void HttpSignatureVerification() {
- SigningBindingElementBase target = new PlainTextSigningBindingElement();
- MessageReceivingEndpoint endpoint = new MessageReceivingEndpoint("http://localtest", HttpDeliveryMethod.GetRequest);
+ SigningBindingElementBase target = new PlaintextSigningBindingElement();
+ MessageReceivingEndpoint endpoint = new MessageReceivingEndpoint("http://localtest", HttpDeliveryMethods.GetRequest);
ITamperResistantOAuthMessage message = new GetRequestTokenMessage(endpoint);
message.ConsumerSecret = "cs";
message.TokenSecret = "ts";
diff --git a/src/DotNetOAuth.Test/ChannelElements/SigningBindingElementBaseTests.cs b/src/DotNetOAuth.Test/ChannelElements/SigningBindingElementBaseTests.cs index 0ce116c..6759bc6 100644 --- a/src/DotNetOAuth.Test/ChannelElements/SigningBindingElementBaseTests.cs +++ b/src/DotNetOAuth.Test/ChannelElements/SigningBindingElementBaseTests.cs @@ -23,7 +23,7 @@ namespace DotNetOAuth.Test.ChannelElements { }
internal static GetRequestTokenMessage CreateTestRequestTokenMessage() {
- MessageReceivingEndpoint endpoint = new MessageReceivingEndpoint("https://www.google.com/accounts/OAuthGetRequestToken", HttpDeliveryMethod.AuthorizationHeaderRequest | HttpDeliveryMethod.GetRequest);
+ MessageReceivingEndpoint endpoint = new MessageReceivingEndpoint("https://www.google.com/accounts/OAuthGetRequestToken", HttpDeliveryMethods.AuthorizationHeaderRequest | HttpDeliveryMethods.GetRequest);
GetRequestTokenMessage message = new GetRequestTokenMessage(endpoint);
message.ConsumerKey = "nerdbank.org";
((ITamperResistantOAuthMessage)message).ConsumerSecret = "nerdbanksecret";
diff --git a/src/DotNetOAuth.Test/DotNetOAuth.Test.csproj b/src/DotNetOAuth.Test/DotNetOAuth.Test.csproj index 35af966..14a1a39 100644 --- a/src/DotNetOAuth.Test/DotNetOAuth.Test.csproj +++ b/src/DotNetOAuth.Test/DotNetOAuth.Test.csproj @@ -89,7 +89,7 @@ <Compile Include="Mocks\TestChannel.cs" />
<Compile Include="Mocks\TestMessage.cs" />
<Compile Include="Mocks\TestMessageTypeProvider.cs" />
- <Compile Include="ChannelElements\PlainTextSigningBindingElementTest.cs" />
+ <Compile Include="ChannelElements\PlaintextSigningBindingElementTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Messaging\ResponseTests.cs" />
<Compile Include="ProtocolTests.cs" />
diff --git a/src/DotNetOAuth.Test/Messaging/Bindings/StandardExpirationBindingElementTests.cs b/src/DotNetOAuth.Test/Messaging/Bindings/StandardExpirationBindingElementTests.cs index bbef6f2..6c05434 100644 --- a/src/DotNetOAuth.Test/Messaging/Bindings/StandardExpirationBindingElementTests.cs +++ b/src/DotNetOAuth.Test/Messaging/Bindings/StandardExpirationBindingElementTests.cs @@ -19,20 +19,20 @@ namespace DotNetOAuth.Test.Messaging.Bindings { message.Recipient = new Uri("http://localtest");
((IExpiringProtocolMessage)message).UtcCreationDate = DateTime.Parse("1/1/1990");
- Channel channel = CreateChannel(MessageProtection.Expiration);
+ Channel channel = CreateChannel(MessageProtections.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(MessageProtection.Expiration);
+ this.Channel = CreateChannel(MessageProtections.Expiration);
this.ParameterizedReceiveProtectedTest(DateTime.UtcNow, false);
}
[TestMethod, ExpectedException(typeof(ExpiredMessageException))]
public void VerifyBadTimestampIsRejected() {
- this.Channel = CreateChannel(MessageProtection.Expiration);
+ this.Channel = CreateChannel(MessageProtections.Expiration);
this.ParameterizedReceiveProtectedTest(DateTime.UtcNow - StandardExpirationBindingElement.DefaultMaximumMessageAge - TimeSpan.FromSeconds(1), false);
}
}
diff --git a/src/DotNetOAuth.Test/Messaging/ChannelTests.cs b/src/DotNetOAuth.Test/Messaging/ChannelTests.cs index 9caa10d..e142c82 100644 --- a/src/DotNetOAuth.Test/Messaging/ChannelTests.cs +++ b/src/DotNetOAuth.Test/Messaging/ChannelTests.cs @@ -205,26 +205,26 @@ namespace DotNetOAuth.Test.Messaging { TestReplayProtectedMessage message = new TestReplayProtectedMessage(MessageTransport.Indirect);
message.Recipient = new Uri("http://localtest");
- this.Channel = CreateChannel(MessageProtection.ReplayProtection);
+ this.Channel = CreateChannel(MessageProtections.ReplayProtection);
this.Channel.Send(message);
Assert.IsNotNull(((IReplayProtectedProtocolMessage)message).Nonce);
}
[TestMethod, ExpectedException(typeof(InvalidSignatureException))]
public void ReceivedInvalidSignature() {
- this.Channel = CreateChannel(MessageProtection.TamperProtection);
+ this.Channel = CreateChannel(MessageProtections.TamperProtection);
this.ParameterizedReceiveProtectedTest(DateTime.UtcNow, true);
}
[TestMethod]
public void ReceivedReplayProtectedMessageJustOnce() {
- this.Channel = CreateChannel(MessageProtection.ReplayProtection);
+ this.Channel = CreateChannel(MessageProtections.ReplayProtection);
this.ParameterizedReceiveProtectedTest(DateTime.UtcNow, false);
}
[TestMethod, ExpectedException(typeof(ReplayedMessageException))]
public void ReceivedReplayProtectedMessageTwice() {
- this.Channel = CreateChannel(MessageProtection.ReplayProtection);
+ this.Channel = CreateChannel(MessageProtections.ReplayProtection);
this.ParameterizedReceiveProtectedTest(DateTime.UtcNow, false);
this.ParameterizedReceiveProtectedTest(DateTime.UtcNow, false);
}
@@ -277,7 +277,7 @@ namespace DotNetOAuth.Test.Messaging { [TestMethod, ExpectedException(typeof(UnprotectedMessageException))]
public void InsufficientlyProtectedMessageReceived() {
- this.Channel = CreateChannel(MessageProtection.None, MessageProtection.TamperProtection);
+ this.Channel = CreateChannel(MessageProtections.None, MessageProtections.TamperProtection);
this.ParameterizedReceiveProtectedTest(DateTime.Now, false);
}
diff --git a/src/DotNetOAuth.Test/Messaging/MessagingTestBase.cs b/src/DotNetOAuth.Test/Messaging/MessagingTestBase.cs index aa4f350..403cd25 100644 --- a/src/DotNetOAuth.Test/Messaging/MessagingTestBase.cs +++ b/src/DotNetOAuth.Test/Messaging/MessagingTestBase.cs @@ -78,30 +78,30 @@ namespace DotNetOAuth.Test { return request;
}
- internal static Channel CreateChannel(MessageProtection capabilityAndRecognition) {
+ internal static Channel CreateChannel(MessageProtections capabilityAndRecognition) {
return CreateChannel(capabilityAndRecognition, capabilityAndRecognition);
}
- internal static Channel CreateChannel(MessageProtection capability, MessageProtection recognition) {
+ internal static Channel CreateChannel(MessageProtections capability, MessageProtections recognition) {
var bindingElements = new List<IChannelBindingElement>();
- if (capability >= MessageProtection.TamperProtection) {
+ if (capability >= MessageProtections.TamperProtection) {
bindingElements.Add(new MockSigningBindingElement());
}
- if (capability >= MessageProtection.Expiration) {
+ if (capability >= MessageProtections.Expiration) {
bindingElements.Add(new StandardExpirationBindingElement());
}
- if (capability >= MessageProtection.ReplayProtection) {
+ if (capability >= MessageProtections.ReplayProtection) {
bindingElements.Add(new MockReplayProtectionBindingElement());
}
bool signing = false, expiration = false, replay = false;
- if (recognition >= MessageProtection.TamperProtection) {
+ if (recognition >= MessageProtections.TamperProtection) {
signing = true;
}
- if (recognition >= MessageProtection.Expiration) {
+ if (recognition >= MessageProtections.Expiration) {
expiration = true;
}
- if (recognition >= MessageProtection.ReplayProtection) {
+ if (recognition >= MessageProtections.ReplayProtection) {
replay = true;
}
diff --git a/src/DotNetOAuth.Test/Mocks/MockReplayProtectionBindingElement.cs b/src/DotNetOAuth.Test/Mocks/MockReplayProtectionBindingElement.cs index 805ace5..ffd6044 100644 --- a/src/DotNetOAuth.Test/Mocks/MockReplayProtectionBindingElement.cs +++ b/src/DotNetOAuth.Test/Mocks/MockReplayProtectionBindingElement.cs @@ -14,8 +14,8 @@ namespace DotNetOAuth.Test.Mocks { #region IChannelBindingElement Members
- MessageProtection IChannelBindingElement.Protection {
- get { return MessageProtection.ReplayProtection; }
+ MessageProtections IChannelBindingElement.Protection {
+ get { return MessageProtections.ReplayProtection; }
}
bool IChannelBindingElement.PrepareMessageForSending(IProtocolMessage message) {
diff --git a/src/DotNetOAuth.Test/Mocks/MockSigningBindingElement.cs b/src/DotNetOAuth.Test/Mocks/MockSigningBindingElement.cs index 58fa96c..97298ad 100644 --- a/src/DotNetOAuth.Test/Mocks/MockSigningBindingElement.cs +++ b/src/DotNetOAuth.Test/Mocks/MockSigningBindingElement.cs @@ -17,8 +17,8 @@ namespace DotNetOAuth.Test.Mocks { #region IChannelBindingElement Members
- MessageProtection IChannelBindingElement.Protection {
- get { return MessageProtection.TamperProtection; }
+ MessageProtections IChannelBindingElement.Protection {
+ get { return MessageProtections.TamperProtection; }
}
bool IChannelBindingElement.PrepareMessageForSending(IProtocolMessage message) {
diff --git a/src/DotNetOAuth.Test/Mocks/MockTransformationBindingElement.cs b/src/DotNetOAuth.Test/Mocks/MockTransformationBindingElement.cs index a569754..8ee6036 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
- MessageProtection IChannelBindingElement.Protection {
- get { return MessageProtection.None; }
+ MessageProtections IChannelBindingElement.Protection {
+ get { return MessageProtections.None; }
}
bool IChannelBindingElement.PrepareMessageForSending(IProtocolMessage message) {
diff --git a/src/DotNetOAuth.Test/Mocks/TestBaseMessage.cs b/src/DotNetOAuth.Test/Mocks/TestBaseMessage.cs index 29a0035..c874d23 100644 --- a/src/DotNetOAuth.Test/Mocks/TestBaseMessage.cs +++ b/src/DotNetOAuth.Test/Mocks/TestBaseMessage.cs @@ -18,21 +18,21 @@ namespace DotNetOAuth.Test.Mocks { internal class TestBaseMessage : IProtocolMessage, IBaseMessageExplicitMembers {
private Dictionary<string, string> extraData = new Dictionary<string, string>();
- [MessagePart(Name = "age", IsRequired = true)]
+ [MessagePart("age", IsRequired = true)]
public int Age { get; set; }
[MessagePart]
public string Name { get; set; }
- [MessagePart(Name = "explicit")]
+ [MessagePart("explicit")]
string IBaseMessageExplicitMembers.ExplicitProperty { get; set; }
Version IProtocolMessage.ProtocolVersion {
get { return new Version(1, 0); }
}
- MessageProtection IProtocolMessage.RequiredProtection {
- get { return MessageProtection.None; }
+ MessageProtections IProtocolMessage.RequiredProtection {
+ get { return MessageProtections.None; }
}
MessageTransport IProtocolMessage.Transport {
@@ -48,7 +48,7 @@ namespace DotNetOAuth.Test.Mocks { set { this.PrivateProperty = value; }
}
- [MessagePart(Name = "private")]
+ [MessagePart("private")]
private string PrivateProperty { get; set; }
void IProtocolMessage.EnsureValidMessage() { }
diff --git a/src/DotNetOAuth.Test/Mocks/TestDirectedMessage.cs b/src/DotNetOAuth.Test/Mocks/TestDirectedMessage.cs index 8906151..1973463 100644 --- a/src/DotNetOAuth.Test/Mocks/TestDirectedMessage.cs +++ b/src/DotNetOAuth.Test/Mocks/TestDirectedMessage.cs @@ -24,7 +24,7 @@ namespace DotNetOAuth.Test.Mocks { #region IProtocolMessage Properties
- MessageProtection IProtocolMessage.RequiredProtection {
+ MessageProtections IProtocolMessage.RequiredProtection {
get { return this.RequiredProtection; }
}
@@ -32,12 +32,12 @@ namespace DotNetOAuth.Test.Mocks { #region IOAuthDirectedMessage Members
- public HttpDeliveryMethod HttpMethods { get; internal set; }
+ public HttpDeliveryMethods HttpMethods { get; internal set; }
#endregion
- protected virtual MessageProtection RequiredProtection {
- get { return MessageProtection.None; }
+ protected virtual MessageProtections RequiredProtection {
+ get { return MessageProtections.None; }
}
}
}
diff --git a/src/DotNetOAuth.Test/Mocks/TestExpiringMessage.cs b/src/DotNetOAuth.Test/Mocks/TestExpiringMessage.cs index 19102a9..b14d4f2 100644 --- a/src/DotNetOAuth.Test/Mocks/TestExpiringMessage.cs +++ b/src/DotNetOAuth.Test/Mocks/TestExpiringMessage.cs @@ -24,7 +24,7 @@ namespace DotNetOAuth.Test.Mocks { #region IExpiringProtocolMessage Members
- [MessagePart(Name = "created_on", IsRequired = true)]
+ [MessagePart("created_on", IsRequired = true)]
DateTime IExpiringProtocolMessage.UtcCreationDate {
get { return this.utcCreationDate; }
set { this.utcCreationDate = value.ToUniversalTime(); }
diff --git a/src/DotNetOAuth.Test/Mocks/TestMessage.cs b/src/DotNetOAuth.Test/Mocks/TestMessage.cs index 33086f8..0cb331c 100644 --- a/src/DotNetOAuth.Test/Mocks/TestMessage.cs +++ b/src/DotNetOAuth.Test/Mocks/TestMessage.cs @@ -23,13 +23,13 @@ namespace DotNetOAuth.Test.Mocks { this.transport = transport;
}
- [MessagePart(Name = "age", IsRequired = true)]
+ [MessagePart("age", IsRequired = true)]
public int Age { get; set; }
[MessagePart("Name")]
public string Name { get; set; }
[MessagePart]
public string EmptyMember { get; set; }
- [MessagePart(Name = null)] // null name tests that Location is still the name.
+ [MessagePart(null)] // null name tests that Location is still the name.
public Uri Location { get; set; }
[MessagePart(IsRequired = true)]
public DateTime Timestamp { get; set; }
@@ -40,8 +40,8 @@ namespace DotNetOAuth.Test.Mocks { get { return new Version(1, 0); }
}
- MessageProtection IProtocolMessage.RequiredProtection {
- get { return MessageProtection.None; }
+ MessageProtections IProtocolMessage.RequiredProtection {
+ get { return MessageProtections.None; }
}
MessageTransport IProtocolMessage.Transport {
diff --git a/src/DotNetOAuth.Test/Mocks/TestReplayProtectedMessage.cs b/src/DotNetOAuth.Test/Mocks/TestReplayProtectedMessage.cs index 2a8bf9e..6467ebc 100644 --- a/src/DotNetOAuth.Test/Mocks/TestReplayProtectedMessage.cs +++ b/src/DotNetOAuth.Test/Mocks/TestReplayProtectedMessage.cs @@ -19,7 +19,7 @@ namespace DotNetOAuth.Test.Mocks { #region IReplayProtectedProtocolMessage Members
- [MessagePart(Name = "Nonce")]
+ [MessagePart("Nonce")]
string IReplayProtectedProtocolMessage.Nonce {
get;
set;
diff --git a/src/DotNetOAuth.Test/Mocks/TestSignedDirectedMessage.cs b/src/DotNetOAuth.Test/Mocks/TestSignedDirectedMessage.cs index 2a52b2e..0cb880d 100644 --- a/src/DotNetOAuth.Test/Mocks/TestSignedDirectedMessage.cs +++ b/src/DotNetOAuth.Test/Mocks/TestSignedDirectedMessage.cs @@ -26,8 +26,8 @@ namespace DotNetOAuth.Test.Mocks { #endregion
- protected override MessageProtection RequiredProtection {
- get { return MessageProtection.TamperProtection; }
+ protected override MessageProtections RequiredProtection {
+ get { return MessageProtections.TamperProtection; }
}
}
}
diff --git a/src/DotNetOAuth.Test/Scenarios/AppendixScenarios.cs b/src/DotNetOAuth.Test/Scenarios/AppendixScenarios.cs index afa49a3..71d0606 100644 --- a/src/DotNetOAuth.Test/Scenarios/AppendixScenarios.cs +++ b/src/DotNetOAuth.Test/Scenarios/AppendixScenarios.cs @@ -20,15 +20,15 @@ namespace DotNetOAuth.Test { [TestMethod]
public void SpecAppendixAExample() {
ServiceProviderDescription serviceDescription = new ServiceProviderDescription() {
- RequestTokenEndpoint = new MessageReceivingEndpoint("https://photos.example.net/request_token", HttpDeliveryMethod.PostRequest),
- UserAuthorizationEndpoint = new MessageReceivingEndpoint("http://photos.example.net/authorize", HttpDeliveryMethod.GetRequest),
- AccessTokenEndpoint = new MessageReceivingEndpoint("https://photos.example.net/access_token", HttpDeliveryMethod.PostRequest),
+ RequestTokenEndpoint = new MessageReceivingEndpoint("https://photos.example.net/request_token", HttpDeliveryMethods.PostRequest),
+ UserAuthorizationEndpoint = new MessageReceivingEndpoint("http://photos.example.net/authorize", HttpDeliveryMethods.GetRequest),
+ AccessTokenEndpoint = new MessageReceivingEndpoint("https://photos.example.net/access_token", HttpDeliveryMethods.PostRequest),
TamperProtectionElements = new ITamperProtectionChannelBindingElement[] {
- new PlainTextSigningBindingElement(),
+ new PlaintextSigningBindingElement(),
new HmacSha1SigningBindingElement(),
},
};
- MessageReceivingEndpoint accessPhotoEndpoint = new MessageReceivingEndpoint("http://photos.example.net/photos?file=vacation.jpg&size=original", HttpDeliveryMethod.AuthorizationHeaderRequest | HttpDeliveryMethod.GetRequest);
+ MessageReceivingEndpoint accessPhotoEndpoint = new MessageReceivingEndpoint("http://photos.example.net/photos?file=vacation.jpg&size=original", HttpDeliveryMethods.AuthorizationHeaderRequest | HttpDeliveryMethods.GetRequest);
ConsumerDescription consumerDescription = new ConsumerDescription("dpf43f3p2l4k3l03", "kd94hf93k423kf44");
Coordinator coordinator = new Coordinator(
diff --git a/src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs b/src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs index d5dddcf..60f216e 100644 --- a/src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs +++ b/src/DotNetOAuth.Test/Scenarios/CoordinatingOAuthChannel.cs @@ -36,7 +36,7 @@ namespace DotNetOAuth.Test.Scenarios { signingBindingElement,
new NonceMemoryStore(StandardExpirationBindingElement.DefaultMaximumMessageAge),
tokenManager,
- isConsumer ? (IMessageTypeProvider)new OAuthConsumerMessageTypeProvider(tokenManager) : new OAuthServiceProviderMessageTypeProvider(tokenManager),
+ isConsumer ? (IMessageTypeProvider)new OAuthConsumerMessageTypeProvider() : new OAuthServiceProviderMessageTypeProvider(tokenManager),
new TestWebRequestHandler()) {
}
@@ -139,8 +139,8 @@ namespace DotNetOAuth.Test.Scenarios { return (T)serializer.Deserialize(serializer.Serialize(message), recipient);
}
- private string GetHttpMethod(HttpDeliveryMethod methods) {
- return (methods & HttpDeliveryMethod.PostRequest) != 0 ? "POST" : "GET";
+ private string GetHttpMethod(HttpDeliveryMethods methods) {
+ return (methods & HttpDeliveryMethods.PostRequest) != 0 ? "POST" : "GET";
}
}
}
diff --git a/src/DotNetOAuth.Test/ServiceProviderDescriptionTests.cs b/src/DotNetOAuth.Test/ServiceProviderDescriptionTests.cs index 99543c1..28b1593 100644 --- a/src/DotNetOAuth.Test/ServiceProviderDescriptionTests.cs +++ b/src/DotNetOAuth.Test/ServiceProviderDescriptionTests.cs @@ -20,7 +20,7 @@ namespace DotNetOAuth.Test { [TestMethod]
public void UserAuthorizationUriTest() {
ServiceProviderDescription target = new ServiceProviderDescription();
- MessageReceivingEndpoint expected = new MessageReceivingEndpoint("http://localhost/authorization", HttpDeliveryMethod.GetRequest);
+ MessageReceivingEndpoint expected = new MessageReceivingEndpoint("http://localhost/authorization", HttpDeliveryMethods.GetRequest);
MessageReceivingEndpoint actual;
target.UserAuthorizationEndpoint = expected;
actual = target.UserAuthorizationEndpoint;
@@ -36,7 +36,7 @@ namespace DotNetOAuth.Test { [TestMethod]
public void RequestTokenUriTest() {
var target = new ServiceProviderDescription();
- MessageReceivingEndpoint expected = new MessageReceivingEndpoint("http://localhost/requesttoken", HttpDeliveryMethod.GetRequest);
+ MessageReceivingEndpoint expected = new MessageReceivingEndpoint("http://localhost/requesttoken", HttpDeliveryMethods.GetRequest);
MessageReceivingEndpoint actual;
target.RequestTokenEndpoint = expected;
actual = target.RequestTokenEndpoint;
@@ -53,7 +53,7 @@ namespace DotNetOAuth.Test { [TestMethod, ExpectedException(typeof(ArgumentException))]
public void RequestTokenUriWithOAuthParametersTest() {
var target = new ServiceProviderDescription();
- target.RequestTokenEndpoint = new MessageReceivingEndpoint("http://localhost/requesttoken?oauth_token=something", HttpDeliveryMethod.GetRequest);
+ target.RequestTokenEndpoint = new MessageReceivingEndpoint("http://localhost/requesttoken?oauth_token=something", HttpDeliveryMethods.GetRequest);
}
/// <summary>
@@ -62,7 +62,7 @@ namespace DotNetOAuth.Test { [TestMethod]
public void AccessTokenUriTest() {
var target = new ServiceProviderDescription();
- MessageReceivingEndpoint expected = new MessageReceivingEndpoint("http://localhost/accesstoken", HttpDeliveryMethod.GetRequest);
+ MessageReceivingEndpoint expected = new MessageReceivingEndpoint("http://localhost/accesstoken", HttpDeliveryMethods.GetRequest);
MessageReceivingEndpoint actual;
target.AccessTokenEndpoint = expected;
actual = target.AccessTokenEndpoint;
diff --git a/src/DotNetOAuth/ChannelElements/IOAuthDirectedMessage.cs b/src/DotNetOAuth/ChannelElements/IOAuthDirectedMessage.cs index a6117d0..012701f 100644 --- a/src/DotNetOAuth/ChannelElements/IOAuthDirectedMessage.cs +++ b/src/DotNetOAuth/ChannelElements/IOAuthDirectedMessage.cs @@ -15,7 +15,7 @@ namespace DotNetOAuth.ChannelElements { /// <summary>
/// Gets the preferred method of transport for the message.
/// </summary>
- HttpDeliveryMethod HttpMethods { get; }
+ HttpDeliveryMethods HttpMethods { get; }
/// <summary>
/// Gets or sets the URL of the intended receiver of this message.
diff --git a/src/DotNetOAuth/ChannelElements/OAuthChannel.cs b/src/DotNetOAuth/ChannelElements/OAuthChannel.cs index 7741931..16e7006 100644 --- a/src/DotNetOAuth/ChannelElements/OAuthChannel.cs +++ b/src/DotNetOAuth/ChannelElements/OAuthChannel.cs @@ -39,7 +39,7 @@ namespace DotNetOAuth.ChannelElements { signingBindingElement,
store,
tokenManager,
- isConsumer ? (IMessageTypeProvider)new OAuthConsumerMessageTypeProvider(tokenManager) : new OAuthServiceProviderMessageTypeProvider(tokenManager),
+ isConsumer ? (IMessageTypeProvider)new OAuthConsumerMessageTypeProvider() : new OAuthServiceProviderMessageTypeProvider(tokenManager),
new StandardWebRequestHandler()) {
}
@@ -292,12 +292,12 @@ namespace DotNetOAuth.ChannelElements { HttpWebRequest httpRequest;
- HttpDeliveryMethod transmissionMethod = oauthRequest.HttpMethods;
- if ((transmissionMethod & HttpDeliveryMethod.AuthorizationHeaderRequest) != 0) {
+ HttpDeliveryMethods transmissionMethod = oauthRequest.HttpMethods;
+ if ((transmissionMethod & HttpDeliveryMethods.AuthorizationHeaderRequest) != 0) {
httpRequest = this.InitializeRequestAsAuthHeader(request);
- } else if ((transmissionMethod & HttpDeliveryMethod.PostRequest) != 0) {
+ } else if ((transmissionMethod & HttpDeliveryMethods.PostRequest) != 0) {
httpRequest = this.InitializeRequestAsPost(request);
- } else if ((transmissionMethod & HttpDeliveryMethod.GetRequest) != 0) {
+ } else if ((transmissionMethod & HttpDeliveryMethods.GetRequest) != 0) {
httpRequest = InitializeRequestAsGet(request);
} else {
throw new NotSupportedException();
diff --git a/src/DotNetOAuth/ChannelElements/OAuthConsumerMessageTypeProvider.cs b/src/DotNetOAuth/ChannelElements/OAuthConsumerMessageTypeProvider.cs index b3cc859..1bb255e 100644 --- a/src/DotNetOAuth/ChannelElements/OAuthConsumerMessageTypeProvider.cs +++ b/src/DotNetOAuth/ChannelElements/OAuthConsumerMessageTypeProvider.cs @@ -16,20 +16,9 @@ namespace DotNetOAuth.ChannelElements { /// </summary>
public class OAuthConsumerMessageTypeProvider : IMessageTypeProvider {
/// <summary>
- /// The token manager to use for discerning between request and access tokens.
- /// </summary>
- private ITokenManager tokenManager;
-
- /// <summary>
/// Initializes a new instance of the <see cref="OAuthConsumerMessageTypeProvider"/> class.
/// </summary>
- /// <param name="tokenManager">The token manager instance to use.</param>
- protected internal OAuthConsumerMessageTypeProvider(ITokenManager tokenManager) {
- if (tokenManager == null) {
- throw new ArgumentNullException("tokenManager");
- }
-
- this.tokenManager = tokenManager;
+ protected internal OAuthConsumerMessageTypeProvider() {
}
#region IMessageTypeProvider Members
diff --git a/src/DotNetOAuth/ChannelElements/OAuthHttpMethodBindingElement.cs b/src/DotNetOAuth/ChannelElements/OAuthHttpMethodBindingElement.cs index 4a5a912..10a845d 100644 --- a/src/DotNetOAuth/ChannelElements/OAuthHttpMethodBindingElement.cs +++ b/src/DotNetOAuth/ChannelElements/OAuthHttpMethodBindingElement.cs @@ -20,8 +20,8 @@ namespace DotNetOAuth.ChannelElements { /// <summary>
/// Gets the protection offered (if any) by this binding element.
/// </summary>
- public MessageProtection Protection {
- get { return MessageProtection.None; }
+ public MessageProtections Protection {
+ get { return MessageProtections.None; }
}
/// <summary>
@@ -36,10 +36,10 @@ namespace DotNetOAuth.ChannelElements { var oauthMessage = message as ITamperResistantOAuthMessage;
if (oauthMessage != null) {
- HttpDeliveryMethod transmissionMethod = oauthMessage.HttpMethods;
- if ((transmissionMethod & HttpDeliveryMethod.PostRequest) != 0) {
+ HttpDeliveryMethods transmissionMethod = oauthMessage.HttpMethods;
+ if ((transmissionMethod & HttpDeliveryMethods.PostRequest) != 0) {
oauthMessage.HttpMethod = "POST";
- } else if ((transmissionMethod & HttpDeliveryMethod.GetRequest) != 0) {
+ } else if ((transmissionMethod & HttpDeliveryMethods.GetRequest) != 0) {
oauthMessage.HttpMethod = "GET";
} else {
return false;
diff --git a/src/DotNetOAuth/ChannelElements/PlainTextSigningBindingElement.cs b/src/DotNetOAuth/ChannelElements/PlainTextSigningBindingElement.cs index 7ca5b7f..f0bbd43 100644 --- a/src/DotNetOAuth/ChannelElements/PlainTextSigningBindingElement.cs +++ b/src/DotNetOAuth/ChannelElements/PlainTextSigningBindingElement.cs @@ -1,5 +1,5 @@ //-----------------------------------------------------------------------
-// <copyright file="PlainTextSigningBindingElement.cs" company="Andrew Arnott">
+// <copyright file="PlaintextSigningBindingElement.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
@@ -15,11 +15,11 @@ namespace DotNetOAuth.ChannelElements { /// <summary>
/// A binding element that signs outgoing messages and verifies the signature on incoming messages.
/// </summary>
- public class PlainTextSigningBindingElement : SigningBindingElementBase {
+ public class PlaintextSigningBindingElement : SigningBindingElementBase {
/// <summary>
- /// Initializes a new instance of the <see cref="PlainTextSigningBindingElement"/> class.
+ /// Initializes a new instance of the <see cref="PlaintextSigningBindingElement"/> class.
/// </summary>
- public PlainTextSigningBindingElement()
+ public PlaintextSigningBindingElement()
: base("PLAINTEXT") {
}
@@ -49,7 +49,7 @@ namespace DotNetOAuth.ChannelElements { /// </summary>
/// <returns>A new instance of the binding element.</returns>
protected override ITamperProtectionChannelBindingElement Clone() {
- return new PlainTextSigningBindingElement();
+ return new PlaintextSigningBindingElement();
}
}
}
diff --git a/src/DotNetOAuth/ChannelElements/PlaintextSigningBindingElement.cs b/src/DotNetOAuth/ChannelElements/PlaintextSigningBindingElement.cs new file mode 100644 index 0000000..f0bbd43 --- /dev/null +++ b/src/DotNetOAuth/ChannelElements/PlaintextSigningBindingElement.cs @@ -0,0 +1,55 @@ +//-----------------------------------------------------------------------
+// <copyright file="PlaintextSigningBindingElement.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOAuth.ChannelElements {
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+ using DotNetOAuth.Messaging;
+ using DotNetOAuth.Messaging.Bindings;
+
+ /// <summary>
+ /// A binding element that signs outgoing messages and verifies the signature on incoming messages.
+ /// </summary>
+ public class PlaintextSigningBindingElement : SigningBindingElementBase {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="PlaintextSigningBindingElement"/> class.
+ /// </summary>
+ public PlaintextSigningBindingElement()
+ : base("PLAINTEXT") {
+ }
+
+ /// <summary>
+ /// Calculates a signature for a given message.
+ /// </summary>
+ /// <param name="message">The message to sign.</param>
+ /// <returns>The signature for the message.</returns>
+ /// <remarks>
+ /// This method signs the message according to OAuth 1.0 section 9.4.1.
+ /// </remarks>
+ protected override string GetSignature(ITamperResistantOAuthMessage message) {
+ return GetConsumerAndTokenSecretString(message);
+ }
+
+ /// <summary>
+ /// Checks whether this binding element applies to this message.
+ /// </summary>
+ /// <param name="message">The message that needs to be signed.</param>
+ /// <returns>True if this binding element can be used to sign the message. False otherwise.</returns>
+ protected override bool IsMessageApplicable(ITamperResistantOAuthMessage message) {
+ return string.Equals(message.Recipient.Scheme, "https", StringComparison.OrdinalIgnoreCase);
+ }
+
+ /// <summary>
+ /// Clones this instance.
+ /// </summary>
+ /// <returns>A new instance of the binding element.</returns>
+ protected override ITamperProtectionChannelBindingElement Clone() {
+ return new PlaintextSigningBindingElement();
+ }
+ }
+}
diff --git a/src/DotNetOAuth/ChannelElements/SigningBindingElementBase.cs b/src/DotNetOAuth/ChannelElements/SigningBindingElementBase.cs index dab4c19..04c6d60 100644 --- a/src/DotNetOAuth/ChannelElements/SigningBindingElementBase.cs +++ b/src/DotNetOAuth/ChannelElements/SigningBindingElementBase.cs @@ -34,8 +34,8 @@ namespace DotNetOAuth.ChannelElements { /// <summary>
/// Gets the message protection provided by this binding element.
/// </summary>
- public MessageProtection Protection {
- get { return MessageProtection.TamperProtection; }
+ public MessageProtections Protection {
+ get { return MessageProtections.TamperProtection; }
}
#endregion
@@ -182,6 +182,23 @@ namespace DotNetOAuth.ChannelElements { }
/// <summary>
+ /// Gets the ConsumerSecret&TokenSecret" string, allowing either property to be empty or null.
+ /// </summary>
+ /// <param name="message">The message to extract the secrets from.</param>
+ /// <returns>The concatenated string.</returns>
+ protected static string GetConsumerAndTokenSecretString(ITamperResistantOAuthMessage message) {
+ StringBuilder builder = new StringBuilder();
+ if (!string.IsNullOrEmpty(message.ConsumerSecret)) {
+ builder.Append(Uri.EscapeDataString(message.ConsumerSecret));
+ }
+ builder.Append("&");
+ if (!string.IsNullOrEmpty(message.TokenSecret)) {
+ builder.Append(Uri.EscapeDataString(message.TokenSecret));
+ }
+ return builder.ToString();
+ }
+
+ /// <summary>
/// Clones this instance.
/// </summary>
/// <returns>A new instance of the binding element.</returns>
@@ -208,23 +225,6 @@ namespace DotNetOAuth.ChannelElements { }
/// <summary>
- /// Gets the ConsumerSecret&TokenSecret" string, allowing either property to be empty or null.
- /// </summary>
- /// <param name="message">The message to extract the secrets from.</param>
- /// <returns>The concatenated string.</returns>
- protected string GetConsumerAndTokenSecretString(ITamperResistantOAuthMessage message) {
- StringBuilder builder = new StringBuilder();
- if (!string.IsNullOrEmpty(message.ConsumerSecret)) {
- builder.Append(Uri.EscapeDataString(message.ConsumerSecret));
- }
- builder.Append("&");
- if (!string.IsNullOrEmpty(message.TokenSecret)) {
- builder.Append(Uri.EscapeDataString(message.TokenSecret));
- }
- return builder.ToString();
- }
-
- /// <summary>
/// Sorts parameters according to OAuth signature base string rules.
/// </summary>
/// <param name="left">The first parameter to compare.</param>
diff --git a/src/DotNetOAuth/ChannelElements/SigningBindingElementChain.cs b/src/DotNetOAuth/ChannelElements/SigningBindingElementChain.cs index 2d490d2..477e542 100644 --- a/src/DotNetOAuth/ChannelElements/SigningBindingElementChain.cs +++ b/src/DotNetOAuth/ChannelElements/SigningBindingElementChain.cs @@ -38,7 +38,7 @@ namespace DotNetOAuth.ChannelElements { if (signers.Contains(null)) {
throw new ArgumentException(MessagingStrings.SequenceContainsNullElement, "signers");
}
- MessageProtection protection = signers[0].Protection;
+ MessageProtections protection = signers[0].Protection;
if (signers.Any(element => element.Protection != protection)) {
throw new ArgumentException(Strings.SigningElementsMustShareSameProtection, "signers");
}
@@ -72,7 +72,7 @@ namespace DotNetOAuth.ChannelElements { /// <summary>
/// Gets the protection offered (if any) by this binding element.
/// </summary>
- public MessageProtection Protection {
+ public MessageProtections Protection {
get { return this.signers[0].Protection; }
}
diff --git a/src/DotNetOAuth/ConsumerBase.cs b/src/DotNetOAuth/ConsumerBase.cs index c3a11e1..fbc7f31 100644 --- a/src/DotNetOAuth/ConsumerBase.cs +++ b/src/DotNetOAuth/ConsumerBase.cs @@ -7,8 +7,8 @@ namespace DotNetOAuth {
using System;
using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
using System.Net;
- using System.Web;
using DotNetOAuth.ChannelElements;
using DotNetOAuth.Messages;
using DotNetOAuth.Messaging;
@@ -34,7 +34,7 @@ namespace DotNetOAuth { this.WebRequestHandler = new StandardWebRequestHandler();
ITamperProtectionChannelBindingElement signingElement = serviceDescription.CreateTamperProtectionElement();
INonceStore store = new NonceMemoryStore(StandardExpirationBindingElement.DefaultMaximumMessageAge);
- this.Channel = new OAuthChannel(signingElement, store, tokenManager, new OAuthConsumerMessageTypeProvider(tokenManager), this.WebRequestHandler);
+ this.Channel = new OAuthChannel(signingElement, store, tokenManager, new OAuthConsumerMessageTypeProvider(), this.WebRequestHandler);
this.ServiceProvider = serviceDescription;
}
@@ -106,16 +106,17 @@ namespace DotNetOAuth { /// </param>
/// <param name="requestParameters">Extra parameters to add to the request token message. Optional.</param>
/// <param name="redirectParameters">Extra parameters to add to the redirect to Service Provider message. Optional.</param>
- /// <param name="token">The request token that must be exchanged for an access token after the user has provided authorization.</param>
+ /// <param name="requestToken">The request token that must be exchanged for an access token after the user has provided authorization.</param>
/// <returns>The pending user agent redirect based message to be sent as an HttpResponse.</returns>
- protected internal Response RequestUserAuthorization(Uri callback, IDictionary<string, string> requestParameters, IDictionary<string, string> redirectParameters, out string token) {
+ [SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "3#", Justification = "Two results")]
+ protected internal Response RequestUserAuthorization(Uri callback, IDictionary<string, string> requestParameters, IDictionary<string, string> redirectParameters, out string requestToken) {
// Obtain an unauthorized request token.
- var requestToken = new GetRequestTokenMessage(this.ServiceProvider.RequestTokenEndpoint) {
+ var token = new GetRequestTokenMessage(this.ServiceProvider.RequestTokenEndpoint) {
ConsumerKey = this.ConsumerKey,
};
- requestToken.AddNonOAuthParameters(requestParameters);
- var requestTokenResponse = this.Channel.Request<GrantRequestTokenMessage>(requestToken);
- this.TokenManager.StoreNewRequestToken(requestToken, requestTokenResponse);
+ token.AddNonOAuthParameters(requestParameters);
+ var requestTokenResponse = this.Channel.Request<GrantRequestTokenMessage>(token);
+ this.TokenManager.StoreNewRequestToken(token, requestTokenResponse);
// Request user authorization.
ITokenContainingMessage assignedRequestToken = requestTokenResponse;
@@ -123,7 +124,7 @@ namespace DotNetOAuth { Callback = callback,
};
requestAuthorization.AddNonOAuthParameters(redirectParameters);
- token = requestAuthorization.RequestToken;
+ requestToken = requestAuthorization.RequestToken;
return this.Channel.Send(requestAuthorization);
}
diff --git a/src/DotNetOAuth/DesktopConsumer.cs b/src/DotNetOAuth/DesktopConsumer.cs index 99f3765..0d86770 100644 --- a/src/DotNetOAuth/DesktopConsumer.cs +++ b/src/DotNetOAuth/DesktopConsumer.cs @@ -7,12 +7,9 @@ namespace DotNetOAuth {
using System;
using System.Collections.Generic;
- using System.Net;
- using System.Web;
+ using System.Diagnostics.CodeAnalysis;
using DotNetOAuth.ChannelElements;
using DotNetOAuth.Messages;
- using DotNetOAuth.Messaging;
- using DotNetOAuth.Messaging.Bindings;
/// <summary>
/// Used by a desktop application to use OAuth to access the Service Provider on behalf of the User.
@@ -38,6 +35,7 @@ namespace DotNetOAuth { /// <param name="redirectParameters">Extra parameters to add to the redirect to Service Provider message. Optional.</param>
/// <param name="requestToken">The request token that must be exchanged for an access token after the user has provided authorization.</param>
/// <returns>The URL to open a browser window to allow the user to provide authorization.</returns>
+ [SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "2#", Justification = "Two results")]
public Uri RequestUserAuthorization(IDictionary<string, string> requestParameters, IDictionary<string, string> redirectParameters, out string requestToken) {
return this.RequestUserAuthorization(null, requestParameters, redirectParameters, out requestToken).DirectUriRequest;
}
diff --git a/src/DotNetOAuth/DotNetOAuth.csproj b/src/DotNetOAuth/DotNetOAuth.csproj index 7f8fc51..82c8593 100644 --- a/src/DotNetOAuth/DotNetOAuth.csproj +++ b/src/DotNetOAuth/DotNetOAuth.csproj @@ -64,13 +64,14 @@ <Compile Include="ChannelElements\ITokenGenerator.cs" />
<Compile Include="ChannelElements\ITokenManager.cs" />
<Compile Include="ChannelElements\OAuthHttpMethodBindingElement.cs" />
- <Compile Include="ChannelElements\PlainTextSigningBindingElement.cs" />
+ <Compile Include="ChannelElements\PlaintextSigningBindingElement.cs" />
<Compile Include="ChannelElements\HmacSha1SigningBindingElement.cs" />
<Compile Include="ChannelElements\SigningBindingElementChain.cs" />
<Compile Include="ChannelElements\StandardTokenGenerator.cs" />
<Compile Include="ChannelElements\TokenType.cs" />
<Compile Include="ConsumerBase.cs" />
<Compile Include="DesktopConsumer.cs" />
+ <Compile Include="GlobalSuppressions.cs" />
<Compile Include="Messages\ITokenSecretContainingMessage.cs" />
<Compile Include="Messaging\ITamperProtectionChannelBindingElement.cs" />
<Compile Include="ServiceProviderDescription.cs" />
@@ -86,7 +87,7 @@ <Compile Include="Messaging\Bindings\INonceStore.cs" />
<Compile Include="Messaging\Bindings\StandardReplayProtectionBindingElement.cs" />
<Compile Include="Messaging\MessagePartAttribute.cs" />
- <Compile Include="Messaging\MessageProtection.cs" />
+ <Compile Include="Messaging\MessageProtections.cs" />
<Compile Include="Messaging\IChannelBindingElement.cs" />
<Compile Include="Messaging\Bindings\ReplayedMessageException.cs" />
<Compile Include="Messaging\Bindings\ExpiredMessageException.cs" />
@@ -103,7 +104,7 @@ <Compile Include="Messaging\HttpRequestInfo.cs" />
<Compile Include="Messaging\IDirectedProtocolMessage.cs" />
<Compile Include="Messaging\IMessageTypeProvider.cs" />
- <Compile Include="Messaging\Bindings\ITamperResistantProtocolMessage.cs" />
+ <Compile Include="Messaging\ITamperResistantProtocolMessage.cs" />
<Compile Include="Messaging\MessageSerializer.cs" />
<Compile Include="Messaging\MessagingStrings.Designer.cs">
<AutoGen>True</AutoGen>
@@ -125,7 +126,7 @@ <Compile Include="Loggers\Log4NetLogger.cs" />
<Compile Include="Loggers\NoOpLogger.cs" />
<Compile Include="Loggers\TraceLogger.cs" />
- <Compile Include="Messaging\HttpDeliveryMethod.cs" />
+ <Compile Include="Messaging\HttpDeliveryMethods.cs" />
<Compile Include="Messaging\MessageTransport.cs" />
<Compile Include="ChannelElements\OAuthServiceProviderMessageTypeProvider.cs" />
<Compile Include="Messaging\ProtocolException.cs" />
diff --git a/src/DotNetOAuth/GlobalSuppressions.cs b/src/DotNetOAuth/GlobalSuppressions.cs new file mode 100644 index 0000000..e252c76 --- /dev/null +++ b/src/DotNetOAuth/GlobalSuppressions.cs @@ -0,0 +1,15 @@ +// <auto-generated/>
+// This file is used by Code Analysis to maintain SuppressMessage
+// attributes that are applied to this project.
+// Project-level suppressions either have no target or are given
+// a specific target and scoped to a namespace, type, member, etc.
+//
+// To add a suppression to this file, right-click the message in the
+// Error List, point to "Suppress Message(s)", and click
+// "In Project Suppression File".
+// You do not need to add suppressions to this file manually.
+
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Sha", Scope = "type", Target = "DotNetOAuth.ChannelElements.HmacSha1SigningBindingElement")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Hmac", Scope = "type", Target = "DotNetOAuth.ChannelElements.HmacSha1SigningBindingElement")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Rsa", Scope = "type", Target = "DotNetOAuth.ChannelElements.RsaSha1SigningBindingElement")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Sha", Scope = "type", Target = "DotNetOAuth.ChannelElements.RsaSha1SigningBindingElement")]
diff --git a/src/DotNetOAuth/Messages/AccessProtectedResourceMessage.cs b/src/DotNetOAuth/Messages/AccessProtectedResourceMessage.cs index d1f6af0..0ff254b 100644 --- a/src/DotNetOAuth/Messages/AccessProtectedResourceMessage.cs +++ b/src/DotNetOAuth/Messages/AccessProtectedResourceMessage.cs @@ -5,7 +5,7 @@ //-----------------------------------------------------------------------
namespace DotNetOAuth.Messages {
- using System;
+ using System.Diagnostics.CodeAnalysis;
using DotNetOAuth.Messaging;
/// <summary>
@@ -24,6 +24,7 @@ namespace DotNetOAuth.Messages { /// <summary>
/// Gets or sets the Token.
/// </summary>
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Justification = "This property IS accessible by a different name.")]
string ITokenContainingMessage.Token {
get { return this.AccessToken; }
set { this.AccessToken = value; }
@@ -38,7 +39,7 @@ namespace DotNetOAuth.Messages { /// has proper authorization for the resource being requested, and to know the
/// context around which user provided the authorization.
/// </remarks>
- [MessagePart(Name = "oauth_token", IsRequired = true)]
+ [MessagePart("oauth_token", IsRequired = true)]
public string AccessToken { get; set; }
}
}
diff --git a/src/DotNetOAuth/Messages/DirectUserToConsumerMessage.cs b/src/DotNetOAuth/Messages/DirectUserToConsumerMessage.cs index d8069cf..56ef959 100644 --- a/src/DotNetOAuth/Messages/DirectUserToConsumerMessage.cs +++ b/src/DotNetOAuth/Messages/DirectUserToConsumerMessage.cs @@ -20,7 +20,7 @@ namespace DotNetOAuth.Messages { /// The class is sealed because extra parameters are determined by the callback URI provided by the Consumer.
/// </remarks>
internal DirectUserToConsumerMessage(Uri consumer)
- : base(MessageProtection.None, MessageTransport.Indirect, new MessageReceivingEndpoint(consumer, HttpDeliveryMethod.GetRequest)) {
+ : base(MessageProtections.None, MessageTransport.Indirect, new MessageReceivingEndpoint(consumer, HttpDeliveryMethods.GetRequest)) {
}
/// <summary>
@@ -34,7 +34,7 @@ namespace DotNetOAuth.Messages { /// <summary>
/// Gets or sets the Request Token.
/// </summary>
- [MessagePart(Name = "oauth_token", IsRequired = true)]
+ [MessagePart("oauth_token", IsRequired = true)]
internal string RequestToken { get; set; }
}
}
diff --git a/src/DotNetOAuth/Messages/DirectUserToServiceProviderMessage.cs b/src/DotNetOAuth/Messages/DirectUserToServiceProviderMessage.cs index 5e3dbca..20ad5b7 100644 --- a/src/DotNetOAuth/Messages/DirectUserToServiceProviderMessage.cs +++ b/src/DotNetOAuth/Messages/DirectUserToServiceProviderMessage.cs @@ -7,6 +7,7 @@ namespace DotNetOAuth.Messages {
using System;
using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
using DotNetOAuth.Messaging;
/// <summary>
@@ -28,12 +29,13 @@ namespace DotNetOAuth.Messages { /// </summary>
/// <param name="serviceProvider">The URI of the Service Provider endpoint to send this message to.</param>
internal DirectUserToServiceProviderMessage(MessageReceivingEndpoint serviceProvider)
- : base(MessageProtection.None, MessageTransport.Indirect, serviceProvider) {
+ : base(MessageProtections.None, MessageTransport.Indirect, serviceProvider) {
}
/// <summary>
/// Gets or sets the Request or Access Token.
/// </summary>
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Justification = "This property IS accessible by a different name.")]
string ITokenContainingMessage.Token {
get { return this.RequestToken; }
set { this.RequestToken = value; }
@@ -42,8 +44,8 @@ namespace DotNetOAuth.Messages { /// <summary>
/// Gets the extra, non-OAuth parameters that will be included in the message.
/// </summary>
- public IDictionary<string, string> ExtraData {
- get { return ((IProtocolMessage)this).ExtraData; }
+ public new IDictionary<string, string> ExtraData {
+ get { return base.ExtraData; }
}
/// <summary>
@@ -54,14 +56,14 @@ namespace DotNetOAuth.Messages { /// accept requests to the User Authorization URL without it, in which
/// case it will prompt the User to enter it manually.
/// </remarks>
- [MessagePart(Name = "oauth_token", IsRequired = false)]
+ [MessagePart("oauth_token", IsRequired = false)]
internal string RequestToken { get; set; }
/// <summary>
/// Gets or sets a URL the Service Provider will use to redirect the User back
/// to the Consumer when Obtaining User Authorization is complete. Optional.
/// </summary>
- [MessagePart(Name = "oauth_callback", IsRequired = false)]
+ [MessagePart("oauth_callback", IsRequired = false)]
internal Uri Callback { get; set; }
}
}
diff --git a/src/DotNetOAuth/Messages/GetAccessTokenMessage.cs b/src/DotNetOAuth/Messages/GetAccessTokenMessage.cs index 8828876..45863d1 100644 --- a/src/DotNetOAuth/Messages/GetAccessTokenMessage.cs +++ b/src/DotNetOAuth/Messages/GetAccessTokenMessage.cs @@ -35,7 +35,7 @@ namespace DotNetOAuth.Messages { /// <summary>
/// Gets or sets the Request Token.
/// </summary>
- [MessagePart(Name = "oauth_token", IsRequired = true)]
+ [MessagePart("oauth_token", IsRequired = true)]
internal string RequestToken { get; set; }
}
}
diff --git a/src/DotNetOAuth/Messages/GetRequestTokenMessage.cs b/src/DotNetOAuth/Messages/GetRequestTokenMessage.cs index 8b77927..f8ebc6b 100644 --- a/src/DotNetOAuth/Messages/GetRequestTokenMessage.cs +++ b/src/DotNetOAuth/Messages/GetRequestTokenMessage.cs @@ -23,8 +23,8 @@ namespace DotNetOAuth.Messages { /// <summary>
/// Gets the extra, non-OAuth parameters that will be included in the message.
/// </summary>
- public IDictionary<string, string> ExtraData {
- get { return ((IProtocolMessage)this).ExtraData; }
+ public new IDictionary<string, string> ExtraData {
+ get { return base.ExtraData; }
}
}
}
diff --git a/src/DotNetOAuth/Messages/GrantAccessTokenMessage.cs b/src/DotNetOAuth/Messages/GrantAccessTokenMessage.cs index ea1c6d1..69823ae 100644 --- a/src/DotNetOAuth/Messages/GrantAccessTokenMessage.cs +++ b/src/DotNetOAuth/Messages/GrantAccessTokenMessage.cs @@ -6,6 +6,7 @@ namespace DotNetOAuth.Messages {
using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
using DotNetOAuth.Messaging;
/// <summary>
@@ -17,18 +18,19 @@ namespace DotNetOAuth.Messages { /// Initializes a new instance of the <see cref="GrantAccessTokenMessage"/> class.
/// </summary>
protected internal GrantAccessTokenMessage()
- : base(MessageProtection.None, MessageTransport.Direct) {
+ : base(MessageProtections.None, MessageTransport.Direct) {
}
/// <summary>
/// Gets or sets the Access Token assigned by the Service Provider.
/// </summary>
- [MessagePart(Name = "oauth_token", IsRequired = true)]
+ [MessagePart("oauth_token", IsRequired = true)]
public string AccessToken { get; set; }
/// <summary>
/// Gets or sets the Request or Access Token.
/// </summary>
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Justification = "This property IS accessible by a different name.")]
string ITokenContainingMessage.Token {
get { return this.AccessToken; }
set { this.AccessToken = value; }
@@ -45,14 +47,14 @@ namespace DotNetOAuth.Messages { /// <summary>
/// Gets the extra, non-OAuth parameters that will be included in the message.
/// </summary>
- public IDictionary<string, string> ExtraData {
- get { return ((IProtocolMessage)this).ExtraData; }
+ public new IDictionary<string, string> ExtraData {
+ get { return base.ExtraData; }
}
/// <summary>
/// Gets or sets the Token Secret.
/// </summary>
- [MessagePart(Name = "oauth_token_secret", IsRequired = true)]
- internal string TokenSecret { get; set; }
+ [MessagePart("oauth_token_secret", IsRequired = true)]
+ protected internal string TokenSecret { get; set; }
}
}
diff --git a/src/DotNetOAuth/Messages/GrantRequestTokenMessage.cs b/src/DotNetOAuth/Messages/GrantRequestTokenMessage.cs index 1838970..1b48243 100644 --- a/src/DotNetOAuth/Messages/GrantRequestTokenMessage.cs +++ b/src/DotNetOAuth/Messages/GrantRequestTokenMessage.cs @@ -6,6 +6,7 @@ namespace DotNetOAuth.Messages {
using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
using DotNetOAuth.Messaging;
/// <summary>
@@ -27,12 +28,13 @@ namespace DotNetOAuth.Messages { /// Initializes a new instance of the <see cref="GrantRequestTokenMessage"/> class.
/// </summary>
protected internal GrantRequestTokenMessage()
- : base(MessageProtection.None, MessageTransport.Direct) {
+ : base(MessageProtections.None, MessageTransport.Direct) {
}
/// <summary>
/// Gets or sets the Request or Access Token.
/// </summary>
+ [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Justification = "This property IS accessible by a different name.")]
string ITokenContainingMessage.Token {
get { return this.RequestToken; }
set { this.RequestToken = value; }
@@ -49,20 +51,20 @@ namespace DotNetOAuth.Messages { /// <summary>
/// Gets the extra, non-OAuth parameters that will be included in the message.
/// </summary>
- public IDictionary<string, string> ExtraData {
- get { return ((IProtocolMessage)this).ExtraData; }
+ public new IDictionary<string, string> ExtraData {
+ get { return base.ExtraData; }
}
/// <summary>
/// Gets or sets the Request Token.
/// </summary>
- [MessagePart(Name = "oauth_token", IsRequired = true)]
+ [MessagePart("oauth_token", IsRequired = true)]
internal string RequestToken { get; set; }
/// <summary>
/// Gets or sets the Token Secret.
/// </summary>
- [MessagePart(Name = "oauth_token_secret", IsRequired = true)]
- internal string TokenSecret { get; set; }
+ [MessagePart("oauth_token_secret", IsRequired = true)]
+ protected internal string TokenSecret { get; set; }
}
}
diff --git a/src/DotNetOAuth/Messages/MessageBase.cs b/src/DotNetOAuth/Messages/MessageBase.cs index 2340bee..76308be 100644 --- a/src/DotNetOAuth/Messages/MessageBase.cs +++ b/src/DotNetOAuth/Messages/MessageBase.cs @@ -25,7 +25,7 @@ namespace DotNetOAuth.Messages { /// <summary>
/// Gets a value indicating whether signing this message is required.
/// </summary>
- private MessageProtection protectionRequired;
+ private MessageProtections protectionRequired;
/// <summary>
/// Gets a value indicating whether this is a direct or indirect message.
@@ -51,7 +51,7 @@ namespace DotNetOAuth.Messages { /// </summary>
/// <param name="protectionRequired">The level of protection the message requires.</param>
/// <param name="transport">A value indicating whether this message requires a direct or indirect transport.</param>
- protected MessageBase(MessageProtection protectionRequired, MessageTransport transport) {
+ protected MessageBase(MessageProtections protectionRequired, MessageTransport transport) {
this.protectionRequired = protectionRequired;
this.transport = transport;
}
@@ -62,7 +62,7 @@ namespace DotNetOAuth.Messages { /// <param name="protectionRequired">The level of protection the message requires.</param>
/// <param name="transport">A value indicating whether this message requires a direct or indirect transport.</param>
/// <param name="recipient">The URI that a directed message will be delivered to.</param>
- protected MessageBase(MessageProtection protectionRequired, MessageTransport transport, MessageReceivingEndpoint recipient) {
+ protected MessageBase(MessageProtections protectionRequired, MessageTransport transport, MessageReceivingEndpoint recipient) {
if (recipient == null) {
throw new ArgumentNullException("recipient");
}
@@ -78,28 +78,28 @@ namespace DotNetOAuth.Messages { /// Gets the version of the protocol this message is prepared to implement.
/// </summary>
Version IProtocolMessage.ProtocolVersion {
- get { return new Version(1, 0); }
+ get { return this.ProtocolVersion; }
}
/// <summary>
/// Gets the level of protection this message requires.
/// </summary>
- MessageProtection IProtocolMessage.RequiredProtection {
- get { return this.protectionRequired; }
+ MessageProtections IProtocolMessage.RequiredProtection {
+ get { return this.RequiredProtection; }
}
/// <summary>
/// Gets a value indicating whether this is a direct or indirect message.
/// </summary>
MessageTransport IProtocolMessage.Transport {
- get { return this.transport; }
+ get { return this.Transport; }
}
/// <summary>
/// Gets the dictionary of additional name/value fields tacked on to this message.
/// </summary>
IDictionary<string, string> IProtocolMessage.ExtraData {
- get { return this.extraData; }
+ get { return this.ExtraData; }
}
#endregion
@@ -120,14 +120,65 @@ namespace DotNetOAuth.Messages { /// <summary>
/// Gets the preferred method of transport for the message.
/// </summary>
- HttpDeliveryMethod IOAuthDirectedMessage.HttpMethods {
- get { return this.recipient != null ? this.recipient.AllowedMethods : HttpDeliveryMethod.None; }
+ HttpDeliveryMethods IOAuthDirectedMessage.HttpMethods {
+ get { return this.HttpMethods; }
}
/// <summary>
/// Gets or sets the URI to the Service Provider endpoint to send this message to.
/// </summary>
Uri IOAuthDirectedMessage.Recipient {
+ get { return this.Recipient; }
+ set { this.Recipient = value; }
+ }
+
+ #endregion
+
+ /// <summary>
+ /// Gets or sets a value indicating whether security sensitive strings are
+ /// emitted from the ToString() method.
+ /// </summary>
+ internal static bool LowSecurityMode { get; set; }
+
+ /// <summary>
+ /// Gets the version of the protocol this message is prepared to implement.
+ /// </summary>
+ protected virtual Version ProtocolVersion {
+ get { return new Version(1, 0); }
+ }
+
+ /// <summary>
+ /// Gets the level of protection this message requires.
+ /// </summary>
+ protected MessageProtections RequiredProtection {
+ get { return this.protectionRequired; }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether this is a direct or indirect message.
+ /// </summary>
+ protected MessageTransport Transport {
+ get { return this.transport; }
+ }
+
+ /// <summary>
+ /// Gets the dictionary of additional name/value fields tacked on to this message.
+ /// </summary>
+ protected IDictionary<string, string> ExtraData {
+ get { return this.extraData; }
+ }
+
+ /// <summary>
+ /// Gets the preferred method of transport for the message.
+ /// </summary>
+ protected HttpDeliveryMethods HttpMethods {
+ get { return this.recipient != null ? this.recipient.AllowedMethods : HttpDeliveryMethods.None; }
+ }
+
+ /// <summary>
+ /// Gets or sets the URI to the Service Provider endpoint to send this message to.
+ /// </summary>
+ protected Uri Recipient {
get {
return this.recipient != null ? this.recipient.Location : null;
}
@@ -141,14 +192,6 @@ namespace DotNetOAuth.Messages { }
}
- #endregion
-
- /// <summary>
- /// Gets or sets a value indicating whether security sensitive strings are
- /// emitted from the ToString() method.
- /// </summary>
- internal static bool LowSecurityMode { get; set; }
-
#region IProtocolMessage Methods
/// <summary>
diff --git a/src/DotNetOAuth/Messages/SignedMessageBase.cs b/src/DotNetOAuth/Messages/SignedMessageBase.cs index e20f2f6..9b05c2c 100644 --- a/src/DotNetOAuth/Messages/SignedMessageBase.cs +++ b/src/DotNetOAuth/Messages/SignedMessageBase.cs @@ -6,7 +6,7 @@ namespace DotNetOAuth.Messages {
using System;
- using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
using DotNetOAuth.ChannelElements;
using DotNetOAuth.Messaging;
using DotNetOAuth.Messaging.Bindings;
@@ -32,10 +32,10 @@ namespace DotNetOAuth.Messages { /// <param name="transport">A value indicating whether this message requires a direct or indirect transport.</param>
/// <param name="recipient">The URI that a directed message will be delivered to.</param>
internal SignedMessageBase(MessageTransport transport, MessageReceivingEndpoint recipient)
- : base(MessageProtection.All, transport, recipient) {
+ : base(MessageProtections.All, transport, recipient) {
ITamperResistantOAuthMessage self = (ITamperResistantOAuthMessage)this;
- HttpDeliveryMethod methods = ((IOAuthDirectedMessage)this).HttpMethods;
- self.HttpMethod = (methods & HttpDeliveryMethod.PostRequest) != 0 ? "POST" : "GET";
+ HttpDeliveryMethods methods = ((IOAuthDirectedMessage)this).HttpMethods;
+ self.HttpMethod = (methods & HttpDeliveryMethods.PostRequest) != 0 ? "POST" : "GET";
}
#region ITamperResistantOAuthMessage Members
@@ -43,29 +43,40 @@ namespace DotNetOAuth.Messages { /// <summary>
/// Gets or sets the signature method used to sign the request.
/// </summary>
- [MessagePart("oauth_signature_method", IsRequired = true)]
- string ITamperResistantOAuthMessage.SignatureMethod { get; set; }
+ string ITamperResistantOAuthMessage.SignatureMethod {
+ get { return this.SignatureMethod; }
+ set { this.SignatureMethod = value; }
+ }
/// <summary>
/// Gets or sets the Token Secret used to sign the message.
/// </summary>
- string ITamperResistantOAuthMessage.TokenSecret { get; set; }
+ string ITamperResistantOAuthMessage.TokenSecret {
+ get { return this.TokenSecret; }
+ set { this.TokenSecret = value; }
+ }
/// <summary>
/// Gets or sets the Consumer key.
/// </summary>
- [MessagePart(Name = "oauth_consumer_key", IsRequired = true)]
+ [MessagePart("oauth_consumer_key", IsRequired = true)]
public string ConsumerKey { get; set; }
/// <summary>
/// Gets or sets the Consumer Secret used to sign the message.
/// </summary>
- string ITamperResistantOAuthMessage.ConsumerSecret { get; set; }
+ string ITamperResistantOAuthMessage.ConsumerSecret {
+ get { return this.ConsumerSecret; }
+ set { this.ConsumerSecret = value; }
+ }
/// <summary>
/// Gets or sets the HTTP method that will be used to transmit the message.
/// </summary>
- string ITamperResistantOAuthMessage.HttpMethod { get; set; }
+ string ITamperResistantOAuthMessage.HttpMethod {
+ get { return this.HttpMethod; }
+ set { this.HttpMethod = value; }
+ }
#endregion
@@ -74,8 +85,10 @@ namespace DotNetOAuth.Messages { /// <summary>
/// Gets or sets the message signature.
/// </summary>
- [MessagePart("oauth_signature", IsRequired = true)]
- string ITamperResistantProtocolMessage.Signature { get; set; }
+ string ITamperResistantProtocolMessage.Signature {
+ get { return this.Signature; }
+ set { this.Signature = value; }
+ }
#endregion
@@ -102,12 +115,40 @@ namespace DotNetOAuth.Messages { #endregion
/// <summary>
+ /// Gets or sets the signature method used to sign the request.
+ /// </summary>
+ [MessagePart("oauth_signature_method", IsRequired = true)]
+ protected string SignatureMethod { get; set; }
+
+ /// <summary>
+ /// Gets or sets the Token Secret used to sign the message.
+ /// </summary>
+ protected string TokenSecret { get; set; }
+
+ /// <summary>
+ /// Gets or sets the Consumer Secret used to sign the message.
+ /// </summary>
+ protected string ConsumerSecret { get; set; }
+
+ /// <summary>
+ /// Gets or sets the HTTP method that will be used to transmit the message.
+ /// </summary>
+ protected string HttpMethod { get; set; }
+
+ /// <summary>
+ /// Gets or sets the message signature.
+ /// </summary>
+ [MessagePart("oauth_signature", IsRequired = true)]
+ protected string Signature { get; set; }
+
+ /// <summary>
/// Gets or sets the version of the protocol this message was created with.
/// </summary>
- [MessagePart(Name = "oauth_version", IsRequired = false)]
+ [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Accessed via reflection.")]
+ [MessagePart("oauth_version", IsRequired = false)]
private string Version {
get {
- return ((IProtocolMessage)this).ProtocolVersion.ToString();
+ return ProtocolVersion.ToString();
}
set {
diff --git a/src/DotNetOAuth/Messaging/Bindings/NonceMemoryStore.cs b/src/DotNetOAuth/Messaging/Bindings/NonceMemoryStore.cs index 05e0f13..98b93ff 100644 --- a/src/DotNetOAuth/Messaging/Bindings/NonceMemoryStore.cs +++ b/src/DotNetOAuth/Messaging/Bindings/NonceMemoryStore.cs @@ -56,6 +56,12 @@ namespace DotNetOAuth.Messaging.Bindings { /// <see cref="StandardExpirationBindingElement.MaximumMessageAge"/> property.
/// </remarks>
public bool StoreNonce(string nonce, DateTime timestamp) {
+ if (timestamp.ToUniversalTime() + this.maximumMessageAge < DateTime.UtcNow) {
+ // The expiration binding element should have taken care of this, but perhaps
+ // it's at the boundary case. We should fail just to be safe.
+ return false;
+ }
+
// TODO: implement actual nonce checking.
Logger.Warn("Nonce checking not implemented yet.");
return true;
diff --git a/src/DotNetOAuth/Messaging/Bindings/StandardExpirationBindingElement.cs b/src/DotNetOAuth/Messaging/Bindings/StandardExpirationBindingElement.cs index 25a24f5..fa7f78c 100644 --- a/src/DotNetOAuth/Messaging/Bindings/StandardExpirationBindingElement.cs +++ b/src/DotNetOAuth/Messaging/Bindings/StandardExpirationBindingElement.cs @@ -48,9 +48,9 @@ namespace DotNetOAuth.Messaging.Bindings { /// <summary>
/// Gets the protection offered by this binding element.
/// </summary>
- /// <value><see cref="MessageProtection.Expiration"/></value>
- MessageProtection IChannelBindingElement.Protection {
- get { return MessageProtection.Expiration; }
+ /// <value><see cref="MessageProtections.Expiration"/></value>
+ MessageProtections IChannelBindingElement.Protection {
+ get { return MessageProtections.Expiration; }
}
#endregion
diff --git a/src/DotNetOAuth/Messaging/Bindings/StandardReplayProtectionBindingElement.cs b/src/DotNetOAuth/Messaging/Bindings/StandardReplayProtectionBindingElement.cs index 5500a3b..b97b25e 100644 --- a/src/DotNetOAuth/Messaging/Bindings/StandardReplayProtectionBindingElement.cs +++ b/src/DotNetOAuth/Messaging/Bindings/StandardReplayProtectionBindingElement.cs @@ -49,8 +49,8 @@ namespace DotNetOAuth.Messaging.Bindings { /// <summary>
/// Gets the protection that this binding element provides messages.
/// </summary>
- public MessageProtection Protection {
- get { return MessageProtection.ReplayProtection; }
+ public MessageProtections Protection {
+ get { return MessageProtections.ReplayProtection; }
}
#endregion
diff --git a/src/DotNetOAuth/Messaging/Channel.cs b/src/DotNetOAuth/Messaging/Channel.cs index 270a540..09e20b9 100644 --- a/src/DotNetOAuth/Messaging/Channel.cs +++ b/src/DotNetOAuth/Messaging/Channel.cs @@ -516,7 +516,7 @@ namespace DotNetOAuth.Messaging { throw new ArgumentNullException("message");
}
- MessageProtection appliedProtection = MessageProtection.None;
+ MessageProtections appliedProtection = MessageProtections.None;
foreach (IChannelBindingElement bindingElement in this.bindingElements) {
if (bindingElement.PrepareMessageForSending(message)) {
appliedProtection |= bindingElement.Protection;
@@ -567,13 +567,13 @@ namespace DotNetOAuth.Messaging { // Filter the elements between the mere transforming ones and the protection ones.
var transformationElements = new List<IChannelBindingElement>(
- elements.Where(element => element.Protection == MessageProtection.None));
+ elements.Where(element => element.Protection == MessageProtections.None));
var protectionElements = new List<IChannelBindingElement>(
- elements.Where(element => element.Protection != MessageProtection.None));
+ elements.Where(element => element.Protection != MessageProtections.None));
bool wasLastProtectionPresent = true;
- foreach (MessageProtection protectionKind in Enum.GetValues(typeof(MessageProtection))) {
- if (protectionKind == MessageProtection.None) {
+ foreach (MessageProtections protectionKind in Enum.GetValues(typeof(MessageProtections))) {
+ if (protectionKind == MessageProtections.None) {
continue;
}
@@ -619,8 +619,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(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.");
+ private static int BindingElementOutgoingMessageApplicationOrder(MessageProtections protection1, MessageProtections protection2) {
+ Debug.Assert(protection1 != MessageProtections.None || protection2 != MessageProtections.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
@@ -653,7 +653,7 @@ namespace DotNetOAuth.Messaging { private void VerifyMessageAfterReceiving(IProtocolMessage message) {
Debug.Assert(message != null, "message == null");
- MessageProtection appliedProtection = MessageProtection.None;
+ MessageProtections appliedProtection = MessageProtections.None;
foreach (IChannelBindingElement bindingElement in this.bindingElements.Reverse<IChannelBindingElement>()) {
if (bindingElement.PrepareMessageForReceiving(message)) {
appliedProtection |= bindingElement.Protection;
diff --git a/src/DotNetOAuth/Messaging/HttpDeliveryMethod.cs b/src/DotNetOAuth/Messaging/HttpDeliveryMethods.cs index b4b8c42..e0f26c0 100644 --- a/src/DotNetOAuth/Messaging/HttpDeliveryMethod.cs +++ b/src/DotNetOAuth/Messaging/HttpDeliveryMethods.cs @@ -1,5 +1,5 @@ //-----------------------------------------------------------------------
-// <copyright file="HttpDeliveryMethod.cs" company="Andrew Arnott">
+// <copyright file="HttpDeliveryMethods.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
@@ -14,7 +14,7 @@ namespace DotNetOAuth.Messaging { /// See 1.0 spec section 5.2.
/// </remarks>
[Flags]
- public enum HttpDeliveryMethod {
+ public enum HttpDeliveryMethods {
/// <summary>
/// No HTTP methods are allowed.
/// </summary>
diff --git a/src/DotNetOAuth/Messaging/IChannelBindingElement.cs b/src/DotNetOAuth/Messaging/IChannelBindingElement.cs index 25f353f..a11509d 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>
- MessageProtection Protection { get; }
+ MessageProtections Protection { get; }
/// <summary>
/// Prepares a message for sending based on the rules of this channel binding element.
diff --git a/src/DotNetOAuth/Messaging/IMessageTypeProvider.cs b/src/DotNetOAuth/Messaging/IMessageTypeProvider.cs index 17affcb..afc0b04 100644 --- a/src/DotNetOAuth/Messaging/IMessageTypeProvider.cs +++ b/src/DotNetOAuth/Messaging/IMessageTypeProvider.cs @@ -12,7 +12,7 @@ namespace DotNetOAuth.Messaging { /// A tool to analyze an incoming message to figure out what concrete class
/// is designed to deserialize it.
/// </summary>
- internal interface IMessageTypeProvider {
+ public interface IMessageTypeProvider {
/// <summary>
/// Analyzes an incoming request message payload to discover what kind of
/// message is embedded in it and returns the type, or null if no match is found.
diff --git a/src/DotNetOAuth/Messaging/IProtocolMessage.cs b/src/DotNetOAuth/Messaging/IProtocolMessage.cs index f96db9e..25779f9 100644 --- a/src/DotNetOAuth/Messaging/IProtocolMessage.cs +++ b/src/DotNetOAuth/Messaging/IProtocolMessage.cs @@ -22,7 +22,7 @@ namespace DotNetOAuth.Messaging { /// <summary>
/// Gets the level of protection this message requires.
/// </summary>
- MessageProtection RequiredProtection { get; }
+ MessageProtections RequiredProtection { get; }
/// <summary>
/// Gets a value indicating whether this is a direct or indirect message.
diff --git a/src/DotNetOAuth/Messaging/Bindings/ITamperResistantProtocolMessage.cs b/src/DotNetOAuth/Messaging/ITamperResistantProtocolMessage.cs index 62c3088..0b6b0d1 100644 --- a/src/DotNetOAuth/Messaging/Bindings/ITamperResistantProtocolMessage.cs +++ b/src/DotNetOAuth/Messaging/ITamperResistantProtocolMessage.cs @@ -4,10 +4,15 @@ // </copyright>
//-----------------------------------------------------------------------
-namespace DotNetOAuth.Messaging.Bindings {
+namespace DotNetOAuth.Messaging {
/// <summary>
/// The contract a message that is signed must implement.
/// </summary>
+ /// <remarks>
+ /// This type might have appeared in the DotNetOAuth.Messaging.Bindings namespace since
+ /// it is only used by types in that namespace, but all those types are internal and this
+ /// is the only one that was public.
+ /// </remarks>
public interface ITamperResistantProtocolMessage : IProtocolMessage {
/// <summary>
/// Gets or sets the message signature.
diff --git a/src/DotNetOAuth/Messaging/MessagePartAttribute.cs b/src/DotNetOAuth/Messaging/MessagePartAttribute.cs index 91053b6..2e089c2 100644 --- a/src/DotNetOAuth/Messaging/MessagePartAttribute.cs +++ b/src/DotNetOAuth/Messaging/MessagePartAttribute.cs @@ -37,11 +37,11 @@ namespace DotNetOAuth.Messaging { }
/// <summary>
- /// Gets or sets the name of the serialized form of this member in the message.
+ /// Gets the name of the serialized form of this member in the message.
/// </summary>
public string Name {
get { return this.name; }
- set { this.name = string.IsNullOrEmpty(value) ? null : value; }
+ private set { this.name = string.IsNullOrEmpty(value) ? null : value; }
}
/// <summary>
diff --git a/src/DotNetOAuth/Messaging/MessageProtection.cs b/src/DotNetOAuth/Messaging/MessageProtections.cs index 9dc2b9d..29b60b7 100644 --- a/src/DotNetOAuth/Messaging/MessageProtection.cs +++ b/src/DotNetOAuth/Messaging/MessageProtections.cs @@ -1,5 +1,5 @@ //-----------------------------------------------------------------------
-// <copyright file="MessageProtection.cs" company="Andrew Arnott">
+// <copyright file="MessageProtections.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]
- public enum MessageProtection {
+ public enum MessageProtections {
/// <summary>
/// No protection.
/// </summary>
diff --git a/src/DotNetOAuth/Messaging/MessageReceivingEndpoint.cs b/src/DotNetOAuth/Messaging/MessageReceivingEndpoint.cs index 31c79ca..2236dd1 100644 --- a/src/DotNetOAuth/Messaging/MessageReceivingEndpoint.cs +++ b/src/DotNetOAuth/Messaging/MessageReceivingEndpoint.cs @@ -18,7 +18,7 @@ namespace DotNetOAuth.Messaging { /// </summary>
/// <param name="locationUri">The URL of this endpoint.</param>
/// <param name="method">The HTTP method(s) allowed.</param>
- public MessageReceivingEndpoint(string locationUri, HttpDeliveryMethod method)
+ public MessageReceivingEndpoint(string locationUri, HttpDeliveryMethods method)
: this(new Uri(locationUri), method) { }
/// <summary>
@@ -26,14 +26,14 @@ namespace DotNetOAuth.Messaging { /// </summary>
/// <param name="location">The URL of this endpoint.</param>
/// <param name="method">The HTTP method(s) allowed.</param>
- public MessageReceivingEndpoint(Uri location, HttpDeliveryMethod method) {
+ public MessageReceivingEndpoint(Uri location, HttpDeliveryMethods method) {
if (location == null) {
throw new ArgumentNullException("location");
}
- if (method == HttpDeliveryMethod.None) {
+ if (method == HttpDeliveryMethods.None) {
throw new ArgumentOutOfRangeException("method");
}
- if ((method & (HttpDeliveryMethod.PostRequest | HttpDeliveryMethod.GetRequest)) == 0) {
+ if ((method & (HttpDeliveryMethods.PostRequest | HttpDeliveryMethods.GetRequest)) == 0) {
throw new ArgumentOutOfRangeException("method", MessagingStrings.GetOrPostFlagsRequired);
}
@@ -49,6 +49,6 @@ namespace DotNetOAuth.Messaging { /// <summary>
/// Gets the HTTP method(s) allowed.
/// </summary>
- public HttpDeliveryMethod AllowedMethods { get; private set; }
+ public HttpDeliveryMethods AllowedMethods { get; private set; }
}
}
diff --git a/src/DotNetOAuth/Messaging/MessagingUtilities.cs b/src/DotNetOAuth/Messaging/MessagingUtilities.cs index 8388051..a645ad3 100644 --- a/src/DotNetOAuth/Messaging/MessagingUtilities.cs +++ b/src/DotNetOAuth/Messaging/MessagingUtilities.cs @@ -180,7 +180,7 @@ namespace DotNetOAuth.Messaging { /// <param name="request">The request to get recipient information from.</param>
/// <returns>The recipient.</returns>
internal static MessageReceivingEndpoint GetRecipient(this HttpRequestInfo request) {
- return new MessageReceivingEndpoint(request.Url, request.HttpMethod == "GET" ? HttpDeliveryMethod.GetRequest : HttpDeliveryMethod.PostRequest);
+ return new MessageReceivingEndpoint(request.Url, request.HttpMethod == "GET" ? HttpDeliveryMethods.GetRequest : HttpDeliveryMethods.PostRequest);
}
/// <summary>
diff --git a/src/DotNetOAuth/Messaging/ProtocolException.cs b/src/DotNetOAuth/Messaging/ProtocolException.cs index d8b3d33..0c31308 100644 --- a/src/DotNetOAuth/Messaging/ProtocolException.cs +++ b/src/DotNetOAuth/Messaging/ProtocolException.cs @@ -7,6 +7,7 @@ namespace DotNetOAuth.Messaging {
using System;
using System.Collections.Generic;
+ using System.Security.Permissions;
/// <summary>
/// An exception to represent errors in the local or remote implementation of the protocol.
@@ -52,7 +53,8 @@ namespace DotNetOAuth.Messaging { /// </summary>
/// <param name="message">The human-readable exception message.</param>
/// <param name="faultedMessage">The message that was the cause of the exception. May not be null.</param>
- internal ProtocolException(string message, IProtocolMessage faultedMessage) : base(message) {
+ internal ProtocolException(string message, IProtocolMessage faultedMessage)
+ : base(message) {
if (faultedMessage == null) {
throw new ArgumentNullException("faultedMessage");
}
@@ -100,7 +102,34 @@ namespace DotNetOAuth.Messaging { protected ProtocolException(
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context)
- : base(info, context) { }
+ : base(info, context) {
+ throw new NotImplementedException();
+ }
+
+ #region IProtocolMessage Properties
+
+ /// <summary>
+ /// Gets the version of the protocol this message is prepared to implement.
+ /// </summary>
+ Version IProtocolMessage.ProtocolVersion {
+ get { return this.ProtocolVersion; }
+ }
+
+ /// <summary>
+ /// Gets the level of protection this exception requires when transmitted as a message.
+ /// </summary>
+ MessageProtections IProtocolMessage.RequiredProtection {
+ get { return RequiredProtection; }
+ }
+
+ /// <summary>
+ /// Gets whether this is a direct or indirect message.
+ /// </summary>
+ MessageTransport IProtocolMessage.Transport {
+ get { return this.Transport; }
+ }
+
+ #endregion
#region IDirectedProtocolMessage Members
@@ -111,6 +140,40 @@ namespace DotNetOAuth.Messaging { /// This property should only be called when the error is being sent as an indirect response.
/// </remarks>
Uri IDirectedProtocolMessage.Recipient {
+ get { return this.Recipient; }
+ }
+
+ #endregion
+
+ /// <summary>
+ /// Gets the dictionary of additional name/value fields tacked on to this message.
+ /// </summary>
+ IDictionary<string, string> IProtocolMessage.ExtraData {
+ get { return this.ExtraData; }
+ }
+
+ /// <summary>
+ /// Gets the message that caused the exception.
+ /// </summary>
+ internal IProtocolMessage FaultedMessage {
+ get;
+ private set;
+ }
+
+ /// <summary>
+ /// Gets the level of protection this exception requires when transmitted as a message.
+ /// </summary>
+ protected static MessageProtections RequiredProtection {
+ get { return MessageProtections.None; }
+ }
+
+ /// <summary>
+ /// Gets the URL of the intended receiver of this message.
+ /// </summary>
+ /// <remarks>
+ /// This property should only be called when the error is being sent as an indirect response.
+ /// </remarks>
+ protected Uri Recipient {
get {
if (this.inResponseTo == null) {
throw new InvalidOperationException(MessagingStrings.ExceptionNotConstructedForTransit);
@@ -119,14 +182,10 @@ namespace DotNetOAuth.Messaging { }
}
- #endregion
-
- #region IProtocolMessage Properties
-
/// <summary>
/// Gets the version of the protocol this message is prepared to implement.
/// </summary>
- Version IProtocolMessage.ProtocolVersion {
+ protected Version ProtocolVersion {
get {
if (this.inResponseTo == null) {
throw new InvalidOperationException(MessagingStrings.ExceptionNotConstructedForTransit);
@@ -136,16 +195,9 @@ namespace DotNetOAuth.Messaging { }
/// <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 {
+ protected MessageTransport Transport {
get {
if (this.inResponseTo == null) {
throw new InvalidOperationException(MessagingStrings.ExceptionNotConstructedForTransit);
@@ -157,18 +209,26 @@ namespace DotNetOAuth.Messaging { /// <summary>
/// Gets the dictionary of additional name/value fields tacked on to this message.
/// </summary>
- IDictionary<string, string> IProtocolMessage.ExtraData {
+ protected IDictionary<string, string> ExtraData {
get { return this.extraData; }
}
- #endregion
-
/// <summary>
- /// Gets the message that caused the exception.
- /// </summary>
- internal IProtocolMessage FaultedMessage {
- get;
- private set;
+ /// When overridden in a derived class, sets the <see cref="T:System.Runtime.Serialization.SerializationInfo"/> with information about the exception.
+ /// </summary>
+ /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
+ /// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination.</param>
+ /// <exception cref="T:System.ArgumentNullException">
+ /// The <paramref name="info"/> parameter is a null reference (Nothing in Visual Basic).
+ /// </exception>
+ /// <PermissionSet>
+ /// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Read="*AllFiles*" PathDiscovery="*AllFiles*"/>
+ /// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="SerializationFormatter"/>
+ /// </PermissionSet>
+ [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
+ public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) {
+ base.GetObjectData(info, context);
+ throw new NotImplementedException();
}
#region IProtocolMessage Methods
@@ -177,6 +237,13 @@ namespace DotNetOAuth.Messaging { /// See <see cref="IProtocolMessage.EnsureValidMessage"/>.
/// </summary>
void IProtocolMessage.EnsureValidMessage() {
+ this.EnsureValidMessage();
+ }
+
+ /// <summary>
+ /// See <see cref="IProtocolMessage.EnsureValidMessage"/>.
+ /// </summary>
+ protected virtual void EnsureValidMessage() {
if (this.inResponseTo == null) {
throw new InvalidOperationException(MessagingStrings.ExceptionNotConstructedForTransit);
}
diff --git a/src/DotNetOAuth/Messaging/Reflection/MessagePart.cs b/src/DotNetOAuth/Messaging/Reflection/MessagePart.cs index b79ad06..8d409d4 100644 --- a/src/DotNetOAuth/Messaging/Reflection/MessagePart.cs +++ b/src/DotNetOAuth/Messaging/Reflection/MessagePart.cs @@ -7,6 +7,7 @@ namespace DotNetOAuth.Messaging.Reflection {
using System;
using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Net.Security;
using System.Reflection;
@@ -49,6 +50,7 @@ namespace DotNetOAuth.Messaging.Reflection { /// <summary>
/// Initializes static members of the <see cref="MessagePart"/> class.
/// </summary>
+ [SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline", Justification = "Much more efficient initialization when we can call methods.")]
static MessagePart() {
Map<Uri>(uri => uri.AbsoluteUri, str => new Uri(str));
Map<DateTime>(dt => XmlConvert.ToString(dt, XmlDateTimeSerializationMode.Utc), str => XmlConvert.ToDateTime(str, XmlDateTimeSerializationMode.Utc));
diff --git a/src/DotNetOAuth/Messaging/Response.cs b/src/DotNetOAuth/Messaging/Response.cs index 36941b3..d837017 100644 --- a/src/DotNetOAuth/Messaging/Response.cs +++ b/src/DotNetOAuth/Messaging/Response.cs @@ -6,6 +6,7 @@ namespace DotNetOAuth.Messaging {
using System;
+ using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Net;
using System.Text;
@@ -112,6 +113,7 @@ namespace DotNetOAuth.Messaging { /// Creates a text reader for the response stream.
/// </summary>
/// <returns>The text reader, initialized for the proper encoding.</returns>
+ [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Costly operation")]
public StreamReader GetResponseReader() {
this.ResponseStream.Seek(0, SeekOrigin.Begin);
string contentEncoding = this.Headers[HttpResponseHeader.ContentEncoding];
diff --git a/src/DotNetOAuth/Messaging/UnprotectedMessageException.cs b/src/DotNetOAuth/Messaging/UnprotectedMessageException.cs index 45a6a41..3e824f2 100644 --- a/src/DotNetOAuth/Messaging/UnprotectedMessageException.cs +++ b/src/DotNetOAuth/Messaging/UnprotectedMessageException.cs @@ -18,7 +18,7 @@ namespace DotNetOAuth.Messaging { /// </summary>
/// <param name="faultedMessage">The message whose protection requirements could not be met.</param>
/// <param name="appliedProtection">The protection requirements that were fulfilled.</param>
- internal UnprotectedMessageException(IProtocolMessage faultedMessage, MessageProtection appliedProtection)
+ internal UnprotectedMessageException(IProtocolMessage faultedMessage, MessageProtections appliedProtection)
: base(string.Format(CultureInfo.CurrentCulture, MessagingStrings.InsufficentMessageProtection, faultedMessage.RequiredProtection, appliedProtection), faultedMessage) {
}
diff --git a/src/DotNetOAuth/ServiceProviderDescription.cs b/src/DotNetOAuth/ServiceProviderDescription.cs index efb4290..870133c 100644 --- a/src/DotNetOAuth/ServiceProviderDescription.cs +++ b/src/DotNetOAuth/ServiceProviderDescription.cs @@ -7,6 +7,7 @@ namespace DotNetOAuth {
using System;
using System.Diagnostics;
+ using System.Diagnostics.CodeAnalysis;
using System.Linq;
using DotNetOAuth.ChannelElements;
using DotNetOAuth.Messaging;
@@ -72,6 +73,7 @@ namespace DotNetOAuth { /// <summary>
/// Gets or sets the signing policies that apply to this Service Provider.
/// </summary>
+ [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "Type initializers require this format.")]
public ITamperProtectionChannelBindingElement[] TamperProtectionElements { get; set; }
/// <summary>
|