IsNullOrBlank() private static méthode

private static IsNullOrBlank ( string value ) : bool
value string
Résultat bool
Exemple #1
0
        /// <summary>
        /// Creates a signature value given a signature base and the consumer secret and a known token secret.
        /// </summary>
        /// <seealso href="http://oauth.net/core/1.0#rfc.section.9.2" />
        /// <param name="signatureMethod">The hashing method</param>
        /// <param name="signatureTreatment">The treatment to use on a signature value</param>
        /// <param name="signatureBase">The signature base</param>
        /// <param name="consumerSecret">The consumer secret</param>
        /// <param name="tokenSecret">The token secret</param>
        /// <returns></returns>
        public static string GetSignature(
            OAuthSignatureMethod signatureMethod,
            OAuthSignatureTreatment signatureTreatment,
            string signatureBase,
            string consumerSecret,
            string tokenSecret)
        {
            if (OAuthTools.IsNullOrBlank(tokenSecret))
            {
                tokenSecret = string.Empty;
            }
            consumerSecret = OAuthTools.UrlEncodeRelaxed(consumerSecret);
            tokenSecret    = OAuthTools.UrlEncodeRelaxed(tokenSecret);
            if (signatureMethod != OAuthSignatureMethod.HmacSha1)
            {
                throw new NotImplementedException("Only HMAC-SHA1 is currently supported.");
            }
            HMACSHA1 hmacshA1 = new HMACSHA1();
            string   s        = consumerSecret + "&" + tokenSecret;

            hmacshA1.Key = OAuthTools._encoding.GetBytes(s);
            string str = OAuthTools.HashWith(signatureBase, (HashAlgorithm)hmacshA1);

            return(signatureTreatment == OAuthSignatureTreatment.Escaped ? OAuthTools.UrlEncodeRelaxed(str) : str);
        }