Module: AWS::Core::Signature::Version2

Included in:
AutoScaling::Request, EC2::Request, ELB::Request, SNS::Request, SQS::Request, SimpleDB::Request
Defined in:
lib/aws/core/signature/version_2.rb

Instance Method Summary collapse

Instance Method Details

#add_authorization!(signer) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/aws/core/signature/version_2.rb', line 19

def add_authorization! signer
  self.access_key_id = signer.access_key_id
  add_param('AWSAccessKeyId', access_key_id)
  if signer.respond_to?(:session_token) and token = signer.session_token
    add_param("SecurityToken", token)
  end
  add_param('SignatureVersion', '2')
  add_param('SignatureMethod', 'HmacSHA256')
  add_param('Signature', signer.sign(string_to_sign))
end

#string_to_signObject



30
31
32
33
34
35
36
37
# File 'lib/aws/core/signature/version_2.rb', line 30

def string_to_sign
  [
    http_method,
    host,
    path,
    params.sort.collect { |p| p.encoded }.join('&'),
  ].join("\n")
end