1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
from gssapi.raw.cython_types cimport *
from gssapi.raw.oids cimport OID
GSSAPI="BASE" # This ensures that a full module is generated by Cython
from gssapi.raw.cython_converters cimport c_make_oid
from gssapi.raw.named_tuples import InquireSASLNameResult
from gssapi.raw.misc import GSSError
cdef extern from "python_gssapi_ext.h":
OM_uint32 gss_inquire_saslname_for_mech(
OM_uint32 *min_stat,
const gss_OID desired_mech,
gss_buffer_t sasl_mech_name,
gss_buffer_t mech_name,
gss_buffer_t mech_description) nogil
OM_uint32 gss_inquire_mech_for_saslname(
OM_uint32 *min_stat,
const gss_buffer_t sasl_mech_name,
gss_OID *mech_type) nogil
def inquire_saslname_for_mech(OID mech not None):
cdef OM_uint32 maj_stat, min_stat
cdef gss_buffer_desc sasl_mech_name
cdef gss_buffer_desc mech_name
cdef gss_buffer_desc mech_desc
cdef gss_OID m = GSS_C_NO_OID
m = &mech.raw_oid
with nogil:
maj_stat = gss_inquire_saslname_for_mech(&min_stat, m, &sasl_mech_name,
&mech_name, &mech_desc)
if maj_stat == GSS_S_COMPLETE:
out_smn = (<char*>sasl_mech_name.value)[:sasl_mech_name.length]
out_mn = (<char*>mech_name.value)[:mech_name.length]
out_md = (<char*>mech_desc.value)[:mech_desc.length]
gss_release_buffer(&min_stat, &sasl_mech_name)
gss_release_buffer(&min_stat, &mech_name)
gss_release_buffer(&min_stat, &mech_desc)
return InquireSASLNameResult(out_smn, out_mn, out_md)
else:
raise GSSError(maj_stat, min_stat)
def inquire_mech_for_saslname(bytes sasl_name not None):
cdef OM_uint32 maj_stat, min_stat
cdef gss_buffer_desc sn
cdef gss_OID m
sn.length = len(sasl_name)
sn.value = sasl_name
with nogil:
maj_stat = gss_inquire_mech_for_saslname(&min_stat, &sn, &m)
if maj_stat == GSS_S_COMPLETE:
return c_make_oid(m)
else:
raise GSSError(maj_stat, min_stat)
|