//----------------------------------------------------------------------- // // Copyright (c) Outercurve Foundation. All rights reserved. // //----------------------------------------------------------------------- namespace DotNetOpenAuth.Samples.OAuthConsumerWpf { using System; using System.Collections.Generic; using System.Diagnostics; using DotNetOpenAuth.OAuth.ChannelElements; using DotNetOpenAuth.OAuth.Messages; internal class InMemoryTokenManager : IConsumerTokenManager { private Dictionary tokensAndSecrets = new Dictionary(); internal InMemoryTokenManager() { } public string ConsumerKey { get; internal set; } public string ConsumerSecret { get; internal set; } #region ITokenManager Members public string GetConsumerSecret(string consumerKey) { if (consumerKey == this.ConsumerKey) { return this.ConsumerSecret; } else { throw new ArgumentException("Unrecognized consumer key.", "consumerKey"); } } public string GetTokenSecret(string token) { return this.tokensAndSecrets[token]; } public void StoreNewRequestToken(UnauthorizedTokenRequest request, ITokenSecretContainingMessage response) { this.tokensAndSecrets[response.Token] = response.TokenSecret; } public void ExpireRequestTokenAndStoreNewAccessToken(string consumerKey, string requestToken, string accessToken, string accessTokenSecret) { this.tokensAndSecrets.Remove(requestToken); this.tokensAndSecrets[accessToken] = accessTokenSecret; } /// /// Classifies a token as a request token or an access token. /// /// The token to classify. /// Request or Access token, or invalid if the token is not recognized. public TokenType GetTokenType(string token) { throw new NotImplementedException(); } #endregion } }