summaryrefslogtreecommitdiffstats
path: root/src/DotNetOAuth
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2008-08-30 13:48:44 -0700
committerAndrew <andrewarnott@gmail.com>2008-09-01 11:02:44 -0700
commitd385d8d38fc971e75d841b7a55591a67828caf17 (patch)
tree24d674abfb6dfcb71f5a79de9f86af225162880d /src/DotNetOAuth
parent5b33ddfca4d707afdd0a616940b7062d6d6e6276 (diff)
downloadDotNetOpenAuth-d385d8d38fc971e75d841b7a55591a67828caf17.zip
DotNetOpenAuth-d385d8d38fc971e75d841b7a55591a67828caf17.tar.gz
DotNetOpenAuth-d385d8d38fc971e75d841b7a55591a67828caf17.tar.bz2
Added test for and accomodated required message parts.
Diffstat (limited to 'src/DotNetOAuth')
-rw-r--r--src/DotNetOAuth/MessageScheme.cs6
-rw-r--r--src/DotNetOAuth/ProtocolMessageSerializer.cs10
-rw-r--r--src/DotNetOAuth/Strings.Designer.cs11
-rw-r--r--src/DotNetOAuth/Strings.resx3
4 files changed, 27 insertions, 3 deletions
diff --git a/src/DotNetOAuth/MessageScheme.cs b/src/DotNetOAuth/MessageScheme.cs
index 8878f40..ab42f28 100644
--- a/src/DotNetOAuth/MessageScheme.cs
+++ b/src/DotNetOAuth/MessageScheme.cs
@@ -3,6 +3,12 @@ using System.Collections.Generic;
using System.Text;
namespace DotNetOAuth {
+ /// <summary>
+ /// The methods available for the Consumer to send messages to the Service Provider.
+ /// </summary>
+ /// <remarks>
+ /// See 1.0 spec section 5.2.
+ /// </remarks>
internal enum MessageScheme {
/// <summary>
/// In the HTTP Authorization header as defined in OAuth HTTP Authorization Scheme (OAuth HTTP Authorization Scheme).
diff --git a/src/DotNetOAuth/ProtocolMessageSerializer.cs b/src/DotNetOAuth/ProtocolMessageSerializer.cs
index a9c92bc..b44aec6 100644
--- a/src/DotNetOAuth/ProtocolMessageSerializer.cs
+++ b/src/DotNetOAuth/ProtocolMessageSerializer.cs
@@ -23,7 +23,7 @@ namespace DotNetOAuth {
internal IDictionary<string, string> Serialize(T message) {
if (message == null) throw new ArgumentNullException("message");
- var fields = new Dictionary<string, string>();
+ var fields = new Dictionary<string, string>(StringComparer.Ordinal);
Serialize(fields, message);
return fields;
}
@@ -46,7 +46,13 @@ namespace DotNetOAuth {
if (fields == null) throw new ArgumentNullException("fields");
var reader = DictionaryXmlReader.Create(rootElement, fields);
- T result = (T)serializer.ReadObject(reader, false);
+ T result;
+ try {
+ result = (T)serializer.ReadObject(reader, false);
+ } catch (SerializationException ex) {
+ // Missing required fields is one cause of this exception.
+ throw new ProtocolException(Strings.InvalidIncomingMessage, ex);
+ }
result.EnsureValidMessage();
return result;
}
diff --git a/src/DotNetOAuth/Strings.Designer.cs b/src/DotNetOAuth/Strings.Designer.cs
index 4679c2c..05bbbc8 100644
--- a/src/DotNetOAuth/Strings.Designer.cs
+++ b/src/DotNetOAuth/Strings.Designer.cs
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:2.0.50727.1434
+// Runtime Version:2.0.50727.3053
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -61,6 +61,15 @@ namespace DotNetOAuth {
}
/// <summary>
+ /// Looks up a localized string similar to An invalid OAuth message received and discarded..
+ /// </summary>
+ internal static string InvalidIncomingMessage {
+ get {
+ return ResourceManager.GetString("InvalidIncomingMessage", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to The request URL query MUST NOT contain any OAuth Protocol Parameters..
/// </summary>
internal static string RequestUrlMustNotHaveOAuthParameters {
diff --git a/src/DotNetOAuth/Strings.resx b/src/DotNetOAuth/Strings.resx
index 52b5577..6c687d9 100644
--- a/src/DotNetOAuth/Strings.resx
+++ b/src/DotNetOAuth/Strings.resx
@@ -117,6 +117,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
+ <data name="InvalidIncomingMessage" xml:space="preserve">
+ <value>An invalid OAuth message received and discarded.</value>
+ </data>
<data name="RequestUrlMustNotHaveOAuthParameters" xml:space="preserve">
<value>The request URL query MUST NOT contain any OAuth Protocol Parameters.</value>
</data>