Skip to content

Commit 0589259

Browse files
author
stroeder
committed
a bit of PEP-8 for ldap.sasl
1 parent 4d05a51 commit 0589259

File tree

1 file changed

+40
-31
lines changed

1 file changed

+40
-31
lines changed

Lib/ldap/sasl.py

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,19 @@
1515
from ldap import __version__
1616

1717
if __debug__:
18-
# Tracing is only supported in debugging mode
19-
import traceback
20-
from ldap import _trace_level,_trace_file,_trace_stack_limit
18+
# Tracing is only supported in debugging mode
19+
from ldap import _trace_level, _trace_file
20+
2121

2222
# These are the SASL callback id's , as defined in sasl.h
23-
CB_USER = 0x4001
24-
CB_AUTHNAME = 0x4002
25-
CB_LANGUAGE = 0x4003
26-
CB_PASS = 0x4004
27-
CB_ECHOPROMPT = 0x4005
28-
CB_NOECHOPROMPT= 0x4006
29-
CB_GETREALM = 0x4008
23+
CB_USER = 0x4001
24+
CB_AUTHNAME = 0x4002
25+
CB_LANGUAGE = 0x4003
26+
CB_PASS = 0x4004
27+
CB_ECHOPROMPT = 0x4005
28+
CB_NOECHOPROMPT = 0x4006
29+
CB_GETREALM = 0x4008
30+
3031

3132
class sasl:
3233
"""This class handles SASL interactions for authentication.
@@ -35,15 +36,15 @@ class sasl:
3536
specific SASL authentication mechanisms, this method can be
3637
overridden"""
3738

38-
def __init__(self,cb_value_dict,mech):
39+
def __init__(self, cb_value_dict, mech):
3940
""" The (generic) base class takes a cb_value_dictionary of
4041
question-answer pairs. Questions are specified by the respective
4142
SASL callback id's. The mech argument is a string that specifies
4243
the SASL mechaninsm to be uesd."""
4344
self.cb_value_dict = cb_value_dict or {}
4445
self.mech = mech
4546

46-
def callback(self,cb_id,challenge,prompt,defresult):
47+
def callback(self, cb_id, challenge, prompt, defresult):
4748
""" The callback method will be called by the sasl_bind_s()
4849
method several times. Each time it will provide the id, which
4950
tells us what kind of information is requested (the CB_ ...
@@ -61,46 +62,54 @@ def callback(self,cb_id,challenge,prompt,defresult):
6162

6263
# The following print command might be useful for debugging
6364
# new sasl mechanisms. So it is left here
64-
cb_result = self.cb_value_dict.get(cb_id,defresult) or ''
65+
cb_result = self.cb_value_dict.get(cb_id, defresult) or ''
6566
if __debug__:
66-
if _trace_level>=1:
67-
_trace_file.write("*** id=%d, challenge=%s, prompt=%s, defresult=%s\n-> %s\n" % (
68-
cb_id, challenge, prompt, repr(defresult), repr(self.cb_value_dict.get(cb_result))
69-
))
67+
if _trace_level >= 1:
68+
_trace_file.write("*** id=%d, challenge=%s, prompt=%s, defresult=%s\n-> %s\n" % (
69+
cb_id,
70+
challenge,
71+
prompt,
72+
repr(defresult),
73+
repr(self.cb_value_dict.get(cb_result))
74+
))
7075
return cb_result
7176

7277

7378
class cram_md5(sasl):
7479
"""This class handles SASL CRAM-MD5 authentication."""
7580

76-
def __init__(self,authc_id, password, authz_id=""):
77-
auth_dict = {CB_AUTHNAME:authc_id, CB_PASS:password,
78-
CB_USER:authz_id}
79-
sasl.__init__(self,auth_dict,"CRAM-MD5")
81+
def __init__(self, authc_id, password, authz_id=""):
82+
auth_dict = {
83+
CB_AUTHNAME: authc_id,
84+
CB_PASS: password,
85+
CB_USER: authz_id,
86+
}
87+
sasl.__init__(self, auth_dict, "CRAM-MD5")
8088

8189

8290
class digest_md5(sasl):
8391
"""This class handles SASL DIGEST-MD5 authentication."""
8492

85-
def __init__(self,authc_id, password, authz_id=""):
86-
auth_dict = {CB_AUTHNAME:authc_id, CB_PASS:password,
87-
CB_USER:authz_id}
88-
sasl.__init__(self,auth_dict,"DIGEST-MD5")
93+
def __init__(self, authc_id, password, authz_id=""):
94+
auth_dict = {
95+
CB_AUTHNAME: authc_id,
96+
CB_PASS: password,
97+
CB_USER: authz_id,
98+
}
99+
sasl.__init__(self, auth_dict, "DIGEST-MD5")
89100

90101

91102
class gssapi(sasl):
92103
"""This class handles SASL GSSAPI (i.e. Kerberos V)
93104
authentication."""
94105

95-
def __init__(self,authz_id=""):
96-
sasl.__init__(self, {CB_USER:authz_id},"GSSAPI")
106+
def __init__(self, authz_id=""):
107+
sasl.__init__(self, {CB_USER: authz_id}, "GSSAPI")
97108

98109

99110
class external(sasl):
100111
"""This class handles SASL EXTERNAL authentication
101112
(i.e. X.509 client certificate)"""
102113

103-
def __init__(self,authz_id=""):
104-
sasl.__init__(self, {CB_USER:authz_id},"EXTERNAL")
105-
106-
114+
def __init__(self, authz_id=""):
115+
sasl.__init__(self, {CB_USER: authz_id}, "EXTERNAL")

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy