File: gss.py

package info (click to toggle)
python-asyncssh 2.10.1-2%2Bdeb12u2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,252 kB
  • sloc: python: 36,288; makefile: 11
file content (61 lines) | stat: -rw-r--r-- 1,972 bytes parent folder | download
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Copyright (c) 2017-2021 by Ron Frederick <ronf@timeheart.net> and others.
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License v2.0 which accompanies this
# distribution and is available at:
#
#     http://www.eclipse.org/legal/epl-2.0/
#
# This program may also be made available under the following secondary
# licenses when the conditions for such availability set forth in the
# Eclipse Public License v2.0 are satisfied:
#
#    GNU General Public License, Version 2.0, or any later versions of
#    that license
#
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
#
# Contributors:
#     Ron Frederick - initial implementation, API, and documentation

"""GSSAPI wrapper"""

import sys

try:
    # pylint: disable=unused-import

    if sys.platform == 'win32': # pragma: no cover
        from .gss_win32 import GSSBase, GSSClient, GSSServer, GSSError
    else:
        from .gss_unix import GSSBase, GSSClient, GSSServer, GSSError

    gss_available = True
except ImportError: # pragma: no cover
    gss_available = False

    class GSSError(ValueError): # type: ignore
        """Stub class for reporting that GSS is not available"""

        def __init__(self, maj_code: int = 0, min_code: int = 0,
                     token: bytes = None):
            super().__init__('GSS not available')

            self.maj_code = maj_code
            self.min_code = min_code
            self.token = token

    class GSSBase: # type: ignore
        """Base class for reporting that GSS is not available"""

    class GSSClient(GSSBase): # type: ignore
        """Stub client class for reporting that GSS is not available"""

        def __init__(self, _host: str, _delegate_creds: bool):
            raise GSSError()

    class GSSServer(GSSBase): # type: ignore
        """Stub client class for reporting that GSS is not available"""

        def __init__(self, _host: str):
            raise GSSError()