Class: Idb::KeychainWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/lib/keychain_wrapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeKeychainWrapper

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

#entriesObject

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, , agroup
  $log.info "Deleting keychain item for service='#{service}', account='#{}', agroup='#{agroup}' ..."
  @ops.execute "#{@keychain_editor_path} --action delete --account \"#{}\" --service \"#{service}\" --agroup \"#{agroup}\""
end

#dumpObject



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, , agroup, data
  $log.info "Modifying keychain item for service='#{service}', account='#{}', agroup='#{agroup}'. New data=#{data}"
  @ops.execute "#{@keychain_editor_path} --action edit --account \"#{}\" --service \"#{service}\" --agroup \"#{agroup}\" --data \"#{data}\""
end

#parseObject



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