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

namespace DotNetOpenAuth.OAuth.ChannelElements {
	/// <summary>
	/// An interface allowing OAuth hosts to inject their own algorithm for generating tokens and secrets.
	/// </summary>
	public interface ITokenGenerator {
		/// <summary>
		/// Generates a new token to represent a not-yet-authorized request to access protected resources.
		/// </summary>
		/// <param name="consumerKey">The consumer that requested this token.</param>
		/// <returns>The newly generated token.</returns>
		/// <remarks>
		/// This method should not store the newly generated token in any persistent store.
		/// This will be done in <see cref="ITokenManager.StoreNewRequestToken"/>.
		/// </remarks>
		string GenerateRequestToken(string consumerKey);

		/// <summary>
		/// Generates a new token to represent an authorized request to access protected resources.
		/// </summary>
		/// <param name="consumerKey">The consumer that requested this token.</param>
		/// <returns>The newly generated token.</returns>
		/// <remarks>
		/// This method should not store the newly generated token in any persistent store.
		/// This will be done in <see cref="ITokenManager.ExpireRequestTokenAndStoreNewAccessToken"/>.
		/// </remarks>
		string GenerateAccessToken(string consumerKey);

		/// <summary>
		/// Returns a cryptographically strong random string for use as a token secret.
		/// </summary>
		/// <returns>The generated string.</returns>
		string GenerateSecret();
	}
}