Class: Nifcloud::Auth
- Inherits:
-
Object
- Object
- Nifcloud::Auth
- Defined in:
- lib/nifcloud/auth.rb
Direct Known Subclasses
Constant Summary collapse
- ALGORITHM =
'HmacSHA1'
Instance Attribute Summary collapse
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
-
#initialize(access_key, secret_key) ⇒ Auth
constructor
A new instance of Auth.
- #signature_header ⇒ Object
Constructor Details
#initialize(access_key, secret_key) ⇒ Auth
Returns a new instance of Auth.
9 10 11 12 |
# File 'lib/nifcloud/auth.rb', line 9 def initialize(access_key, secret_key) @access_key = access_key || ENV['ACCESS_KEY'] @secret_key = secret_key || ENV['SECRET_KEY'] end |
Instance Attribute Details
#time ⇒ Object (readonly)
Returns the value of attribute time.
21 22 23 |
# File 'lib/nifcloud/auth.rb', line 21 def time @time end |
Instance Method Details
#signature_header ⇒ Object
14 15 16 17 18 19 |
# File 'lib/nifcloud/auth.rb', line 14 def signature_header @time = Time.now.httpdate hmac = HMAC::SHA1.new(@secret_key).update(@time) signature = Base64.encode64("#{hmac.digest}") "NIFTY3-HTTPS NiftyAccessKeyId=#{@access_key},Algorithm=#{ALGORITHM},Signature=#{signature.chomp}" end |