Example #1
0
    def updateUserPassword(self, user_id, login_name, password):
        existingUser = self.getUserInfo(user_id)
        if existingUser is None:
            raise KeyError, 'Invalid user ID: %s' % user_id

        encrypter = encrypt.find_encrypter(self.default_encryption)
        if encrypter is None:
            raise LookupError('Could not find an encrypter for "%s"'
                              % self.default_encryption)
        self.sqlUpdateUser(username=login_name,
                           password=encrypter.encrypt(password))
Example #2
0
    def addUser(self, user_id, login_name, password):
        encrypter = encrypt.find_encrypter(self.default_encryption)
        if encrypter is None:
            raise LookupError('Could not find an encrypter for "%s"'
                              % self.default_encryption)
        password = encrypter.encrypt(password)

        existingUser = self.getUserInfo(user_id)
        if existingUser:
            raise KeyError, 'Duplicate user ID: %s' % user_id
        self.sqlCreateUser(username=login_name, password=password)
        self.invalidateCacheForChangedUser(user_id)
Example #3
0
    def authenticateCredentials(self, credentials):
        """See IAuthenticationPlugin.

        o We expect the credentials to be those returned by
          ILoginPasswordExtractionPlugin.
        """
        login = credentials.get('login')
        password = credentials.get('password')

        if login is None or password is None:
            return None

        user = self.getUserInfo(login, auth=True)
        if user:
            encrypter = encrypt.find_encrypter(self.default_encryption)
            if encrypter is None:
                raise LookupError('Could not find an encrypter for "%s"'
                                  % self.default_encryption)

            if encrypter.validate(user['password'], password):
                return login, login

        return None