コード例 #1
0
 /// <summary>
 /// A constructor that only takes the encryption method. The consumer key
 /// and secret are defaulted to string.Empty.
 /// </summary>
 /// <param name="signatureMethod">The signature encryption method</param>
 public OAuthConsumer(OAuthBase.SignatureTypes signatureMethod)
 {
     consumerKey          = string.Empty;
     consumerSecret       = string.Empty;
     this.signatureMethod = signatureMethod;
     oAuth = new OAuthBase();
 }
コード例 #2
0
 /// <summary>
 /// A constructor that take the consumer key, consumer secret and signature method.
 /// </summary>
 /// <param name="consumerKey">Consumer key</param>
 /// <param name="consumerSecret">Consumer secret</param>
 /// <param name="signatureMethod">Signature encryption method</param>
 public OAuthConsumer(string consumerKey, string consumerSecret, OAuthBase.SignatureTypes signatureMethod)
 {
     this.consumerKey     = consumerKey;
     this.consumerSecret  = consumerSecret;
     this.signatureMethod = signatureMethod;
     oAuth = new OAuthBase();
 }
コード例 #3
0
 /// <summary>
 /// A Parameterless constructor. Defaults the consumer key and secret to string.Empty
 /// and the encryption method to HMAC-SHA1.
 /// </summary>
 public OAuthConsumer()
 {
     consumerKey     = string.Empty;
     consumerSecret  = string.Empty;
     signatureMethod = OAuthBase.SignatureTypes.HMACSHA1;
     oAuth           = new OAuthBase();
 }
コード例 #4
0
 public void GenerateSignatureTest()
 {
     OAuthBase target = new OAuthBase(); // TODO: Initialize to an appropriate value
     Uri url = null; // TODO: Initialize to an appropriate value
     string consumerKey = string.Empty; // TODO: Initialize to an appropriate value
     string consumerSecret = string.Empty; // TODO: Initialize to an appropriate value
     string token = string.Empty; // TODO: Initialize to an appropriate value
     string tokenSecret = string.Empty; // TODO: Initialize to an appropriate value
     string verifier = string.Empty; // TODO: Initialize to an appropriate value
     string httpMethod = string.Empty; // TODO: Initialize to an appropriate value
     string timeStamp = string.Empty; // TODO: Initialize to an appropriate value
     string nonce = string.Empty; // TODO: Initialize to an appropriate value
     OAuthBase.SignatureTypes signatureType = new OAuthBase.SignatureTypes(); // TODO: Initialize to an appropriate value
     string normalizedUrl = string.Empty; // TODO: Initialize to an appropriate value
     string normalizedUrlExpected = string.Empty; // TODO: Initialize to an appropriate value
     string normalizedRequestParameters = string.Empty; // TODO: Initialize to an appropriate value
     string normalizedRequestParametersExpected = string.Empty; // TODO: Initialize to an appropriate value
     string expected = string.Empty; // TODO: Initialize to an appropriate value
     string actual;
     actual = target.GenerateSignature(url, consumerKey, consumerSecret, token, tokenSecret, verifier, httpMethod, timeStamp, nonce, signatureType, out normalizedUrl, out normalizedRequestParameters);
     Assert.AreEqual(normalizedUrlExpected, normalizedUrl);
     Assert.AreEqual(normalizedRequestParametersExpected, normalizedRequestParameters);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
コード例 #5
0
		/// <summary>
		/// A constructor that take the consumer key, consumer secret and signature method.
		/// </summary>
		/// <param name="consumerKey">Consumer key</param>
		/// <param name="consumerSecret">Consumer secret</param>
		/// <param name="signatureMethod">Signature encryption method</param>
		public OAuthConsumer(string consumerKey, string consumerSecret, OAuthBase.SignatureTypes signatureMethod)
		{
			this.consumerKey = consumerKey;
			this.consumerSecret = consumerSecret;
			this.signatureMethod = signatureMethod;
			oAuth = new OAuthBase();
		}
コード例 #6
0
		/// <summary>
		/// A constructor that only takes the encryption method. The consumer key
		/// and secret are defaulted to string.Empty.
		/// </summary>
		/// <param name="signatureMethod">The signature encryption method</param>
		public OAuthConsumer(OAuthBase.SignatureTypes signatureMethod)
		{
			consumerKey = string.Empty;
			consumerSecret = string.Empty;
			this.signatureMethod = signatureMethod;
			oAuth = new OAuthBase();
		}
コード例 #7
0
		/// <summary>
		/// A Parameterless constructor. Defaults the consumer key and secret to string.Empty
		/// and the encryption method to HMAC-SHA1.
		/// </summary>
		public OAuthConsumer()
		{
			consumerKey = string.Empty;
			consumerSecret = string.Empty;
			signatureMethod = OAuthBase.SignatureTypes.HMACSHA1;
			oAuth = new OAuthBase();
		}
コード例 #8
0
ファイル: HomeController.cs プロジェクト: wingfay/studio
        /// <summary>
        /// Generates a signature using the specified signatureType
        /// </summary>
        /// <param name="url">The full url that needs to be signed including its non OAuth url parameters</param>
        /// <param name="consumerKey">The consumer key</param>
        /// <param name="consumerSecret">The consumer seceret</param>
        /// <param name="token">The token, if available. If not available pass null or an empty string</param>
        /// <param name="tokenSecret">The token secret, if available. If not available pass null or an empty string</param>
        /// <param name="httpMethod">The http method used. Must be a valid HTTP method verb (POST,GET,PUT, etc)</param>
        /// <param name="signatureType">The type of signature to use</param>
        /// <returns>A base64 string of the hash value</returns>
        public string BuildOAuth(string url, string consumerKey, string consumerSecret, string token, string tokenSecret, HttpMethod httpMethod
                                 , string timeStamp, string nonce, SignatureTypes signatureType)
        {
            OAuthBase oAuthBase     = new OAuthBase();
            string    normalizedUrl = string.Empty;
            string    normalizedRequestParameters = string.Empty;

            OAuthBase.SignatureTypes OAuthBaseSignatureTypes = OAuthBase.SignatureTypes.PLAINTEXT;

            if (signatureType == SignatureTypes.HMACSHA1)
            {
                OAuthBaseSignatureTypes = OAuthBase.SignatureTypes.HMACSHA1;
            }


            string oauth_signature = oAuthBase.GenerateSignature(new Uri(url), consumerKey, consumerSecret
                                                                 , token, tokenSecret, httpMethod.ToString(), timeStamp, nonce, OAuthBaseSignatureTypes, string.Empty, out normalizedUrl, out normalizedRequestParameters);



            return(oAuthBase.Header(new Uri(url), consumerKey, token, timeStamp, nonce, OAuthBaseSignatureTypes, string.Empty, oauth_signature));
        }