class SecretService

standards.freedesktop.org/secret-service/ch14.html#id481899 Creating a “secret”

Constants

ALGO
COLLECTION_PREFIX
DBUS_EXEC_FAILED
DBUS_NO_REPLY
DBUS_NO_SUCH_OBJECT
DBUS_SERVICE_UNKNOWN
DBUS_UNKNOWN_METHOD
DEFAULT_COLLECTION
IFACE
SECRETS
SS_PATH
SS_PREFIX

Attributes

bus[RW]
proxy[RW]

Public Class Methods

new() click to toggle source
# File lib/secret_service.rb, line 33
def initialize
  begin
    @bus = DBus::SessionBus.instance

    @proxy_maker = @bus.service SECRETS
    @proxy = get_proxy SS_PATH, IFACE[:service]
    @collections = {}

    @collection_paths = self.list_collections
  rescue
    raise NoSessionBus
  end
end

Public Instance Methods

collection(name=DEFAULT_COLLECTION, path=nil) click to toggle source
# File lib/secret_service.rb, line 58
def collection(name=DEFAULT_COLLECTION, path=nil)
  @collections[name.to_s] ||= Collection.new(self, name, path)
end
create_collection(name, properties={}) click to toggle source
# File lib/secret_service.rb, line 66
def create_collection name, properties={}
  properties["#{SS_PREFIX}Collection.Label"] = name

  coll, prompt_path = @proxy.CreateCollection properties, ""
  prompt!(prompt_path) if prompt_path != "/"
  collection(name, coll)
end
get_proxy(path, iface=nil) click to toggle source
# File lib/secret_service.rb, line 47
def get_proxy path, iface=nil
  obj = @proxy_maker.object path
  obj.introspect
  obj.default_iface = iface unless iface.nil?
  obj
end
list_collections() click to toggle source
# File lib/secret_service.rb, line 62
def list_collections
  @proxy.Get(IFACE[:service], 'Collections')
end
prompt!(prompt_path) click to toggle source
# File lib/secret_service.rb, line 92
def prompt!(prompt_path)
  SecretService::Prompt.new(self, prompt_path).prompt!
end
read_alias(name) click to toggle source
# File lib/secret_service.rb, line 79
def read_alias name
  path = @proxy.ReadAlias name
  collection(name, path)
end
search_items(attrs={}) click to toggle source
# File lib/secret_service.rb, line 84
def search_items attrs={}
  @proxy.SearchItems(attrs)
end
session() click to toggle source
# File lib/secret_service.rb, line 54
def session
  @session ||= @proxy.OpenSession(ALGO, "")
end
set_alias(name, collection) click to toggle source
# File lib/secret_service.rb, line 75
def set_alias name, collection
  @proxy.SetAlias name, (collection.class == String ? collection : collection.path)
end
unlock(objects) click to toggle source
# File lib/secret_service.rb, line 88
def unlock objects
  @proxy.Unlock objects
end