Class: AWS::Core::DefaultSigner
- Inherits:
-
Object
- Object
- AWS::Core::DefaultSigner
- Defined in:
- lib/aws/core/default_signer.rb
Overview
Computes signatures using credentials that are stored in memory.
Instance Attribute Summary collapse
-
#access_key_id ⇒ String
readonly
The Access Key ID used to sign requests.
-
#secret_access_key ⇒ String
readonly
The Secret Access Key used to sign requests.
-
#session_token ⇒ String
readonly
The Session Token used to sign requests.
Instance Method Summary collapse
-
#initialize(access_key_id, secret_access_key, session_token = nil) ⇒ DefaultSigner
constructor
A new instance of DefaultSigner.
-
#sign(string_to_sign, digest_method = 'sha256') ⇒ Object
Signs a string using the credentials stored in memory.
Constructor Details
#initialize(access_key_id, secret_access_key, session_token = nil) ⇒ DefaultSigner
Returns a new instance of DefaultSigner.
41 42 43 44 45 46 47 48 49 |
# File 'lib/aws/core/default_signer.rb', line 41 def initialize(access_key_id, secret_access_key, session_token = nil) @access_key_id = access_key_id @secret_access_key = secret_access_key @session_token = session_token raise "Missing credentials" unless access_key_id and secret_access_key end |
Instance Attribute Details
#access_key_id ⇒ String (readonly)
Returns The Access Key ID used to sign requests.
24 25 26 |
# File 'lib/aws/core/default_signer.rb', line 24 def access_key_id @access_key_id end |
#secret_access_key ⇒ String (readonly)
Returns The Secret Access Key used to sign requests.
27 28 29 |
# File 'lib/aws/core/default_signer.rb', line 27 def secret_access_key @secret_access_key end |
#session_token ⇒ String (readonly)
Returns The Session Token used to sign requests.
30 31 32 |
# File 'lib/aws/core/default_signer.rb', line 30 def session_token @session_token end |
Instance Method Details
#sign(string_to_sign, digest_method = 'sha256') ⇒ Object
Signs a string using the credentials stored in memory.
57 58 59 60 61 62 63 |
# File 'lib/aws/core/default_signer.rb', line 57 def sign(string_to_sign, digest_method = 'sha256') Base64.encode64( OpenSSL::HMAC.digest( OpenSSL::Digest::Digest.new(digest_method), secret_access_key, string_to_sign)).strip end |