Class: Auric::Vault::Door
- Inherits:
-
Object
- Object
- Auric::Vault::Door
- Defined in:
- lib/auric/vault/door.rb,
lib/auric/vault/door/version.rb
Defined Under Namespace
Classes: DecryptionError, EncryptionError
Constant Summary collapse
- SANDBOXURLS =
['https://vault01-sb.auricsystems.com/vault/v2/', 'https://vault02-sb.auricsystems.com/vault/v2/']
- PRODUCTIONURLS =
['https://vault01.auricsystems.com/vault/v2/', 'https://vault02.auricsystems.com/vault/v2/']
- VERSION =
"0.0.6"
Instance Attribute Summary collapse
-
#config_id ⇒ Object
Returns the value of attribute config_id.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#mtid ⇒ Object
Returns the value of attribute mtid.
-
#production ⇒ Object
Returns the value of attribute production.
-
#secret ⇒ Object
Returns the value of attribute secret.
-
#segment ⇒ Object
Returns the value of attribute segment.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
Instance Method Summary collapse
- #decrypt(token) ⇒ Object
- #encrypt(data) ⇒ Object
-
#initialize(args) ⇒ Door
constructor
A new instance of Door.
Constructor Details
#initialize(args) ⇒ Door
Returns a new instance of Door.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/auric/vault/door.rb', line 17 def initialize(args) required_args = [:secret, :mtid, :config_id] required_args.each do |arg| raise ArgumentError, "Required argument: (#{arg}) not provided" unless args.include?(arg) end @secret = args[:secret] @mtid = args[:mtid] @config_id = args[:config_id] @production = args[:production] || false @segment = args[:segment] @success = false @error = nil if @production @url = PRODUCTIONURLS else @url = SANDBOXURLS end end |
Instance Attribute Details
#config_id ⇒ Object
Returns the value of attribute config_id.
12 13 14 |
# File 'lib/auric/vault/door.rb', line 12 def config_id @config_id end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
13 14 15 |
# File 'lib/auric/vault/door.rb', line 13 def error @error end |
#mtid ⇒ Object
Returns the value of attribute mtid.
12 13 14 |
# File 'lib/auric/vault/door.rb', line 12 def mtid @mtid end |
#production ⇒ Object
Returns the value of attribute production.
12 13 14 |
# File 'lib/auric/vault/door.rb', line 12 def production @production end |
#secret ⇒ Object
Returns the value of attribute secret.
12 13 14 |
# File 'lib/auric/vault/door.rb', line 12 def secret @secret end |
#segment ⇒ Object
Returns the value of attribute segment.
12 13 14 |
# File 'lib/auric/vault/door.rb', line 12 def segment @segment end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
13 14 15 |
# File 'lib/auric/vault/door.rb', line 13 def success @success end |
Instance Method Details
#decrypt(token) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/auric/vault/door.rb', line 46 def decrypt(token) json = get_data('decrypt', token) if @success return json['result']['plaintextValue'] else @error = json['error'] raise DecryptionError, @error end end |
#encrypt(data) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/auric/vault/door.rb', line 36 def encrypt(data) json = post_data('encrypt', data) if @success return json['result']['token'] else @error = json['error'] raise EncryptionError, @error end end |