C# Class Ramone.OAuth1.SignatureHelper

Show file Open project: JornWildt/Ramone Class Usage Examples

Protected Properties

Property Type Description
random System.Random

Public Methods

Method Description
ComputeHash ( HashAlgorithm hashAlgorithm, string data ) : string

Helper function to compute a hash value

GenerateNonce ( ) : string

Generate a nonce

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

Generates a signature using the specified signatureType

GenerateSignatureBase ( Uri url, string consumerKey, string callback, string token, 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, HashAlgorithm hash ) : string

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

GenerateTimeStamp ( ) : string

Generate the timestamp for the signature

GetQueryParameters ( string query ) : List

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

NormalizeRequestParameters ( List parameters ) : string

Normalizes the request parameters according to the spec

SignatureHelper ( Ramone.OAuth1.OAuth1Settings settings, IOAuth1Logger logger ) : System
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

Protected Methods

Method Description
Log ( string message ) : void

Method Details

ComputeHash() public method

Helper function to compute a hash value
public ComputeHash ( HashAlgorithm hashAlgorithm, string data ) : string
hashAlgorithm System.Security.Cryptography.HashAlgorithm The hashing algorihtm used. If that algorithm needs some initialization, like HMAC and its derivatives, they should be initialized prior to passing it to this function
data string The data to hash
return string

GenerateNonce() public method

Generate a nonce
public GenerateNonce ( ) : string
return string

GenerateSignature() public method

Generates a signature using the specified signatureType
public GenerateSignature ( Uri url, string consumerKey, string consumerSecret, string callback, 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
callback string
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

GenerateSignatureBase() public method

Generate the signature base that is used to produce the signature
public GenerateSignatureBase ( Uri url, string consumerKey, string callback, string token, 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
callback string OAuth callback value.
token string The token, 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, HashAlgorithm hash ) : string
signatureBase string The signature based as produced by the GenerateSignatureBase method or by any other means
hash System.Security.Cryptography.HashAlgorithm 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 string

GenerateTimeStamp() public method

Generate the timestamp for the signature
public GenerateTimeStamp ( ) : string
return string

GetQueryParameters() public method

Internal function to cut out all non oauth query string parameters (all parameters not begining with "oauth_")
public GetQueryParameters ( string query ) : List
query string The query string part of the Url
return List

Log() protected method

protected Log ( string message ) : void
message string
return void

NormalizeRequestParameters() public method

Normalizes the request parameters according to the spec
public NormalizeRequestParameters ( List parameters ) : string
parameters List The list of parameters already sorted
return string

SignatureHelper() public method

public SignatureHelper ( Ramone.OAuth1.OAuth1Settings settings, IOAuth1Logger logger ) : System
settings Ramone.OAuth1.OAuth1Settings
logger IOAuth1Logger
return System

UrlEncode() public static method

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
public static UrlEncode ( string value ) : string
value string The value to Url encode
return string

Property Details

random protected property

protected Random,System random
return System.Random