Class: Keybox::URLAccountEntry

Inherits:
AccountEntry show all
Defined in:
lib/keybox/entry.rb

Overview

URLAccounts do not have a password field, although it appears to. It is calculated based upon the URL and the master password for the Container. The minimum fields for URLAccountEntry are:

- title
- url
- username
- additional_info

This is inspired by crypto.stanford.edu/PwdHash/ and www.xs4all.nl/~jlpoutre/BoT/Javascript/PasswordComposer/

This class also needs to be told the container’s passphrase to calculate its own password.

TODO: Have this class use any other Keybox::Storage::Record for the master password instead of the container.

Constant Summary

Constants inherited from Storage::Record

Storage::Record::PROTECTED_METHODS

Instance Attribute Summary

Attributes inherited from Storage::Record

#creation_time, #data_members, #last_access_time, #modification_time, #uuid

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AccountEntry

default_fields, #default_fields, display_fields, #display_fields, #each, #fields, #max_field_length, private_field?, #private_field?, #private_fields, #to_s, #values, visible_field?, #visible_field?, #visible_fields, visible_fields

Methods inherited from Storage::Record

#==, #data_member_names, #eql?, #method_missing, #modified=, #modified?, #to_yaml_properties

Constructor Details

#initialize(title = "", url = "", username = "") ⇒ URLAccountEntry

Returns a new instance of URLAccountEntry.



175
176
177
178
# File 'lib/keybox/entry.rb', line 175

def initialize(title = "",url = "",username = "")
    super(title,username)
    self.url = url
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Keybox::Storage::Record

Class Method Details

.initial_fieldsObject



166
167
168
# File 'lib/keybox/entry.rb', line 166

def initial_fields
    %w(title url username additional_info)
end

.private_fieldsObject



170
171
172
# File 'lib/keybox/entry.rb', line 170

def private_fields
    %w(password)
end

Instance Method Details

#container_passphrase=(p) ⇒ Object



191
192
193
# File 'lib/keybox/entry.rb', line 191

def container_passphrase=(p)
    password_hash_alg.master_password = p.dup
end

#needs_container_passphrase?Boolean

Returns:

  • (Boolean)


187
188
189
# File 'lib/keybox/entry.rb', line 187

def needs_container_passphrase?
    true
end

#passwordObject



195
196
197
# File 'lib/keybox/entry.rb', line 195

def password
    password_hash_alg.password_for_url(self.url)
end

#password_hash_algObject



180
181
182
183
184
185
# File 'lib/keybox/entry.rb', line 180

def password_hash_alg
    if not instance_variables.include?("@password_hash_alg") then
        @password_hash_alg = Keybox::PasswordHash.new
    end
    @password_hash_alg
end