def testSynchronous(self):
		attributes = { "number": "9", "string": "nine", "even": "false" }

		password = Secret.password_lookup_sync(STORE_SCHEMA, attributes, None)
		self.assertEqual(None, password)

		stored = Secret.password_store_sync(STORE_SCHEMA, attributes, Secret.COLLECTION_DEFAULT,
		                                    "The number nine", "999", None)
		self.assertEqual(True, stored);

		password = Secret.password_lookup_sync(STORE_SCHEMA, attributes, None)
		self.assertEqual("999", password)
	def testSyncNotFound(self):
		attributes = { "number": "11", "string": "one", "even": "true" }

		password = Secret.password_lookup_sync(STORE_SCHEMA, attributes, None)
		self.assertEqual(None, password)

		deleted = Secret.password_remove_sync(STORE_SCHEMA, attributes, None)
		self.assertEqual(False, deleted)
	def testSynchronous(self):
		attributes = { "number": "1", "string": "one", "even": "false" }

		password = Secret.password_lookup_sync(STORE_SCHEMA, attributes, None)
		self.assertEqual("111", password)

		deleted = Secret.password_remove_sync(STORE_SCHEMA, attributes, None)
		self.assertEqual(True, deleted)
Beispiel #4
0
 def find_password(self, scheme, host, username):
     """Return the password of username@root."""
     template = dict(zip(self.category, (scheme, host, username)))
     try:
         password = Secret.password_lookup_sync(self.schema, template, None)
     except Secret.SECRET_ERROR_PROTOCOL:
         return
     return password
	def testAsynchronous(self):
		attributes = { "number": "888", "string": "eight", "even": "true" }

		password = Secret.password_lookup_sync(STORE_SCHEMA, attributes, None)
		self.assertEqual(None, password);

		loop = GLib.MainLoop(None, False)

		def on_result_ready(source, result, unused):
			loop.quit()
			stored = Secret.password_store_finish(result)
			self.assertEquals(True, stored)

		Secret.password_store(STORE_SCHEMA, attributes, None, "The number eight", "888",
		                      None, on_result_ready, None)

		loop.run()

		password = Secret.password_lookup_sync(STORE_SCHEMA, attributes, None)
		self.assertEqual("888", password)
    def get_by_id(secret_id):
        """
        Return the OTP token based on a secret ID.

        :param secret_id: the secret ID associated to an OTP token
        :type secret_id: str
        :return: the secret OTP token.
        """
        schema = Keyring.get_default().schema
        password = Secret.password_lookup_sync(
            schema, {"id": str(secret_id)}, None)
        return password
Beispiel #7
0
    def getTokens(self, user):
        attributes = {
            "user": user,
            "scope": self.scope,
        }

        password = Secret.password_lookup_sync(self.TOKEN_SCHEMA, attributes,
                                               None)

        if password:
            return self.decodeTokens(password)
        else:
            return (None, None)
Beispiel #8
0
    def getTokens(self, user):
        attributes = {
                         "user": user,
                         "scope": self.scope,
                     }

        password = Secret.password_lookup_sync(self.TOKEN_SCHEMA,
                                               attributes, None)

        if password:
            return self.decodeTokens(password)
        else:
            return (None, None)
def get():
    attributes = get_attributes()

    if 'password' in attributes:
        del attributes['password']
    password = Secret.password_lookup_sync(
        GIT_CREDENTIALS_SCHEMA,
        attributes,
        None
        )
    if password:
        secret_item = find_secret_item(attributes)
        print('protocol=%s' % secret_item['protocol'])
        print('host=%s' % secret_item['host'])
        print('username=%s' % secret_item['username'])
        print('password=%s' % secret_item['password'])
Beispiel #10
0
    def __init__(self):
        self.url = 'mattermost.example.com'
        self._login = '******'
        self._scheme = 'https'
        self._port = 443
        self.insecure = False
        self.timeout = DEFAULT_TIMEOUT
        self.teamid = ''
        self.token = ''
        self.driver = None

        # Get password from Gnome keyring, matching the stored Chromium password
        self._password = Secret.password_lookup_sync(
            SECRET_SCHEMA, {
                'username_value': self._login,
                'action_url': 'https://mattermost.example.com/login'
            }, None)
 def testSynchronous(self):
     password = Secret.password_lookup_sync(STORE_SCHEMA, {
         "number": "1",
         "even": "false"
     }, None)
     self.assertEqual("111", password)
	def testSyncNotFound(self):
		password = Secret.password_lookup_sync (STORE_SCHEMA, { "number": "5", "even": "true" }, None)
		self.assertEqual(None, password)
	def testSynchronous(self):
		password = Secret.password_lookup_sync (STORE_SCHEMA, { "number": "1", "even": "false" }, None)
		self.assertEqual("111", password)
Beispiel #14
0
 def _get_secret(self, ex_schema, kwargs):
     password = Secret.password_lookup_sync(ex_schema, kwargs, None)
     return password
Beispiel #15
0
def get_account_password(email):
    return Secret.password_lookup_sync(_ACCOUNT_SCHEMA, {"email": email}, None) or ''
Beispiel #16
0
 def is_password_enabled(self) -> bool:
     schema = self.password_state_schema
     state = Secret.password_lookup_sync(schema, {}, None)
     return state == 'true' if state else False
Beispiel #17
0
def get_password(label, username=None):
    attrs = {SCHEMA_LABEL_KEY: label}
    if username is not None:
        attrs[SCHEMA_USERNAME_KEY] = username

    return Secret.password_lookup_sync(EXAMPLE_SCHEMA, attrs, None)
Beispiel #18
0
def secret_password_lookup(attributes):
    return Secret.password_lookup_sync(GENOTP_SCHEMA, attributes, None)
Beispiel #19
0
def get_pw(account, field):
    schema, attributes, label = stuff(account, field)
    password = Secret.password_lookup_sync(schema, attributes, None)
    print "account {!r} field {!r} password {!r}".format(
        account, field, password)
    return password
Beispiel #20
0
 def load(self):
     """Load a password in the secret service, return None when found nothing"""
     return Secret.password_lookup_sync(self._schema, self._attributes,
                                        None)
Beispiel #21
0
 def get_password(self, pass_name):
     log.debug(f"get_password {pass_name}")
     passwd = Secret.password_lookup_sync(self._SECRET_SCHEMA,
                                          {"id": pass_name}, None)
     return passwd or ""
 def testSyncNotFound(self):
     password = Secret.password_lookup_sync(STORE_SCHEMA, {
         "number": "5",
         "even": "true"
     }, None)
     self.assertEqual(None, password)
Beispiel #23
0
 def get_password(self) -> str:
     schema = self.password_schema
     password = Secret.password_lookup_sync(schema, {}, None)
     return password
Beispiel #24
0
def get_account_password(email):
    return Secret.password_lookup_sync(_ACCOUNT_SCHEMA, {"email": email},
                                       None) or ''
Beispiel #25
0
 def get_sessions(self):
     sessions = Secret.password_lookup_sync(SESSION_SCHEMA,
                                            {'name': 'session'}, None)
     if not sessions:
         return None
     return sessions.split('][')
Beispiel #26
0
 def get_by_id(id_):
     """Return the secret code"""
     schema = Keyring.get_default().schema
     password = Secret.password_lookup_sync(schema, {"id": str(id_)}, None)
     return password
Beispiel #27
0
"""
Companion script to test RDP-set-credentials.py
"""

import gi
gi.require_version('Secret', '1')

from gi.repository import Secret, GLib

RDP_SCHEMA = Secret.Schema.new(
    "org.gnome.RemoteDesktop.RdpCredentials", Secret.SchemaFlags.NONE, {
        "credentials": Secret.SchemaAttributeType.STRING,
        "NULL": 0
    })

vdict = Secret.password_lookup_sync(RDP_SCHEMA, {"credentials": "username"},
                                    None)
gvd = GLib.Variant.parse(None, vdict, None, None)

assert isinstance(gvd, GLib.Variant)

uname = gvd.lookup_value("username", None)
print(uname)
pwd = gvd.lookup_value("password", None)
print(pwd)
Beispiel #28
0
 def get_token(self, uuid):
     return Secret.password_lookup_sync(
         Secret.Schema.new("nl.g4d.Girens", Secret.SchemaFlags.NONE,
                           {'uuid': Secret.SchemaAttributeType.STRING}),
         {'uuid': uuid}, None)
Beispiel #29
0
    def update_settings_ui(self):
        """ this function updates ui widgets as per settings.json """

        remote_type = self.get_setting(self.SETTING.REMOTE_TYPE)

        if (remote_type == "zip"):
            if self.get_setting(self.SETTING.REMOTE) is not None:
                self.source_file_chooser.set_filename(
                    self.get_setting(self.SETTING.REMOTE))
            self.zip_radio_btn.set_active(True)
            self.on_zip_radio_btn_toggled(None)
        elif (remote_type == "dir"):
            if self.get_setting(self.SETTING.REMOTE) is not None:
                self.source_folder_chooser.set_filename(
                    self.get_setting(self.SETTING.REMOTE))
            self.dir_radio_btn.set_active(True)
            self.on_dir_radio_btn_toggled(None)
        else:
            if remote_type is None:
                self.set_setting(self.SETTING.REMOTE_TYPE, "url")
            remote = self.get_setting(self.SETTING.REMOTE)
            self.url_radio_btn.set_active(True)
            if remote is not None:
                self.remote_addr_entry.set_text(remote)
            self.on_url_radio_btn_toggled(None)

        mgr = self.get_setting(self.SETTING.MANAGER)
        if mgr == "networkmanager":
            self.nm_radio.set_active(True)

        elif mgr == "openvpn":
            self.ovpn_radio.set_active(True)
        else:
            self.nm_radio.set_active(False)
            self.ovpn_radio.set_active(False)

        if self.get_setting(self.SETTING.UPDATE_ON_START):
            self.update_on_launch_switch.set_state(True)

        if self.get_setting(self.SETTING.NOTIFICATIONS):
            self.notification_switch.set_state(True)

        if self.get_setting(self.SETTING.REQ_AUTH):
            self.req_auth.set_active(True)

            if self.get_setting(self.SETTING.AUTH_USER) is not None:
                self.auth_user.set_text(
                    self.get_setting(self.SETTING.AUTH_USER))

                if self.get_setting(self.SETTING.MANAGER) == "networkmanager":
                    nm_password = Secret.password_lookup_sync(
                        self.EOVPN_SECRET_SCHEMA,
                        {"username": self.get_setting(self.SETTING.AUTH_USER)},
                        None)
                    if nm_password is not None:
                        self.auth_pass.set_text(nm_password)

            if self.get_setting(self.SETTING.AUTH_PASS) is not None:
                self.auth_pass.set_text(
                    self.get_setting(self.SETTING.AUTH_PASS))

        else:
            self.req_auth.set_active(False)
            self.user_pass_box.set_sensitive(False)

        ca_path = self.get_setting(self.SETTING.CA)
        if ca_path is not None:
            self.ca_chooser.set_filename(ca_path)

        if self.get_setting(self.SETTING.CONNECT_ON_LAUNCH):
            self.connect_on_launch_switch.set_state(True)

        self.on_mgr_change_revealer.set_reveal_child(False)