//----------------------------------------------------------------------- // // Copyright (c) Andrew Arnott. All rights reserved. // //----------------------------------------------------------------------- namespace DotNetOAuth.ChannelElements { using System; using System.Collections.Generic; using System.Linq; using System.Text; using DotNetOAuth.Messages; /// /// An interface OAuth hosts must implement for persistent storage and recall of tokens and secrets. /// public interface ITokenManager { /// /// Gets the Consumer Secret given a Consumer Key. /// /// The Consumer Key. /// The Consumer Secret. /// Thrown if the consumer key cannot be found. /// /// TODO: In the case of RSA hashing, the consumer may not have a secret /// like this. What to do in that case? /// string GetConsumerSecret(string consumerKey); /// /// Gets the Token Secret given a request or access token. /// /// The request or access token. /// The secret associated with the given token. /// Thrown if the secret cannot be found for the given token. string GetTokenSecret(string token); /// /// Stores a newly generated unauthorized request token, secret, and optional /// application-specific parameters for later recall. /// /// The request message that resulted in the generation of a new unauthorized request token. /// The response message that includes the unauthorized request token. /// Thrown if the consumer key is not registered, or a required parameter was not found in the parameters collection. void StoreNewRequestToken(RequestTokenMessage request, UnauthorizedRequestTokenMessage response); /// /// Checks whether a given request token has already been authorized /// by some user for use by the Consumer that requested it. /// /// The Consumer's request token. /// /// True if the request token has already been fully authorized by the user /// who owns the relevant protected resources. False if the token has not yet /// been authorized, has expired or does not exist. /// bool IsRequestTokenAuthorized(string requestToken); /// /// Deletes a request token and its associated secret and stores a new access token and secret. /// /// The Consumer that is exchanging its request token for an access token. /// The Consumer's request token that should be deleted/expired. /// The new access token that is being issued to the Consumer. /// The secret associated with the newly issued access token. /// /// Any scope of granted privileges associated with the request token from the /// original call to should be carried over /// to the new Access Token. /// void ExpireRequestTokenAndStoreNewAccessToken(string consumerKey, string requestToken, string accessToken, string 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. TokenType GetTokenType(string token); } }