Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar/profile.py
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2007-02-26 00:24:48 (GMT)
committer Dan Williams <dcbw@redhat.com>2007-02-26 00:24:48 (GMT)
commita72175ff68de54fac9f50136b29f9d156400a5a7 (patch)
tree356850eb7029a81a411abcf42aa6d7686f0c5e7f /sugar/profile.py
parent1f91f7f7afd34143721ac66936546e4444950369 (diff)
Create separate plugins for connection methods
Diffstat (limited to 'sugar/profile.py')
-rw-r--r--sugar/profile.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/sugar/profile.py b/sugar/profile.py
index 43f3657..f34e390 100644
--- a/sugar/profile.py
+++ b/sugar/profile.py
@@ -19,6 +19,7 @@ import logging
from ConfigParser import ConfigParser
from sugar import env
+from sugar import util
from sugar.graphics.xocolor import XoColor
class _Profile(object):
@@ -26,6 +27,7 @@ class _Profile(object):
self.name = None
self.color = None
self.pubkey = None
+ self.privkey_hash = None
self._load()
def update(self):
@@ -45,6 +47,7 @@ class _Profile(object):
del cp
self._load_pubkey()
+ self._hash_private_key()
def _load_pubkey(self):
self.pubkey = None
@@ -68,6 +71,32 @@ class _Profile(object):
if not self.pubkey:
logging.error("Error parsing public key.")
+ def _hash_private_key(self):
+ self.privkey_hash = None
+
+ key_path = os.path.join(env.get_profile_path(), 'owner.key')
+ try:
+ f = open(key_path, "r")
+ lines = f.readlines()
+ f.close()
+ except IOError, e:
+ logging.error("Error reading private key: %s" % e)
+ return
+
+ key = ""
+ for l in lines:
+ l = l.strip()
+ if l.startswith("-----BEGIN DSA PRIVATE KEY-----"):
+ continue
+ if l.startswith("-----END DSA PRIVATE KEY-----"):
+ continue
+ key += l
+ if not len(key):
+ logging.error("Error parsing public key.")
+
+ # hash it
+ key_hash = util._sha_data(key)
+ self.privkey_hash = util.printable_hash(key_hash)
def get_nick_name():
return _profile.name
@@ -78,6 +107,9 @@ def get_color():
def get_pubkey():
return _profile.pubkey
+def get_private_key_hash():
+ return _profile.privkey_hash
+
def update():
_profile.update()