Class: Idb::KeychainWrapper
- Inherits:
-
Object
- Object
- Idb::KeychainWrapper
- Defined in:
- lib/lib/keychain_wrapper.rb
Instance Attribute Summary collapse
-
#entries ⇒ Object
Returns the value of attribute entries.
Instance Method Summary collapse
- #delete_item(service, account, agroup) ⇒ Object
- #dump ⇒ Object
- #edit_item(service, account, agroup, data) ⇒ Object
-
#initialize ⇒ KeychainWrapper
constructor
A new instance of KeychainWrapper.
- #parse ⇒ Object
Constructor Details
#initialize ⇒ KeychainWrapper
Returns a new instance of KeychainWrapper.
4 5 6 7 |
# File 'lib/lib/keychain_wrapper.rb', line 4 def initialize @keychain_editor_path = $device.keychain_editor_path @ops = $device.ops end |
Instance Attribute Details
#entries ⇒ Object
Returns the value of attribute entries.
3 4 5 |
# File 'lib/lib/keychain_wrapper.rb', line 3 def entries @entries end |
Instance Method Details
#delete_item(service, account, agroup) ⇒ Object
30 31 32 33 |
# File 'lib/lib/keychain_wrapper.rb', line 30 def delete_item service, account, agroup $log.info "Deleting keychain item for service='#{service}', account='#{account}', agroup='#{agroup}' ..." @ops.execute "#{@keychain_editor_path} --action delete --account \"#{account}\" --service \"#{service}\" --agroup \"#{agroup}\"" end |
#dump ⇒ Object
22 23 24 25 |
# File 'lib/lib/keychain_wrapper.rb', line 22 def dump $log.info "Dumping keychain using keychain_editor..." @ops.execute "#{@keychain_editor_path} --action dump" end |
#edit_item(service, account, agroup, data) ⇒ Object
35 36 37 38 |
# File 'lib/lib/keychain_wrapper.rb', line 35 def edit_item service, account, agroup, data $log.info "Modifying keychain item for service='#{service}', account='#{account}', agroup='#{agroup}'. New data=#{data}" @ops.execute "#{@keychain_editor_path} --action edit --account \"#{account}\" --service \"#{service}\" --agroup \"#{agroup}\" --data \"#{data}\"" end |
#parse ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/lib/keychain_wrapper.rb', line 9 def parse begin @parsed = JSON.parse(dump) @entries = Hash.new @parsed.each {|x| @entries[x[0].to_i] = x[1] } rescue $log.error "Couldn't parse keychain json." @entries = {} end end |