Sha256: b4979c025963e78c723c17838f0e295dceb5ff3f3f83384e6d746f9a79e3e4eb
Contents?: true
Size: 1.01 KB
Versions: 3
Compression:
Stored size: 1.01 KB
Contents
require 'lockr/action/aes' require 'lockr/pwdstore' class AddAction < AesAction def initialize(id,url,username,pwd,keyfile,vault) keyfilehash = calculate_hash( keyfile) pwd_directory = load_from_vault( vault) if pwd_directory.has_key?( id) pwd_directory_id = YAML::load(decrypt( pwd_directory[id][:enc], keyfilehash, pwd_directory[id][:salt])) else pwd_directory_id = {} end if ( pwd_directory_id.has_key?( username)) overwrite = ask( "Password already exists. Update? (y/n) ") { |q| } unless overwrite.downcase == 'y' exit 14 end end new_store = PasswordStore.new( id, url, username, pwd) pwd_directory_id[username] = new_store pwd_directory[id] = {} pwd_directory[id][:enc], pwd_directory[id][:salt] = encrypt( pwd_directory_id.to_yaml, keyfilehash) save_to_vault( pwd_directory, vault) say("Password saved for ID '<%= color('#{id}', :blue) %>' and user '<%= color('#{username}', :green) %>'") end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lockr-0.3.0 | lib/lockr/action/add.rb |
lockr-0.2.1 | lib/lockr/action/add.rb |
lockr-0.2.0 | lib/lockr/action/add.rb |