Class: SignatureUtils
- Inherits:
-
Object
- Object
- SignatureUtils
- Defined in:
- lib/aspmarketplace/signature_utils.rb
Overview
Copyright 2008 Amazon Technologies, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
You may not use this file except in compliance with the License.
You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
Constant Summary collapse
- SIGNATURE_KEYNAME =
"signature"
- HMAC_SHA256_ALGORITHM =
"HmacSHA256"
- HMAC_SHA1_ALGORITHM =
"HmacSHA1"
Class Method Summary collapse
- .sign_parameters(args) ⇒ Object
-
.urlencode(plaintext) ⇒ Object
Convert a string into URL encoded form.
Instance Method Summary collapse
Class Method Details
.sign_parameters(args) ⇒ Object
52 53 54 55 56 |
# File 'lib/aspmarketplace/signature_utils.rb', line 52 def self.sign_parameters(args) string_to_sign = ""; string_to_sign = calculate_string_to_sign_v2(args) return compute_signature(string_to_sign, args[:aws_secret_key],get_algorithm(args[:algorithm])) end |
.urlencode(plaintext) ⇒ Object
Convert a string into URL encoded form.
59 60 61 |
# File 'lib/aspmarketplace/signature_utils.rb', line 59 def self.urlencode(plaintext) CGI.escape(plaintext.to_s).gsub("+", "%20").gsub("%7E", "~") end |
Instance Method Details
#authentic?(args, signature, secret_key = Service.secret_key) ⇒ Boolean
46 47 48 49 50 |
# File 'lib/aspmarketplace/signature_utils.rb', line 46 def authentic?(args, signature, secret_key = Service.secret_key) string_to_sign = ""; string_to_sign = calculate_string_to_sign_v2(args) return signature == compute_signature(string_to_sign, secret_key) end |