- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
Class ::xo::oauth::Signature
::xo::oauth::Signature create ... \
[ -base_string_uri base_string_uri ] \
[ -client_secret client_secret ] \
[ -request_method (default "POST") ] \
[ -signature_parameters signature_parameters ] \
[ -token_secret (default "") ]
Defined in
Class Relations
::xotcl::Class create ::xo::oauth::Signature \ -superclass ::xotcl::ObjectMethods (to be applied on the object)
base_string_from_url (scripted, public)
xo::oauth::Signature base_string_from_url uriThis procedure transforms a given URL into a format that is conformant to "http://tools.ietf.org/html/rfc5849#section-3.4.1.2". Most importantly, it strips any query part from the URL.
- Parameters:
- uri (required)
- Testcases:
- No testcase defined.
set info [uri::split $uri] set base_string_uri [uri::join scheme [dict get $info scheme] host [dict get $info host] port [dict get $info port] path [dict get $info path]] return $base_string_uriMethods (to be applied on instances)
base_string_uri (setter)
client_secret (setter)
construct_base_string (scripted)
# @see http://tools.ietf.org/html/rfc3986#section-3.1 append sbs [:encode [string toupper [:request_method]]] append sbs "&" append sbs [:encode [:base_string_uri]] append sbs "&" append sbs [:normalize_parameters] #:log "Signature Base String:\n$sbs" return $sbsencode (scripted, public)
<instance of xo::oauth::Signature> encode s
- Parameters:
- s (required)
- See Also:
- Testcases:
- No testcase defined.
#return [::xowiki::utility urlencode $s] return [::xo::oauth::utility urlencode $s]generate (scripted)
set signature [ns_crypto::hmac string -binary -digest sha1 -encoding base64 [:encode ${:client_secret}]&[:encode ${:token_secret}] [:construct_base_string] ] return $signaturenormalize_parameters (scripted)
set parameter_pair_list [:signature_parameters] set encoded_parameter_pair_list {} foreach pair $parameter_pair_list { lassign $pair key value if {[string match "*secret" $key]} continue lappend encoded_parameter_pair_list [list [:encode $key] [:encode $value]] } #ns_log notice "encoded_parameter_pair_list $encoded_parameter_pair_list" foreach pair $encoded_parameter_pair_list { lassign $pair key value lappend concatenated_parameter_list [list ${key}=${value}] } # Note: OAuth requires the parameters to be sorted first by name and then, # if two parameters have the same name, by value. So instead of sorting # twice here, we just sort the concatenated value (e.g. a=b) as a whole. # I hope I have no error in reasoning here... # set sorted_parameter_pair_list [lsort -index 0 $encoded_parameter_pair_list] set sorted_concatenated_parameter_list [lsort $concatenated_parameter_list] #:log "Sorted Concatenated Parameters" #foreach pair $sorted_concatenated_parameter_list { # foreach {key value} $pair { # :log "Name: $key Value: $value" # } #} set normalized_parameters [join $sorted_concatenated_parameter_list &] set encoded_normalized_parameters [:encode $normalized_parameters] return $encoded_normalized_parametersrequest_method (setter)
signature_parameters (setter)
token_secret (setter)
- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables