class Keychain

Attributes

content[R]
encryption_key[R]

Public Class Methods

new(path) click to toggle source
# File lib/keychain.rb, line 9
def initialize(path)
        @path = path
        load_encryption_keys
        load_contents
end

Public Instance Methods

get(name) click to toggle source
# File lib/keychain.rb, line 19
def get(name)
        item = @content.find(name)
        return unless item
        key = Key.new load_file(item.uuid + ".1password")
        key.decrypt(@encryption_key)
end
unlock(password) click to toggle source
# File lib/keychain.rb, line 15
def unlock(password)
        @unlocked = @encryption_key.unlock(password)
end

Private Instance Methods

load_contents() click to toggle source
# File lib/keychain.rb, line 31
def load_contents
        @content = Content.new load_file("contents.js")
end
load_encryption_keys() click to toggle source
# File lib/keychain.rb, line 27
def load_encryption_keys
        @encryption_key = EncryptionKey.new load_file("encryptionKeys.js")
end
load_file(file_name) click to toggle source
# File lib/keychain.rb, line 35
def load_file(file_name)
        file = File.join(@path, "data", "default", file_name)
        JSON.parse(IO.read(file))
end