コード例 #1
0
ファイル: Gnome.py プロジェクト: tliu22/keyrings.alt
 def priority(cls):
     if 'GnomeKeyring' not in globals():
         raise RuntimeError("GnomeKeyring module required")
     result = GnomeKeyring.get_default_keyring_sync()[0]
     if result != GnomeKeyring.Result.OK:
         raise RuntimeError(result.value_name)
     return 1
コード例 #2
0
ファイル: Gnome.py プロジェクト: jaraco/keyrings.alt
 def priority(cls):
     if 'GnomeKeyring' not in globals():
         raise RuntimeError("GnomeKeyring module required")
     result = GnomeKeyring.get_default_keyring_sync()[0]
     if result != GnomeKeyring.Result.OK:
         raise RuntimeError(result.value_name)
     return 1
コード例 #3
0
 def _set_value_to_gnomekeyring(self, name, value):
     """Store a value in the keyring."""
     attributes = GnomeKeyring.Attribute.list_new()
     GnomeKeyring.Attribute.list_append_string(attributes, "id", str(name))
     keyring = GnomeKeyring.get_default_keyring_sync()[1]
     value = GnomeKeyring.item_create_sync(
         keyring, GnomeKeyring.ItemType.GENERIC_SECRET, "%s preferences" % (com.APP), attributes, str(value), True
     )
     return value[1]
コード例 #4
0
def setup_gnome_keyring():
    """
    Provide clean login Gnome keyring (removes the previous one
    beforehand, if there is a one).
    """
    try:
        # Delete originally stored password
        (response, keyring) = GnomeKeyring.get_default_keyring_sync()
        log.debug('get_info default: %s, %s' % (response, keyring))
        if response == GnomeKeyring.Result.OK:
            if keyring is not None:
                delete_response = GnomeKeyring.delete_sync(keyring)
                log.debug('delete default: %s' % delete_response)
                assert delete_response == GnomeKeyring.Result.OK, \
                    "Delete failed: %s" % delete_response
            response, keyring = GnomeKeyring.get_info_sync('login')
            if response == GnomeKeyring.Result.OK:
                if keyring is not None:
                    delete_response = GnomeKeyring.delete_sync('login')
                    log.debug('delete login: %s' % delete_response)
                    assert delete_response == GnomeKeyring.Result.OK, \
                        "Delete failed: %s" % delete_response
            elif response != GnomeKeyring.Result.NO_SUCH_KEYRING:
                raise IOError(
                    'Unexpected error when manipulating login keyring')

            # This is result of the underlying DBus error:
            # CKR_WRAPPED_KEY_INVALID, CKR_WRAPPED_KEY_LEN_RANGE,
            # CKR_MECHANISM_PARAM_INVALID
            # So, failed either
            # * egg_padding_pkcs7_unpad
            #   (gnome-keyring/egg/egg-padding.c)
            # * gkm_aes_mechanism_unwrap
            #   (gnome-keyring/pkcs11/gkm/gkm-aes-mechanism.c)
            # * gkm_dh_mechanism_derive
            #   (gnome-keyring/pkcs11/gkm/gkm-dh-mechanism.c)
            # * gkm_null_mechanism_unwrap or gkm_null_mechanism_wrap
            #   (gnome-keyring/pkcs11/gkm/gkm-null-mechanism.c)
            create_response = GnomeKeyring.create_sync('login', 'redhat')
            log.debug('create login: %s' % create_response)
            if create_response != GnomeKeyring.Result.OK:
                raise IOError(
                    'Create failed: %s\n%s' %
                    (create_response,
                     GnomeKeyring.result_to_message(create_response)))

            set_default_response = \
                GnomeKeyring.set_default_keyring_sync('login')
            assert set_default_response == GnomeKeyring.Result.OK, \
                "Set default failed: %s" % set_default_response
        unlock_response = GnomeKeyring.unlock_sync("login", 'redhat')
        assert unlock_response == GnomeKeyring.Result.OK, \
            "Unlock failed: %s" % unlock_response
    except Exception as e:
        log.error("Exception while unlocking a keyring: %s", e.message)
        raise  # We shouldn’t let this exception evaporate
コード例 #5
0
def setup_gnome_keyring():
    """
    Provide clean login Gnome keyring (removes the previous one
    beforehand, if there is a one).
    """
    try:
        # Delete originally stored password
        (response, keyring) = GnomeKeyring.get_default_keyring_sync()
        log.debug('get_info default: %s, %s' % (response, keyring))
        if response == GnomeKeyring.Result.OK:
            if keyring is not None:
                delete_response = GnomeKeyring.delete_sync(keyring)
                log.debug('delete default: %s' % delete_response)
                assert delete_response == GnomeKeyring.Result.OK, \
                    "Delete failed: %s" % delete_response
            response, keyring = GnomeKeyring.get_info_sync('login')
            if response == GnomeKeyring.Result.OK:
                if keyring is not None:
                    delete_response = GnomeKeyring.delete_sync('login')
                    log.debug('delete login: %s' % delete_response)
                    assert delete_response == GnomeKeyring.Result.OK, \
                        "Delete failed: %s" % delete_response
            elif response != GnomeKeyring.Result.NO_SUCH_KEYRING:
                raise IOError(
                    'Unexpected error when manipulating login keyring')

            # This is result of the underlying DBus error:
            # CKR_WRAPPED_KEY_INVALID, CKR_WRAPPED_KEY_LEN_RANGE,
            # CKR_MECHANISM_PARAM_INVALID
            # So, failed either
            # * egg_padding_pkcs7_unpad
            #   (gnome-keyring/egg/egg-padding.c)
            # * gkm_aes_mechanism_unwrap
            #   (gnome-keyring/pkcs11/gkm/gkm-aes-mechanism.c)
            # * gkm_dh_mechanism_derive
            #   (gnome-keyring/pkcs11/gkm/gkm-dh-mechanism.c)
            # * gkm_null_mechanism_unwrap or gkm_null_mechanism_wrap
            #   (gnome-keyring/pkcs11/gkm/gkm-null-mechanism.c)
            create_response = GnomeKeyring.create_sync('login', 'redhat')
            log.debug('create login: %s' % create_response)
            if create_response != GnomeKeyring.Result.OK:
                raise IOError(
                    'Create failed: %s\n%s' %
                    (create_response,
                     GnomeKeyring.result_to_message(create_response)))

            set_default_response = \
                GnomeKeyring.set_default_keyring_sync('login')
            assert set_default_response == GnomeKeyring.Result.OK, \
                "Set default failed: %s" % set_default_response
        unlock_response = GnomeKeyring.unlock_sync("login", 'redhat')
        assert unlock_response == GnomeKeyring.Result.OK, \
            "Unlock failed: %s" % unlock_response
    except Exception as e:
        log.error("Exception while unlocking a keyring: %s", e.message)
        raise  # We shouldn’t let this exception evaporate
コード例 #6
0
ファイル: keyring.py プロジェクト: thnguyn2/ECE_527_MP
def put_in_keyring(acctid, name, value):
  """Store a value in the keyring."""
  id = "%s/%s" % (acctid, name)
  attributes = GnomeKeyring.Attribute.list_new()
  GnomeKeyring.Attribute.list_append_string(attributes, 'id', str(id))
  keyring = GnomeKeyring.get_default_keyring_sync()[1]
  value = GnomeKeyring.item_create_sync(
    keyring, GnomeKeyring.ItemType.GENERIC_SECRET,
    "Gwibber preference: %s" % id,
    attributes, str(value), True)
  return value[1]
コード例 #7
0
ファイル: credentialstore.py プロジェクト: Mailaender/mailnag
	def __init__(self):
		(result, kr_name) = GnomeKeyring.get_default_keyring_sync()
		self._defaultKeyring = kr_name
		
		if self._defaultKeyring == None:
			self._defaultKeyring = 'login'

		result = GnomeKeyring.unlock_sync(self._defaultKeyring, None)
		
		if result != GnomeKeyring.Result.OK:
			raise KeyringUnlockException('Failed to unlock default keyring')

		self._migrate_keyring()
コード例 #8
0
ファイル: keyring.py プロジェクト: mikeit/mailnag
	def __init__(self):
		self.KEYRING_ITEM_NAME = 'Mailnag password for %s://%s@%s'
		
		(result, kr_name) = GnomeKeyring.get_default_keyring_sync()
		self._defaultKeyring = kr_name
		
		if self._defaultKeyring == None:
			self._defaultKeyring = 'login'

		result = GnomeKeyring.unlock_sync(self._defaultKeyring, None)
		
		if (result != GnomeKeyring.Result.OK):
			raise Exception('Failed to unlock default keyring')
コード例 #9
0
    def __init__(self):
        (result, kr_name) = GnomeKeyring.get_default_keyring_sync()
        self._defaultKeyring = kr_name

        if self._defaultKeyring == None:
            self._defaultKeyring = 'login'

        result = GnomeKeyring.unlock_sync(self._defaultKeyring, None)

        if result != GnomeKeyring.Result.OK:
            raise KeyringUnlockException('Failed to unlock default keyring')

        self._migrate_keyring()
コード例 #10
0
def before_all(context):
    """Setup evolution stuff
    Being executed before all features
    """

    # Reset GSettings
    schemas = [x for x in Gio.Settings.list_schemas() if 'evolution' in x.lower()]
    for schema in schemas:
        os.system("gsettings reset-recursively %s" % schema)

    # Skip warning dialog
    os.system("gsettings set org.gnome.evolution.shell skip-warning-dialog true")
    # Show switcher buttons as icons (to minimize tree scrolling)
    os.system("gsettings set org.gnome.evolution.shell buttons-style icons")

    # Wait for things to settle
    sleep(0.5)

    # Skip dogtail actions to print to stdout
    config.logDebugToStdOut = False
    config.typingDelay = 0.2

    # Include assertion object
    context.assertion = dummy()

    # Kill initial setup
    os.system("killall /usr/libexec/gnome-initial-setup")

    # Delete existing ABRT problems
    if problem.list():
        [x.delete() for x in problem.list()]

    try:
        from gi.repository import GnomeKeyring
        # Delete originally stored password
        (response, keyring) = GnomeKeyring.get_default_keyring_sync()
        if response == GnomeKeyring.Result.OK:
            if keyring is not None:
                delete_response = GnomeKeyring.delete_sync(keyring)
                assert delete_response == GnomeKeyring.Result.OK, "Delete failed: %s" % delete_response
            create_response = GnomeKeyring.create_sync("login", 'gnome')
            assert create_response == GnomeKeyring.Result.OK, "Create failed: %s" % create_response
            set_default_response = GnomeKeyring.set_default_keyring_sync('login')
            assert set_default_response == GnomeKeyring.Result.OK, "Set default failed: %s" % set_default_response
        unlock_response = GnomeKeyring.unlock_sync("login", 'gnome')
        assert unlock_response == GnomeKeyring.Result.OK, "Unlock failed: %s" % unlock_response
    except Exception as e:
        print("Exception while unlocking a keyring: %s" % e.message)

    context.app = App('evolution')
コード例 #11
0
 def do_delete(self, id):
     keyring = GnomeKeyring.get_default_keyring_sync()[1]
     GnomeKeyring.item_delete_sync(keyring, id)
コード例 #12
0
ファイル: keyring.py プロジェクト: whitwhittle/gtg
 def __init__(self):
     super().__init__()
     if not hasattr(self, "keyring"):
         result, self.keyring = GnomeKeyring.get_default_keyring_sync()
         if result != GnomeKeyring.Result.OK:
             raise Exception(f"Can't get default keyring, error={result}")
コード例 #13
0
	def __init__(self):
		self.keyring = GnomeKeyring.get_default_keyring_sync()[1]
コード例 #14
0
ファイル: Gnome.py プロジェクト: tliu22/keyrings.alt
 def keyring_name(self):
     system_default = GnomeKeyring.get_default_keyring_sync()[1]
     return self.KEYRING_NAME or system_default
コード例 #15
0
ファイル: gnome-keyring.py プロジェクト: tiwoc/liferea
 def do_delete(self, id):
     keyring = GnomeKeyring.get_default_keyring_sync()[1]
     GnomeKeyring.item_delete_sync(keyring, id)
コード例 #16
0
ファイル: keyring.py プロジェクト: Ethcelon/gtg
 def __init__(self):
     super(Keyring, self).__init__()
     if not hasattr(self, "keyring"):
         result, self.keyring = GnomeKeyring.get_default_keyring_sync()
         if result != GnomeKeyring.Result.OK:
             raise Exception("Can't get default keyring, error=%s" % result)
コード例 #17
0
ファイル: keyring.py プロジェクト: thnguyn2/ECE_527_MP
def del_from_keyring(keyring_id):
  """Delete an entry from the keyring."""
  keyring = GnomeKeyring.get_default_keyring_sync()[1]
  GnomeKeyring.item_delete_sync(keyring, keyring_id)
コード例 #18
0
ファイル: client.py プロジェクト: FlorianLudwig/gpwg
#!/usr/bin/python
# copyright 2012 Florian Ludwig <*****@*****.**>

import os
import socket
from gi.repository import GnomeKeyring, GLib
import glib

import gpwg


SOCKET_PATH = '/tmp/gpwg'
KEYRING = GnomeKeyring.get_default_keyring_sync()[1]


def insert_master_key(master_key):
    GnomeKeyring.item_create_sync(KEYRING, GnomeKeyring.ItemType.GENERIC_SECRET, 'gpwg:masterkey', GLib.Array(), master_key, 1)


def get_master_key():
    ids = GnomeKeyring.list_item_ids_sync(KEYRING)[1]
    for id in ids:
        info = GnomeKeyring.item_get_info_sync('login', id)[1]
        if info.get_display_name() == 'gpwg:masterkey':
            return info.get_secret()
    return None


def main():
    GLib.set_application_name('GNOME password generator')
    master_key = get_master_key()
コード例 #19
0
ファイル: client.py プロジェクト: FlorianLudwig/gpwg
#!/usr/bin/python
# copyright 2012 Florian Ludwig <*****@*****.**>

import os
import socket
from gi.repository import GnomeKeyring, GLib
import glib

import gpwg

SOCKET_PATH = '/tmp/gpwg'
KEYRING = GnomeKeyring.get_default_keyring_sync()[1]


def insert_master_key(master_key):
    GnomeKeyring.item_create_sync(KEYRING,
                                  GnomeKeyring.ItemType.GENERIC_SECRET,
                                  'gpwg:masterkey', GLib.Array(), master_key,
                                  1)


def get_master_key():
    ids = GnomeKeyring.list_item_ids_sync(KEYRING)[1]
    for id in ids:
        info = GnomeKeyring.item_get_info_sync('login', id)[1]
        if info.get_display_name() == 'gpwg:masterkey':
            return info.get_secret()
    return None


def main():
コード例 #20
0
ファイル: Gnome.py プロジェクト: jaraco/keyrings.alt
 def keyring_name(self):
     system_default = GnomeKeyring.get_default_keyring_sync()[1]
     return self.KEYRING_NAME or system_default
コード例 #21
0
 def __init__(self, name, server, protocol):
     self._name = name
     self._server = server
     self._protocol = protocol
     result, self._keyring = GnomeKeyring.get_default_keyring_sync()