aiosasl/__init__.py
def response(self, payload):
        """
        Send a response to the previously received challenge, with the given
        `payload`. The payload is encoded using base64 and transmitted to the
        server.

        Return the next state of the state machine as tuple (see
        :class:`SASLStateMachine` for details).
        """
        if self._state == SASLState.SUCCESS_SIMULATE_CHALLENGE:
            if payload != b"":
                # XXX: either our mechanism is buggy or the server
                # sent SASLState.SUCCESS before all challenge-response
                # messages defined by the mechanism were sent
                self._state = SASLState.FAILURE
                raise SASLFailure(
                    None,
                    "protocol violation: mechanism did not"
                    " respond with an empty response to a"
                    " challenge with final data – this suggests"
                    " a protocol-violating early success from the server."
                )
            self._state = SASLState.SUCCESS
            return SASLState.SUCCESS, None

        if self._state != SASLState.CHALLENGE:
            raise RuntimeError(
                "no challenge has been made or negotiation failed")

        try:
            next_state, payload = yield from self.interface.respond(payload)
        except SASLFailure:
            self._state = SASLState.FAILURE
            raise

        next_state = SASLState.from_reply(next_state)

        # unfold the (SASLState.SUCCESS, payload) to a sequence of
        # (SASLState.CHALLENGE, payload), (SASLState.SUCCESS, None) for the SASLMethod
        # to allow uniform treatment of both cases
        if next_state == SASLState.SUCCESS and payload is not None:
            self._state = SASLState.SUCCESS_SIMULATE_CHALLENGE
            return SASLState.CHALLENGE, payload

        self._state = next_state
        return next_state, payload
def response(self, payload):
        if self._state == SASLState.SUCCESS_SIMULATE_CHALLENGE:
            if payload != b"":
                # XXX: either our mechanism is buggy or the server
                # sent SASLState.SUCCESS before all challenge-response
                # messages defined by the mechanism were sent
                self._state = SASLState.FAILURE
                raise SASLFailure(
                    None,
                    "protocol violation: mechanism did not"
                    " respond with an empty response to a"
                    " challenge with final data – this suggests"
                    " a protocol-violating early success from the server."
                )
            self._state = SASLState.SUCCESS
            return SASLState.SUCCESS, None

        if self._state != SASLState.CHALLENGE:
            raise RuntimeError(
                "no challenge has been made or negotiation failed")

        try:
            next_state, payload = yield from self.interface.respond(payload)
        except SASLFailure:
            self._state = SASLState.FAILURE
            raise

        next_state = SASLState.from_reply(next_state)

        # unfold the (SASLState.SUCCESS, payload) to a sequence of
        # (SASLState.CHALLENGE, payload), (SASLState.SUCCESS, None) for the SASLMethod
        # to allow uniform treatment of both cases
        if next_state == SASLState.SUCCESS and payload is not None:
            self._state = SASLState.SUCCESS_SIMULATE_CHALLENGE
            return SASLState.CHALLENGE, payload

        self._state = next_state
        return next_state, payload
def response ( self , payload ) : if self . _state == SASLState . SUCCESS_SIMULATE_CHALLENGE : if payload != b"" : # XXX: either our mechanism is buggy or the server # sent SASLState.SUCCESS before all challenge-response # messages defined by the mechanism were sent self . _state = SASLState . FAILURE raise SASLFailure ( None , "protocol violation: mechanism did not" " respond with an empty response to a" " challenge with final data – this suggests" " a protocol-violating early success from the server." ) self . _state = SASLState . SUCCESS return SASLState . SUCCESS , None if self . _state != SASLState . CHALLENGE : raise RuntimeError ( "no challenge has been made or negotiation failed" ) try : next_state , payload = yield from self . interface . respond ( payload ) except SASLFailure : self . _state = SASLState . FAILURE raise next_state = SASLState . from_reply ( next_state ) # unfold the (SASLState.SUCCESS, payload) to a sequence of # (SASLState.CHALLENGE, payload), (SASLState.SUCCESS, None) for the SASLMethod # to allow uniform treatment of both cases if next_state == SASLState . SUCCESS and payload is not None : self . _state = SASLState . SUCCESS_SIMULATE_CHALLENGE return SASLState . CHALLENGE , payload self . _state = next_state return next_state , payload
Send a response to the previously received challenge, with the given
        `payload`. The payload is encoded using base64 and transmitted to the
        server.

        Return the next state of the state machine as tuple (see
        :class:`SASLStateMachine` for details).
Send a response to the previously received challenge with the given payload . The payload is encoded using base64 and transmitted to the server .