Class: Aliyun::OSS::Authentication::CanonicalString

Inherits:
String
  • Object
show all
Defined in:
lib/aliyun/oss/authentication.rb

Overview

The CanonicalString is used to generate an encrypted signature, signed with your secrect access key. It is composed of data related to the given request for which it provides authentication. This data includes the request method, request headers, and the request path. Both Header and QueryString use it to generate their signature.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from String

#previous, #previous!, #remove_extended, #remove_extended!, #tap, #to_header, #underscore, #valid_utf8?

Constructor Details

#initialize(request, options = {}) ⇒ CanonicalString

Returns a new instance of CanonicalString.



152
153
154
155
156
157
158
159
160
161
162
# File 'lib/aliyun/oss/authentication.rb', line 152

def initialize(request, options = {})
  super()
  @request = request
  @headers = {}
  @options = options
  # "For non-authenticated or anonymous requests. A NotImplemented error result code will be returned if 
  # an authenticated (signed) request specifies a Host: header other than 'oss.aliyuncs.com'"
  # (from http://docs.aliyunwebservices.com/AliyunOSS/2006-03-01/VirtualHosting.html)
  request['Host'] = DEFAULT_HOST
  build
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



150
151
152
# File 'lib/aliyun/oss/authentication.rb', line 150

def headers
  @headers
end

#requestObject (readonly)

Returns the value of attribute request.



150
151
152
# File 'lib/aliyun/oss/authentication.rb', line 150

def request
  @request
end

Class Method Details

.aliyun_header_prefixObject



145
146
147
# File 'lib/aliyun/oss/authentication.rb', line 145

def aliyun_header_prefix
  /^#{OSS_HEADER_PREFIX}/io
end

.default_headersObject



137
138
139
# File 'lib/aliyun/oss/authentication.rb', line 137

def default_headers
  %w(content-type content-md5)
end

.interesting_headersObject



141
142
143
# File 'lib/aliyun/oss/authentication.rb', line 141

def interesting_headers
  ['content-md5', 'content-type', 'date', aliyun_header_prefix]
end