diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2009-04-08 16:22:58 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2009-04-08 16:22:58 -0700 |
commit | d9c0ee017807cc17132e9c760d274afffc9b981c (patch) | |
tree | 28a79463a760a10c4d67cbac48f9a6af5cd25b32 /src/DotNetOpenAuth.Test/Mocks | |
parent | 1c3247abc8fb37405d0602e5037b3cebbe8e944a (diff) | |
download | DotNetOpenAuth-d9c0ee017807cc17132e9c760d274afffc9b981c.zip DotNetOpenAuth-d9c0ee017807cc17132e9c760d274afffc9b981c.tar.gz DotNetOpenAuth-d9c0ee017807cc17132e9c760d274afffc9b981c.tar.bz2 |
Split up ITokenManager into two derived interfaces to better fit Consumer and Service Provider scenarios.
Diffstat (limited to 'src/DotNetOpenAuth.Test/Mocks')
-rw-r--r-- | src/DotNetOpenAuth.Test/Mocks/CoordinatingOAuthChannel.cs | 20 | ||||
-rw-r--r-- | src/DotNetOpenAuth.Test/Mocks/InMemoryTokenManager.cs | 25 |
2 files changed, 37 insertions, 8 deletions
diff --git a/src/DotNetOpenAuth.Test/Mocks/CoordinatingOAuthChannel.cs b/src/DotNetOpenAuth.Test/Mocks/CoordinatingOAuthChannel.cs index 88ada15..2d14bc8 100644 --- a/src/DotNetOpenAuth.Test/Mocks/CoordinatingOAuthChannel.cs +++ b/src/DotNetOpenAuth.Test/Mocks/CoordinatingOAuthChannel.cs @@ -26,14 +26,26 @@ namespace DotNetOpenAuth.Test.Mocks { /// <param name="signingBindingElement"> /// The signing element for the Consumer to use. Null for the Service Provider. /// </param> - /// <param name="isConsumer">True if this channel is constructed for a Consumer.</param> /// <param name="tokenManager">The token manager to use.</param> - internal CoordinatingOAuthChannel(ITamperProtectionChannelBindingElement signingBindingElement, bool isConsumer, ITokenManager tokenManager) + internal CoordinatingOAuthChannel(ITamperProtectionChannelBindingElement signingBindingElement, IConsumerTokenManager tokenManager) : base( signingBindingElement, new NonceMemoryStore(StandardExpirationBindingElement.DefaultMaximumMessageAge), - tokenManager, - isConsumer ? (IMessageFactory)new OAuthConsumerMessageFactory() : new OAuthServiceProviderMessageFactory(tokenManager)) { + tokenManager) { + } + + /// <summary> + /// Initializes a new instance of the <see cref="CoordinatingOAuthChannel"/> class for Consumers. + /// </summary> + /// <param name="signingBindingElement"> + /// The signing element for the Consumer to use. Null for the Service Provider. + /// </param> + /// <param name="tokenManager">The token manager to use.</param> + internal CoordinatingOAuthChannel(ITamperProtectionChannelBindingElement signingBindingElement, IServiceProviderTokenManager tokenManager) + : base( + signingBindingElement, + new NonceMemoryStore(StandardExpirationBindingElement.DefaultMaximumMessageAge), + tokenManager) { } /// <summary> diff --git a/src/DotNetOpenAuth.Test/Mocks/InMemoryTokenManager.cs b/src/DotNetOpenAuth.Test/Mocks/InMemoryTokenManager.cs index 571bba7..be3c563 100644 --- a/src/DotNetOpenAuth.Test/Mocks/InMemoryTokenManager.cs +++ b/src/DotNetOpenAuth.Test/Mocks/InMemoryTokenManager.cs @@ -8,10 +8,11 @@ namespace DotNetOpenAuth.Test.Mocks { using System; using System.Collections.Generic; using System.Diagnostics; + using System.Linq; using DotNetOpenAuth.OAuth.ChannelElements; using DotNetOpenAuth.OAuth.Messages; - internal class InMemoryTokenManager : ITokenManager { + internal class InMemoryTokenManager : IConsumerTokenManager, IServiceProviderTokenManager { private Dictionary<string, string> consumersAndSecrets = new Dictionary<string, string>(); private Dictionary<string, string> tokensAndSecrets = new Dictionary<string, string>(); @@ -25,12 +26,20 @@ namespace DotNetOpenAuth.Test.Mocks { /// </summary> private List<string> accessTokens = new List<string>(); - #region ITokenManager Members + #region IConsumerTokenManager Members - public string GetConsumerSecret(string consumerKey) { - return this.consumersAndSecrets[consumerKey]; + public string ConsumerKey { + get { return this.consumersAndSecrets.Keys.Single(); } + } + + public string ConsumerSecret { + get { return this.consumersAndSecrets.Values.Single(); } } + #endregion + + #region ITokenManager Members + public string GetTokenSecret(string token) { return this.tokensAndSecrets[token]; } @@ -82,6 +91,14 @@ namespace DotNetOpenAuth.Test.Mocks { #endregion + #region IServiceProviderTokenManager Members + + public string GetConsumerSecret(string consumerKey) { + return this.consumersAndSecrets[consumerKey]; + } + + #endregion + /// <summary> /// Tells a Service Provider's token manager about a consumer and its secret /// so that the SP can verify the Consumer's signed messages. |