Parent

Class Index [+]

Quicksearch

Vuzit::Service

Global data class.

Public Class Methods

debug() click to toggle source

Returns whether debugging is turned on or off.

# File lib/vuzitruby/service.rb, line 92
    def self.debug
      @@debug
    end
debug=(value) click to toggle source

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
get_signature(service, id = '', time = nil) click to toggle source

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
private_key() click to toggle source

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
private_key=(value) click to toggle source

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
public_key() click to toggle source

Returns the Vuzit public API key

# File lib/vuzitruby/service.rb, line 59
    def self.public_key
      @@public_key
    end
public_key=(value) click to toggle source

Sets the Vuzit public API key

# File lib/vuzitruby/service.rb, line 54
    def self.public_key=(value)
      @@public_key = value
    end
service_url() click to toggle source

Returns the URL of the Vuzit web service.

# File lib/vuzitruby/service.rb, line 81
    def self.service_url
      @@service_url
    end
service_url=(value) click to toggle source

Sets the URL of the Vuzit web service. This only needs to be changed if you are running Vuzit Enterprise on your own server. The default value is “vuzit.com

# File lib/vuzitruby/service.rb, line 76
    def self.service_url=(value)
      @@service_url = value
    end

Private Class Methods

hmac_sha1(key, s) click to toggle source

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.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.