class HMAC

Public Instance Methods

get_auth_credentials(uid, secret, method, url, rfc1123date, body) click to toggle source
# File lib/hmac.rb, line 30
def get_auth_credentials(uid, secret, method, url, rfc1123date, body)
        signature = get_signature(secret,method,url,rfc1123date,body)
        if !signature.empty?
                output = "#{GAAS_SCHEME_STRING} #{uid}#{SEPARATOR}#{signature}"
                return output
        end
end
get_rfc1123_date() click to toggle source
# File lib/hmac.rb, line 48
def get_rfc1123_date
        Time.now.httpdate
end
get_signature(secret,method,url,rfc1123date,body) click to toggle source
# File lib/hmac.rb, line 38
def get_signature(secret,method,url,rfc1123date,body)
        secret.encode(ENCODING)
        
        key = "#{method.encode(ENCODING)}\n#{url.encode(ENCODING)}\n#{rfc1123date.encode(ENCODING)}\n#{body.encode(ENCODING)}"
        
        digest = OpenSSL::Digest.new(SHA1_STRING)
        hex_string = OpenSSL::HMAC.digest(digest,secret,key)
        return Base64.encode64(hex_string)
end