summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth/OAuthWrap/Protocol.cs
blob: 9ee7091d8d36ce6cb4f43a7e3039bc35a337526f (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
// <auto-generated/> // disable StyleCop on this file
//-----------------------------------------------------------------------
// <copyright file="Protocol.cs" company="Andrew Arnott">
//     Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace DotNetOpenAuth.OAuthWrap {
	using System;
	using System.Collections.Generic;

	/// <summary>
	/// An enumeration of the OAuth WRAP protocol versions supported by this library.
	/// </summary>
	public enum ProtocolVersion {
		/// <summary>
		/// The OAuth 2.0 specification.
		/// </summary>
		V20,
	}

	/// <summary>
	/// Protocol constants for OAuth WRAP.
	/// </summary>
	internal class Protocol {
		/// <summary>
		/// The HTTP authorization scheme "WRAP";
		/// </summary>
		internal const string HttpAuthorizationScheme = "WRAP";

		/// <summary>
		/// The format of the HTTP Authorization header value that authorizes OAuth WRAP requests.
		/// </summary>
		internal const string HttpAuthorizationHeaderFormat = "WRAP access_token=\"{0}\"";

		/// <summary>
		/// The "type" string.
		/// </summary>
		internal const string type = "type";

		/// <summary>
		/// The "state" string.
		/// </summary>
		internal const string state = "state";

		/// <summary>
		/// The "redirect_uri" string.
		/// </summary>
		internal const string redirect_uri = "redirect_uri";

		/// <summary>
		/// The "client_id" string.
		/// </summary>
		internal const string client_id = "client_id";

		/// <summary>
		/// The "scope" string.
		/// </summary>
		internal const string scope = "scope";

		/// <summary>
		/// The "immediate" string.
		/// </summary>
		internal const string immediate = "immediate";

		/// <summary>
		/// The "client_secret" string.
		/// </summary>
		internal const string client_secret = "client_secret";

		/// <summary>
		/// The "wrap_verification_code" string.
		/// </summary>
		internal const string code = "code";

		/// <summary>
		/// The "user_code" string.
		/// </summary>
		internal const string user_code = "user_code";

		/// <summary>
		/// The "user_uri" string.
		/// </summary>
		internal const string user_uri = "user_uri";

		/// <summary>
		/// The "interval" string.
		/// </summary>
		internal const string interval = "interval";

		/// <summary>
		/// The "wrap_verification_url" string.
		/// </summary>
		internal const string wrap_verification_url = "wrap_verification_url";

		/// <summary>
		/// The "error" string.
		/// </summary>
		internal const string error = "error";

		/// <summary>
		/// The "access_token" string.
		/// </summary>
		internal const string access_token = "access_token";

		/// <summary>
		/// The "access_token_secret" string.
		/// </summary>
		internal const string access_token_secret = "access_token_secret";

		/// <summary>
		/// The "refresh_token" string.
		/// </summary>
		internal const string refresh_token = "refresh_token";

		/// <summary>
		/// The "expires_in" string.
		/// </summary>
		internal const string expires_in = "expires_in";

		/// <summary>
		/// The "expired_delegation_code" string.
		/// </summary>
		internal const string expired_delegation_code = "expired_delegation_code";

		/// <summary>
		/// The "wrap_username" string.
		/// </summary>
		internal const string wrap_username = "wrap_username";

		/// <summary>
		/// The "wrap_password" string.
		/// </summary>
		internal const string wrap_password = "wrap_password";

		/// <summary>
		/// The "wrap_name" string.
		/// </summary>
		internal const string wrap_name = "wrap_name";

		/// <summary>
		/// The "format" string.
		/// </summary>
		internal const string format = "format";

		/// <summary>
		/// The "assertion" string.
		/// </summary>
		internal const string assertion = "assertion";

		/// <summary>
		/// The "wrap_SAML" string.
		/// </summary>
		internal const string wrap_saml = "wrap_SAML";

		/// <summary>
		/// The "wrap_SWT" string.
		/// </summary>
		internal const string wrap_swt = "wrap_SWT";

		/// <summary>
		/// The "wrap_captcha_url" string.
		/// </summary>
		internal const string wrap_captcha_url = "wrap_captcha_url";

		/// <summary>
		/// The "wrap_captcha_solution" string.
		/// </summary>
		internal const string wrap_captcha_solution = "wrap_captcha_solution";

		/// <summary>
		/// The "user_denied" string.
		/// </summary>
		internal const string user_denied = "user_denied";

		/// <summary>
		/// The "secret_type" string.
		/// </summary>
		internal const string secret_type = "secret_type";

		/// <summary>
		/// Gets the <see cref="Protocol"/> instance with values initialized for V1.0 of the protocol.
		/// </summary>
		internal static readonly Protocol V20 = new Protocol {
			Version = new Version(2, 0),
			ProtocolVersion = ProtocolVersion.V20,
		};

		/// <summary>
		/// A list of all supported OAuth versions, in order starting from newest version.
		/// </summary>
		internal static readonly List<Protocol> AllVersions = new List<Protocol>() { V20 };

		/// <summary>
		/// The default (or most recent) supported version of the OpenID protocol.
		/// </summary>
		internal static readonly Protocol Default = AllVersions[0];

		/// <summary>
		/// Gets or sets the OAuth WRAP version represented by this instance.
		/// </summary>
		/// <value>The version.</value>
		internal Version Version { get; private set; }

		/// <summary>
		/// Gets or sets the OAuth WRAP version represented by this instance.
		/// </summary>
		/// <value>The protocol version.</value>
		internal ProtocolVersion ProtocolVersion { get; private set; }

		/// <summary>
		/// Gets the OAuth Protocol instance to use for the given version.
		/// </summary>
		/// <param name="version">The OAuth version to get.</param>
		/// <returns>A matching <see cref="Protocol"/> instance.</returns>
		public static Protocol Lookup(ProtocolVersion version) {
			switch (version) {
				case ProtocolVersion.V20: return Protocol.V20;
				default: throw new ArgumentOutOfRangeException("version");
			}
		}
	}
}