summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/DotNetOAuth.Test/ChannelElements/HmacSha1SigningBindingElementTests.cs22
-rw-r--r--src/DotNetOAuth.Test/ChannelElements/SigningBindingElementBaseTests.cs40
-rw-r--r--src/DotNetOAuth.Test/DotNetOAuth.Test.csproj2
-rw-r--r--src/DotNetOAuth/ChannelElements/OAuthHttpMethodBindingElement.cs28
-rw-r--r--src/DotNetOAuth/Messages/MessageBase.cs3
-rw-r--r--src/DotNetOAuth/Messaging/MessagingUtilities.cs5
-rw-r--r--src/Settings.StyleCop49
7 files changed, 99 insertions, 50 deletions
diff --git a/src/DotNetOAuth.Test/ChannelElements/HmacSha1SigningBindingElementTests.cs b/src/DotNetOAuth.Test/ChannelElements/HmacSha1SigningBindingElementTests.cs
new file mode 100644
index 0000000..b35855e
--- /dev/null
+++ b/src/DotNetOAuth.Test/ChannelElements/HmacSha1SigningBindingElementTests.cs
@@ -0,0 +1,22 @@
+//-----------------------------------------------------------------------
+// <copyright file="HmacSha1SigningBindingElementTests.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOAuth.Test.ChannelElements {
+ using DotNetOAuth.ChannelElements;
+ using DotNetOAuth.Messages;
+ using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+ [TestClass]
+ public class HmacSha1SigningBindingElementTests : MessagingTestBase {
+ [TestMethod]
+ public void SignatureTest() {
+ RequestTokenMessage message = SigningBindingElementBaseTests.CreateTestRequestTokenMessage();
+
+ HmacSha1SigningBindingElement_Accessor hmac = new HmacSha1SigningBindingElement_Accessor();
+ Assert.AreEqual("kR0LhH8UqylaLfR%2FesXVVlP4sQI%3D", hmac.GetSignature(message));
+ }
+ }
+}
diff --git a/src/DotNetOAuth.Test/ChannelElements/SigningBindingElementBaseTests.cs b/src/DotNetOAuth.Test/ChannelElements/SigningBindingElementBaseTests.cs
new file mode 100644
index 0000000..832f50c
--- /dev/null
+++ b/src/DotNetOAuth.Test/ChannelElements/SigningBindingElementBaseTests.cs
@@ -0,0 +1,40 @@
+//-----------------------------------------------------------------------
+// <copyright file="SigningBindingElementBaseTests.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOAuth.Test.ChannelElements {
+ using DotNetOAuth.ChannelElements;
+ using DotNetOAuth.Messages;
+ using DotNetOAuth.Messaging;
+ using DotNetOAuth.Messaging.Reflection;
+ using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+ [TestClass]
+ public class SigningBindingElementBaseTests : MessagingTestBase {
+ [TestMethod]
+ public void BaseSignatureStringTest() {
+ RequestTokenMessage message = CreateTestRequestTokenMessage();
+
+ Assert.AreEqual(
+ "GET&https%3A%2F%2Fwww.google.com%2Faccounts%2FOAuthGetRequestToken&oauth_consumer_key%3Dnerdbank.org%26oauth_nonce%3Dfe4045a3f0efdd1e019fa8f8ae3f5c38%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1222665749%26oauth_version%3D1.0%26scope%3Dhttp%253A%252F%252Fwww.google.com%252Fm8%252Ffeeds%252F",
+ SigningBindingElementBase_Accessor.ConstructSignatureBaseString(message));
+ }
+
+ internal static RequestTokenMessage CreateTestRequestTokenMessage() {
+ MessageReceivingEndpoint endpoint = new MessageReceivingEndpoint("https://www.google.com/accounts/OAuthGetRequestToken", HttpDeliveryMethod.AuthorizationHeaderRequest);
+ RequestTokenMessage message = new RequestTokenMessage(endpoint);
+ message.ConsumerKey = "nerdbank.org";
+ message.ConsumerSecret = "nerdbanksecret";
+ var signedMessage = (ITamperResistantOAuthMessage)message;
+ signedMessage.HttpMethod = "GET";
+ signedMessage.SignatureMethod = "HMAC-SHA1";
+ MessageDictionary dictionary = new MessageDictionary(message);
+ dictionary["oauth_timestamp"] = "1222665749";
+ dictionary["oauth_nonce"] = "fe4045a3f0efdd1e019fa8f8ae3f5c38";
+ dictionary["scope"] = "http://www.google.com/m8/feeds/";
+ return message;
+ }
+ }
+}
diff --git a/src/DotNetOAuth.Test/DotNetOAuth.Test.csproj b/src/DotNetOAuth.Test/DotNetOAuth.Test.csproj
index 6afe84c..19917ea 100644
--- a/src/DotNetOAuth.Test/DotNetOAuth.Test.csproj
+++ b/src/DotNetOAuth.Test/DotNetOAuth.Test.csproj
@@ -58,6 +58,8 @@
</Reference>
</ItemGroup>
<ItemGroup>
+ <Compile Include="ChannelElements\SigningBindingElementBaseTests.cs" />
+ <Compile Include="ChannelElements\HmacSha1SigningBindingElementTests.cs" />
<Compile Include="Messaging\CollectionAssert.cs" />
<Compile Include="Messaging\MessageSerializerTests.cs" />
<Compile Include="Messaging\Reflection\MessageDescriptionTests.cs" />
diff --git a/src/DotNetOAuth/ChannelElements/OAuthHttpMethodBindingElement.cs b/src/DotNetOAuth/ChannelElements/OAuthHttpMethodBindingElement.cs
index 9a157b5..f247fbc 100644
--- a/src/DotNetOAuth/ChannelElements/OAuthHttpMethodBindingElement.cs
+++ b/src/DotNetOAuth/ChannelElements/OAuthHttpMethodBindingElement.cs
@@ -11,14 +11,27 @@ namespace DotNetOAuth.ChannelElements {
using System.Text;
using DotNetOAuth.Messaging;
+ /// <summary>
+ /// Sets the HTTP Method property on a signed message before the signing module gets to it.
+ /// </summary>
internal class OAuthHttpMethodBindingElement : IChannelBindingElement {
-
#region IChannelBindingElement Members
+ /// <summary>
+ /// Gets the protection offered (if any) by this binding element.
+ /// </summary>
public MessageProtection Protection {
get { return MessageProtection.None; }
}
+ /// <summary>
+ /// Prepares a message for sending based on the rules of this channel binding element.
+ /// </summary>
+ /// <param name="message">The message to prepare for sending.</param>
+ /// <returns>
+ /// True if the <paramref name="message"/> applied to this binding element
+ /// and the operation was successful. False otherwise.
+ /// </returns>
public bool PrepareMessageForSending(IProtocolMessage message) {
var oauthMessage = message as ITamperResistantOAuthMessage;
@@ -40,6 +53,19 @@ namespace DotNetOAuth.ChannelElements {
}
}
+ /// <summary>
+ /// Performs any transformation on an incoming message that may be necessary and/or
+ /// validates an incoming message based on the rules of this channel binding element.
+ /// </summary>
+ /// <param name="message">The incoming message to process.</param>
+ /// <returns>
+ /// True if the <paramref name="message"/> applied to this binding element
+ /// and the operation was successful. False if the operation did not apply to this message.
+ /// </returns>
+ /// <exception cref="ProtocolException">
+ /// Thrown when the binding element rules indicate that this message is invalid and should
+ /// NOT be processed.
+ /// </exception>
public bool PrepareMessageForReceiving(IProtocolMessage message) {
return false;
}
diff --git a/src/DotNetOAuth/Messages/MessageBase.cs b/src/DotNetOAuth/Messages/MessageBase.cs
index 58b3cbf..5edd936 100644
--- a/src/DotNetOAuth/Messages/MessageBase.cs
+++ b/src/DotNetOAuth/Messages/MessageBase.cs
@@ -38,6 +38,9 @@ namespace DotNetOAuth.Messages {
private MessageReceivingEndpoint recipient;
#if DEBUG
+ /// <summary>
+ /// Initializes static members of the <see cref="MessageBase"/> class.
+ /// </summary>
static MessageBase() {
LowSecurityMode = true;
}
diff --git a/src/DotNetOAuth/Messaging/MessagingUtilities.cs b/src/DotNetOAuth/Messaging/MessagingUtilities.cs
index 5ec157c..24ad0c4 100644
--- a/src/DotNetOAuth/Messaging/MessagingUtilities.cs
+++ b/src/DotNetOAuth/Messaging/MessagingUtilities.cs
@@ -140,6 +140,11 @@ namespace DotNetOAuth.Messaging {
return new MessageReceivingEndpoint(request.Url, request.HttpMethod == "GET" ? HttpDeliveryMethod.GetRequest : HttpDeliveryMethod.PostRequest);
}
+ /// <summary>
+ /// Copies some extra parameters into a message.
+ /// </summary>
+ /// <param name="message">The message to copy the extra data into.</param>
+ /// <param name="extraParameters">The extra data to copy into the message. May be null to do nothing.</param>
internal static void AddExtraFields(this IProtocolMessage message, IDictionary<string, string> extraParameters) {
if (message == null) {
throw new ArgumentNullException("message");
diff --git a/src/Settings.StyleCop b/src/Settings.StyleCop
deleted file mode 100644
index a00cce5..0000000
--- a/src/Settings.StyleCop
+++ /dev/null
@@ -1,49 +0,0 @@
-<StyleCopSettings Version="4.3">
- <Analyzers>
- <Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.SpacingRules">
- <Rules>
- <Rule Name="TabsMustNotBeUsed">
- <RuleSettings>
- <BooleanProperty Name="Enabled">False</BooleanProperty>
- </RuleSettings>
- </Rule>
- </Rules>
- <AnalyzerSettings />
- </Analyzer>
- <Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.LayoutRules">
- <Rules>
- <Rule Name="CurlyBracketsForMultiLineStatementsMustNotShareLine">
- <RuleSettings>
- <BooleanProperty Name="Enabled">False</BooleanProperty>
- </RuleSettings>
- </Rule>
- <Rule Name="ElementMustNotBeOnSingleLine">
- <RuleSettings>
- <BooleanProperty Name="Enabled">False</BooleanProperty>
- </RuleSettings>
- </Rule>
- <Rule Name="ClosingCurlyBracketMustBeFollowedByBlankLine">
- <RuleSettings>
- <BooleanProperty Name="Enabled">False</BooleanProperty>
- </RuleSettings>
- </Rule>
- </Rules>
- <AnalyzerSettings />
- </Analyzer>
- <Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.ReadabilityRules">
- <Rules>
- <Rule Name="ParametersMustBeOnSameLineOrSeparateLines">
- <RuleSettings>
- <BooleanProperty Name="Enabled">False</BooleanProperty>
- </RuleSettings>
- </Rule>
- <Rule Name="CodeMustNotContainMultipleStatementsOnOneLine">
- <RuleSettings>
- <BooleanProperty Name="Enabled">False</BooleanProperty>
- </RuleSettings>
- </Rule>
- </Rules>
- <AnalyzerSettings />
- </Analyzer>
- </Analyzers>
-</StyleCopSettings> \ No newline at end of file