summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/DotNetOpenAuth.Test/Messaging/ChannelTests.cs2
-rw-r--r--src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs6
-rw-r--r--src/DotNetOpenAuth.Test/Mocks/CoordinatingOAuthChannel.cs6
-rw-r--r--src/DotNetOpenAuth.Test/Mocks/TestBadChannel.cs6
-rw-r--r--src/DotNetOpenAuth.Test/Mocks/TestChannel.cs2
-rw-r--r--src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs4
-rw-r--r--src/DotNetOpenAuth.Test/OpenId/ChannelElements/OpenIdChannelTests.cs6
-rw-r--r--src/DotNetOpenAuth/Messaging/Channel.cs12
-rw-r--r--src/DotNetOpenAuth/Messaging/ChannelContract.cs2
-rw-r--r--src/DotNetOpenAuth/Messaging/OutgoingWebResponse.cs3
-rw-r--r--src/DotNetOpenAuth/OAuth/ChannelElements/OAuthChannel.cs2
-rw-r--r--src/DotNetOpenAuth/OpenId/ChannelElements/OpenIdChannel.cs2
-rw-r--r--src/DotNetOpenAuth/OpenId/Provider/OpenIdProvider.cs37
13 files changed, 62 insertions, 28 deletions
diff --git a/src/DotNetOpenAuth.Test/Messaging/ChannelTests.cs b/src/DotNetOpenAuth.Test/Messaging/ChannelTests.cs
index 8039b21..ca902cd 100644
--- a/src/DotNetOpenAuth.Test/Messaging/ChannelTests.cs
+++ b/src/DotNetOpenAuth.Test/Messaging/ChannelTests.cs
@@ -172,7 +172,7 @@ namespace DotNetOpenAuth.Test.Messaging {
[TestMethod, ExpectedException(typeof(ArgumentNullException))]
public void SendIndirectMessageNull() {
TestBadChannel badChannel = new TestBadChannel(false);
- badChannel.SendIndirectMessage(null);
+ badChannel.PrepareIndirectResponse(null);
}
[TestMethod, ExpectedException(typeof(ArgumentNullException))]
diff --git a/src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs b/src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs
index 56fe8bc..4afd2cf 100644
--- a/src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs
+++ b/src/DotNetOpenAuth.Test/Mocks/CoordinatingChannel.cs
@@ -167,15 +167,15 @@ namespace DotNetOpenAuth.Test.Mocks {
return responseMessage;
}
- protected override OutgoingWebResponse SendDirectMessageResponse(IProtocolMessage response) {
+ protected override OutgoingWebResponse PrepareDirectResponse(IProtocolMessage response) {
this.ProcessMessageFilter(response, true);
return new CoordinatingOutgoingWebResponse(response, this.RemoteChannel);
}
- protected override OutgoingWebResponse SendIndirectMessage(IDirectedProtocolMessage message) {
+ protected override OutgoingWebResponse PrepareIndirectResponse(IDirectedProtocolMessage message) {
this.ProcessMessageFilter(message, true);
// In this mock transport, direct and indirect messages are the same.
- return this.SendDirectMessageResponse(message);
+ return this.PrepareDirectResponse(message);
}
protected override IDirectedProtocolMessage ReadFromRequestCore(HttpRequestInfo request) {
diff --git a/src/DotNetOpenAuth.Test/Mocks/CoordinatingOAuthChannel.cs b/src/DotNetOpenAuth.Test/Mocks/CoordinatingOAuthChannel.cs
index 6c32495..2c02a7f 100644
--- a/src/DotNetOpenAuth.Test/Mocks/CoordinatingOAuthChannel.cs
+++ b/src/DotNetOpenAuth.Test/Mocks/CoordinatingOAuthChannel.cs
@@ -71,15 +71,15 @@ namespace DotNetOpenAuth.Test.Mocks {
return this.AwaitIncomingMessage();
}
- protected override OutgoingWebResponse SendDirectMessageResponse(IProtocolMessage response) {
+ protected override OutgoingWebResponse PrepareDirectResponse(IProtocolMessage response) {
this.RemoteChannel.incomingMessage = CloneSerializedParts(response, null);
this.RemoteChannel.incomingMessageSignal.Set();
return null;
}
- protected override OutgoingWebResponse SendIndirectMessage(IDirectedProtocolMessage message) {
+ protected override OutgoingWebResponse PrepareIndirectResponse(IDirectedProtocolMessage message) {
// In this mock transport, direct and indirect messages are the same.
- return this.SendDirectMessageResponse(message);
+ return this.PrepareDirectResponse(message);
}
protected override IDirectedProtocolMessage ReadFromRequestCore(HttpRequestInfo request) {
diff --git a/src/DotNetOpenAuth.Test/Mocks/TestBadChannel.cs b/src/DotNetOpenAuth.Test/Mocks/TestBadChannel.cs
index c55d176..439acbb 100644
--- a/src/DotNetOpenAuth.Test/Mocks/TestBadChannel.cs
+++ b/src/DotNetOpenAuth.Test/Mocks/TestBadChannel.cs
@@ -25,8 +25,8 @@ namespace DotNetOpenAuth.Test.Mocks {
base.CreateFormPostResponse(message, fields);
}
- internal new void SendIndirectMessage(IDirectedProtocolMessage message) {
- base.SendIndirectMessage(message);
+ internal new void PrepareIndirectResponse(IDirectedProtocolMessage message) {
+ base.PrepareIndirectResponse(message);
}
internal new IProtocolMessage Receive(Dictionary<string, string> fields, MessageReceivingEndpoint recipient) {
@@ -41,7 +41,7 @@ namespace DotNetOpenAuth.Test.Mocks {
throw new NotImplementedException();
}
- protected override OutgoingWebResponse SendDirectMessageResponse(IProtocolMessage response) {
+ protected override OutgoingWebResponse PrepareDirectResponse(IProtocolMessage response) {
throw new NotImplementedException();
}
}
diff --git a/src/DotNetOpenAuth.Test/Mocks/TestChannel.cs b/src/DotNetOpenAuth.Test/Mocks/TestChannel.cs
index 3754f01..95fb90a 100644
--- a/src/DotNetOpenAuth.Test/Mocks/TestChannel.cs
+++ b/src/DotNetOpenAuth.Test/Mocks/TestChannel.cs
@@ -33,7 +33,7 @@ namespace DotNetOpenAuth.Test.Mocks {
throw new NotImplementedException("CreateHttpRequest");
}
- protected override OutgoingWebResponse SendDirectMessageResponse(IProtocolMessage response) {
+ protected override OutgoingWebResponse PrepareDirectResponse(IProtocolMessage response) {
throw new NotImplementedException("SendDirectMessageResponse");
}
}
diff --git a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs
index 143e9be..fd8c15a 100644
--- a/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs
+++ b/src/DotNetOpenAuth.Test/OAuth/ChannelElements/OAuthChannelTests.cs
@@ -160,13 +160,13 @@ namespace DotNetOpenAuth.Test.ChannelElements {
[TestMethod]
public void SendDirectMessageResponseHonorsHttpStatusCodes() {
IProtocolMessage message = MessagingTestBase.GetStandardTestMessage(MessagingTestBase.FieldFill.AllRequired);
- OutgoingWebResponse directResponse = this.accessor.SendDirectMessageResponse(message);
+ OutgoingWebResponse directResponse = this.accessor.PrepareDirectResponse(message);
Assert.AreEqual(HttpStatusCode.OK, directResponse.Status);
var httpMessage = new TestDirectResponseMessageWithHttpStatus();
MessagingTestBase.GetStandardTestMessage(MessagingTestBase.FieldFill.AllRequired, httpMessage);
httpMessage.HttpStatusCode = HttpStatusCode.NotAcceptable;
- directResponse = this.accessor.SendDirectMessageResponse(httpMessage);
+ directResponse = this.accessor.PrepareDirectResponse(httpMessage);
Assert.AreEqual(HttpStatusCode.NotAcceptable, directResponse.Status);
}
diff --git a/src/DotNetOpenAuth.Test/OpenId/ChannelElements/OpenIdChannelTests.cs b/src/DotNetOpenAuth.Test/OpenId/ChannelElements/OpenIdChannelTests.cs
index a9c1924..385cd19 100644
--- a/src/DotNetOpenAuth.Test/OpenId/ChannelElements/OpenIdChannelTests.cs
+++ b/src/DotNetOpenAuth.Test/OpenId/ChannelElements/OpenIdChannelTests.cs
@@ -80,7 +80,7 @@ namespace DotNetOpenAuth.Test.OpenId.ChannelElements {
byte[] expectedBytes = KeyValueFormEncoding.GetBytes(messageFields);
string expectedContentType = OpenIdChannel_Accessor.KeyValueFormContentType;
- OutgoingWebResponse directResponse = this.accessor.SendDirectMessageResponse(message);
+ OutgoingWebResponse directResponse = this.accessor.PrepareDirectResponse(message);
Assert.AreEqual(expectedContentType, directResponse.Headers[HttpResponseHeader.ContentType]);
byte[] actualBytes = new byte[directResponse.ResponseStream.Length];
directResponse.ResponseStream.Read(actualBytes, 0, actualBytes.Length);
@@ -108,13 +108,13 @@ namespace DotNetOpenAuth.Test.OpenId.ChannelElements {
[TestMethod]
public void SendDirectMessageResponseHonorsHttpStatusCodes() {
IProtocolMessage message = MessagingTestBase.GetStandardTestMessage(MessagingTestBase.FieldFill.AllRequired);
- OutgoingWebResponse directResponse = this.accessor.SendDirectMessageResponse(message);
+ OutgoingWebResponse directResponse = this.accessor.PrepareDirectResponse(message);
Assert.AreEqual(HttpStatusCode.OK, directResponse.Status);
var httpMessage = new TestDirectResponseMessageWithHttpStatus();
MessagingTestBase.GetStandardTestMessage(MessagingTestBase.FieldFill.AllRequired, httpMessage);
httpMessage.HttpStatusCode = HttpStatusCode.NotAcceptable;
- directResponse = this.accessor.SendDirectMessageResponse(httpMessage);
+ directResponse = this.accessor.PrepareDirectResponse(httpMessage);
Assert.AreEqual(HttpStatusCode.NotAcceptable, directResponse.Status);
}
}
diff --git a/src/DotNetOpenAuth/Messaging/Channel.cs b/src/DotNetOpenAuth/Messaging/Channel.cs
index b9fdb0c..b9f4b73 100644
--- a/src/DotNetOpenAuth/Messaging/Channel.cs
+++ b/src/DotNetOpenAuth/Messaging/Channel.cs
@@ -218,6 +218,7 @@ namespace DotNetOpenAuth.Messaging {
/// Requires an HttpContext.Current context.
/// </remarks>
public void Send(IProtocolMessage message) {
+ Contract.Requires(HttpContext.Current != null);
Contract.Requires(message != null);
this.PrepareResponse(message).Send();
}
@@ -230,6 +231,7 @@ namespace DotNetOpenAuth.Messaging {
/// <returns>The pending user agent redirect based message to be sent as an HttpResponse.</returns>
public OutgoingWebResponse PrepareResponse(IProtocolMessage message) {
Contract.Requires(message != null);
+ Contract.Ensures(Contract.Result<OutgoingWebResponse>() != null);
ErrorUtilities.VerifyArgumentNotNull(message, "message");
this.PrepareMessageForSending(message);
@@ -238,7 +240,7 @@ namespace DotNetOpenAuth.Messaging {
switch (message.Transport) {
case MessageTransport.Direct:
// This is a response to a direct message.
- return this.SendDirectMessageResponse(message);
+ return this.PrepareDirectResponse(message);
case MessageTransport.Indirect:
var directedMessage = message as IDirectedProtocolMessage;
ErrorUtilities.VerifyArgumentNamed(
@@ -250,7 +252,7 @@ namespace DotNetOpenAuth.Messaging {
directedMessage.Recipient != null,
"message",
MessagingStrings.DirectedMessageMissingRecipient);
- return this.SendIndirectMessage(directedMessage);
+ return this.PrepareIndirectResponse(directedMessage);
default:
throw ErrorUtilities.ThrowArgumentNamed(
"message",
@@ -577,7 +579,7 @@ namespace DotNetOpenAuth.Messaging {
/// </summary>
/// <param name="message">The message to send.</param>
/// <returns>The pending user agent redirect based message to be sent as an HttpResponse.</returns>
- protected virtual OutgoingWebResponse SendIndirectMessage(IDirectedProtocolMessage message) {
+ protected virtual OutgoingWebResponse PrepareIndirectResponse(IDirectedProtocolMessage message) {
Contract.Requires(message != null && message.Recipient != null);
ErrorUtilities.VerifyArgumentNotNull(message, "message");
@@ -694,9 +696,9 @@ namespace DotNetOpenAuth.Messaging {
/// <param name="response">The message to send as a response.</param>
/// <returns>The pending user agent redirect based message to be sent as an HttpResponse.</returns>
/// <remarks>
- /// This method implements spec V1.0 section 5.3.
+ /// This method implements spec OAuth V1.0 section 5.3.
/// </remarks>
- protected abstract OutgoingWebResponse SendDirectMessageResponse(IProtocolMessage response);
+ protected abstract OutgoingWebResponse PrepareDirectResponse(IProtocolMessage response);
/// <summary>
/// Prepares a message for transmit by applying signatures, nonces, etc.
diff --git a/src/DotNetOpenAuth/Messaging/ChannelContract.cs b/src/DotNetOpenAuth/Messaging/ChannelContract.cs
index 8b45ce1..551d7c4 100644
--- a/src/DotNetOpenAuth/Messaging/ChannelContract.cs
+++ b/src/DotNetOpenAuth/Messaging/ChannelContract.cs
@@ -45,7 +45,7 @@ namespace DotNetOpenAuth.Messaging {
/// <remarks>
/// This method implements spec V1.0 section 5.3.
/// </remarks>
- protected override OutgoingWebResponse SendDirectMessageResponse(IProtocolMessage response) {
+ protected override OutgoingWebResponse PrepareDirectResponse(IProtocolMessage response) {
Contract.Requires(response != null);
Contract.Ensures(Contract.Result<OutgoingWebResponse>() != null);
throw new NotImplementedException();
diff --git a/src/DotNetOpenAuth/Messaging/OutgoingWebResponse.cs b/src/DotNetOpenAuth/Messaging/OutgoingWebResponse.cs
index 0112585..55cb4b6 100644
--- a/src/DotNetOpenAuth/Messaging/OutgoingWebResponse.cs
+++ b/src/DotNetOpenAuth/Messaging/OutgoingWebResponse.cs
@@ -120,7 +120,8 @@ namespace DotNetOpenAuth.Messaging {
/// Requires a current HttpContext.
/// </remarks>
public virtual void Send() {
- ErrorUtilities.VerifyOperation(HttpContext.Current != null, MessagingStrings.CurrentHttpContextRequired);
+ Contract.Requires(HttpContext.Current != null);
+ ErrorUtilities.VerifyHttpContext();
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.StatusCode = (int)this.Status;
diff --git a/src/DotNetOpenAuth/OAuth/ChannelElements/OAuthChannel.cs b/src/DotNetOpenAuth/OAuth/ChannelElements/OAuthChannel.cs
index f91b1b0..b7c8715 100644
--- a/src/DotNetOpenAuth/OAuth/ChannelElements/OAuthChannel.cs
+++ b/src/DotNetOpenAuth/OAuth/ChannelElements/OAuthChannel.cs
@@ -197,7 +197,7 @@ namespace DotNetOpenAuth.OAuth.ChannelElements {
/// <remarks>
/// This method implements spec V1.0 section 5.3.
/// </remarks>
- protected override OutgoingWebResponse SendDirectMessageResponse(IProtocolMessage response) {
+ protected override OutgoingWebResponse PrepareDirectResponse(IProtocolMessage response) {
ErrorUtilities.VerifyArgumentNotNull(response, "response");
var messageAccessor = this.MessageDescriptions.GetAccessor(response);
diff --git a/src/DotNetOpenAuth/OpenId/ChannelElements/OpenIdChannel.cs b/src/DotNetOpenAuth/OpenId/ChannelElements/OpenIdChannel.cs
index 75bc4e4..9d0b881 100644
--- a/src/DotNetOpenAuth/OpenId/ChannelElements/OpenIdChannel.cs
+++ b/src/DotNetOpenAuth/OpenId/ChannelElements/OpenIdChannel.cs
@@ -232,7 +232,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements {
/// <remarks>
/// This method implements spec V1.0 section 5.3.
/// </remarks>
- protected override OutgoingWebResponse SendDirectMessageResponse(IProtocolMessage response) {
+ protected override OutgoingWebResponse PrepareDirectResponse(IProtocolMessage response) {
ErrorUtilities.VerifyArgumentNotNull(response, "response");
var messageAccessor = this.MessageDescriptions.GetAccessor(response);
diff --git a/src/DotNetOpenAuth/OpenId/Provider/OpenIdProvider.cs b/src/DotNetOpenAuth/OpenId/Provider/OpenIdProvider.cs
index 3d7e804..6671490 100644
--- a/src/DotNetOpenAuth/OpenId/Provider/OpenIdProvider.cs
+++ b/src/DotNetOpenAuth/OpenId/Provider/OpenIdProvider.cs
@@ -224,12 +224,13 @@ namespace DotNetOpenAuth.OpenId.Provider {
/// <exception cref="ThreadAbortException">Thrown by ASP.NET in order to prevent additional data from the page being sent to the client and corrupting the response.</exception>
/// <remarks>
/// <para>Requires an HttpContext.Current context. If one is not available, the caller should use
- /// <see cref="GetResponse"/> instead and manually send the <see cref="OutgoingWebResponse"/>
+ /// <see cref="PrepareResponse"/> instead and manually send the <see cref="OutgoingWebResponse"/>
/// to the client.</para>
/// </remarks>
/// <exception cref="InvalidOperationException">Thrown if <see cref="IRequest.IsResponseReady"/> is <c>false</c>.</exception>
[SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily", Justification = "Code Contract requires that we cast early.")]
public void SendResponse(IRequest request) {
+ Contract.Requires(HttpContext.Current != null);
Contract.Requires(request != null);
Contract.Requires(((Request)request).IsResponseReady);
ErrorUtilities.VerifyArgumentNotNull(request, "request");
@@ -245,7 +246,7 @@ namespace DotNetOpenAuth.OpenId.Provider {
/// <returns>The response that should be sent to the client.</returns>
/// <exception cref="InvalidOperationException">Thrown if <see cref="IRequest.IsResponseReady"/> is <c>false</c>.</exception>
[SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily", Justification = "Code Contract requires that we cast early.")]
- public OutgoingWebResponse GetResponse(IRequest request) {
+ public OutgoingWebResponse PrepareResponse(IRequest request) {
Contract.Requires(request != null);
Contract.Requires(((Request)request).IsResponseReady);
ErrorUtilities.VerifyArgumentNotNull(request, "request");
@@ -255,7 +256,37 @@ namespace DotNetOpenAuth.OpenId.Provider {
}
/// <summary>
- /// Send an identity assertion on behalf of one of this Provider's
+ /// Sends an identity assertion on behalf of one of this Provider's
+ /// members in order to redirect the user agent to a relying party
+ /// web site and log him/her in immediately in one uninterrupted step.
+ /// </summary>
+ /// <param name="providerEndpoint">The absolute URL on the Provider site that receives OpenID messages.</param>
+ /// <param name="relyingParty">The URL of the Relying Party web site.
+ /// This will typically be the home page, but may be a longer URL if
+ /// that Relying Party considers the scope of its realm to be more specific.
+ /// The URL provided here must allow discovery of the Relying Party's
+ /// XRDS document that advertises its OpenID RP endpoint.</param>
+ /// <param name="claimedIdentifier">The Identifier you are asserting your member controls.</param>
+ /// <param name="localIdentifier">The Identifier you know your user by internally. This will typically
+ /// be the same as <paramref name="claimedIdentifier"/>.</param>
+ /// <param name="extensions">The extensions.</param>
+ /// <returns>
+ /// A <see cref="OutgoingWebResponse"/> object describing the HTTP response to send
+ /// the user agent to allow the redirect with assertion to happen.
+ /// </returns>
+ public void SendUnsolicitedAssertion(Uri providerEndpoint, Realm relyingParty, Identifier claimedIdentifier, Identifier localIdentifier, params IExtensionMessage[] extensions) {
+ Contract.Requires(HttpContext.Current != null);
+ Contract.Requires(providerEndpoint != null);
+ Contract.Requires(providerEndpoint.IsAbsoluteUri);
+ Contract.Requires(relyingParty != null);
+ Contract.Requires(claimedIdentifier != null);
+ Contract.Requires(localIdentifier != null);
+
+ this.PrepareUnsolicitedAssertion(providerEndpoint, relyingParty, claimedIdentifier, localIdentifier, extensions).Send();
+ }
+
+ /// <summary>
+ /// Prepares an identity assertion on behalf of one of this Provider's
/// members in order to redirect the user agent to a relying party
/// web site and log him/her in immediately in one uninterrupted step.
/// </summary>