Module: Aliyun::STS::Util
- Extended by:
- Common::Logging
- Defined in:
- lib/aliyun/sts/util.rb
Overview
Util functions to help generate formatted Date, signatures, etc.
Constant Summary
Constants included from Common::Logging
Common::Logging::MAX_NUM_LOG, Common::Logging::ROTATE_SIZE
Class Method Summary collapse
-
.get_signature(verb, params, key) ⇒ Object
Calculate request signatures.
-
.sign(key, string_to_sign) ⇒ String
Sign a string using HMAC and BASE64.
Methods included from Common::Logging
logger, set_log_file, set_log_level
Class Method Details
.get_signature(verb, params, key) ⇒ Object
Calculate request signatures
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/aliyun/sts/util.rb', line 22 def get_signature(verb, params, key) logger.debug("Sign, verb: #{verb}, params: #{params}") cano_query = params.sort.map { |k, v| [CGI.escape(k), CGI.escape(v)].join('=') }.join('&') string_to_sign = verb + '&' + CGI.escape('/') + '&' + CGI.escape(cano_query) logger.debug("String to sign: #{string_to_sign}") Util.sign(key + '&', string_to_sign) end |
.sign(key, string_to_sign) ⇒ String
Sign a string using HMAC and BASE64
40 41 42 43 |
# File 'lib/aliyun/sts/util.rb', line 40 def sign(key, string_to_sign) Base64.strict_encode64( OpenSSL::HMAC.digest('sha1', key, string_to_sign)) end |