class KeyControl::KeyRing
Attributes
Public Class Methods
Public: Get a new KeyControl::KeyRing
instance with the specified keyring identifier.
keyring - A String or Integer identifying the desired keyring.
Returns a KeyControl::KeyRing
instance.
# File lib/key_control/key_ring.rb, line 13 def initialize(keyring) @keyring = keyring @system = System.new end
Public Instance Methods
Public: Get the data matching the passed description from the keychain.
name - The description of the data for which to search.
Returns the requested data or nil.
# File lib/key_control/key_ring.rb, line 33 def [](name) handle = system.run(:search, "user", name, nil, @keyring) return nil if handle == -1 system.get(:read, handle) end
Public: Add the requested data to the keychain for the given description.
name - The description of the data. data - The data to store in the keychain.
Returns nothing.
# File lib/key_control/key_ring.rb, line 24 def []=(name, data) system.run(:add, "user", name, data, data.length, @keyring) end
Public: Remove the data matching the passed description from the keychain.
name - The description of the data to remove.
Returns nothing.
# File lib/key_control/key_ring.rb, line 45 def delete(name) handle = system.run!(:search, "user", name, nil, @keyring) system.run!(:unlink, handle, @keyring) end
Public: Set a timeout for the data matching the passed description.
name - The description of the data for which to set a timeout. timeout - The timeout to set in seconds.
Returns nothing.
# File lib/key_control/key_ring.rb, line 56 def set_timeout(name, timeout) handle = system.run!(:search, "user", name, nil, @keyring) system.run!(:set_timeout, handle, timeout) end