services/presence/: identify Buddies by "key ID" (pubkey hash), not whole key.

This allows us to create Buddy objects as soon as we see a contact on the
server. For contacts not on trusted servers, or seen in anonymous MUCs, we
create a Buddy identified by JID instead (so we have some way to talk
about the anonymous contact within the Sugar API).

The concept of "trusted server" means a server which we trust to validate that
users with a keyID as the username part of their JID do in fact have that key.
Currently we just pretend that olpc.collabora.co.uk does this - in future, the
school servers will do this validation by using key rather than password
authentication.

Also create Buddy object paths based on the keyID or JID (for easier debugging).
This commit is contained in:
Simon McVittie
2007-05-28 17:25:52 +01:00
parent 5dacfdd365
commit a4a06206e3
4 changed files with 165 additions and 48 deletions
+6 -4
View File
@@ -26,6 +26,7 @@ from sugar import env, util
from buddy import GenericOwner, _PROP_NICK, _PROP_CURACT, _PROP_COLOR
from presenceservice import PresenceService
from psutils import pubkey_to_keyid
_logger = logging.getLogger('s-p-s.pstest')
@@ -37,7 +38,7 @@ class TestOwner(GenericOwner):
__gtype_name__ = "TestOwner"
def __init__(self, ps, bus, object_id, test_num, randomize):
def __init__(self, ps, bus, test_num, randomize):
self._cp = ConfigParser()
self._section = "Info"
self._test_activities = []
@@ -62,8 +63,9 @@ class TestOwner(GenericOwner):
icon = _get_random_image()
_logger.debug("pubkey is %s" % pubkey)
GenericOwner.__init__(self, ps, bus, object_id, key=pubkey, nick=nick,
color=color, icon=icon, registered=registered, key_hash=privkey_hash)
GenericOwner.__init__(self, ps, bus, pubkey_to_keyid(pubkey),
key=pubkey, nick=nick, color=color, icon=icon,
registered=registered, key_hash=privkey_hash)
# Only do the random stuff if randomize is true
if randomize:
@@ -169,7 +171,7 @@ class TestPresenceService(PresenceService):
PresenceService.__init__(self)
def _create_owner(self):
return TestOwner(self, self._session_bus, self._get_next_object_id(),
return TestOwner(self, self._session_bus,
self.__test_num, self.__randomize)
def internal_get_activity(self, actid):