@stream_element_handler(AUTH_TAG, "<STR_LIT>")<EOL><INDENT>def process_sasl_auth(self, stream, element):<DEDENT>
if self.authenticator:<EOL><INDENT>logger.debug("<STR_LIT>")<EOL>return False<EOL><DEDENT>password_db = self.settings["<STR_LIT>"]<EOL>mechanism = element.get("<STR_LIT>")<EOL>if not mechanism:<EOL><INDENT>stream.send_stream_error("<STR_LIT>")<EOL>raise FatalStreamError("<STR_LIT>")<EOL><DEDENT>stream.auth_method_used = mechanism<EOL>self.authenticator = sasl.server_authenticator_factory(mechanism,<EOL>password_db)<EOL>content = element.text.encode("<STR_LIT>")<EOL>ret = self.authenticator.start(stream.auth_properties,<EOL>a2b_base64(content))<EOL>if isinstance(ret, sasl.Success):<EOL><INDENT>element = ElementTree.Element(SUCCESS_TAG)<EOL>element.text = ret.encode()<EOL><DEDENT>elif isinstance(ret, sasl.Challenge):<EOL><INDENT>element = ElementTree.Element(CHALLENGE_TAG)<EOL>element.text = ret.encode()<EOL><DEDENT>else:<EOL><INDENT>element = ElementTree.Element(FAILURE_TAG)<EOL>ElementTree.SubElement(element, SASL_QNP + ret.reason)<EOL><DEDENT>stream.write_element(element)<EOL>if isinstance(ret, sasl.Success):<EOL><INDENT>self._handle_auth_success(stream, ret)<EOL><DEDENT>elif isinstance(ret, sasl.Failure):<EOL><INDENT>raise SASLAuthenticationFailed("<STR_LIT>"<EOL>.format(ret.reason))<EOL><DEDENT>return True<EOL>
Process incoming <sasl:auth/> element.

        [receiving entity only]