def imprt(import_token):
        """
        This is the corresponding method to :meth:`export`, used to import a saved context token
        from another process into this one and construct a :class:`Context` object from it.

        :param import_token: a token obtained from the :meth:`export` of another context
        :type import_token: bytes
        :returns: a Context object created from the imported token
        :rtype: :class:`Context`
        """

        minor_status = ffi.new('OM_uint32[1]')
        import_token_buffer = ffi.new('gss_buffer_desc[1]')
        import_token_buffer[0].length = len(import_token)
        c_str_import_token = ffi.new('char[]', import_token)
        import_token_buffer[0].value = c_str_import_token
        new_context = ffi.new('gss_ctx_id_t[1]')
        retval = C.gss_import_sec_context(
            minor_status,
            import_token_buffer,
            new_context
        )
        try:
            if GSS_ERROR(retval):
                raise _exception_for_status(retval, minor_status[0])

            src_name = ffi.new('gss_name_t[1]')
            target_name = ffi.new('gss_name_t[1]')
            mech_type = ffi.new('gss_OID[1]')
            flags = ffi.new('OM_uint32[1]')
            locally_initiated = ffi.new('int[1]')
            established = ffi.new('int[1]')
            retval = C.gss_inquire_context(
                minor_status,
                new_context[0],
                src_name,
                target_name,
                ffi.NULL,  # lifetime_rec
                mech_type,
                flags,
                locally_initiated,
                established
            )
            src_name = Name(src_name)
            target_name = Name(target_name)
            if GSS_ERROR(retval):
                raise _exception_for_status(retval, minor_status[0])

            mech = OID(mech_type[0][0]) if mech_type[0] else None

            if locally_initiated:
                new_context_obj = InitContext(target_name, mech_type=mech)
            else:
                new_context_obj = AcceptContext()
                new_context_obj.peer_name = src_name
            new_context_obj.mech_type = mech
            new_context_obj.flags = flags[0]
            new_context_obj.established = bool(established[0])
            new_context_obj._ctx = ffi.gc(new_context, _release_gss_ctx_id_t)
            return new_context_obj
        except:
            if new_context[0]:
                C.gss_delete_sec_context(
                    minor_status,
                    new_context,
                    ffi.cast('gss_buffer_t', C.GSS_C_NO_BUFFER)
                )
            raise
def imprt(import_token):
        """
        This is the corresponding method to :meth:`export`, used to import a saved context token
        from another process into this one and construct a :class:`Context` object from it.

        :param import_token: a token obtained from the :meth:`export` of another context
        :type import_token: bytes
        :returns: a Context object created from the imported token
        :rtype: :class:`Context`
        """

        minor_status = ffi.new('OM_uint32[1]')
        import_token_buffer = ffi.new('gss_buffer_desc[1]')
        import_token_buffer[0].length = len(import_token)
        c_str_import_token = ffi.new('char[]', import_token)
        import_token_buffer[0].value = c_str_import_token
        new_context = ffi.new('gss_ctx_id_t[1]')
        retval = C.gss_import_sec_context(
            minor_status,
            import_token_buffer,
            new_context
        )
        try:
            if GSS_ERROR(retval):
                raise _exception_for_status(retval, minor_status[0])

            src_name = ffi.new('gss_name_t[1]')
            target_name = ffi.new('gss_name_t[1]')
            mech_type = ffi.new('gss_OID[1]')
            flags = ffi.new('OM_uint32[1]')
            locally_initiated = ffi.new('int[1]')
            established = ffi.new('int[1]')
            retval = C.gss_inquire_context(
                minor_status,
                new_context[0],
                src_name,
                target_name,
                ffi.NULL,  # lifetime_rec
                mech_type,
                flags,
                locally_initiated,
                established
            )
            src_name = Name(src_name)
            target_name = Name(target_name)
            if GSS_ERROR(retval):
                raise _exception_for_status(retval, minor_status[0])

            mech = OID(mech_type[0][0]) if mech_type[0] else None

            if locally_initiated:
                new_context_obj = InitContext(target_name, mech_type=mech)
            else:
                new_context_obj = AcceptContext()
                new_context_obj.peer_name = src_name
            new_context_obj.mech_type = mech
            new_context_obj.flags = flags[0]
            new_context_obj.established = bool(established[0])
            new_context_obj._ctx = ffi.gc(new_context, _release_gss_ctx_id_t)
            return new_context_obj
        except:
            if new_context[0]:
                C.gss_delete_sec_context(
                    minor_status,
                    new_context,
                    ffi.cast('gss_buffer_t', C.GSS_C_NO_BUFFER)
                )
            raise
def imprt ( import_token ) : minor_status = ffi . new ( 'OM_uint32[1]' ) import_token_buffer = ffi . new ( 'gss_buffer_desc[1]' ) import_token_buffer [ 0 ] . length = len ( import_token ) c_str_import_token = ffi . new ( 'char[]' , import_token ) import_token_buffer [ 0 ] . value = c_str_import_token new_context = ffi . new ( 'gss_ctx_id_t[1]' ) retval = C . gss_import_sec_context ( minor_status , import_token_buffer , new_context ) try : if GSS_ERROR ( retval ) : raise _exception_for_status ( retval , minor_status [ 0 ] ) src_name = ffi . new ( 'gss_name_t[1]' ) target_name = ffi . new ( 'gss_name_t[1]' ) mech_type = ffi . new ( 'gss_OID[1]' ) flags = ffi . new ( 'OM_uint32[1]' ) locally_initiated = ffi . new ( 'int[1]' ) established = ffi . new ( 'int[1]' ) retval = C . gss_inquire_context ( minor_status , new_context [ 0 ] , src_name , target_name , ffi . NULL , # lifetime_rec mech_type , flags , locally_initiated , established ) src_name = Name ( src_name ) target_name = Name ( target_name ) if GSS_ERROR ( retval ) : raise _exception_for_status ( retval , minor_status [ 0 ] ) mech = OID ( mech_type [ 0 ] [ 0 ] ) if mech_type [ 0 ] else None if locally_initiated : new_context_obj = InitContext ( target_name , mech_type = mech ) else : new_context_obj = AcceptContext ( ) new_context_obj . peer_name = src_name new_context_obj . mech_type = mech new_context_obj . flags = flags [ 0 ] new_context_obj . established = bool ( established [ 0 ] ) new_context_obj . _ctx = ffi . gc ( new_context , _release_gss_ctx_id_t ) return new_context_obj except : if new_context [ 0 ] : C . gss_delete_sec_context ( minor_status , new_context , ffi . cast ( 'gss_buffer_t' , C . GSS_C_NO_BUFFER ) ) raise
This is the corresponding method to :meth:`export`, used to import a saved context token
        from another process into this one and construct a :class:`Context` object from it.

        :param import_token: a token obtained from the :meth:`export` of another context
        :type import_token: bytes
        :returns: a Context object created from the imported token
        :rtype: :class:`Context`
This is the corresponding method to : meth : export used to import a saved context token from another process into this one and construct a : class : Context object from it .