def authenticate(self):
<EOL>if self._authenticated is not None:<EOL><INDENT>return self._authenticated<EOL><DEDENT>self._logger.debug('<STR_LIT>' % self.username)<EOL>user = self.get_user(self.username)<EOL>if user is None:<EOL><INDENT>self._logger.debug('<STR_LIT>' % self.username)<EOL>self._authenticated = False<EOL>return self._authenticated<EOL><DEDENT>if self._gen_hash(self.password, user['<STR_LIT>']) != user['<STR_LIT>']:<EOL><INDENT>self._logger.debug('<STR_LIT>' % self.username)<EOL>self._authenticated = False<EOL>return self._authenticated<EOL><DEDENT>self.authenticated_as = self.username<EOL>self._authenticated = True<EOL>self.trusted = bool(user['<STR_LIT>'])<EOL>self.readonly = bool(user['<STR_LIT>'])<EOL>if self.trusted:<EOL><INDENT>if '<STR_LIT:username>' in self._auth_options:<EOL><INDENT>self.username = self._auth_options['<STR_LIT:username>']<EOL><DEDENT>if '<STR_LIT>' in self._auth_options:<EOL><INDENT>self.full_name = self._auth_options['<STR_LIT>']<EOL><DEDENT>if '<STR_LIT>' in self._auth_options:<EOL><INDENT>self.authoritative_source = self._auth_options['<STR_LIT>']<EOL><DEDENT>if '<STR_LIT>' in self._auth_options:<EOL><INDENT>self.readonly = self._auth_options['<STR_LIT>']<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self.full_name = user['<STR_LIT>']<EOL><DEDENT>self._logger.debug('<STR_LIT>' % (self.authenticated_as, self.username, self.full_name, str(self.readonly)))<EOL>return self._authenticated<EOL>
Verify authentication.

            Returns True/False dependant on whether the authentication
            succeeded or not.