1
# This application is released under the GNU General Public License
2
# v3 (or, at your option, any later version). You can find the full
3
# text of the license under http://www.gnu.org/licenses/gpl.txt.
4
# By using, editing and/or distributing this software you agree to
5
# the terms and conditions of this license.
6
# Thank you for using free software!
8
# keyring-test.py(c) RYX 2007 <ryx [at] ryxperience [dot] com>
16
HAVE_GNOMEKEYRING = False
18
HAVE_GNOMEKEYRING = True
22
#gtk.set_application_name("keyring-test")
25
if not gnomekeyring.is_available():
26
print "Keyring not available."
27
# list names of keyrings and use the first one we can find
28
keyring_list = gnomekeyring.list_keyring_names_sync()
29
if len(keyring_list) == 0:
30
print "No keyrings available."
34
print "We have %i keyrings" % len(keyring_list)
35
print "KEYRING: %s" % keyring_list[0]
36
# name/password to store
40
keyring = gnomekeyring.get_default_keyring_sync() # crashes if no default exists
42
attribs = dict(name=name, magic='something')
44
# create keyring item with password
45
auth_token = gnomekeyring.item_create_sync(keyring,
46
gnomekeyring.ITEM_GENERIC_SECRET, name, attribs, password, True)
48
print "save: token for account %s: %i" % (name, auth_token)
49
token = "gnomekeyring:%i" % (auth_token,)
52
# now read it back from the keyring
53
print "Password read from keyring is:"
54
print gnomekeyring.item_get_info_sync(keyring, auth_token).get_secret()