Class: Firefox::Login
- Inherits:
-
Object
- Object
- Firefox::Login
- Defined in:
- lib/firefox/login.rb
Constant Summary collapse
- JSON_SCHEMA =
{ 'type' => 'object', 'required' => ['id', 'hostname', 'encryptedUsername', 'encryptedPassword'], 'properties' => { 'id' => {'type': 'integer'}, 'hostname' => {'type': 'string'}, 'httpRealm' => {'type': ['string', 'null']}, 'formSubmitURL' => {'type': ['string', 'null']}, 'usernameField' => {'type': ['string', 'null']}, 'passwordField' => {'type': ['string', 'null']}, 'encryptedUsername' => {'type': 'string'}, 'encryptedPassword' => {'type': 'string'}, 'guid' => {'type': ['string', 'null']}, 'encType' => {'type': 'integer'}, 'timeCreated' => {'type': 'integer'}, 'timeLastUsed' => {'type': 'integer'}, 'timePasswordChanged' => {'type': 'integer'}, 'timesUsed' => {'type': 'integer'}, }, }
Instance Attribute Summary collapse
-
#enc_type ⇒ Object
Returns the value of attribute enc_type.
-
#encrypted_password ⇒ Object
Returns the value of attribute encrypted_password.
-
#encrypted_username ⇒ Object
Returns the value of attribute encrypted_username.
-
#form_submit_url ⇒ Object
Returns the value of attribute form_submit_url.
-
#guid ⇒ Object
Returns the value of attribute guid.
-
#hostname ⇒ Object
Returns the value of attribute hostname.
-
#http_realm ⇒ Object
Returns the value of attribute http_realm.
-
#id ⇒ Object
Returns the value of attribute id.
-
#password ⇒ Object
Returns the value of attribute password.
-
#password_field ⇒ Object
Returns the value of attribute password_field.
-
#time_created ⇒ Object
Returns the value of attribute time_created.
-
#time_last_used ⇒ Object
Returns the value of attribute time_last_used.
-
#time_password_changed ⇒ Object
Returns the value of attribute time_password_changed.
-
#times_used ⇒ Object
Returns the value of attribute times_used.
-
#username ⇒ Object
Returns the value of attribute username.
-
#username_field ⇒ Object
Returns the value of attribute username_field.
Class Method Summary collapse
Instance Method Summary collapse
- #decrypt ⇒ Object
-
#initialize ⇒ Login
constructor
A new instance of Login.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Login
Returns a new instance of Login.
56 57 |
# File 'lib/firefox/login.rb', line 56 def initialize() end |
Instance Attribute Details
#enc_type ⇒ Object
Returns the value of attribute enc_type.
48 49 50 |
# File 'lib/firefox/login.rb', line 48 def enc_type @enc_type end |
#encrypted_password ⇒ Object
Returns the value of attribute encrypted_password.
48 49 50 |
# File 'lib/firefox/login.rb', line 48 def encrypted_password @encrypted_password end |
#encrypted_username ⇒ Object
Returns the value of attribute encrypted_username.
48 49 50 |
# File 'lib/firefox/login.rb', line 48 def encrypted_username @encrypted_username end |
#form_submit_url ⇒ Object
Returns the value of attribute form_submit_url.
48 49 50 |
# File 'lib/firefox/login.rb', line 48 def form_submit_url @form_submit_url end |
#guid ⇒ Object
Returns the value of attribute guid.
48 49 50 |
# File 'lib/firefox/login.rb', line 48 def guid @guid end |
#hostname ⇒ Object
Returns the value of attribute hostname.
48 49 50 |
# File 'lib/firefox/login.rb', line 48 def hostname @hostname end |
#http_realm ⇒ Object
Returns the value of attribute http_realm.
48 49 50 |
# File 'lib/firefox/login.rb', line 48 def http_realm @http_realm end |
#id ⇒ Object
Returns the value of attribute id.
48 49 50 |
# File 'lib/firefox/login.rb', line 48 def id @id end |
#password ⇒ Object
Returns the value of attribute password.
48 49 50 |
# File 'lib/firefox/login.rb', line 48 def password @password end |
#password_field ⇒ Object
Returns the value of attribute password_field.
48 49 50 |
# File 'lib/firefox/login.rb', line 48 def password_field @password_field end |
#time_created ⇒ Object
Returns the value of attribute time_created.
48 49 50 |
# File 'lib/firefox/login.rb', line 48 def time_created @time_created end |
#time_last_used ⇒ Object
Returns the value of attribute time_last_used.
48 49 50 |
# File 'lib/firefox/login.rb', line 48 def time_last_used @time_last_used end |
#time_password_changed ⇒ Object
Returns the value of attribute time_password_changed.
48 49 50 |
# File 'lib/firefox/login.rb', line 48 def time_password_changed @time_password_changed end |
#times_used ⇒ Object
Returns the value of attribute times_used.
48 49 50 |
# File 'lib/firefox/login.rb', line 48 def times_used @times_used end |
#username ⇒ Object
Returns the value of attribute username.
48 49 50 |
# File 'lib/firefox/login.rb', line 48 def username @username end |
#username_field ⇒ Object
Returns the value of attribute username_field.
48 49 50 |
# File 'lib/firefox/login.rb', line 48 def username_field @username_field end |
Class Method Details
.from_json(data) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/firefox/login.rb', line 67 def self.from_json(data) # In firefox (checked in the mercurial repository on 2017-02-11), # logins.json is updated in # toolkit/components/passwordmgr/storage-json.js begin JSON::Validator.validate!(JSON_SCHEMA, data) rescue JSON::Schema::ValidationError => err raise InvalidLogin, "invalid login data: #{err.}" end login = Login.new() to_date = lambda do || seconds = / 1000 milliseconds = % 1000 Time.at(seconds, milliseconds).utc() end login.id = data['id'] login.hostname = data['hostname'] login.http_realm = data['httpRealm'] login.form_submit_url = data['formSubmitURL'] login.username_field = data['usernameField'] login.password_field = data['passwordField'] login.encrypted_username = data['encryptedUsername'] login.encrypted_password = data['encryptedPassword'] login.enc_type = data['encType'] login.guid = data['guid'] login.time_created = to_date.(data['timeCreated']) login.time_last_used = to_date.(data['timeLastUsed']) login.time_password_changed = to_date.(data['timePasswordChanged']) login.times_used = data['timesUsed'] login end |
Instance Method Details
#decrypt ⇒ Object
104 105 106 107 |
# File 'lib/firefox/login.rb', line 104 def decrypt() @username = NSS.decrypt(@encrypted_username) @password = NSS.decrypt(@encrypted_password) end |
#inspect ⇒ Object
63 64 65 |
# File 'lib/firefox/login.rb', line 63 def inspect() to_s() end |
#to_s ⇒ Object
59 60 61 |
# File 'lib/firefox/login.rb', line 59 def to_s() "#<Firefox::Login #{@hostname}>" end |