gssapi/ctx.py
def delete(self):
        """
        Delete a security context. This method will delete the local data structures associated
        with the specified security context, and may return an output token, which when passed to
        :meth:`process_context_token` on the peer may instruct it to also delete its context.

        RFC 2744 recommends that GSSAPI mechanisms do not emit any output token when they're
        deleted, so this behaviour could be considered deprecated.

        After this method is called, this security context will become invalid and should not be
        used in any way.

        :returns: An output token if one was emitted by the GSSAPI mechanism, otherwise an empty
            bytestring.
        :rtype: bytes
        """

        if not self._ctx[0]:
            raise GSSException("Can't delete invalid context")
        output_token_buffer = ffi.new('gss_buffer_desc[1]')
        minor_status = ffi.new('OM_uint32[1]')
        retval = C.gss_delete_sec_context(
            minor_status,
            self._ctx,
            output_token_buffer
        )
        self._ctx = ffi.new('gss_ctx_id_t[1]')
        self._reset_flags()
        try:
            if GSS_ERROR(retval):
                if minor_status[0] and self.mech_type:
                    raise _exception_for_status(retval, minor_status[0], self.mech_type)
                else:
                    raise _exception_for_status(retval, minor_status[0])

            return _buf_to_str(output_token_buffer[0])
        finally:
            if output_token_buffer[0].length != 0:
                C.gss_release_buffer(minor_status, output_token_buffer)
def delete(self):
        """
        Delete a security context. This method will delete the local data structures associated
        with the specified security context, and may return an output token, which when passed to
        :meth:`process_context_token` on the peer may instruct it to also delete its context.

        RFC 2744 recommends that GSSAPI mechanisms do not emit any output token when they're
        deleted, so this behaviour could be considered deprecated.

        After this method is called, this security context will become invalid and should not be
        used in any way.

        :returns: An output token if one was emitted by the GSSAPI mechanism, otherwise an empty
            bytestring.
        :rtype: bytes
        """

        if not self._ctx[0]:
            raise GSSException("Can't delete invalid context")
        output_token_buffer = ffi.new('gss_buffer_desc[1]')
        minor_status = ffi.new('OM_uint32[1]')
        retval = C.gss_delete_sec_context(
            minor_status,
            self._ctx,
            output_token_buffer
        )
        self._ctx = ffi.new('gss_ctx_id_t[1]')
        self._reset_flags()
        try:
            if GSS_ERROR(retval):
                if minor_status[0] and self.mech_type:
                    raise _exception_for_status(retval, minor_status[0], self.mech_type)
                else:
                    raise _exception_for_status(retval, minor_status[0])

            return _buf_to_str(output_token_buffer[0])
        finally:
            if output_token_buffer[0].length != 0:
                C.gss_release_buffer(minor_status, output_token_buffer)
Delete a security context. This method will delete the local data structures associated
        with the specified security context, and may return an output token, which when passed to
        :meth:`process_context_token` on the peer may instruct it to also delete its context.

        RFC 2744 recommends that GSSAPI mechanisms do not emit any output token when they're
        deleted, so this behaviour could be considered deprecated.

        After this method is called, this security context will become invalid and should not be
        used in any way.

        :returns: An output token if one was emitted by the GSSAPI mechanism, otherwise an empty
            bytestring.
        :rtype: bytes