Class: Battlenet::Authentication
- Inherits:
-
Object
- Object
- Battlenet::Authentication
- Defined in:
- lib/battlenet/authentication.rb
Instance Method Summary collapse
-
#initialize(private) ⇒ Authentication
constructor
A new instance of Authentication.
- #sign(verb, path, time) ⇒ Object
- #string_to_sign(verb, path, time) ⇒ Object
Constructor Details
#initialize(private) ⇒ Authentication
Returns a new instance of Authentication.
7 8 9 |
# File 'lib/battlenet/authentication.rb', line 7 def initialize(private) @private = private end |
Instance Method Details
#sign(verb, path, time) ⇒ Object
11 12 13 14 15 |
# File 'lib/battlenet/authentication.rb', line 11 def sign(verb, path, time) string = string_to_sign(verb, path, time) signature = OpenSSL::HMAC.digest 'sha1', @private, string Base64.encode64 signature end |
#string_to_sign(verb, path, time) ⇒ Object
17 18 19 |
# File 'lib/battlenet/authentication.rb', line 17 def string_to_sign(verb, path, time) "#{verb.to_s.upcase}\n#{time.httpdate}\n#{path}\n" end |