VirtualMailManager/VirtualMailManager.py
changeset 70 a3663ad491bf
parent 69 0c124160a991
child 76 14c0a092d7d2
equal deleted inserted replaced
69:0c124160a991 70:a3663ad491bf
   389             from base64 import standard_b64encode
   389             from base64 import standard_b64encode
   390             return standard_b64encode(_md5.digest())
   390             return standard_b64encode(_md5.digest())
   391         elif self.__scheme == 'PLAIN-MD5':
   391         elif self.__scheme == 'PLAIN-MD5':
   392             return _md5.hexdigest()
   392             return _md5.hexdigest()
   393         elif self.__scheme == 'DIGEST-MD5' and emailaddress is not None:
   393         elif self.__scheme == 'DIGEST-MD5' and emailaddress is not None:
   394             _md5 = md5.new('%s:%s:' % tuple(emailaddress.split('@')))
   394             # use an empty realm - works better with usenames like user@dom
   395             _md5.update(password)
   395             _md5 = md5.new('%s::%s' % (emailaddress, password))
   396             return _md5.hexdigest()
   396             return _md5.hexdigest()
   397 
   397 
   398     def __pwMD4(self, password):
   398     def __pwMD4(self, password):
   399         # for: PLAIN-MD4
   399         # for: PLAIN-MD4
   400         from Crypto.Hash import MD4
   400         from Crypto.Hash import MD4
   633         return getAccountByID(uid, self.__dbh)
   633         return getAccountByID(uid, self.__dbh)
   634 
   634 
   635     def userPassword(self, emailaddress, password):
   635     def userPassword(self, emailaddress, password):
   636         acc = self.__getAccount(emailaddress)
   636         acc = self.__getAccount(emailaddress)
   637         if acc.getUID() == 0:
   637         if acc.getUID() == 0:
   638            raise VMMException(_(u"Account doesn't exists"),
   638            raise VMMException(_(u"Account doesn't exists"), ERR.NO_SUCH_ACCOUNT)
   639                ERR.NO_SUCH_ACCOUNT)
       
   640         if password is None:
   639         if password is None:
   641             password = self._readpass()
   640             password = self._readpass()
   642         acc.modify('password', self.__pwhash(password))
   641         acc.modify('password', self.__pwhash(password, user=emailaddress))
   643 
   642 
   644     def userName(self, emailaddress, name):
   643     def userName(self, emailaddress, name):
   645         acc = self.__getAccount(emailaddress)
   644         acc = self.__getAccount(emailaddress)
   646         acc.modify('name', name)
   645         acc.modify('name', name)
   647 
   646