Class: AceClient::Base3
Instance Attribute Summary collapse
-
#sampler ⇒ Object
Returns the value of attribute sampler.
-
#signature_method ⇒ Object
TODO: HMAC-SHA256 or HMAC-SHA1.
Attributes inherited from Base
#access_key_id, #endpoint, #http_method, #http_proxy, #last_response, #last_response_time, #secret_access_key, #use_ssl, #user_agent
Instance Method Summary collapse
- #create_signature ⇒ Object
- #date ⇒ Object
-
#initialize(options = {}) ⇒ Base3
constructor
A new instance of Base3.
- #string_to_sign ⇒ Object
Methods inherited from Base
#endpoint_url, #record_response, #set_http_proxy
Constructor Details
#initialize(options = {}) ⇒ Base3
Returns a new instance of Base3.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ace-client/base3.rb', line 13 def initialize(={}) super() @signature_method = [:signature_method] || 'HmacSHA256' @authorization_key = [:authorization_key] || 'authorization' @date_key = [:date_key] || 'x-date' @nonce_key = [:nonce_key] || 'x-amz-nonce' @authorization_prefix = [:authorization_prefix] || 'AWS3-HTTPS' @nonce = [:nonce] @sampler = [:sampler] @before_signature = [:before_signature] @before_request = [:before_request] end |
Instance Attribute Details
#sampler ⇒ Object
Returns the value of attribute sampler.
9 10 11 |
# File 'lib/ace-client/base3.rb', line 9 def sampler @sampler end |
#signature_method ⇒ Object
TODO: HMAC-SHA256 or HMAC-SHA1
8 9 10 |
# File 'lib/ace-client/base3.rb', line 8 def signature_method @signature_method end |
Instance Method Details
#create_signature ⇒ Object
27 28 29 30 |
# File 'lib/ace-client/base3.rb', line 27 def create_signature digest = OpenSSL::Digest::Digest.new(@signature_method.downcase.gsub(/hmac/, '')) Base64.encode64(OpenSSL::HMAC.digest(digest, secret_access_key, string_to_sign)).strip end |
#date ⇒ Object
36 37 38 |
# File 'lib/ace-client/base3.rb', line 36 def date @date ||= Time.now.utc.rfc822.gsub(/[\-\+]\d{4}$/, 'GMT') end |
#string_to_sign ⇒ Object
32 33 34 |
# File 'lib/ace-client/base3.rb', line 32 def string_to_sign @nonce ? date + @nonce : date end |