Skip to content

Commit 6281fe1

Browse files
committed
Normalize 'usage' argument name
Now, all instances of the 'usage' argument are called 'usage' (previously, some were called 'cred_usage').
1 parent 881fc75 commit 6281fe1

File tree

5 files changed

+77
-77
lines changed

5 files changed

+77
-77
lines changed

gssapi/raw/creds.pyx

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ cdef class Creds:
8080
self.raw_creds = NULL
8181

8282

83-
def acquire_cred(Name name, ttl=None, mechs=None, cred_usage='both'):
83+
def acquire_cred(Name name, ttl=None, mechs=None, usage='both'):
8484
"""
8585
Get GSSAPI credentials for the given name and mechanisms.
8686
@@ -94,7 +94,7 @@ def acquire_cred(Name name, ttl=None, mechs=None, cred_usage='both'):
9494
ttl (int): the lifetime for the credentials (or None for indefinite)
9595
mechs ([MechType]): the desired mechanisms for which the credentials
9696
should work, or None for the default set
97-
cred_usage (str): the usage type for the credentials: may be
97+
usage (str): the usage type for the credentials: may be
9898
'initiate', 'accept', or 'both'
9999
100100
Returns:
@@ -113,20 +113,20 @@ def acquire_cred(Name name, ttl=None, mechs=None, cred_usage='both'):
113113
desired_mechs = GSS_C_NO_OID_SET
114114

115115
cdef OM_uint32 input_ttl = c_py_ttl_to_c(ttl)
116-
cdef gss_cred_usage_t usage
117116

118117
cdef gss_name_t c_name
119118
if name is None:
120119
c_name = GSS_C_NO_NAME
121120
else:
122121
c_name = name.raw_name
123122

124-
if cred_usage == 'initiate':
125-
usage = GSS_C_INITIATE
126-
elif cred_usage == 'accept':
127-
usage = GSS_C_ACCEPT
123+
cdef gss_cred_usage_t c_usage
124+
if usage == 'initiate':
125+
c_usage = GSS_C_INITIATE
126+
elif usage == 'accept':
127+
c_usage = GSS_C_ACCEPT
128128
else:
129-
usage = GSS_C_BOTH
129+
c_usage = GSS_C_BOTH
130130

131131
cdef gss_cred_id_t creds
132132
cdef gss_OID_set actual_mechs
@@ -136,7 +136,7 @@ def acquire_cred(Name name, ttl=None, mechs=None, cred_usage='both'):
136136

137137
with nogil:
138138
maj_stat = gss_acquire_cred(&min_stat, c_name, input_ttl,
139-
desired_mechs, usage, &creds,
139+
desired_mechs, c_usage, &creds,
140140
&actual_mechs, &actual_ttl)
141141

142142
cdef OM_uint32 tmp_min_stat
@@ -173,7 +173,7 @@ def release_cred(Creds creds not None):
173173

174174

175175
def add_cred(Creds input_cred, Name name not None, OID mech not None,
176-
cred_usage='initiate', initiator_ttl=None, acceptor_ttl=None):
176+
usage='initiate', initiator_ttl=None, acceptor_ttl=None):
177177
"""Add a credential element to a credential.
178178
179179
This method can be used to either compose two credentials (i.e., original
@@ -184,7 +184,7 @@ def add_cred(Creds input_cred, Name name not None, OID mech not None,
184184
credentials
185185
name (Name): name of principal to acquire a credential for
186186
mech (MechType): the desired security mechanism (required).
187-
cred_usage (str): usage type for credentials. Possible values:
187+
usage (str): usage type for credentials. Possible values:
188188
'initiate' (default), 'accept', 'both' (failsafe).
189189
initiator_ttl (int): lifetime of credentials for use in initiating
190190
security contexts (None for indefinite)
@@ -200,13 +200,13 @@ def add_cred(Creds input_cred, Name name not None, OID mech not None,
200200
GSSError
201201
202202
"""
203-
cdef gss_cred_usage_t usage
204-
if cred_usage == 'initiate':
205-
usage = GSS_C_INITIATE
206-
elif cred_usage == 'accept':
207-
usage = GSS_C_ACCEPT
208-
else: # cred_usage == 'both'
209-
usage = GSS_C_BOTH
203+
cdef gss_cred_usage_t c_usage
204+
if usage == 'initiate':
205+
c_usage = GSS_C_INITIATE
206+
elif usage == 'accept':
207+
c_usage = GSS_C_ACCEPT
208+
else: # usage == 'both'
209+
c_usage = GSS_C_BOTH
210210

211211
cdef gss_cred_id_t raw_input_cred
212212
if input_cred is not None:
@@ -225,7 +225,7 @@ def add_cred(Creds input_cred, Name name not None, OID mech not None,
225225

226226
with nogil:
227227
maj_stat = gss_add_cred(&min_stat, raw_input_cred, name.raw_name,
228-
&mech.raw_oid, usage, input_initiator_ttl,
228+
&mech.raw_oid, c_usage, input_initiator_ttl,
229229
input_acceptor_ttl, &output_creds,
230230
&actual_mechs, &actual_initiator_ttl,
231231
&actual_acceptor_ttl)

gssapi/raw/ext_cred_store.pyx

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ cdef void c_free_key_value_set(gss_key_value_set_desc *kvset):
9595
# TODO(directxman12): some of these probably need a "not null",
9696
# but that's not clear from the wiki page
9797
def acquire_cred_from(dict store, Name name, ttl=None,
98-
mechs=None, cred_usage='both'):
98+
mechs=None, usage='both'):
9999
"""Acquire credentials from the given store
100100
101101
This method acquires credentials from the store specified by the
@@ -114,7 +114,7 @@ def acquire_cred_from(dict store, Name name, ttl=None,
114114
for indefinite
115115
mechs (list): the desired mechanisms to be used with these
116116
credentials, or None for the default set
117-
cred_usage (str): the usage for these credentials -- either 'both',
117+
usage (str): the usage for these credentials -- either 'both',
118118
'initiate', or 'accept'
119119
120120
Returns:
@@ -139,13 +139,13 @@ def acquire_cred_from(dict store, Name name, ttl=None,
139139
else:
140140
c_name = name.raw_name
141141

142-
cdef gss_cred_usage_t usage
143-
if cred_usage == 'initiate':
144-
usage = GSS_C_INITIATE
145-
elif cred_usage == 'accept':
146-
usage = GSS_C_ACCEPT
142+
cdef gss_cred_usage_t c_usage
143+
if usage == 'initiate':
144+
c_usage = GSS_C_INITIATE
145+
elif usage == 'accept':
146+
c_usage = GSS_C_ACCEPT
147147
else:
148-
usage = GSS_C_BOTH
148+
c_usage = GSS_C_BOTH
149149

150150
cdef gss_key_value_set_desc *c_store
151151
if store is not None:
@@ -161,7 +161,7 @@ def acquire_cred_from(dict store, Name name, ttl=None,
161161

162162
with nogil:
163163
maj_stat = gss_acquire_cred_from(&min_stat, c_name, input_ttl,
164-
desired_mechs, usage, c_store,
164+
desired_mechs, c_usage, c_store,
165165
&creds, &actual_mechs, &actual_ttl)
166166

167167
cdef OM_uint32 tmp_min_stat
@@ -182,7 +182,7 @@ def acquire_cred_from(dict store, Name name, ttl=None,
182182

183183
def add_cred_from(dict store, Creds input_creds,
184184
Name name not None, OID mech not None,
185-
cred_usage='both', initiator_ttl=None,
185+
usage='both', initiator_ttl=None,
186186
acceptor_ttl=None):
187187
"""Acquire credentials to add to the current set from the given store
188188
@@ -202,7 +202,7 @@ def add_cred_from(dict store, Creds input_creds,
202202
name (Name): the name associated with the credentials
203203
mech (OID): the desired mechanism to be used with these
204204
credentials
205-
cred_usage (str): the usage for these credentials -- either 'both',
205+
usage (str): the usage for these credentials -- either 'both',
206206
'initiate', or 'accept'
207207
initiator_ttl): the desired initiate lifetime of the
208208
credentials, or None for indefinite
@@ -220,13 +220,13 @@ def add_cred_from(dict store, Creds input_creds,
220220
cdef OM_uint32 input_initiator_ttl = c_py_ttl_to_c(initiator_ttl)
221221
cdef OM_uint32 input_acceptor_ttl = c_py_ttl_to_c(acceptor_ttl)
222222

223-
cdef gss_cred_usage_t usage
224-
if cred_usage == 'initiate':
225-
usage = GSS_C_INITIATE
226-
elif cred_usage == 'accept':
227-
usage = GSS_C_ACCEPT
223+
cdef gss_cred_usage_t c_usage
224+
if usage == 'initiate':
225+
c_usage = GSS_C_INITIATE
226+
elif usage == 'accept':
227+
c_usage = GSS_C_ACCEPT
228228
else:
229-
usage = GSS_C_BOTH
229+
c_usage = GSS_C_BOTH
230230

231231
cdef gss_name_t c_name = name.raw_name
232232
cdef gss_OID c_mech = &mech.raw_oid
@@ -252,7 +252,7 @@ def add_cred_from(dict store, Creds input_creds,
252252

253253
with nogil:
254254
maj_stat = gss_add_cred_from(&min_stat, c_input_creds, c_name,
255-
c_mech, usage, input_initiator_ttl,
255+
c_mech, c_usage, input_initiator_ttl,
256256
input_acceptor_ttl, c_store, &creds,
257257
&actual_mechs, &actual_initiator_ttl,
258258
&actual_acceptor_ttl)
@@ -272,7 +272,7 @@ def add_cred_from(dict store, Creds input_creds,
272272

273273

274274
def store_cred_into(dict store, Creds creds not None,
275-
cred_usage='both', OID mech=None, bint overwrite=False,
275+
usage='both', OID mech=None, bint overwrite=False,
276276
bint set_default=False):
277277
"""Store credentials to the given store
278278
@@ -288,7 +288,7 @@ def store_cred_into(dict store, Creds creds not None,
288288
store (dict): the store into which to store the credentials,
289289
or None for the default store.
290290
creds (Creds): the credentials to store
291-
cred_usage (str): the usage to store the credentials with -- either
291+
usage (str): the usage to store the credentials with -- either
292292
'both', 'initiate', or 'accept'
293293
mech (OID): the mechansim to associate with the stored credentials
294294
overwrite (bool): whether or not to overwrite existing credentials
@@ -309,13 +309,13 @@ def store_cred_into(dict store, Creds creds not None,
309309
else:
310310
desired_mech = GSS_C_NO_OID
311311

312-
cdef gss_cred_usage_t usage
313-
if cred_usage == 'initiate':
314-
usage = GSS_C_INITIATE
315-
elif cred_usage == 'accept':
316-
usage = GSS_C_ACCEPT
312+
cdef gss_cred_usage_t c_usage
313+
if usage == 'initiate':
314+
c_usage = GSS_C_INITIATE
315+
elif usage == 'accept':
316+
c_usage = GSS_C_ACCEPT
317317
else:
318-
usage = GSS_C_BOTH
318+
c_usage = GSS_C_BOTH
319319

320320
cdef gss_key_value_set_desc *c_store
321321
if store is not None:
@@ -331,7 +331,7 @@ def store_cred_into(dict store, Creds creds not None,
331331
cdef OM_uint32 maj_stat, min_stat
332332

333333
with nogil:
334-
maj_stat = gss_store_cred_into(&min_stat, c_creds, usage,
334+
maj_stat = gss_store_cred_into(&min_stat, c_creds, c_usage,
335335
desired_mech, overwrite,
336336
set_default, c_store,
337337
&actual_mech_types,

gssapi/raw/ext_rfc5588.pyx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ cdef extern from "gssapi.h":
2222
gss_cred_usage_t *actual_usage) nogil
2323

2424

25-
def store_cred(Creds creds not None, cred_usage='both', OID mech=None,
25+
def store_cred(Creds creds not None, usage='both', OID mech=None,
2626
bint overwrite=False, bint set_default=False):
2727
"""Store credentials to the default store
2828
@@ -31,7 +31,7 @@ def store_cred(Creds creds not None, cred_usage='both', OID mech=None,
3131
3232
Args:
3333
creds (Creds): the credentials to store
34-
cred_usage (str): the usage to store the credentials with -- either
34+
usage (str): the usage to store the credentials with -- either
3535
'both', 'initiate', or 'accept'
3636
mech (OID): the mechansim to associate with the stored credentials
3737
overwrite (bool): whether or not to overwrite existing credentials
@@ -51,13 +51,13 @@ def store_cred(Creds creds not None, cred_usage='both', OID mech=None,
5151
else:
5252
desired_mech = GSS_C_NO_OID
5353

54-
cdef gss_cred_usage_t usage
55-
if cred_usage == 'initiate':
56-
usage = GSS_C_INITIATE
57-
elif cred_usage == 'accept':
58-
usage = GSS_C_ACCEPT
54+
cdef gss_cred_usage_t c_usage
55+
if usage == 'initiate':
56+
c_usage = GSS_C_INITIATE
57+
elif usage == 'accept':
58+
c_usage = GSS_C_ACCEPT
5959
else:
60-
usage = GSS_C_BOTH
60+
c_usage = GSS_C_BOTH
6161

6262
cdef gss_cred_id_t c_creds = creds.raw_creds
6363

@@ -67,7 +67,7 @@ def store_cred(Creds creds not None, cred_usage='both', OID mech=None,
6767
cdef OM_uint32 maj_stat, min_stat
6868

6969
with nogil:
70-
maj_stat = gss_store_cred(&min_stat, c_creds, usage,
70+
maj_stat = gss_store_cred(&min_stat, c_creds, c_usage,
7171
desired_mech, overwrite,
7272
set_default, &actual_mech_types,
7373
&actual_usage)

gssapi/raw/ext_s4u.pyx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ cdef extern from "gssapi/gssapi_ext.h":
3939

4040
def acquire_cred_impersonate_name(Creds impersonator_cred not None,
4141
Name name not None, ttl=None, mechs=None,
42-
cred_usage='initiate'):
42+
usage='initiate'):
4343
"""
4444
Acquire credentials by impersonating another name.
4545
@@ -54,7 +54,7 @@ def acquire_cred_impersonate_name(Creds impersonator_cred not None,
5454
ttl (int): the lifetime for the credentials (or None for indefinite)
5555
mechs ([MechType]): the desired mechanisms for which the credentials
5656
should work (or None for the default set)
57-
cred_usage (str): the usage type for the credentials: may be
57+
usage (str): the usage type for the credentials: may be
5858
'initiate', 'accept', or 'both'
5959
6060
Returns:
@@ -73,15 +73,15 @@ def acquire_cred_impersonate_name(Creds impersonator_cred not None,
7373
desired_mechs = GSS_C_NO_OID_SET
7474

7575
cdef OM_uint32 input_ttl = c_py_ttl_to_c(ttl)
76-
cdef gss_cred_usage_t usage
7776
cdef gss_name_t c_name = name.raw_name
7877

79-
if cred_usage == 'initiate':
80-
usage = GSS_C_INITIATE
81-
elif cred_usage == 'accept':
82-
usage = GSS_C_ACCEPT
78+
cdef gss_cred_usage_t c_usage
79+
if usage == 'initiate':
80+
c_usage = GSS_C_INITIATE
81+
elif usage == 'accept':
82+
c_usage = GSS_C_ACCEPT
8383
else:
84-
usage = GSS_C_BOTH
84+
c_usage = GSS_C_BOTH
8585

8686
cdef gss_cred_id_t creds
8787
cdef gss_OID_set actual_mechs
@@ -92,7 +92,7 @@ def acquire_cred_impersonate_name(Creds impersonator_cred not None,
9292
with nogil:
9393
maj_stat = gss_acquire_cred_impersonate_name(
9494
&min_stat, impersonator_cred.raw_creds, name.raw_name,
95-
input_ttl, desired_mechs, usage, &creds, &actual_mechs,
95+
input_ttl, desired_mechs, c_usage, &creds, &actual_mechs,
9696
&actual_ttl)
9797

9898
cdef OM_uint32 tmp_min_stat
@@ -111,7 +111,7 @@ def acquire_cred_impersonate_name(Creds impersonator_cred not None,
111111
def add_cred_impersonate_name(Creds input_cred,
112112
Creds impersonator_cred not None,
113113
Name name not None, OID mech not None,
114-
cred_usage='initiate', initiator_ttl=None,
114+
usage='initiate', initiator_ttl=None,
115115
acceptor_ttl=None):
116116
"""
117117
Add a credential-element to a credential by impersonating another name.
@@ -129,7 +129,7 @@ def add_cred_impersonate_name(Creds input_cred,
129129
name (Name): the name to impersonate
130130
mech (MechType): the desired mechanism. Note that this is both
131131
singular and required, unlike acquireCredImpersonateName
132-
cred_usage (str): the usage type for the credentials: may be
132+
usage (str): the usage type for the credentials: may be
133133
'initiate', 'accept', or 'both'
134134
initiator_ttl (int): the lifetime for the credentials to remain valid
135135
when using them to initiate security contexts (or None for
@@ -149,15 +149,15 @@ def add_cred_impersonate_name(Creds input_cred,
149149

150150
cdef OM_uint32 input_initiator_ttl = c_py_ttl_to_c(initiator_ttl)
151151
cdef OM_uint32 input_acceptor_ttl = c_py_ttl_to_c(acceptor_ttl)
152-
cdef gss_cred_usage_t usage
153152
cdef gss_name_t c_name = name.raw_name
154153

155-
if cred_usage == 'initiate':
156-
usage = GSS_C_INITIATE
157-
elif cred_usage == 'accept':
158-
usage = GSS_C_ACCEPT
154+
cdef gss_cred_usage_t c_usage
155+
if usage == 'initiate':
156+
c_usage = GSS_C_INITIATE
157+
elif usage == 'accept':
158+
c_usage = GSS_C_ACCEPT
159159
else:
160-
usage = GSS_C_BOTH
160+
c_usage = GSS_C_BOTH
161161

162162
cdef gss_cred_id_t raw_input_cred
163163
if input_cred is not None:
@@ -176,7 +176,7 @@ def add_cred_impersonate_name(Creds input_cred,
176176
maj_stat = gss_add_cred_impersonate_name(&min_stat, raw_input_cred,
177177
impersonator_cred.raw_creds,
178178
name.raw_name, &mech.raw_oid,
179-
usage, input_initiator_ttl,
179+
c_usage, input_initiator_ttl,
180180
input_acceptor_ttl, &creds,
181181
&actual_mechs,
182182
&actual_initiator_ttl,

0 commit comments

Comments
 (0)