//-----------------------------------------------------------------------
//
// Copyright (c) Outercurve Foundation. All rights reserved.
//
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.OpenId.Provider {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.OpenId.Messages;
using Validation;
///
/// Handles messages coming into an OpenID Provider for which the entire
/// response message can be automatically determined without help from
/// the hosting web site.
///
internal class AutoResponsiveRequest : Request {
///
/// The response message to send.
///
private readonly IProtocolMessage response;
///
/// Initializes a new instance of the class.
///
/// The request message.
/// The response that is ready for transmittal.
/// The security settings.
internal AutoResponsiveRequest(IDirectedProtocolMessage request, IProtocolMessage response, ProviderSecuritySettings securitySettings)
: base(request, securitySettings) {
Requires.NotNull(response, "response");
this.response = response;
}
///
/// Initializes a new instance of the class
/// for a response to an unrecognizable request.
///
/// The response that is ready for transmittal.
/// The security settings.
internal AutoResponsiveRequest(IProtocolMessage response, ProviderSecuritySettings securitySettings)
: base(IndirectResponseBase.GetVersion(response), securitySettings) {
Requires.NotNull(response, "response");
this.response = response;
}
///
/// Gets a value indicating whether the response is ready to be sent to the user agent.
///
///
/// This property returns false if there are properties that must be set on this
/// request instance before the response can be sent.
///
public override bool IsResponseReady {
get { return true; }
}
///
/// Gets the response message, once is true.
///
/// The cancellation token.
///
/// The response message.
///
internal Task GetResponseMessageAsyncTestHook(CancellationToken cancellationToken) {
return this.GetResponseMessageAsync(cancellationToken);
}
///
/// Gets the response message, once is true.
///
/// The cancellation token.
///
/// The response message.
///
protected override Task GetResponseMessageAsync(CancellationToken cancellationToken) {
return Task.FromResult(this.response);
}
}
}