C# Class OAuth.OAuthBase

Mostrar archivo Open project: shiftkey/oauth-winrt Class Usage Examples

Public Methods

Method Description
GenerateSignature ( Uri url, string consumerKey, string consumerSecret, string token, string tokenSecret, string httpMethod, string timeStamp, string nonce, SignatureTypes signatureType, string &normalizedUrl, string &normalizedRequestParameters ) : string

Generates a signature using the specified signatureType

GenerateSignature ( Uri url, string consumerKey, string consumerSecret, string token, string tokenSecret, string httpMethod, string timeStamp, string nonce, string &normalizedUrl, string &normalizedRequestParameters ) : string

Generates a signature using the HMAC-SHA1 algorithm

GenerateSignatureBase ( Uri url, string consumerKey, string token, string tokenSecret, string httpMethod, string timeStamp, string nonce, string signatureType, string &normalizedUrl, string &normalizedRequestParameters ) : string

Generate the signature base that is used to produce the signature

GenerateSignatureUsingHash ( string signatureBase, CryptographicKey hash ) : Windows.Storage.Streams.IBuffer

Generate the signature value based on the given signature base and hash algorithm

Private Methods

Method Description
ComputeHash ( CryptographicKey hashAlgorithm, string data ) : Windows.Storage.Streams.IBuffer

Helper function to compute a hash value

GenerateNonce ( ) : string

Generate a nonce

GenerateTimeStamp ( ) : string

Generate the timestamp for the signature

GetQueryParameters ( string parameters ) : List

Internal function to cut out all non oauth query string parameters (all parameters not begining with "oauth_")

NormalizeRequestParameters ( IList parameters ) : string

Normalizes the request parameters according to the spec

UrlEncode ( string value ) : string

This is a different Url Encode implementation since the default .NET one outputs the percent encoding in lower case. While this is not a problem with the percent encoding spec, it is used in upper case throughout OAuth

Method Details

GenerateSignature() public method

Generates a signature using the specified signatureType
public GenerateSignature ( Uri url, string consumerKey, string consumerSecret, string token, string tokenSecret, string httpMethod, string timeStamp, string nonce, SignatureTypes signatureType, string &normalizedUrl, string &normalizedRequestParameters ) : string
url System.Uri The full url that needs to be signed including its non OAuth url parameters
consumerKey string The consumer key
consumerSecret string The consumer seceret
token string The token, if available. If not available pass null or an empty string
tokenSecret string The token secret, if available. If not available pass null or an empty string
httpMethod string The http method used. Must be a valid HTTP method verb (POST,GET,PUT, etc)
timeStamp string
nonce string
signatureType SignatureTypes The type of signature to use
normalizedUrl string
normalizedRequestParameters string
return string

GenerateSignature() public method

Generates a signature using the HMAC-SHA1 algorithm
public GenerateSignature ( Uri url, string consumerKey, string consumerSecret, string token, string tokenSecret, string httpMethod, string timeStamp, string nonce, string &normalizedUrl, string &normalizedRequestParameters ) : string
url System.Uri The full url that needs to be signed including its non OAuth url parameters
consumerKey string The consumer key
consumerSecret string The consumer seceret
token string The token, if available. If not available pass null or an empty string
tokenSecret string The token secret, if available. If not available pass null or an empty string
httpMethod string The http method used. Must be a valid HTTP method verb (POST,GET,PUT, etc)
timeStamp string
nonce string
normalizedUrl string
normalizedRequestParameters string
return string

GenerateSignatureBase() public method

Generate the signature base that is used to produce the signature
public GenerateSignatureBase ( Uri url, string consumerKey, string token, string tokenSecret, string httpMethod, string timeStamp, string nonce, string signatureType, string &normalizedUrl, string &normalizedRequestParameters ) : string
url System.Uri The full url that needs to be signed including its non OAuth url parameters
consumerKey string The consumer key
token string The token, if available. If not available pass null or an empty string
tokenSecret string The token secret, if available. If not available pass null or an empty string
httpMethod string The http method used. Must be a valid HTTP method verb (POST,GET,PUT, etc)
timeStamp string
nonce string
signatureType string The signature type. To use the default values use OAuthBase.SignatureTypes.
normalizedUrl string
normalizedRequestParameters string
return string

GenerateSignatureUsingHash() public method

Generate the signature value based on the given signature base and hash algorithm
public GenerateSignatureUsingHash ( string signatureBase, CryptographicKey hash ) : Windows.Storage.Streams.IBuffer
signatureBase string The signature based as produced by the GenerateSignatureBase method or by any other means
hash Windows.Security.Cryptography.Core.CryptographicKey The hash algorithm used to perform the hashing. If the hashing algorithm requires initialization or a key it should be set prior to calling this method
return Windows.Storage.Streams.IBuffer