Class: Keen::ScopedKey
- Inherits:
-
Object
- Object
- Keen::ScopedKey
- Defined in:
- lib/keen/scoped_key.rb
Overview
DEPRECATED: Please use access keys
instead.
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#data ⇒ Object
Returns the value of attribute data.
Class Method Summary collapse
Instance Method Summary collapse
- #encrypt!(iv = nil) ⇒ Object
-
#initialize(api_key, data) ⇒ ScopedKey
constructor
A new instance of ScopedKey.
Constructor Details
#initialize(api_key, data) ⇒ ScopedKey
Returns a new instance of ScopedKey.
24 25 26 27 |
# File 'lib/keen/scoped_key.rb', line 24 def initialize(api_key, data) self.api_key = api_key self.data = data end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
9 10 11 |
# File 'lib/keen/scoped_key.rb', line 9 def api_key @api_key end |
#data ⇒ Object
Returns the value of attribute data.
10 11 12 |
# File 'lib/keen/scoped_key.rb', line 10 def data @data end |
Class Method Details
.decrypt!(api_key, scoped_key) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/keen/scoped_key.rb', line 13 def decrypt!(api_key, scoped_key) if api_key.length == 64 decrypted = Keen::AESHelper.aes256_decrypt(api_key, scoped_key) else decrypted = Keen::AESHelperOld.aes256_decrypt(api_key, scoped_key) end data = MultiJson.load(decrypted) self.new(api_key, data) end |
Instance Method Details
#encrypt!(iv = nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/keen/scoped_key.rb', line 29 def encrypt!(iv = nil) warn "[DEPRECATION] Scoped keys are deprecated. Please use `access_keys` instead." json_str = MultiJson.dump(self.data) if self.api_key.length == 64 Keen::AESHelper.aes256_encrypt(self.api_key, json_str, iv) else Keen::AESHelperOld.aes256_encrypt(self.api_key, json_str, iv) end end |