Class: SafeDb::Init
Overview
The init use case initializes safe thus preparing it for the ability to lock secrets, unlock them, transport their keys and much more.
safe is a (glorified) placeholder. It takes things in now, keeps them safe and gives them back later, in a helpful manner.
Alternat Error Flows
An error will be thrown
-
if safe cannot create, extend, read or write the drive folder
-
if the domain is already in the configuration file
-
if domain has non alphanums, excl hyphens, underscores, @ symbols, periods
-
if domain does not begin or end with alphanums.
-
if non alpha-nums (excl at signs) appear consecutively
-
if no alpha-nums appear in the string
-
if the domain string’s length is less than 5
-
if “safedb.net” appears twice (or more) in a directory tree
Constant Summary
Constants inherited from UseCase
UseCase::APP_DIR_NAME, UseCase::COMMANDMENT, UseCase::ENV_VAR_KEY_NAME, UseCase::ENV_VAR_PREFIX_A, UseCase::ENV_VAR_PREFIX_B, UseCase::FILE_CONTENT_KEY, UseCase::FILE_KEY_PREFIX, UseCase::FILE_NAME_KEY
Instance Attribute Summary collapse
-
#base_path ⇒ Object
writeonly
Sets the attribute base_path.
-
#domain_name ⇒ Object
writeonly
Sets the attribute domain_name.
-
#password ⇒ Object
writeonly
Sets the attribute password.
Attributes inherited from UseCase
Instance Method Summary collapse
-
#execute ⇒ Object
The init use case prepares the safe so that you can open an envelope, put secrets into it and then seal (lock) it.
- #pre_validation ⇒ Object
Methods inherited from UseCase
#check_post_conditions, #check_pre_conditions, #cleanup, #config_directory, #config_file, #flow_of_events, #get_master_database, #initialize, #post_validation
Constructor Details
This class inherits a constructor from SafeDb::UseCase
Instance Attribute Details
#base_path=(value) ⇒ Object (writeonly)
Sets the attribute base_path
27 28 29 |
# File 'lib/usecase/init.rb', line 27 def base_path=(value) @base_path = value end |
#domain_name=(value) ⇒ Object (writeonly)
Sets the attribute domain_name
27 28 29 |
# File 'lib/usecase/init.rb', line 27 def domain_name=(value) @domain_name = value end |
#password=(value) ⇒ Object (writeonly)
Sets the attribute password
27 28 29 |
# File 'lib/usecase/init.rb', line 27 def password=(value) @password = value end |
Instance Method Details
#execute ⇒ Object
The init use case prepares the safe so that you can open an envelope, put secrets into it and then seal (lock) it. Locking effectively writes crypted blocks to both keystore and crypt store.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/usecase/init.rb', line 33 def execute return unless ops_key_exists? KeyApi.init_app_domain( @domain_name, @base_path ) keys_setup = KeyApi.is_domain_keys_setup?( @domain_name ) if ( keys_setup ) print_already_initialized return end domain_password = KeyPass.password_from_shell( true ) if @password.nil? domain_password = @password unless @password.nil? KeyApi.setup_domain_keys( @domain_name, domain_password, create_header() ) print_domain_initialized # --> unless @base_path.nil? # --> key_api.register_keystore( @base_path ) # --> end end |
#pre_validation ⇒ Object
58 59 |
# File 'lib/usecase/init.rb', line 58 def pre_validation end |