File: ext_rfc4178.pyx

package info (click to toggle)
python-gssapi 1.10.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 876 kB
  • sloc: python: 3,707; sh: 198; makefile: 154; ansic: 60
file content (31 lines) | stat: -rw-r--r-- 950 bytes parent folder | download | duplicates (3)
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
GSSAPI="BASE"  # This ensures that a full module is generated by Cython

from gssapi.raw.cython_types cimport *
from gssapi.raw.cython_converters cimport c_get_mech_oid_set
from gssapi.raw.creds cimport Creds

from gssapi.raw.misc import GSSError

cdef extern from "python_gssapi_ext.h":
    OM_uint32 gss_set_neg_mechs(
        OM_uint32 *minor_status,
        gss_cred_id_t cred_handle,
        const gss_OID_set mech_set) nogil


def set_neg_mechs(Creds cred_handle not None, mech_set not None):
    cdef gss_OID_set negotiable_mechs = c_get_mech_oid_set(mech_set)

    cdef OM_uint32 maj_stat, min_stat

    with nogil:
        maj_stat = gss_set_neg_mechs(&min_stat, cred_handle.raw_creds,
                                     negotiable_mechs)

    cdef OM_uint32 tmp_min_stat
    gss_release_oid_set(&tmp_min_stat, &negotiable_mechs)

    if maj_stat == GSS_S_COMPLETE:
        return None
    else:
        raise GSSError(maj_stat, min_stat)