def auth_in_stage2(self,stanza):
self.lock.acquire()<EOL>try:<EOL><INDENT>if "<STR_LIT>" not in self.auth_methods and "<STR_LIT>" not in self.auth_methods:<EOL><INDENT>iq=stanza.make_error_response("<STR_LIT>")<EOL>self.send(iq)<EOL>return<EOL><DEDENT>username=stanza.xpath_eval("<STR_LIT>",{"<STR_LIT:a>":"<STR_LIT>"})<EOL>if username:<EOL><INDENT>username=from_utf8(username[<NUM_LIT:0>].getContent())<EOL><DEDENT>resource=stanza.xpath_eval("<STR_LIT>",{"<STR_LIT:a>":"<STR_LIT>"})<EOL>if resource:<EOL><INDENT>resource=from_utf8(resource[<NUM_LIT:0>].getContent())<EOL><DEDENT>if not username or not resource:<EOL><INDENT>self.__logger.debug("<STR_LIT>")<EOL>iq=stanza.make_error_response("<STR_LIT>")<EOL>self.send(iq)<EOL>return<EOL><DEDENT>if stanza.xpath_eval("<STR_LIT>",{"<STR_LIT:a>":"<STR_LIT>"}):<EOL><INDENT>if "<STR_LIT>" not in self.auth_methods:<EOL><INDENT>iq=stanza.make_error_response("<STR_LIT>")<EOL>self.send(iq)<EOL>return<EOL><DEDENT>else:<EOL><INDENT>return self._plain_auth_in_stage2(username,resource,stanza)<EOL><DEDENT><DEDENT>if stanza.xpath_eval("<STR_LIT>",{"<STR_LIT:a>":"<STR_LIT>"}):<EOL><INDENT>if "<STR_LIT>" not in self.auth_methods:<EOL><INDENT>iq=stanza.make_error_response("<STR_LIT>")<EOL>self.send(iq)<EOL>return<EOL><DEDENT>else:<EOL><INDENT>return self._digest_auth_in_stage2(username,resource,stanza)<EOL><DEDENT><DEDENT><DEDENT>finally:<EOL><INDENT>self.lock.release()<EOL><DEDENT>
Handle the second stage (<iq type='set'/>) of legacy ("plain" or
        "digest") authentication.

        [server only]