blob: f3231f089cb2c8b4fa65a6a8cc20d5cb73c84457 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
//-----------------------------------------------------------------------
// <copyright file="AccessProtectedResourceRequest.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.OAuth.Messages {
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using DotNetOpenAuth.Messaging;
/// <summary>
/// A message attached to a request for protected resources that provides the necessary
/// credentials to be granted access to those resources.
/// </summary>
public class AccessProtectedResourceRequest : SignedMessageBase, ITokenContainingMessage, IMessageWithBinaryData {
/// <summary>
/// A store for the binary data that is carried in the message.
/// </summary>
private List<MultipartPostPart> binaryData = new List<MultipartPostPart>();
/// <summary>
/// Initializes a new instance of the <see cref="AccessProtectedResourceRequest"/> class.
/// </summary>
/// <param name="serviceProvider">The URI of the Service Provider endpoint to send this message to.</param>
/// <param name="version">The OAuth version.</param>
protected internal AccessProtectedResourceRequest(MessageReceivingEndpoint serviceProvider, Version version)
: base(MessageTransport.Direct, serviceProvider, version) {
}
/// <summary>
/// Gets or sets the Token.
/// </summary>
[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; }
}
/// <summary>
/// Gets or sets the Access Token.
/// </summary>
/// <remarks>
/// 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.
/// </remarks>
[MessagePart("oauth_token", IsRequired = true)]
public string AccessToken { get; set; }
#region IMessageWithBinaryData Members
/// <summary>
/// Gets the parts of the message that carry binary data.
/// </summary>
/// <value>A list of parts. Never null.</value>
public IList<MultipartPostPart> BinaryData {
get { return this.binaryData; }
}
/// <summary>
/// Gets a value indicating whether this message should be sent as multi-part POST.
/// </summary>
public bool SendAsMultipart {
get { return this.HttpMethod == "POST" && this.BinaryData.Count > 0; }
}
#endregion
}
}
|