diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2009-03-10 20:26:55 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2009-03-10 20:26:55 -0700 |
commit | bd3b3f6b07dbd1d43c2ffdff4504fd5eec1eb388 (patch) | |
tree | 528b4dac98713b3a1026ff1d89993bc14b54bec1 /src | |
parent | ed93583c59e776b673ea96c350ae5b284435ca24 (diff) | |
download | DotNetOpenAuth-bd3b3f6b07dbd1d43c2ffdff4504fd5eec1eb388.zip DotNetOpenAuth-bd3b3f6b07dbd1d43c2ffdff4504fd5eec1eb388.tar.gz DotNetOpenAuth-bd3b3f6b07dbd1d43c2ffdff4504fd5eec1eb388.tar.bz2 |
OpenID spec review up to (and excluding) section 8.
Diffstat (limited to 'src')
5 files changed, 34 insertions, 8 deletions
diff --git a/src/DotNetOpenAuth.Test/OpenId/Messages/DirectErrorResponseTests.cs b/src/DotNetOpenAuth.Test/OpenId/Messages/DirectErrorResponseTests.cs index 3a5e824..c0ac7de 100644 --- a/src/DotNetOpenAuth.Test/OpenId/Messages/DirectErrorResponseTests.cs +++ b/src/DotNetOpenAuth.Test/OpenId/Messages/DirectErrorResponseTests.cs @@ -39,7 +39,8 @@ namespace DotNetOpenAuth.Test.OpenId.Messages { } /// <summary> - /// Verifies that error messages are created as HTTP 400 errors. + /// Verifies that error messages are created as HTTP 400 errors, + /// per OpenID 2.0 section 5.1.2.2. /// </summary> [TestMethod] public void ErrorMessagesAsHttp400() { diff --git a/src/DotNetOpenAuth/Messaging/Channel.cs b/src/DotNetOpenAuth/Messaging/Channel.cs index 5a81770..5c17485 100644 --- a/src/DotNetOpenAuth/Messaging/Channel.cs +++ b/src/DotNetOpenAuth/Messaging/Channel.cs @@ -462,6 +462,7 @@ namespace DotNetOpenAuth.Messaging { Contract.Requires(request != null); HttpWebRequest webRequest = this.CreateHttpRequest(request); IDictionary<string, string> responseFields; + IDirectResponseProtocolMessage responseMessage; using (DirectWebResponse response = this.GetDirectResponse(webRequest)) { if (response.ResponseStream == null) { @@ -469,11 +470,22 @@ namespace DotNetOpenAuth.Messaging { } responseFields = this.ReadFromResponseInternal(response); - } - IDirectResponseProtocolMessage responseMessage = this.MessageFactory.GetNewResponseMessage(request, responseFields); - if (responseMessage == null) { - return null; + responseMessage = this.MessageFactory.GetNewResponseMessage(request, responseFields); + if (responseMessage == null) { + return null; + } + + // Verify that the expected HTTP status code was used for the message, + // per OpenID 2.0 section 5.1.2.2. + var httpDirectResponse = responseMessage as IHttpDirectResponse; + if (httpDirectResponse != null) { + ErrorUtilities.VerifyProtocol( + httpDirectResponse.HttpStatusCode == response.Status, + MessagingStrings.UnexpectedHttpStatusCode, + (int)httpDirectResponse.HttpStatusCode, + (int)response.Status); + } } var responseSerializer = MessageSerializer.Get(responseMessage.GetType()); diff --git a/src/DotNetOpenAuth/Messaging/MessagingStrings.Designer.cs b/src/DotNetOpenAuth/Messaging/MessagingStrings.Designer.cs index 8ee0543..fb8620b 100644 --- a/src/DotNetOpenAuth/Messaging/MessagingStrings.Designer.cs +++ b/src/DotNetOpenAuth/Messaging/MessagingStrings.Designer.cs @@ -448,6 +448,15 @@ namespace DotNetOpenAuth.Messaging { } /// <summary> + /// Looks up a localized string similar to Expected direct response to use HTTP status code {0} but was {1} instead.. + /// </summary> + internal static string UnexpectedHttpStatusCode { + get { + return ResourceManager.GetString("UnexpectedHttpStatusCode", resourceCulture); + } + } + + /// <summary> /// Looks up a localized string similar to Message parameter '{0}' had unexpected value '{1}'.. /// </summary> internal static string UnexpectedMessagePartValue { diff --git a/src/DotNetOpenAuth/Messaging/MessagingStrings.resx b/src/DotNetOpenAuth/Messaging/MessagingStrings.resx index 3c5b67c..0a6f6a5 100644 --- a/src/DotNetOpenAuth/Messaging/MessagingStrings.resx +++ b/src/DotNetOpenAuth/Messaging/MessagingStrings.resx @@ -285,4 +285,7 @@ <data name="UnsupportedHttpVerbForMessageType" xml:space="preserve"> <value>'{0}' messages cannot be received with HTTP verb '{1}'.</value> </data> + <data name="UnexpectedHttpStatusCode" xml:space="preserve"> + <value>Expected direct response to use HTTP status code {0} but was {1} instead.</value> + </data> </root>
\ No newline at end of file diff --git a/src/DotNetOpenAuth/OpenId/Messages/DirectErrorResponse.cs b/src/DotNetOpenAuth/OpenId/Messages/DirectErrorResponse.cs index 29ee18d..ad20ff7 100644 --- a/src/DotNetOpenAuth/OpenId/Messages/DirectErrorResponse.cs +++ b/src/DotNetOpenAuth/OpenId/Messages/DirectErrorResponse.cs @@ -6,6 +6,7 @@ namespace DotNetOpenAuth.OpenId.Messages { using System; + using System.Net; using DotNetOpenAuth.Messaging; /// <summary> @@ -30,9 +31,9 @@ namespace DotNetOpenAuth.OpenId.Messages { /// <summary> /// Gets the HTTP status code that the direct respones should be sent with. /// </summary> - /// <value><see cref="System.Net.HttpStatusCode.BadRequest"/></value> - public System.Net.HttpStatusCode HttpStatusCode { - get { return System.Net.HttpStatusCode.BadRequest; } + /// <value><see cref="HttpStatusCode.BadRequest"/></value> + HttpStatusCode IHttpDirectResponse.HttpStatusCode { + get { return HttpStatusCode.BadRequest; } } #endregion |