Inheritance: IssuedToken
コード例 #1
0
        /// <summary>
        /// Determines whether the specified <see cref="RequestToken"/> is equal to the current <see cref="RequestToken"/>.
        /// </summary>
        /// <param name="token">The <see cref="RequestToken"/> to compare with the current <see cref="RequestToken"/>.</param>
        /// <returns>
        /// true if the specified <see cref="RequestToken"/> is equal to the current <see cref="RequestToken"/>; otherwise false.
        /// </returns>
        public bool Equals(RequestToken token)
        {
            if (token == null)
            {
                return false;
            }

            return base.Equals(token)
                && this.Authorised == token.Authorised
                && this.Callback == token.Callback
                && this.ConsumerVersion == token.ConsumerVersion
                && this.VerificationCode == token.VerificationCode;
        }
コード例 #2
0
        /// <summary>
        /// Stores a newly generated unauthorized request token, secret, and optional
        /// application-specific parameters for later recall. 
        /// </summary>
        /// <param name="request">The request message that resulted in the generation of a new unauthorized request token.</param>
        /// <param name="response">The response message that includes the unauthorized request token.</param>
        /// <exception cref="ArgumentException">Thrown if the consumer key is not registered, or a required parameter was not found in the parameters collection.</exception>
        /// <exception cref="ArgumentNullException">Thrown if a parameter is null.</exception>
        /// <exception cref="Glipho.OAuth.OAuthException">Thrown if an error occurs while executing the requested command.</exception>
        /// <remarks>
        /// Request tokens stored by this method SHOULD NOT associate any user account with this token.
        /// It usually opens up security holes in your application to do so.  Instead, you associate a user
        /// account with access tokens (not request tokens) in the <see cref="TokenManager.ExpireRequestTokenAndStoreNewAccessToken(string, string, string, string)"/>
        /// method. 
        /// </remarks>
        public void StoreNewRequestToken(UnauthorizedTokenRequest request, ITokenSecretContainingMessage response)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request", "request is null");
            }

            if (response == null)
            {
                throw new ArgumentNullException("response", "response is null");
            }

            var consumer = this.consumers.Get(request.ConsumerKey);
            if (consumer == null)
            {
                throw new ArgumentException(string.Format("Consumer with key \"{0}\" does not exist.", request.ConsumerKey));
            }

            string scope;
            request.ExtraData.TryGetValue("scope", out scope);

            var requestToken = new Database.RequestToken(request.Callback, consumer.Id, response.Token, response.TokenSecret, scope != null ? scope.Split(',').AsEnumerable() : null);
            this.issuedTokens.Create(requestToken);
        }