Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib64/python3.7/site-packages/twisted/cred/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/site-packages/twisted/cred/__pycache__/strcred.cpython-37.pyc

B

:��]� �@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	�G/opt/alt/python37/lib64/python3.7/site-packages/twisted/cred/strcred.py�generateChecker5szICheckerFactory.generateCheckerN)
�__name__�
__module__�__qualname__�__doc__r�authType�authHelp�argStringFormat�credentialInterfacesrr	r	r	rrsrc@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).
    N)r
rrrr	r	r	rrDsrc@seZdZdZdS)�InvalidAuthArgumentStringzl
    Raised by an authentication plugin when the argument string
    provided is formatted incorrectly.
    N)r
rrrr	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.
    N)r
rrrr	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*xt�D]}|j|kr|SqWt|��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"x|jD]}|�|�rdSqWdS)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$x"|jD]}|�|�r|�|�qW|sHt|j��d|krXi|d<d|krhg|d<|d�|�x"|D]}|d�|g��|�q|WdS)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�y|�t|��Wn�tk
rH}zt�d|jd��Wdd}~XYndtk
r|}zt�d|jd��Wdd}~XYn0tk
r�}zt�d|��Wdd}~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_authccs6x0t�D]&}x |jD]}|�|�r|VPqWqWdS)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$rr%r	r	r�_checkerFactoriesForOptHelpAuth�s

z/AuthOptionMixin._checkerFactoriesForOptHelpAuthcCs�|j�d�|j�d�|j�d�d}x(|��D]}t|j�|kr2t|j�}q2Wd|}|j�|d�|j�|d�x(|��D]}|j�||j|jf�q�W|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�writer0�lenrr�
SystemExit)r$ZfirstLengthrZformatStringr	r	r�
opt_help_auth�szAuthOptionMixin.opt_help_authcCs�yt|�}Wn"tk
r.t�d|��YnX|j�d|�|j�d|j�|j�d�x*|j���	�D]}|j�d|�
��qnW|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
r1z  %s
rN)rrrr+r2r3rr�strip�
splitlines�rstripr'�notSupportedWarningr5)r$rZcf�liner	r	r�opt_help_auth_type�s
z"AuthOptionMixin.opt_help_auth_type)r
rrrr#�sys�stdoutr2r&r'r*r/r0r6r<r	r	r	rr"�sr")r�
__future__rrr=Zzope.interfacerrZtwisted.pluginrZtwisted.pythonrrr-rrrrr:rrr!r"r	r	r	r�<module>s!