HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/twisted/cred/__pycache__/strcred.cpython-38.pyc
U


W[� �@s�dZddlmZmZddlZddlmZmZddlm	Z	ddl
mZGdd�de�ZGd	d
�d
e
�ZGdd�de�ZGd
d�de�ZGdd�de�ZdZdd�Zdd�Zdd�ZGdd�d�ZdS)z�
Support for resolving command-line strings that represent different
checkers available to cred.

Examples:
 - passwd:/etc/passwd
 - memory:admin:asdf:user:lkj
 - unix
�)�absolute_import�divisionN)�	Interface�	Attribute)�
getPlugins)�usagec@s8eZdZdZed�Zed�Zed�Zed�Zdd�Z	dS)	�ICheckerFactoryz�
    A factory for objects which provide
    L{twisted.cred.checkers.ICredentialsChecker}.

    It's implemented by twistd plugins creating checkers.
    z0A tag that identifies the authentication method.zmA detailed (potentially multi-line) description of precisely what functionality this CheckerFactory provides.z=A short (one-line) description of the argument string format.z@A list of credentials interfaces that this factory will support.cCsdS)z}
        Return an L{twisted.cred.checkers.ICredentialsChecker} provider using the supplied
        argument string.
        N�)�	argstringr	r	�6/usr/lib/python3/dist-packages/twisted/cred/strcred.py�generateChecker5szICheckerFactory.generateCheckerN)
�__name__�
__module__�__qualname__�__doc__r�authType�authHelp�argStringFormat�credentialInterfacesrr	r	r	rrs����rc@seZdZdZdS)�StrcredExceptionz+
    Base exception class for strcred.
    N�r
rrrr	r	r	rr=src@seZdZdZdS)�InvalidAuthTypezv
    Raised when a user provides an invalid identifier for the
    authentication plugin (known as the authType).
    Nrr	r	r	rrDsrc@seZdZdZdS)�InvalidAuthArgumentStringzl
    Raised by an authentication plugin when the argument string
    provided is formatted incorrectly.
    Nrr	r	r	rrLsrc@seZdZdZdS)�UnsupportedInterfacesz�
    Raised when an application is given a checker to use that does not
    provide any of the application's supported credentials interfaces.
    Nrr	r	r	rrTsrz<WARNING: This authType is not supported by this application.cCstt�S)z=
    Find all objects that implement L{ICheckerFactory}.
    )rrr	r	r	r�findCheckerFactoriescsrcCs*t�D]}|j|kr|Sqt|��dS)zJ
    Find the first checker factory that supports the given authType.
    N)rrr)r�factoryr	r	r�findCheckerFactoryks


rcCs0d|kr|�dd�\}}n|}d}t|��|�S)z�
    Returns an L{twisted.cred.checkers.ICredentialsChecker} based on the
    contents of a descriptive string. Similar to
    L{twisted.application.strports}.
    �:��)�splitrr)�descriptionrr
r	r	r�makeCheckervs
r"c@sReZdZdZdZejZdd�Zdd�Z	dd�Z
d	d
�Zdd�Zd
d�Z
dd�ZdS)�AuthOptionMixinak
    Defines helper methods that can be added on to any
    L{usage.Options} subclass that needs authentication.

    This mixin implements three new options methods:

    The opt_auth method (--auth) will write two new values to the
    'self' dictionary: C{credInterfaces} (a dict of lists) and
    C{credCheckers} (a list).

    The opt_help_auth method (--help-auth) will search for all
    available checker plugins and list them for the user; it will exit
    when finished.

    The opt_help_auth_type method (--help-auth-type) will display
    detailed help for a particular checker plugin.

    @cvar supportedInterfaces: An iterable object that returns
       credential interfaces which this application is able to support.

    @cvar authOutput: A writeable object to which this options class
        will send all help-related output. Default: L{sys.stdout}
    NcCs|jdkp||jkS)zR
        Returns whether a particular credentials interface is supported.
        N)�supportedInterfaces)�self�	interfacer	r	r�supportsInterface�s
�z!AuthOptionMixin.supportsInterfacecCs |jD]}|�|�rdSqdS)z�
        Returns whether a checker factory will provide at least one of
        the credentials interfaces that we care about.
        TF)rr'�r%rr&r	r	r�supportsCheckerFactory�s

z&AuthOptionMixin.supportsCheckerFactorycCs�g}|jdkr|j}n |jD]}|�|�r|�|�q|sDt|j��d|krTi|d<d|krdg|d<|d�|�|D]}|d�|g��|�qvdS)zM
        Supply a supplied credentials checker to the Options class.
        NZcredInterfacesZcredCheckers)r$rr'�appendr�
setdefault)r%ZcheckerZ	supportedr&r	r	r�
addChecker�s



zAuthOptionMixin.addCheckerc
Cs�z|�t|��Wn�tk
rH}zt�d|jd��W5d}~XYndtk
r|}zt�d|jd��W5d}~XYn0tk
r�}zt�d|��W5d}~XYnXdS)zB
        Specify an authentication method for the server.
        zAuth plugin not supported: %srNzAuth plugin not recognized: %szUnexpected error: %s)r,r"rr�
UsageError�argsr�	Exception)r%r!�er	r	r�opt_auth�s��zAuthOptionMixin.opt_authccs0t�D]$}|jD]}|�|�r|VqqqdS)z�
        Return a list of which authTypes will be displayed by --help-auth.
        This makes it a lot easier to test this module.
        N)rrr'r(r	r	r�_checkerFactoriesForOptHelpAuth�s



z/AuthOptionMixin._checkerFactoriesForOptHelpAuthcCs�|j�d�|j�d�|j�d�d}|��D]}t|j�|kr0t|j�}q0d|}|j�|d�|j�|d�|��D]}|j�||j|jf�q~|j�d�td��dS)	z<
        Show all authentication methods available.
        z#Usage: --auth AuthType[:ArgString]
z-For detailed help: --help-auth-type AuthType
�
rz
  %%-%is	%%s
)ZAuthTypezArgString format)z========z================N)�
authOutput�writer2�lenrr�
SystemExit)r%ZfirstLengthrZformatStringr	r	r�
opt_help_auth�s �zAuthOptionMixin.opt_help_authcCs�zt|�}Wn"tk
r.t�d|��YnX|j�d|�|j�d|j�|j�d�|j���	�D]}|j�d|�
��ql|j�d�|�|�s�|j�dt�|j�d�t
d��dS)zA
        Show help for a particular authentication type.
        zInvalid auth type: %szUsage: --auth %s[:ArgString]
zArgString format: %s
r3z  %s
rN)rrrr-r4r5rr�strip�
splitlines�rstripr)�notSupportedWarningr7)r%rZcf�liner	r	r�opt_help_auth_type�s
z"AuthOptionMixin.opt_help_auth_type)r
rrrr$�sys�stdoutr4r'r)r,r1r2r8r>r	r	r	rr#�sr#)rZ
__future__rrr?Zzope.interfacerrZtwisted.pluginrZtwisted.pythonrrr/rrrrr<rrr"r#r	r	r	r�<module>s
!