| 1 | __version__ = '0.5.1' |
| 2 | __version_info__ = (0, 5, 1) |
| 3 | |
| 4 | |
| 5 | class SASLError(Exception): |
| 6 | """ |
| 7 | Typically represents a user error in configuration or usage of the |
| 8 | SASL client or mechanism. |
| 9 | """ |
| 10 | pass |
| 11 | |
| 12 | |
| 13 | class SASLProtocolException(Exception): |
| 14 | """ |
| 15 | Raised when an error occurs while communicating with the SASL server |
| 16 | or the client and server fail to agree on negotiated properties such |
| 17 | as quality of protection. |
| 18 | """ |
| 19 | pass |
| 20 | |
| 21 | |
| 22 | class SASLWarning(Warning): |
| 23 | """ |
| 24 | Emitted in potentially fatal circumstances. |
| 25 | """ |
| 26 | pass |
| 27 | |
| 28 | |
| 29 | class QOP(object): |
| 30 | |
| 31 | AUTH = b'auth' |
| 32 | AUTH_INT = b'auth-int' |
| 33 | AUTH_CONF = b'auth-conf' |
| 34 | |
| 35 | all = (AUTH, AUTH_INT, AUTH_CONF) |
| 36 | |
| 37 | bit_map = {1: AUTH, 2: AUTH_INT, 4: AUTH_CONF} |
| 38 | |
| 39 | name_map = dict((bit, name) for name, bit in bit_map.items()) |
| 40 | |
| 41 | @classmethod |
| 42 | def names_from_bitmask(cls, byt): |
| 43 | return set(name for bit, name in cls.bit_map.items() if bit & byt) |
| 44 | |
| 45 | @classmethod |
| 46 | def flag_from_name(cls, name): |
| 47 | return cls.name_map[name] |