Class: Rubizon::SecurityCredentials
- Inherits:
-
Object
- Object
- Rubizon::SecurityCredentials
- Defined in:
- lib/rubizon/security_credentials.rb
Instance Attribute Summary collapse
-
#accessID ⇒ Object
readonly
Returns the value of attribute accessID.
Instance Method Summary collapse
-
#initialize(accessID, secretID) ⇒ SecurityCredentials
constructor
A new instance of SecurityCredentials.
- #sign(signature_method, string_to_sign) ⇒ Object
- #sign256(string_to_sign) ⇒ Object
Constructor Details
#initialize(accessID, secretID) ⇒ SecurityCredentials
Returns a new instance of SecurityCredentials.
7 8 9 10 |
# File 'lib/rubizon/security_credentials.rb', line 7 def initialize(accessID, secretID) @accessID= accessID @secretID= secretID end |
Instance Attribute Details
#accessID ⇒ Object (readonly)
Returns the value of attribute accessID.
6 7 8 |
# File 'lib/rubizon/security_credentials.rb', line 6 def accessID @accessID end |
Instance Method Details
#sign(signature_method, string_to_sign) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/rubizon/security_credentials.rb', line 16 def sign(signature_method,string_to_sign) case signature_method when 'HmacSHA256' sign256(string_to_sign) else raise UnsupportedSignatureMethodError, "The #{signature_method} signature method is not supported" end end |
#sign256(string_to_sign) ⇒ Object
11 12 13 14 15 |
# File 'lib/rubizon/security_credentials.rb', line 11 def sign256(string_to_sign) @hmac256||= HMAC::SHA256.new(@secretID) @hmac256.update(string_to_sign) Base64.encode64(@hmac256.digest).chomp end |