Module: Keychain
- Defined in:
- lib/keychain.rb,
lib/keychain/version.rb,
lib/keychain/keychain.rb
Overview
top level constant for this library
Defined Under Namespace
Modules: Protocols Classes: AuthFailedError, DuplicateItemError, Error, Item, Keychain, NoSuchKeychainError, Scope, UserCancelledError
Constant Summary collapse
- VERSION =
The current version string
'0.1.0'
Class Method Summary collapse
-
.create(path, password) ⇒ Keychain::Keychain
creates a new keychain file and adds it to the keychain search path ( SecKeychainCreate ).
-
.default ⇒ Keychain::Keychain
Gets the default keychain object ( SecKeychainCopyDefault ).
-
.generic_passwords ⇒ Keychain::Scope
Returns a scope for generic passwords in all keychains.
-
.internet_passwords ⇒ Keychain::Scope
Returns a scope for internet passwords contained in all keychains.
-
.open(path) ⇒ Keychain::Keychain
Opens the keychain file at the specified path and adds it to the keychain search path ( SecKeychainOpen ).
Class Method Details
.create(path, password) ⇒ Keychain::Keychain
creates a new keychain file and adds it to the keychain search path ( SecKeychainCreate )
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/keychain.rb', line 20 def create(path, password) password = password.encode(Encoding::UTF_8) path = path.encode(Encoding::UTF_8) out_buffer = FFI::MemoryPointer.new(:pointer) status = Sec.SecKeychainCreate(path, password.bytesize, FFI::MemoryPointer.from_string(password), 0, nil, out_buffer) Sec.check_osstatus(status) Keychain.new(out_buffer.read_pointer).release_on_gc end |
.default ⇒ Keychain::Keychain
Gets the default keychain object ( SecKeychainCopyDefault )
36 37 38 39 40 41 42 |
# File 'lib/keychain.rb', line 36 def default out_buffer = FFI::MemoryPointer.new(:pointer) status = Sec.SecKeychainCopyDefault(out_buffer); Sec.check_osstatus(status) Keychain.new(out_buffer.read_pointer).release_on_gc end |
.generic_passwords ⇒ Keychain::Scope
Returns a scope for generic passwords in all keychains
68 69 70 |
# File 'lib/keychain.rb', line 68 def generic_passwords Scope.new(Sec::Classes::GENERIC) end |
.internet_passwords ⇒ Keychain::Scope
Returns a scope for internet passwords contained in all keychains
61 62 63 |
# File 'lib/keychain.rb', line 61 def internet_passwords Scope.new(Sec::Classes::INTERNET) end |
.open(path) ⇒ Keychain::Keychain
Opens the keychain file at the specified path and adds it to the keychain search path ( SecKeychainOpen )
Will succeed even if the file doesn’t exists (however most operations on the keychain will then fail)
51 52 53 54 55 56 |
# File 'lib/keychain.rb', line 51 def open(path) out_buffer = FFI::MemoryPointer.new(:pointer) status = Sec.SecKeychainOpen(path,out_buffer); Sec.check_osstatus(status) Keychain.new(out_buffer.read_pointer).release_on_gc end |