summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.OpenId/OpenId/Extensions/OAuth/AuthorizationApprovedResponse.cs
blob: 2e0f4681b6c3fabf9bec4113dbeca1ea5a26d849 (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
//-----------------------------------------------------------------------
// <copyright file="AuthorizationApprovedResponse.cs" company="Outercurve Foundation">
//     Copyright (c) Outercurve Foundation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace DotNetOpenAuth.OpenId.Extensions.OAuth {
	using System;
	using DotNetOpenAuth.Messaging;

	/// <summary>
	/// The OAuth response that a Provider may include with a positive 
	/// OpenID identity assertion with an approved request token.
	/// </summary>
	[Serializable]
	public class AuthorizationApprovedResponse : ExtensionBase {
		/// <summary>
		/// The factory method that may be used in deserialization of this message.
		/// </summary>
		internal static readonly StandardOpenIdExtensionFactory.CreateDelegate Factory = (typeUri, data, baseMessage, isProviderRole) => {
			if (typeUri == Constants.TypeUri && !isProviderRole && data.ContainsKey(Constants.RequestTokenParameter)) {
				return new AuthorizationApprovedResponse();
			}

			return null;
		};

		/// <summary>
		/// Initializes a new instance of the <see cref="AuthorizationApprovedResponse"/> class.
		/// </summary>
		public AuthorizationApprovedResponse()
			: base(new Version(1, 0), Constants.TypeUri, null) {
		}

		/// <summary>
		/// Gets or sets the user-approved request token.
		/// </summary>
		/// <value>The request token.</value>
		[MessagePart(Constants.RequestTokenParameter, IsRequired = true, AllowEmpty = false)]
		public string RequestToken { get; set; }

		/// <summary>
		/// Gets or sets a string that encodes, in a way possibly specific to the Combined Provider, one or more scopes that the returned request token is valid for. This will typically indicate a subset of the scopes requested in Section 8.
		/// </summary>
		[MessagePart("scope", IsRequired = false, AllowEmpty = true)]
		public string Scope { get; set; }
	}
}