core: misc improvments:
- added some constants for message types and presence
- removed profile authentification specific methods in favor of a more generic "validated" key
This commit is contained in:
parent
6e144c6458
commit
05e5e1448b
1 changed files with 35 additions and 14 deletions
|
|
@ -332,8 +332,11 @@ class Memory(object):
|
|||
|
||||
def getProfileName(self, profile_key, return_profile_keys=False):
|
||||
"""Return name of profile from keyword
|
||||
|
||||
@param profile_key: can be the profile name or a keywork (like @DEFAULT@)
|
||||
@return: profile name or None if it doesn't exist"""
|
||||
@param return_profile_keys: if True, return unmanaged profile keys (like "@ALL@"). This keys must be managed by the caller
|
||||
@return: requested profile name or emptry string if it doesn't exist
|
||||
"""
|
||||
return self.params.getProfileName(profile_key, return_profile_keys)
|
||||
|
||||
def asyncCreateProfile(self, name, password=''):
|
||||
|
|
@ -342,6 +345,10 @@ class Memory(object):
|
|||
@param password: profile password
|
||||
@return: Deferred
|
||||
"""
|
||||
if not name:
|
||||
raise ValueError("Empty profile name")
|
||||
if name[0] == '@':
|
||||
raise ValueError("A profile name can't start with a '@'")
|
||||
personal_key = BlockCipher.getRandomKey(base64=True) # generated once for all and saved in a PersistentDict
|
||||
self.auth_sessions.newSession({C.MEMORY_CRYPTO_KEY: personal_key}, profile=name) # will be encrypted by setParam
|
||||
d = self.params.asyncCreateProfile(name)
|
||||
|
|
@ -579,7 +586,7 @@ class Memory(object):
|
|||
try:
|
||||
del self._entities_cache[profile][entity]
|
||||
except KeyError:
|
||||
log.debug("Can't delete entity [%s]: not in cache" % entity.full())
|
||||
log.warning(_("Can't delete entity [{}]: not in cache").format(entity.full()))
|
||||
|
||||
def encryptValue(self, value, profile):
|
||||
"""Encrypt a value for the given profile. The personal key must be loaded
|
||||
|
|
|
|||
Loading…
Reference in a new issue