66
77
88class Name (rname .Name ):
9+ """GSSAPI Name
10+
11+ This class represents a GSSAPI name which may be used with
12+ used with and/or returned by other GSSAPI methods.
13+
14+ It inherits from the low-level GSSAPI :class:`~gssapi.raw.names.Name`
15+ class, and thus may used with both low-level and high-level API methods.
16+
17+ This class may be pickled and unpickled, as well as copied.
18+
19+ The :func:`str` and :func:`bytes` methods may be used to retrieve the
20+ text of the name.
21+ """
22+
923 __slots__ = ()
1024
1125 def __new__ (cls , base = None , name_type = None , token = None ):
26+ """Create or import a GSSAPI name
27+
28+ The constructor either creates or imports a GSSAPI name.
29+
30+ If a :python:`~gssapi.raw.names.Name` object from the low-level API
31+ is passed as the `base` argument, it will be converted into a
32+ high-level object.
33+
34+ If the `token` argument is used, the name will be imported using
35+ the token.
36+
37+ Otherwise, a new name will be created, using the `base` argument as
38+ the string and the `name_type` argument to denote the name type.
39+ """
40+
1241 if token is not None :
1342 base_name = rname .import_name (token , NameType .export )
1443 elif isinstance (base , rname .Name ):
@@ -39,6 +68,7 @@ def __bytes__(self):
3968
4069 @property
4170 def name_type (self ):
71+ """Get the name type of this name"""
4272 return rname .display_name (self , name_type = True ).name_type
4373
4474 def __eq__ (self , other ):
@@ -58,9 +88,30 @@ def __repr__(self):
5888 name_type = disp_res .name_type )
5989
6090 def export (self ):
91+ """Export the name
92+
93+ This method exports the name into a byte string which can then be
94+ imported by using the `token` argument of the constructor.
95+
96+ Returns:
97+ bytes: the exported name in token form
98+ """
99+
61100 return rname .export_name (self )
62101
63102 def canonicalize (self , mech_type ):
103+ """Canonicalize a name with respect to a mechanism
104+
105+ This method returns a new Name that is canonicalized according to
106+ the given mechanism.
107+
108+ Args:
109+ mech_type (OID): the mechanism type to use
110+
111+ Returns:
112+ Name: the canonicalized name
113+ """
114+
64115 return type (self )(rname .canonicalize_name (self , mech_type ))
65116
66117 def __copy__ (self ):
0 commit comments