How to use the secretstorage.dbus_init function in SecretStorage

To help you get started, we’ve selected a few SecretStorage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mitya57 / secretstorage / tests / test_context_manager.py View on Github external
def test_closing_context_manager(self) -> None:
		with closing(dbus_init()) as connection:
			collection = get_any_collection(connection)
			self.assertIsNotNone(collection)
			label = collection.get_label()
			self.assertIsNotNone(label)
github mitya57 / secretstorage / tests / test_collection.py View on Github external
def setUp(self) -> None:
		self.connection = dbus_init()
github mitya57 / secretstorage / tests / cleanup_test_items.py View on Github external
#!/usr/bin/env python3

from contextlib import closing
import secretstorage

with closing(secretstorage.dbus_init()) as connection:
	items = secretstorage.search_items(connection, {'application': 'secretstorage-test'})

	for item in items:
		print('Deleting item with label %r.' % item.get_label())
		item.delete()
github roddhjav / pass-import / pass_import.py View on Github external
def parse(self, label):
        """Direct import from the Gnome keyring using Dbus.

        :param str label: The collection label to import. If empty string
            import all collection.

        """
        try:
            import secretstorage
        except ImportError as error:
            raise ImportError(error, name='secretstorage')

        keys = self._invkeys()
        connection = secretstorage.dbus_init()
        for collection in secretstorage.get_all_collections(connection):
            group = collection.get_label()
            if label not in ('', group):
                continue

            collection.unlock()
            for item in collection.get_all_items():
                entry = dict()
                entry['group'] = group
                entry['title'] = item.get_label()
                entry['password'] = item.get_secret().decode('utf-8')
                entry['modified'] = item.get_modified()
                entry['created'] = item.get_created()
                for key, value in item.get_attributes().items():
                    entry[keys.get(key, key)] = value
                self.data.append(entry)
github ansible / awx / awx / lib / site-packages / keyring / backends / SecretService.py View on Github external
def get_default_collection(self):
        bus = secretstorage.dbus_init()
        try:
            collection = secretstorage.get_default_collection(bus)
        except exceptions.SecretStorageException as e:
            raise InitError("Failed to create the collection: %s." % e)
        if collection.is_locked():
            collection.unlock()
            if collection.is_locked(): # User dismissed the prompt
                raise InitError("Failed to unlock the collection!")
        return collection
github HenriWahl / Nagstamon / Nagstamon / Nagstamon / thirdparty / keyring / backends / SecretService.py View on Github external
def get_default_collection(self):
        bus = secretstorage.dbus_init()
        try:
            collection = secretstorage.get_default_collection(bus)
        except exceptions.SecretStorageException as e:
            raise InitError("Failed to create the collection: %s." % e)
        if collection.is_locked():
            collection.unlock()
            if collection.is_locked(): # User dismissed the prompt
                raise InitError("Failed to unlock the collection!")
        return collection
github n1nj4sec / pupy / pupy / pupylib / PupyCredentials.py View on Github external
def __init__(self):
        try:
            self.bus = secretstorage.dbus_init()
        except:
            self.bus = None

        self.collection = {'application':'pupy'}
github OpenCobolIDE / OpenCobolIDE / open_cobol_ide / extlibs / keyring / backends / SecretService.py View on Github external
def priority(cls):
        with ExceptionRaisedContext() as exc:
            secretstorage.__name__
        if exc:
            raise RuntimeError("SecretStorage required")
        if not hasattr(secretstorage, 'get_default_collection'):
            raise RuntimeError("SecretStorage 1.0 or newer required")
        try:
            bus = secretstorage.dbus_init()
            list(secretstorage.get_all_collections(bus))
        except exceptions.SecretServiceNotAvailableException as e:
            raise RuntimeError(
                "Unable to initialize SecretService: %s" % e)
        return 5