summaryrefslogtreecommitdiffstats
path: root/src/DotNetOAuth.Test/Mocks/InMemoryTokenManager.cs
blob: 002eee11e1bf6041ee5baca8550c2d9800f7eada (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
namespace DotNetOAuth.Test.Mocks {
	using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.Text;
	using DotNetOAuth.ChannelElements;

	internal class InMemoryTokenManager : ITokenManager {
		Dictionary<string, string> consumersAndSecrets = new Dictionary<string, string>();
		Dictionary<string, string> tokensAndSecrets = new Dictionary<string, string>();

		#region ITokenManager Members

		public string GetConsumerSecret(string consumerKey) {
			return consumersAndSecrets[consumerKey];
		}

		public string GetTokenSecret(string token) {
			return tokensAndSecrets[token];
		}

		public void StoreNewRequestToken(string consumerKey, string requestToken, string requestTokenSecret, IDictionary<string, string> parameters) {
			tokensAndSecrets[requestToken] = requestTokenSecret;
		}

		public void ExpireRequestTokenAndStoreNewAccessToken(string consumerKey, string requestToken, string accessToken, string accessTokenSecret) {
			tokensAndSecrets.Remove(requestToken);
			tokensAndSecrets[accessToken] = accessTokenSecret;
		}

		#endregion

		internal void AddConsumer(string key, string secret) {
			consumersAndSecrets.Add(key, secret);
		}
	}
}