gssapi/creds.py
def imprt(cls, token):
        """
        Deserializes a byte string token into a :class:`Credential` object. The token must have
        previously been exported by the same GSSAPI implementation as is being used to import it.

        :param token: A token previously obtained from the :meth:`export` of another
            :class:`Credential` object.
        :type token: bytes
        :returns: A :class:`Credential` object constructed from the token.
        :raises: :exc:`~gssapi.error.GSSException` if there is a problem with importing the
            credential.

            :exc:`NotImplementedError` if the underlying GSSAPI implementation does not
            support the ``gss_import_cred`` C function.
        """
        if not hasattr(C, 'gss_import_cred'):
            raise NotImplementedError("The GSSAPI implementation does not support gss_import_cred")

        minor_status = ffi.new('OM_uint32[1]')

        token_buffer = ffi.new('gss_buffer_desc[1]')
        token_buffer[0].length = len(token)
        c_str_token = ffi.new('char[]', token)
        token_buffer[0].value = c_str_token

        imported_cred = ffi.new('gss_cred_id_t[1]')

        retval = C.gss_import_cred(minor_status, token_buffer, imported_cred)
        try:
            if GSS_ERROR(retval):
                raise _exception_for_status(retval, minor_status[0])

            return cls(imported_cred)
        except:
            _release_gss_cred_id_t(imported_cred)
            raise
def imprt(cls, token):
        """
        Deserializes a byte string token into a :class:`Credential` object. The token must have
        previously been exported by the same GSSAPI implementation as is being used to import it.

        :param token: A token previously obtained from the :meth:`export` of another
            :class:`Credential` object.
        :type token: bytes
        :returns: A :class:`Credential` object constructed from the token.
        :raises: :exc:`~gssapi.error.GSSException` if there is a problem with importing the
            credential.

            :exc:`NotImplementedError` if the underlying GSSAPI implementation does not
            support the ``gss_import_cred`` C function.
        """
        if not hasattr(C, 'gss_import_cred'):
            raise NotImplementedError("The GSSAPI implementation does not support gss_import_cred")

        minor_status = ffi.new('OM_uint32[1]')

        token_buffer = ffi.new('gss_buffer_desc[1]')
        token_buffer[0].length = len(token)
        c_str_token = ffi.new('char[]', token)
        token_buffer[0].value = c_str_token

        imported_cred = ffi.new('gss_cred_id_t[1]')

        retval = C.gss_import_cred(minor_status, token_buffer, imported_cred)
        try:
            if GSS_ERROR(retval):
                raise _exception_for_status(retval, minor_status[0])

            return cls(imported_cred)
        except:
            _release_gss_cred_id_t(imported_cred)
            raise
Deserializes a byte string token into a :class:`Credential` object. The token must have
        previously been exported by the same GSSAPI implementation as is being used to import it.

        :param token: A token previously obtained from the :meth:`export` of another
            :class:`Credential` object.
        :type token: bytes
        :returns: A :class:`Credential` object constructed from the token.
        :raises: :exc:`~gssapi.error.GSSException` if there is a problem with importing the
            credential.

            :exc:`NotImplementedError` if the underlying GSSAPI implementation does not
            support the ``gss_import_cred`` C function.