summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.OAuth.Consumer/OAuth/ServiceProviderDescription.cs
blob: b04b35b4c8fd38d854037845dcc63a812d53cefa (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
73
74
75
76
77
78
79
80
81
82
83
84
85
//-----------------------------------------------------------------------
// <copyright file="ServiceProviderDescription.cs" company="Andrew Arnott">
//     Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace DotNetOpenAuth.OAuth {
	using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.Net.Http;
	using System.Text;
	using System.Threading.Tasks;
	using Validation;

	/// <summary>
	/// Describes an OAuth 1.0 service provider.
	/// </summary>
	public class ServiceProviderDescription {
		/// <summary>
		/// Initializes a new instance of the <see cref="ServiceProviderDescription" /> class.
		/// </summary>
		public ServiceProviderDescription() {
			this.TemporaryCredentialsRequestEndpointMethod = HttpMethod.Post;
			this.TokenRequestEndpointMethod = HttpMethod.Post;
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="ServiceProviderDescription"/> class.
		/// </summary>
		/// <param name="temporaryCredentialsRequestEndpoint">The temporary credentials request endpoint.</param>
		/// <param name="resourceOwnerAuthorizationEndpoint">The resource owner authorization endpoint.</param>
		/// <param name="tokenRequestEndpoint">The token request endpoint.</param>
		public ServiceProviderDescription(
			string temporaryCredentialsRequestEndpoint, string resourceOwnerAuthorizationEndpoint, string tokenRequestEndpoint)
			: this() {
			if (temporaryCredentialsRequestEndpoint != null) {
				this.TemporaryCredentialsRequestEndpoint = new Uri(temporaryCredentialsRequestEndpoint, UriKind.Absolute);
			}

			if (resourceOwnerAuthorizationEndpoint != null) {
				this.ResourceOwnerAuthorizationEndpoint = new Uri(resourceOwnerAuthorizationEndpoint, UriKind.Absolute);
			}

			if (tokenRequestEndpoint != null) {
				this.TokenRequestEndpoint = new Uri(tokenRequestEndpoint, UriKind.Absolute);
			}
		}

		/// <summary>
		/// Gets or sets the temporary credentials request endpoint.
		/// </summary>
		/// <value>
		/// The temporary credentials request endpoint.
		/// </value>
		public Uri TemporaryCredentialsRequestEndpoint { get; set; }

		/// <summary>
		/// Gets or sets the HTTP method to use with the temporary credentials request endpoint.
		/// </summary>
		public HttpMethod TemporaryCredentialsRequestEndpointMethod { get; set; }

		/// <summary>
		/// Gets or sets the resource owner authorization endpoint.
		/// </summary>
		/// <value>
		/// The resource owner authorization endpoint.
		/// May be <c>null</c> for 2-legged OAuth.
		/// </value>
		public Uri ResourceOwnerAuthorizationEndpoint { get; set; }

		/// <summary>
		/// Gets or sets the token request endpoint.
		/// </summary>
		/// <value>
		/// The token request endpoint.
		/// </value>
		public Uri TokenRequestEndpoint { get; set; }

		/// <summary>
		/// Gets or sets the HTTP method to use with the token request endpoint.
		/// </summary>
		public HttpMethod TokenRequestEndpointMethod { get; set; }
	}
}