How to use the gssapi._utils._get_encoding function in gssapi

To help you get started, we’ve selected a few gssapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pythongssapi / python-gssapi / gssapi / mechs.py View on Github external
def _bytes_desc(self):
        base = self.dotted_form
        if rfc5801 is not None and self._saslname and self._saslname.mech_name:
            base = self._saslname.mech_name

        if isinstance(base, str):
            base = base.encode(_utils._get_encoding())

        return base
github pythongssapi / python-gssapi / gssapi / names.py View on Github external
# where GSS_C_NT_COMPOSITE_EXPORT doesn't trigger
                        # immediate import logic.  However, we can just use
                        # the normal GSS_C_NT_EXPORT_NAME in this case.
                        base_name = rname.import_name(token, NameType.export)
                else:
                    # NB(directxman12): some older versions of MIT krb5 don't
                    # have support for the GSS_C_NT_COMPOSITE_EXPORT, but do
                    # support composite tokens via GSS_C_NT_EXPORT_NAME.
                    base_name = rname.import_name(token, NameType.export)
            else:
                base_name = rname.import_name(token, NameType.export)
        elif isinstance(base, rname.Name):
            base_name = base
        else:
            if isinstance(base, str):
                base = base.encode(_utils._get_encoding())

            base_name = rname.import_name(base, name_type)

        return super(Name, cls).__new__(cls, base_name)
github pythongssapi / python-gssapi / gssapi / names.py View on Github external
def __str__(self):
        return bytes(self).decode(_utils._get_encoding())
github pythongssapi / python-gssapi / gssapi / names.py View on Github external
name_type (OID): the :class:`NameType` to use to display the given
                name

        Returns:
            str: the displayed name

        Raises:
            OperationUnavailableError
        """

        if rname_rfc6680 is None:
            raise NotImplementedError("Your GSSAPI implementation does not "
                                      "support RFC 6680 (the GSSAPI naming "
                                      "extensions)")
        return rname_rfc6680.display_name_ext(self, name_type).decode(
            _utils._get_encoding())
github pythongssapi / python-gssapi / gssapi / mechs.py View on Github external
def __unicode__(self):
        return self._bytes_desc().decode(_utils._get_encoding())
github pythongssapi / python-gssapi / gssapi / names.py View on Github external
def __getitem__(self, key):
        if isinstance(key, str):
            key = key.encode(_utils._get_encoding())

        res = rname_rfc6680.get_name_attribute(self._name, key)
        return tuples.GetNameAttributeResult(frozenset(res.values),
                                             frozenset(res.display_values),
                                             res.authenticated,
                                             res.complete)
github pythongssapi / python-gssapi / gssapi / mechs.py View on Github external
Args:
            name (str): SASL name of the desired mechanism

        Returns:
            Mechanism: the desired mechanism

        Raises:
            GSSError

        :requires-ext:`rfc5801`
        """
        if rfc5801 is None:
            raise NotImplementedError("Your GSSAPI implementation does not "
                                      "have support for RFC 5801")
        if isinstance(name, str):
            name = name.encode(_utils._get_encoding())

        m = rfc5801.inquire_mech_for_saslname(name)

        return cls(m)
github pythongssapi / python-gssapi / gssapi / mechs.py View on Github external
def __str__(self):
        return self._bytes_desc().decode(_utils._get_encoding())