Method: MacKeychain#find

Defined in:
lib/mac_keychain.rb

#find(username) ⇒ Object

Find Key by username (Account of Keychain item)



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/mac_keychain.rb', line 36

def find(username)
  status, *data = SecKeychainFindGenericPassword(nil, @service.length, @service, username.length, username)
  case status
  when ErrSecItemNotFound
    nil
  when 0
    Key.create(data)
  else
    raise "Error when accessing Keychain looking for key: #{username} of #{@service}"
  end
end