def __new__(cls, base=None, name_type=None, token=None, composite=False): if token is not None: if composite: if rname_rfc6680 is None: raise NotImplementedError( "Your GSSAPI implementation does not support RFC 6680 " "(the GSSAPI naming extensions)") if rname_rfc6680_comp_oid is not None: base_name = rname.import_name(token, NameType.composite_export) displ_name = rname.display_name(base_name, name_type=True) if displ_name.name_type == NameType.composite_export: # NB(directxman12): there's a bug in MIT krb5 <= 1.13 # 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, six.text_type): base = base.encode(_utils._get_encoding()) base_name = rname.import_name(base, name_type) return super(Name, cls).__new__(cls, base_name)
def __repr__(self): disp_res = rname.display_name(self, name_type=True) return "Name({name}, {name_type})".format(name=disp_res.name, name_type=disp_res.name_type)
def name_type(self): """The :class:`NameType` of this name""" return rname.display_name(self, name_type=True).name_type
def __bytes__(self): # Python 3 -- someone asked for bytes return rname.display_name(self, name_type=False).name