Class: Ralexa::UriSigner

Inherits:
Object
  • Object
show all
Defined in:
lib/ralexa/uri_signer.rb

Constant Summary collapse

SIGNATURE_VERSION =
2

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_key_id, secret_access_key) ⇒ UriSigner

Returns a new instance of UriSigner.



10
11
12
13
# File 'lib/ralexa/uri_signer.rb', line 10

def initialize(access_key_id, secret_access_key)
  @access_key_id = access_key_id
  @secret_access_key = secret_access_key
end

Instance Attribute Details

#base64_encoder=(value) ⇒ Object

Sets the attribute base64_encoder

Parameters:

  • value

    the value to set the attribute base64_encoder to.



18
19
20
# File 'lib/ralexa/uri_signer.rb', line 18

def base64_encoder=(value)
  @base64_encoder = value
end

#digest=(value) ⇒ Object

dependency injectors



16
17
18
# File 'lib/ralexa/uri_signer.rb', line 16

def digest=(value)
  @digest = value
end

#hmac_signer=(value) ⇒ Object

Sets the attribute hmac_signer

Parameters:

  • value

    the value to set the attribute hmac_signer to.



17
18
19
# File 'lib/ralexa/uri_signer.rb', line 17

def hmac_signer=(value)
  @hmac_signer = value
end

#time_utc=(value) ⇒ Object

Sets the attribute time_utc

Parameters:

  • value

    the value to set the attribute time_utc to.



19
20
21
# File 'lib/ralexa/uri_signer.rb', line 19

def time_utc=(value)
  @time_utc = value
end

Instance Method Details

#sign_uri(original_uri) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ralexa/uri_signer.rb', line 21

def sign_uri(original_uri)
  original_uri.dup.tap do |uri|
    add_query_values(uri,
      "AWSAccessKeyId" => @access_key_id,
      "Timestamp" => timestamp,
      "SignatureVersion" => SIGNATURE_VERSION.to_s,
      "SignatureMethod" => signature_method,
    )
    add_query_values(uri,
      "Signature" => signature(uri)
    )
  end
end