//-----------------------------------------------------------------------
//
// Copyright (c) Outercurve Foundation. All rights reserved.
//
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.OAuth.Messages {
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using DotNetOpenAuth.Messaging;
///
/// A message attached to a request for protected resources that provides the necessary
/// credentials to be granted access to those resources.
///
public class AccessProtectedResourceRequest : SignedMessageBase, ITokenContainingMessage, IMessageWithBinaryData {
///
/// A store for the binary data that is carried in the message.
///
private List binaryData = new List();
///
/// Initializes a new instance of the class.
///
/// The URI of the Service Provider endpoint to send this message to.
/// The OAuth version.
protected internal AccessProtectedResourceRequest(MessageReceivingEndpoint serviceProvider, Version version)
: base(MessageTransport.Direct, serviceProvider, version) {
}
///
/// Gets or sets the Token.
///
[SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Justification = "This property IS accessible by a different name.")]
string ITokenContainingMessage.Token {
get { return this.AccessToken; }
set { this.AccessToken = value; }
}
///
/// Gets or sets the Access Token.
///
///
/// In addition to just allowing OAuth to verify a valid message,
/// this property is useful on the Service Provider to verify that the access token
/// has proper authorization for the resource being requested, and to know the
/// context around which user provided the authorization.
///
[MessagePart("oauth_token", IsRequired = true)]
public string AccessToken { get; set; }
#region IMessageWithBinaryData Members
///
/// Gets the parts of the message that carry binary data.
///
/// A list of parts. Never null.
public IList BinaryData {
get { return this.binaryData; }
}
///
/// Gets a value indicating whether this message should be sent as multi-part POST.
///
public bool SendAsMultipart {
get { return this.HttpMethod == "POST" && this.BinaryData.Count > 0; }
}
#endregion
}
}