Class: Carioca::Services::SecureStore
- Inherits:
-
Object
- Object
- Carioca::Services::SecureStore
- Extended by:
- Injector
- Defined in:
- lib/carioca/services/securestore.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
Instance Method Summary collapse
- #init! ⇒ Object
-
#initialize(storefile: Carioca::Registry.config.secure_store_file, keyfile: Carioca::Registry.config.master_key_file) ⇒ SecureStore
constructor
A new instance of SecureStore.
- #initialized? ⇒ Boolean
- #save! ⇒ Object
Methods included from Injector
active_services, add, create_methods, extended, inject, services
Constructor Details
#initialize(storefile: Carioca::Registry.config.secure_store_file, keyfile: Carioca::Registry.config.master_key_file) ⇒ SecureStore
Returns a new instance of SecureStore.
13 14 15 16 17 18 19 20 21 |
# File 'lib/carioca/services/securestore.rb', line 13 def initialize(storefile: Carioca::Registry.config.secure_store_file, keyfile: Carioca::Registry.config.master_key_file) [storefile, keyfile].map { |file| File.dirname(file) }.each do |path| setup.make_folder path: File.(path), mode: '400' unless sanitycheck.verify_folder name: path end @storefile = File.(storefile) @keyfile = File.(keyfile) init! unless initialized? @data = decrypt end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
6 7 8 |
# File 'lib/carioca/services/securestore.rb', line 6 def data @data end |
Instance Method Details
#init! ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/carioca/services/securestore.rb', line 31 def init! path = File.dirname(@storefile) FileUtils.mkdir_p path generate_key init_data = {} encrypt(init_data) logger.warn(to_s) { 'Secure Store initialized' } end |
#initialized? ⇒ Boolean
23 24 25 |
# File 'lib/carioca/services/securestore.rb', line 23 def initialized? File.exist?(@storefile) && File.exist?(@keyfile) end |
#save! ⇒ Object
27 28 29 |
# File 'lib/carioca/services/securestore.rb', line 27 def save! encrypt(@data) end |