summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/AuthorizationDataBag.cs
blob: c073008563be5a34348237f736612d4376fd3a46 (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
//-----------------------------------------------------------------------
// <copyright file="AuthorizationDataBag.cs" company="Outercurve Foundation">
//     Copyright (c) Outercurve Foundation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace DotNetOpenAuth.OAuth2.ChannelElements {
	using System;
	using System.Collections.Generic;

	using DotNetOpenAuth.Messaging;

	/// <summary>
	/// A data bag that stores authorization data.
	/// </summary>
	public abstract class AuthorizationDataBag : DataBag, IAuthorizationDescription {
		/// <summary>
		/// Initializes a new instance of the <see cref="AuthorizationDataBag"/> class.
		/// </summary>
		protected AuthorizationDataBag() {
			this.Scope = new HashSet<string>(OAuthUtilities.ScopeStringComparer);
		}

		/// <summary>
		/// Gets or sets the identifier of the client authorized to access protected data.
		/// </summary>
		[MessagePart]
		public string ClientIdentifier { get; set; }

		/// <summary>
		/// Gets the date this authorization was established or the token was issued.
		/// </summary>
		/// <value>A date/time expressed in UTC.</value>
		public DateTime UtcIssued {
			get { return this.UtcCreationDate; }
		}

		/// <summary>
		/// Gets or sets the name on the account whose data on the resource server is accessible using this authorization.
		/// </summary>
		[MessagePart]
		public string User { get; set; }

		/// <summary>
		/// Gets the scope of operations the client is allowed to invoke.
		/// </summary>
		[MessagePart(Encoder = typeof(ScopeEncoder))]
		public HashSet<string> Scope { get; private set; }
	}
}