Class: SafeDb::Keys
- Inherits:
-
EditVerse
- Object
- Controller
- EditVerse
- SafeDb::Keys
- Defined in:
- lib/controller/edit/keys.rb
Overview
The default action of the keys use case is to create a private and public keypair and store them within the open chapter and verse.
The optional keypair name parameter (if given) is used as a prefix to compose the private and public key keynames. The prefix and descriptors will be period separated.
Currently the only algorithm used is the super secure EC (eliptic curve) with 384 bits.
Generating Public Key for Unit Test
To validate public key generation for SSH we can use the below command that points to an on-disk private key file. The -y flag produces the magic.
ssh-keygen -f /path/to/private/key.pem -y
Instance Attribute Summary collapse
-
#keyfile_name ⇒ Object
writeonly
Set the keyfile_name to fashion the name of the private key file that will be ejected (in the future) into the ‘~/.ssh` folder.
-
#keypair_name ⇒ Object
writeonly
To insert MORE THAN ONE KEY in the same verse you send the keypair_name.
Instance Method Summary collapse
-
#edit_verse ⇒ Object
The keypair use case creates a private and public keypair and stores them within the open chapter and verse.
Methods inherited from EditVerse
Methods inherited from Controller
#check_post_conditions, #check_pre_conditions, #execute, #flow, #initialize, #open_remote_backend_location, #post_validation, #pre_validation, #read_verse, #set_verse, #update_verse
Constructor Details
This class inherits a constructor from SafeDb::Controller
Instance Attribute Details
#keyfile_name=(value) ⇒ Object (writeonly)
Set the keyfile_name to fashion the name of the private key file that will be ejected (in the future) into the ‘~/.ssh` folder. Omit it and the filename will be formatted with the book, chapter and verse name followed by a .pem
33 34 35 |
# File 'lib/controller/edit/keys.rb', line 33 def keyfile_name=(value) @keyfile_name = value end |
#keypair_name=(value) ⇒ Object (writeonly)
To insert MORE THAN ONE KEY in the same verse you send the keypair_name. The keypair name fashions the key name of the embodied private key file. Omit it and it will be simply set to “private.key”.
28 29 30 |
# File 'lib/controller/edit/keys.rb', line 28 def keypair_name=(value) @keypair_name = value end |
Instance Method Details
#edit_verse ⇒ Object
The keypair use case creates a private and public keypair and stores them within the open chapter and verse.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/controller/edit/keys.rb', line 38 def edit_verse() keypair = Keypair.new() keyname_postfix = "" unless @keypair_name keyname_postfix = ".#{@keypair_name}" if @keypair_name bcv_name = "#{@book.book_name()}.#{@book.get_open_chapter_name()}.#{@book.get_open_verse_name()}#{keyname_postfix}" filename_prefix = bcv_name unless @keyfile_name filename_prefix = @keyfile_name if @keyfile_name private_key_filename = "#{filename_prefix}.pem" private_key_keyname = "#{Indices::PRIVATE_KEY_DEFAULT_KEY_NAME}#{keyname_postfix}" public_key_keyname = "#{Indices::PUBLIC_KEY_DEFAULT_KEY_NAME}#{keyname_postfix}" file_content64 = Base64.urlsafe_encode64( keypair.private_key_pem() ) log.info(x) { "Keypair prefix => #{@keypair_name}" } if @keypair_name log.info(x) { "The keypair fully qualified name => [ #{private_key_filename} ]" } log.info(x) { "Keynames are [ #{private_key_keyname} ] and [ #{public_key_keyname} ]" } filedata_map = {} filedata_map.store( Indices::INGESTED_FILE_BASE_NAME_KEY, private_key_filename ) filedata_map.store( Indices::INGESTED_FILE_CONTENT64_KEY, file_content64 ) filedata_map.store( Indices::FILE_CHMOD_PERMISSIONS_KEY, "0600" ) @verse.store( Indices::INGESTED_FILE_LINE_NAME_KEY + private_key_keyname, filedata_map ) @verse.store( public_key_keyname, keypair.public_key_ssh() ) end |