def _digest_auth_in_stage2(self, username, _unused, stanza):
digest=stanza.xpath_eval("<STR_LIT>",{"<STR_LIT:a>":"<STR_LIT>"})<EOL>if digest:<EOL><INDENT>digest=digest[<NUM_LIT:0>].getContent()<EOL><DEDENT>if not digest:<EOL><INDENT>self.__logger.debug("<STR_LIT>")<EOL>iq=stanza.make_error_response("<STR_LIT>")<EOL>self.send(iq)<EOL>return<EOL><DEDENT>password,pwformat=self.get_password(username)<EOL>if not password or pwformat!="<STR_LIT>":<EOL><INDENT>iq=stanza.make_error_response("<STR_LIT>")<EOL>e=iq.get_error()<EOL>e.add_custom_condition('<STR_LIT>',"<STR_LIT>")<EOL>self.send(iq)<EOL>return<EOL><DEDENT>mydigest = hashlib.sha1(to_utf8(self.stream_id)+to_utf8(password)).hexdigest()<EOL>if mydigest==digest:<EOL><INDENT>iq=stanza.make_result_response()<EOL>self.send(iq)<EOL>self.peer_authenticated=True<EOL>self.auth_method_used="<STR_LIT>"<EOL>self.state_change("<STR_LIT>",self.peer)<EOL>self._post_auth()<EOL><DEDENT>else:<EOL><INDENT>self.__logger.debug("<STR_LIT>" % (digest,mydigest))<EOL>iq=stanza.make_error_response("<STR_LIT>")<EOL>e=iq.get_error()<EOL>e.add_custom_condition('<STR_LIT>',"<STR_LIT>")<EOL>self.send(iq)<EOL><DEDENT>
Handle the second stage (<iq type='set'/>) of legacy "digest"
        authentication.

        [server only]