Class: Moguera::Authentication::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/moguera/authentication/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_key:, secret_access_key:, request_path:, request_method:, http_date:, content_type:) ⇒ Request

Returns a new instance of Request.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/moguera/authentication/request.rb', line 6

def initialize(access_key:, secret_access_key:, request_path:, request_method:, http_date:, content_type:)
  require 'time'
  require 'openssl'
  require 'base64'

  @access_key = access_key
  @secret_access_key = secret_access_key
  @request_path = request_path
  @request_method = request_method
  @http_date = http_date
  @content_type = content_type

  @token_prefix = token_prefix || 'MOGUERA'

  validate_parameter!
end

Instance Attribute Details

#access_keyObject (readonly)

Returns the value of attribute access_key.



23
24
25
# File 'lib/moguera/authentication/request.rb', line 23

def access_key
  @access_key
end

#content_typeObject (readonly)

Returns the value of attribute content_type.



23
24
25
# File 'lib/moguera/authentication/request.rb', line 23

def content_type
  @content_type
end

#http_dateObject (readonly)

Returns the value of attribute http_date.



23
24
25
# File 'lib/moguera/authentication/request.rb', line 23

def http_date
  @http_date
end

#request_methodObject (readonly)

Returns the value of attribute request_method.



23
24
25
# File 'lib/moguera/authentication/request.rb', line 23

def request_method
  @request_method
end

#request_pathObject (readonly)

Returns the value of attribute request_path.



23
24
25
# File 'lib/moguera/authentication/request.rb', line 23

def request_path
  @request_path
end

#secret_access_keyObject (readonly)

Returns the value of attribute secret_access_key.



23
24
25
# File 'lib/moguera/authentication/request.rb', line 23

def secret_access_key
  @secret_access_key
end

#token_prefixObject

Returns the value of attribute token_prefix.



4
5
6
# File 'lib/moguera/authentication/request.rb', line 4

def token_prefix
  @token_prefix
end

Instance Method Details

#tokenObject

Raises:



26
27
28
29
30
# File 'lib/moguera/authentication/request.rb', line 26

def token
  raise ParameterInvalid, 'Token prefix required.' if @token_prefix.nil?

  @token_prefix + ' ' + @access_key + ':' + signature
end