protected virtual void SetRequestToken(OAuthRequestContext requestContext) { IRequestToken token = provider.TokenStore.Get(requestContext.Parameters.Token, TokenType.Request) as IRequestToken; if (token == null) { throw new OAuthRequestException(null, OAuthProblemTypes.TokenRejected); } if (!token.ConsumerKey.Equals(requestContext.Parameters.ConsumerKey)) { throw new OAuthRequestException(null, OAuthProblemTypes.TokenRejected); } switch (token.Status) { case TokenStatus.Authorized: requestContext.RequestToken = token; break; case TokenStatus.Expired: throw new OAuthRequestException(null, OAuthProblemTypes.TokenExpired); case TokenStatus.Used: throw new OAuthRequestException(null, OAuthProblemTypes.TokenUsed); case TokenStatus.Revoked: throw new OAuthRequestException(null, OAuthProblemTypes.TokenRevoked); case TokenStatus.Unauthorized: case TokenStatus.Unknown: default: throw new OAuthRequestException(null, OAuthProblemTypes.TokenRejected); } }
/// <summary> /// Determins if the store contains a callback for the supplied token. /// </summary> /// <param name="token"></param> /// <returns></returns> public bool ContainsCallback(IRequestToken token) { lock (this.callbackStore) { return(this.callbackStore.ContainsKey(token)); } }
protected override void IssueToken(IHttpContext httpContext, OAuthRequestContext requestContext) { // Generate a request token IRequestToken token = GenerateToken(TokenType.Request, httpContext, requestContext) as IRequestToken; // Check to see if the request for a token is oob and that oob is allowed. if (requestContext.Parameters.Callback.Equals("oob")) { if (!Provider.AllowOutOfBandCallback) { throw new ParametersRejectedException("Out of band is not supported.", new string[] { OAuthParameterKeys.Callback }); } } else { Uri callbackUri; if (!Uri.TryCreate(requestContext.Parameters.Callback, UriKind.Absolute, out callbackUri)) { throw new ParametersRejectedException("Not a valid Uri.", new string[] { OAuthParameterKeys.Callback }); } Provider.CallbackStore.SaveCallback(token, callbackUri); } // Store the token requestContext.RequestToken = token; Provider.TokenStore.Add(token); // Add to the response requestContext.ResponseParameters[OAuthParameterKeys.CallbackConfirmed] = "true"; // The spec never defines when to send false or what will happen if you do. requestContext.ResponseParameters[OAuthParameterKeys.Token] = token.Token; requestContext.ResponseParameters[OAuthParameterKeys.TokenSecret] = token.Secret; }
public OAuthAccessToken( string token, string secret, IConsumer consumer, TokenStatus status, IRequestToken requestToken) : this() { if (string.IsNullOrEmpty(token)) { throw new ArgumentException("token must not be null or empty", "token"); } if (secret == null) { throw new ArgumentNullException("secret", "secret must not be null"); } if (consumer == null) { throw new ArgumentNullException("consumer", "consumer must not be null"); } if (requestToken == null) { throw new ArgumentNullException("requestToken", "requestToken must not be null"); } this.Token = token; this.Secret = secret; this.Status = status; this.ConsumerKey = consumer.Key; this.RequestToken = requestToken; }
public OAuthAccessToken( string token, string secret, IConsumer consumer, TokenStatus status, IRequestToken requestToken) : this() { if (string.IsNullOrEmpty(token)) throw new ArgumentException("token must not be null or empty", "token"); if (secret == null) throw new ArgumentNullException("secret", "secret must not be null"); if (consumer == null) throw new ArgumentNullException("consumer", "consumer must not be null"); if (requestToken == null) throw new ArgumentNullException("requestToken", "requestToken must not be null"); this.Token = token; this.Secret = secret; this.Status = status; this.ConsumerKey = consumer.Key; this.RequestToken = requestToken; }
/// <summary> /// Determins if the store contains a callback for the supplied token. /// </summary> /// <param name="token"></param> /// <returns></returns> public bool ContainsCallback(IRequestToken token) { lock (this.callbackStore) { return this.callbackStore.ContainsKey(token); } }
/// <summary> /// Create a new access token /// </summary> /// <param name="consumer">The consumer for whom the token is to be created</param> /// <param name="requestToken">The request token being swapped for this access token</param> /// <returns>An access token</returns> public virtual IAccessToken CreateAccessToken(IConsumer consumer, IRequestToken requestToken) { return new OAuthAccessToken( GuidHelper.CreateGuid().ToString("D"), GuidHelper.CreateGuid().ToString("D"), consumer, TokenStatus.Unauthorized, requestToken); }
/// <summary> /// Create a new access token /// </summary> /// <param name="consumer">The consumer for whom the token is to be created</param> /// <param name="requestToken">The request token being swapped for this access token</param> /// <returns>An access token</returns> public virtual IAccessToken CreateAccessToken(IConsumer consumer, IRequestToken requestToken) { return(new OAuthAccessToken( GuidHelper.CreateGuid().ToString("D"), GuidHelper.CreateGuid().ToString("D"), consumer, TokenStatus.Unauthorized, requestToken)); }
public bool SaveCallback(IRequestToken token, Uri callback) { lock (heapStore) { bool found = heapStore.ContainsKey(token); if (!found) heapStore.Add(token, callback); return found; } }
public bool ObtainCallback(IRequestToken token, out Uri callback) { lock (heapStore) { if (heapStore.TryGetValue(token, out callback)) { heapStore.Remove(token); return true; } return false; } }
/// <summary> /// Removes the callbackUri from the store for the supplied token. /// This method should be used to obtain the callback Uri when redirecting the user to ensure /// that it is removed from the store. /// </summary> /// <param name="token"></param> /// <returns>The callback URI or null if none found.</returns> public Uri RemoveCallback(IRequestToken token) { Uri uri = null; lock (this.callbackStore) { this.callbackStore.TryGetValue(token, out uri); this.callbackStore.Remove(token); } return uri; }
public bool ObtainCallback(IRequestToken token, out Uri callback) { lock (heapStore) { if (heapStore.TryGetValue(token, out callback)) { heapStore.Remove(token); return(true); } return(false); } }
/// <summary> /// Removes the callbackUri from the store for the supplied token. /// This method should be used to obtain the callback Uri when redirecting the user to ensure /// that it is removed from the store. /// </summary> /// <param name="token"></param> /// <returns>The callback URI or null if none found.</returns> public Uri RemoveCallback(IRequestToken token) { Uri uri = null; lock (this.callbackStore) { this.callbackStore.TryGetValue(token, out uri); this.callbackStore.Remove(token); } return(uri); }
public bool SaveCallback(IRequestToken token, Uri callback) { lock (heapStore) { bool found = heapStore.ContainsKey(token); if (!found) { heapStore.Add(token, callback); } return(found); } }
/// <summary> /// Appends a new callback to the store. /// </summary> /// <param name="token"></param> /// <param name="callbackUri"></param> /// <returns>true if the callbackUri is succesfully appended or false if there already exists a callbackUri for the token</returns> public bool AddCallback(IRequestToken token, Uri callbackUri) { lock (this.callbackStore) { if (this.callbackStore.ContainsKey(token)) return false; else { this.callbackStore.Add(token, callbackUri); return true; } } }
public IList <IToken> FindByUser(IIdentity user, string consumerKey) { if (user == null) { throw new ArgumentNullException("user"); } lock (SyncRoot) { List <IToken> tokens = new List <IToken>(); foreach (KeyValuePair <string, IToken> pair in accessTokens) { IAccessToken token = pair.Value as IAccessToken; if (token == null) { continue; } if (token.RequestToken.AuthenticatedUser.Equals(user)) { if (!String.IsNullOrEmpty(consumerKey) && !token.ConsumerKey.Equals(consumerKey)) { continue; } tokens.Add(token); } } foreach (KeyValuePair <string, IToken> pair in requestTokens) { IRequestToken token = pair.Value as IRequestToken; if (token == null) { continue; } if (token.AuthenticatedUser.Equals(user)) { if (!String.IsNullOrEmpty(consumerKey) && !token.ConsumerKey.Equals(consumerKey)) { continue; } tokens.Add(token); } } return(tokens.AsReadOnly()); } }
/// <summary> /// Revoke the request token. /// </summary> /// <param name="token">The request token to revoke</param> /// <returns><c>true</c>, if the token was revoked; /// <c>false</c>, if the token could not be revoked</returns> public static bool RevokeToken(IRequestToken token) { token.Status = TokenStatus.Revoked; if (ServiceProviderContext.TokenStore.Update(token)) { return(true); } else { token.Status = TokenStatus.Unauthorized; return(false); } }
public OAuthPrincipal(IAccessToken accessToken) { if (accessToken == null) throw new ArgumentNullException("accessToken"); if (accessToken.RequestToken == null) throw new ArgumentException("Access token must have a request token", "accessToken"); if (accessToken.RequestToken.AuthenticatedUser == null) throw new ArgumentException("Request token must have an authenticated user", "accessToken"); this.accessToken = accessToken; requestToken = accessToken.RequestToken; identity = RequestToken.AuthenticatedUser; }
/// <summary> /// Appends a new callback to the store. /// </summary> /// <param name="token"></param> /// <param name="callbackUri"></param> /// <returns>true if the callbackUri is succesfully appended or false if there already exists a callbackUri for the token</returns> public bool AddCallback(IRequestToken token, Uri callbackUri) { lock (this.callbackStore) { if (this.callbackStore.ContainsKey(token)) { return(false); } else { this.callbackStore.Add(token, callbackUri); return(true); } } }
protected override void IssueRequestToken( HttpContext httpContext, OAuthRequestContext requestContext) { // Generate a request token IRequestToken token = this.GenerateRequestToken(httpContext, requestContext); // Store the token requestContext.RequestToken = token; // Don't add to the token store (as it is already in there) // Add to the response requestContext.ResponseParameters[Constants.TokenParameter] = token.Token; requestContext.ResponseParameters[Constants.TokenSecretParameter] = token.Secret; }
public bool Equals(IRequestToken other) { if (other == null) { return(false); } return(token.Equals(other.Token) && secret.Equals(other.Secret) && status == other.Status && String.Equals(consumerKey, other.ConsumerKey) && ((parameters == null && other.AssociatedParameters == null) || (parameters != null && parameters.Equals(other.AssociatedParameters))) && ((user == null && other.AuthenticatedUser == null) || (user != null && user.Equals(other.AuthenticatedUser))) && RolesEquals(other.Roles)); }
private bool Equals(IRequestToken other) { if (other == null) { return(false); } return(this.Token.Equals(other.Token) && this.Secret.Equals(other.Secret) && // Constructor ensures that this is not null this.Status == other.Status && string.Equals(this.ConsumerKey, other.ConsumerKey) && ((this.AssociatedParameters == null && other.AssociatedParameters == null) || (this.AssociatedParameters != null && this.AssociatedParameters.Equals(other.AssociatedParameters))) && ((this.AuthenticatedUser == null && other.AuthenticatedUser == null) || (this.AuthenticatedUser != null && this.AuthenticatedUser.Equals(other.AuthenticatedUser))) && this.Roles.IsEqualTo <string>(other.Roles)); }
/// <summary> /// Removes the specified request token from the store. /// </summary> /// <param name="token">The token to remove</param> /// <returns><c>true</c>, iff the token was successfully removed /// from the store. This will return <c>false</c> if the token /// did not exist in the store.</returns> public virtual bool Remove(IRequestToken token) { if (token == null) { throw new ArgumentNullException("token"); } lock (SyncRoot) { if (!this.ContainsRequestToken(token.Token)) { return(false); } else { return(this.RequestTokenDictionary.Remove(token.Token)); } } }
/// <summary> /// Adds the supplied request token to the token store. If the token conflicts /// with a token already in the store, then <c>false</c> is /// returned. /// </summary> /// <param name="token">The token to store</param> /// <returns><c>true</c>, iff the token was stored</returns> public virtual bool Add(IRequestToken token) { if (token == null) { throw new ArgumentNullException("token"); } lock (SyncRoot) { if (this.Contains(token.Token)) { return(false); } else { this.RequestTokenDictionary[token.Token] = token; } } return(true); }
public OAuthPrincipal(IAccessToken accessToken) { if (accessToken == null) { throw new ArgumentNullException("accessToken"); } if (accessToken.RequestToken == null) { throw new ArgumentException("Access token must have a request token", "accessToken"); } if (accessToken.RequestToken.AuthenticatedUser == null) { throw new ArgumentException("Request token must have an authenticated user", "accessToken"); } this.accessToken = accessToken; requestToken = accessToken.RequestToken; identity = RequestToken.AuthenticatedUser; }
protected virtual void IssueRequestToken(HttpContext httpContext, OAuthRequestContext requestContext) { // Generate a request token IRequestToken token = this.GenerateRequestToken(httpContext, requestContext); // Check to see if the request for a token is oob and that oob is allowed. if (requestContext.Parameters.Callback.Equals(Constants.OAuthOutOfBandCallback)) { if (ServiceProviderContext.Settings.AllowOutOfBandCallback == false) { OAuthRequestException.ThrowParametersRejected(new string[] { Constants.CallbackParameter }, "Out of band is not supported."); } } else { Uri callbackUri; if (Uri.TryCreate(requestContext.Parameters.Callback, UriKind.Absolute, out callbackUri)) { ServiceProviderContext.CallbackStore.AddCallback(token, callbackUri); } else { OAuthRequestException.ThrowParametersRejected(new string[] { Constants.CallbackParameter }, "Not a valid Uri."); } } // Store the token requestContext.RequestToken = token; ServiceProviderContext.TokenStore.Add(token); // Add to the response requestContext.ResponseParameters[Constants.CallbackConfirmedParameter] = "true"; // The spec never defines when to send false or what will happen if you do. requestContext.ResponseParameters[Constants.TokenParameter] = token.Token; requestContext.ResponseParameters[Constants.TokenSecretParameter] = token.Secret; }
protected IRequestToken LoadScores(RangeInt scoreRange, ScoreloopCallback<LeaderboardScoresResponse> callback) { ScoreloopCallback<LeaderboardScoresResponse> innerCallback = response => { if (_latestScoreRequestToken != null && response.RequestSource == _latestScoreRequestToken.RequestSource) { _latestScoreRequestToken = null; } // if less scores than the requested amount was loaded, that *should* mean that there are no more scores to load if (response.Success && response.Data.Scores.Count != scoreRange.Length) { _canLoadMoreScores = false; } this.OnScoresLoaded(response); if (callback != null) { callback(response); } }; this.CancelLatestScoreRequest(); _latestScoreRequestToken = _scoreloopManager.LoadScores(_leaderboardScope, scoreRange, _mode, innerCallback); return _latestScoreRequestToken; }
public string GenerateVerifier(IRequestToken token) { return(CreateBase64MD5Hash(BuildHashValue(token))); }
public IAccessToken CreateAccessToken(IConsumer consumer, IRequestToken requestToken) { return new OAuthAccessToken(Guid.NewGuid().ToString(Format), Guid.NewGuid().ToString(Format), consumer, TokenStatus.Unauthorized, requestToken); }
/// <summary> /// Checks to see if the provided verifier is valid for this Request token. /// </summary> /// <param name="token"></param> /// <param name="verifier"></param> /// <returns></returns> public bool IsValid(IRequestToken token, string verifier) { string hash = this.CreateBase64MD5Hash(this.BuildHashValue(token)); return(hash.Equals(verifier, StringComparison.Ordinal)); }
protected void CancelLatestScoreRequest() { if (_latestScoreRequestToken != null) { _latestScoreRequestToken.Cancel(); _latestScoreRequestToken = null; } }
public override bool Remove(IRequestToken token) { throw new NotSupportedException("Tokens cannot be removed from the token store--it is fixed."); }
public IAccessToken CreateAccessToken(IConsumer consumer, IRequestToken requestToken) { return TokenGenerator.FixedAccessToken; }
public override bool Add(IRequestToken token) { throw new NotSupportedException("Tokens cannot be added to the token store--it is fixed."); }
public string GenerateVerifier(IRequestToken token) { return CreateBase64MD5Hash(BuildHashValue(token)); }
public IAccessToken CreateAccessToken(IConsumer consumer, IRequestToken requestToken) { return(TokenGenerator.FixedAccessToken); }
public IAccessToken CreateAccessToken(IConsumer consumer, IRequestToken requestToken) { return(new OAuthAccessToken(Guid.NewGuid().ToString(Format), Guid.NewGuid().ToString(Format), consumer, TokenStatus.Unauthorized, requestToken)); }
public EmptyAccessToken(string consumerKey) : base(consumerKey, TokenType.Access) { requestToken = new EmptyRequestToken(consumerKey); status = TokenStatus.Authorized; }
/// <summary> /// Authorize the request token for the specified user. /// </summary> /// <param name="token">The request token to authorize</param> /// <param name="authenticatedUser">The user (must be authenticated)</param> /// <returns><c>true</c>, if the token was authorized; /// <c>false</c>, if the token could not be authorized</returns> /// <exception cref="OAuth.Net.Common.OAuthRequestException"> /// If there is a problem with the request that prevents access being granted. /// </exception> public static bool GrantAccess(IRequestToken token, IIdentity authenticatedUser) { if (token == null) { throw new ArgumentNullException("token"); } if (authenticatedUser == null) { throw new ArgumentNullException("authenticatedUser"); } if (!authenticatedUser.IsAuthenticated) { throw new ArgumentException("User must be authenticated", "authenticatedUser"); } switch (token.Status) { case TokenStatus.Authorized: break; case TokenStatus.Expired: OAuthRequestException.ThrowTokenExpired(null); break; case TokenStatus.Revoked: OAuthRequestException.ThrowTokenRevoked(null); break; case TokenStatus.Used: OAuthRequestException.ThrowTokenUsed(null); break; case TokenStatus.Unknown: OAuthRequestException.ThrowTokenRejected(null); break; case TokenStatus.Unauthorized: break; default: throw new ArgumentException("Token status is invalid", "token"); } if (token.ConsumerKey == null) { OAuthRequestException.ThrowTokenRejected("Token must have a consumer key"); } IConsumer consumer = ServiceProviderContext.ConsumerStore.GetByKey(token.ConsumerKey); if (consumer == null) { OAuthRequestException.ThrowConsumerKeyUnknown("Consumer is unknown"); } switch (consumer.Status) { case ConsumerStatus.TemporarilyDisabled: OAuthRequestException.ThrowConsumerKeyRefused("Consumer is temporarily disabled"); break; case ConsumerStatus.PermanentlyDisabled: OAuthRequestException.ThrowConsumerKeyRejected("Consumer is permanently disabled"); break; case ConsumerStatus.Valid: break; case ConsumerStatus.Unknown: OAuthRequestException.ThrowConsumerKeyUnknown("Consumer is unknown"); break; default: throw new ArgumentException("Token consumer's status is invalid", "token"); } token.Status = TokenStatus.Authorized; token.AuthenticatedUser = authenticatedUser; if (ServiceProviderContext.TokenStore.Update(token)) { return(true); } else { token.Status = TokenStatus.Unauthorized; token.AuthenticatedUser = null; return(false); } }
/// <summary> /// Authorize the request token for the specified user. /// </summary> /// <param name="token">The request token to authorize</param> /// <param name="authenticatedUser">The user (must be authenticated)</param> /// <returns><c>true</c>, if the token was authorized; /// <c>false</c>, if the token could not be authorized</returns> /// <exception cref="OAuth.Net.Common.OAuthRequestException"> /// If there is a problem with the request that prevents access being granted. /// </exception> public static bool GrantAccess(IRequestToken token, IIdentity authenticatedUser) { if (token == null) throw new ArgumentNullException("token"); if (authenticatedUser == null) throw new ArgumentNullException("authenticatedUser"); if (!authenticatedUser.IsAuthenticated) throw new ArgumentException("User must be authenticated", "authenticatedUser"); switch (token.Status) { case TokenStatus.Authorized: break; case TokenStatus.Expired: OAuthRequestException.ThrowTokenExpired(null); break; case TokenStatus.Revoked: OAuthRequestException.ThrowTokenRevoked(null); break; case TokenStatus.Used: OAuthRequestException.ThrowTokenUsed(null); break; case TokenStatus.Unknown: OAuthRequestException.ThrowTokenRejected(null); break; case TokenStatus.Unauthorized: break; default: throw new ArgumentException("Token status is invalid", "token"); } if (token.ConsumerKey == null) OAuthRequestException.ThrowTokenRejected("Token must have a consumer key"); IConsumer consumer = ServiceProviderContext.ConsumerStore.GetByKey(token.ConsumerKey); if (consumer == null) OAuthRequestException.ThrowConsumerKeyUnknown("Consumer is unknown"); switch (consumer.Status) { case ConsumerStatus.TemporarilyDisabled: OAuthRequestException.ThrowConsumerKeyRefused("Consumer is temporarily disabled"); break; case ConsumerStatus.PermanentlyDisabled: OAuthRequestException.ThrowConsumerKeyRejected("Consumer is permanently disabled"); break; case ConsumerStatus.Valid: break; case ConsumerStatus.Unknown: OAuthRequestException.ThrowConsumerKeyUnknown("Consumer is unknown"); break; default: throw new ArgumentException("Token consumer's status is invalid", "token"); } token.Status = TokenStatus.Authorized; token.AuthenticatedUser = authenticatedUser; if (ServiceProviderContext.TokenStore.Update(token)) return true; else { token.Status = TokenStatus.Unauthorized; token.AuthenticatedUser = null; return false; } }
/// <summary> /// Generates a new Verification code for the given token. /// </summary> /// <param name="token"></param> /// <returns></returns> public string Generate(IRequestToken token) { return(this.CreateBase64MD5Hash(this.BuildHashValue(token))); }
/// <summary> /// Removes the specified request token from the store. /// </summary> /// <param name="token">The token to remove</param> /// <returns><c>true</c>, iff the token was successfully removed /// from the store. This will return <c>false</c> if the token /// did not exist in the store.</returns> public virtual bool Remove(IRequestToken token) { if (token == null) throw new ArgumentNullException("token"); lock (SyncRoot) { if (!this.ContainsRequestToken(token.Token)) return false; else return this.RequestTokenDictionary.Remove(token.Token); } }
private string BuildHashValue(IRequestToken token) { return(token.Token + this.GetConsumerSecret(token.ConsumerKey)); }
/// <summary> /// Generates a new Verification code for the given token. /// </summary> /// <param name="token"></param> /// <returns></returns> public string Generate(IRequestToken token) { return this.CreateBase64MD5Hash(this.BuildHashValue(token)); }
public EmptyAccessToken(string consumerKey) : base(consumerKey, TokenType.Access) { this.requestToken = new EmptyRequestToken(consumerKey); this.Status = TokenStatus.Authorized; }
/// <summary> /// Checks to see if the provided verifier is valid for this Request token. /// </summary> /// <param name="token"></param> /// <param name="verifier"></param> /// <returns></returns> public bool IsValid(IRequestToken token, string verifier) { string hash = this.CreateBase64MD5Hash(this.BuildHashValue(token)); return hash.Equals(verifier, StringComparison.Ordinal); }
public bool Equals(IRequestToken other) { if (other == null) return false; return token.Equals(other.Token) && secret.Equals(other.Secret) && status == other.Status && String.Equals(consumerKey, other.ConsumerKey) && ((parameters == null && other.AssociatedParameters == null) || (parameters != null && parameters.Equals(other.AssociatedParameters))) && ((user == null && other.AuthenticatedUser == null) || (user != null && user.Equals(other.AuthenticatedUser))) && RolesEquals(other.Roles); }
private string BuildHashValue(IRequestToken token) { return token.Token + this.GetConsumerSecret(token.ConsumerKey); }
private bool Equals(IRequestToken other) { if (other == null) return false; return this.Token.Equals(other.Token) && this.Secret.Equals(other.Secret) // Constructor ensures that this is not null && this.Status == other.Status && string.Equals(this.ConsumerKey, other.ConsumerKey) && ((this.AssociatedParameters == null && other.AssociatedParameters == null) || (this.AssociatedParameters != null && this.AssociatedParameters.Equals(other.AssociatedParameters))) && ((this.AuthenticatedUser == null && other.AuthenticatedUser == null) || (this.AuthenticatedUser != null && this.AuthenticatedUser.Equals(other.AuthenticatedUser))) && this.Roles.IsEqualTo<string>(other.Roles); }
/// <summary> /// Updates the the given request token in the store. /// </summary> /// <param name="token">The token to update</param> /// <returns><c>true</c>, iff the token was successfully updated /// in the store.</returns> public virtual bool Update(IRequestToken token) { if (token == null) throw new ArgumentNullException("token"); lock (SyncRoot) { if (!this.ContainsRequestToken(token.Token)) return false; else this.RequestTokenDictionary[token.Token] = token; } return true; }
public override bool Update(IRequestToken token) { throw new NotSupportedException("Tokens cannot be updated in the token store--it is fixed."); }
/// <summary> /// Revoke the request token. /// </summary> /// <param name="token">The request token to revoke</param> /// <returns><c>true</c>, if the token was revoked; /// <c>false</c>, if the token could not be revoked</returns> public static bool RevokeToken(IRequestToken token) { token.Status = TokenStatus.Revoked; if (ServiceProviderContext.TokenStore.Update(token)) return true; else { token.Status = TokenStatus.Unauthorized; return false; } }