//-----------------------------------------------------------------------
//
// Copyright (c) Outercurve Foundation. All rights reserved.
//
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.OAuth2.ChannelElements {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Messaging;
///
/// The base class for any authorization server channel binding element.
///
internal abstract class AuthServerBindingElementBase : IChannelBindingElement {
///
/// Initializes a new instance of the class.
///
protected AuthServerBindingElementBase() {
}
///
/// Gets or sets the channel that this binding element belongs to.
///
///
/// This property is set by the channel when it is first constructed.
///
public Channel Channel { get; set; }
///
/// Gets the protection commonly offered (if any) by this binding element.
///
///
/// This value is used to assist in sorting binding elements in the channel stack.
///
public abstract MessageProtections Protection { get; }
///
/// Gets the channel to which this binding element belongs.
///
internal IOAuth2ChannelWithAuthorizationServer AuthServerChannel {
get { return (IOAuth2ChannelWithAuthorizationServer)this.Channel; }
}
///
/// Gets the authorization server hosting this channel.
///
/// The authorization server.
protected IAuthorizationServerHost AuthorizationServer {
get { return ((IOAuth2ChannelWithAuthorizationServer)this.Channel).AuthorizationServer; }
}
///
/// Prepares a message for sending based on the rules of this channel binding element.
///
/// The message to prepare for sending.
/// The cancellation token.
///
/// The protections (if any) that this binding element applied to the message.
/// Null if this binding element did not even apply to this binding element.
///
///
/// Implementations that provide message protection must honor the
/// properties where applicable.
///
public abstract Task ProcessOutgoingMessageAsync(IProtocolMessage message, CancellationToken cancellationToken);
///
/// 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.
///
/// The incoming message to process.
/// The cancellation token.
///
/// The protections (if any) that this binding element applied to the message.
/// Null if this binding element did not even apply to this binding element.
///
///
/// Thrown when the binding element rules indicate that this message is invalid and should
/// NOT be processed.
///
///
/// Implementations that provide message protection must honor the
/// properties where applicable.
///
public abstract Task ProcessIncomingMessageAsync(IProtocolMessage message, CancellationToken cancellationToken);
}
}