Object
Global data class.
Returns whether debugging is turned on or off.
# File lib/vuzitruby/service.rb, line 92 def self.debug @@debug end
Switch this to true if you would like to see debug messages in the output.
# File lib/vuzitruby/service.rb, line 87 def self.debug=(value) @@debug = value end
Returns The signature string. NOTE: If you are going to use this with the Vuzit Javascript API then the value must be encoded with the CGI.escape function. See the Wiki example for more information:
http://wiki.github.com/vuzit/vuzitruby/code-samples
Example:
timestamp = Time.now
sig = Vuzit::Service.get_signature("show", "DOCUMENT_ID", timestamp)
# File lib/vuzitruby/service.rb, line 106 def self.get_signature(service, id = '', time = nil) if Vuzit::Service.public_key == nil || Vuzit::Service.private_key == nil raise Vuzit::Exception.new("The public_key or private_key variables are nil") end time = (time == nil) ? Time.now.to_i : time.to_i if @@public_key == nil raise Vuzit::Exception.new("Vuzit::Service.public_key not set") end if @@private_key == nil raise Vuzit::Exception.new("Vuzit::Service.private_key not set") end msg = "#{service}#{id}#{@@public_key}#{time}" hmac = hmac_sha1(@@private_key, msg) result = Base64::encode64(hmac).chomp return result end
Returns the Vuzit private API key. Do NOT share this with anyone!
# File lib/vuzitruby/service.rb, line 69 def self.private_key @@private_key end
Sets Vuzit private API key. Do NOT share this with anyone!
# File lib/vuzitruby/service.rb, line 64 def self.private_key=(value) @@private_key = value end
Returns the Vuzit public API key
# File lib/vuzitruby/service.rb, line 59 def self.public_key @@public_key end
Sets the Vuzit public API key
# File lib/vuzitruby/service.rb, line 54 def self.public_key=(value) @@public_key = value end
Returns the URL of the Vuzit web service.
# File lib/vuzitruby/service.rb, line 81 def self.service_url @@service_url end
Creates the SHA1 key.
# File lib/vuzitruby/service.rb, line 130 def self.hmac_sha1(key, s) ipad = [].fill(0x36, 0, 64) opad = [].fill(0x5C, 0, 64) key = key.unpack("C*") key += [].fill(0, 0, 64-key.length) if key.length < 64 inner = [] 64.times { |i| inner.push(key[i] ^ ipad[i]) } inner += s.unpack("C*") outer = [] 64.times { |i| outer.push(key[i] ^ opad[i]) } outer = outer.pack("c*") outer += Digest::SHA1.digest(inner.pack("c*")) return Digest::SHA1.digest(outer) end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.