Class: RightAws::AwsUtils
Overview
:nodoc:
Constant Summary collapse
- @@digest =
OpenSSL::Digest::Digest.new("sha1")
Class Method Summary collapse
- .allow_only(allowed_keys, params) ⇒ Object
- .caller_method ⇒ Object
- .mandatory_arguments(required_args, params) ⇒ Object
- .sign(aws_secret_access_key, auth_string) ⇒ Object
-
.URLencode(raw) ⇒ Object
From Amazon’s SQS Dev Guide, a brief description of how to escape: “URL encode the computed signature and other query parameters as specified in RFC1738, section 2.2.
Class Method Details
.allow_only(allowed_keys, params) ⇒ Object
49 50 51 52 53 |
# File 'lib/awsbase/right_awsbase.rb', line 49 def self.allow_only(allowed_keys, params) bogus_args = [] params.keys.each {|p| bogus_args.push(p) unless allowed_keys.include?(p) } raise AwsError.new("The following arguments were given but are not legal for the function call #{caller_method}: #{bogus_args.inspect}") if bogus_args.length > 0 end |
.caller_method ⇒ Object
61 62 63 64 |
# File 'lib/awsbase/right_awsbase.rb', line 61 def self.caller_method caller[1]=~/`(.*?)'/ $1 end |
.mandatory_arguments(required_args, params) ⇒ Object
55 56 57 58 59 |
# File 'lib/awsbase/right_awsbase.rb', line 55 def self.mandatory_arguments(required_args, params) rargs = required_args.dup params.keys.each {|p| rargs.delete(p)} raise AwsError.new("The following mandatory arguments were not provided to #{caller_method}: #{rargs.inspect}") if rargs.length > 0 end |
.sign(aws_secret_access_key, auth_string) ⇒ Object
31 32 33 |
# File 'lib/awsbase/right_awsbase.rb', line 31 def self.sign(aws_secret_access_key, auth_string) Base64.encode64(OpenSSL::HMAC.digest(@@digest, aws_secret_access_key, auth_string)).strip end |
.URLencode(raw) ⇒ Object
From Amazon’s SQS Dev Guide, a brief description of how to escape: “URL encode the computed signature and other query parameters as specified in RFC1738, section 2.2. In addition, because the + character is interpreted as a blank space by Sun Java classes that perform URL decoding, make sure to encode the + character although it is not required by RFC1738.” Avoid using CGI::escape to escape URIs. CGI::escape will escape characters in the protocol, host, and port sections of the URI. Only target chars in the query string should be escaped.
44 45 46 47 |
# File 'lib/awsbase/right_awsbase.rb', line 44 def self.URLencode(raw) e = URI.escape(raw) e.gsub(/\+/, "%2b") end |