File: __init__.py

package info (click to toggle)
python-pure-sasl 0.5.1%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 156 kB
  • sloc: python: 772; makefile: 34
file content (47 lines) | stat: -rw-r--r-- 1,026 bytes parent folder | download | duplicates (2)
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
__version__ = '0.5.1'
__version_info__ = (0, 5, 1)


class SASLError(Exception):
    """
    Typically represents a user error in configuration or usage of the
    SASL client or mechanism.
    """
    pass


class SASLProtocolException(Exception):
    """
    Raised when an error occurs while communicating with the SASL server
    or the client and server fail to agree on negotiated properties such
    as quality of protection.
    """
    pass


class SASLWarning(Warning):
    """
    Emitted in potentially fatal circumstances.
    """
    pass


class QOP(object):

    AUTH = b'auth'
    AUTH_INT = b'auth-int'
    AUTH_CONF = b'auth-conf'

    all = (AUTH, AUTH_INT, AUTH_CONF)

    bit_map = {1: AUTH, 2: AUTH_INT, 4: AUTH_CONF}

    name_map = dict((bit, name) for name, bit in bit_map.items())

    @classmethod
    def names_from_bitmask(cls, byt):
        return set(name for bit, name in cls.bit_map.items() if bit & byt)

    @classmethod
    def flag_from_name(cls, name):
        return cls.name_map[name]