Ë
    oj’   ã                   óä   — d Z ddlZddlmZmZmZ ddlmZmZ ddl	m
Z
 ddlmZ  G d„ de«      Z G d	„ d
e«      Z G d„ de«      Z G d„ de«      Z G d„ de«      ZdZd„ Zd„ Zd„ Z G d„ d«      Zy)z¨
Support for resolving command-line strings that represent different
checkers available to cred.

Examples:
 - passwd:/etc/passwd
 - memory:admin:asdf:user:lkj
 - unix
é    N)ÚOptionalÚSequenceÚType)Ú	AttributeÚ	Interface)Ú
getPlugins)Úusagec                   óV   — e Zd ZdZ ed«      Z ed«      Z ed«      Z ed«      Zd„ Z	y)Ú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.c                  ó   — y)z}
        Return an L{twisted.cred.checkers.ICredentialsChecker} provider using the supplied
        argument string.
        N© )Ú	argstrings    ú6/usr/lib/python3/dist-packages/twisted/cred/strcred.pyÚgenerateCheckerzICheckerFactory.generateChecker2   s   � ó    N)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚauthTypeÚauthHelpÚargStringFormatÚcredentialInterfacesr   r   r   r   r   r      sG   „ ññ ÐKÓL€Háð	;ó€Hñ
  ØGó€Oñ %ØJóÐór   r   c                   ó   — e Zd ZdZy)ÚStrcredExceptionz+
    Base exception class for strcred.
    N©r   r   r   r   r   r   r   r   r   9   s   „ òr   r   c                   ó   — e Zd ZdZy)ÚInvalidAuthTypezv
    Raised when a user provides an invalid identifier for the
    authentication plugin (known as the authType).
    Nr   r   r   r   r   r   ?   ó   „ òr   r   c                   ó   — e Zd ZdZy)ÚInvalidAuthArgumentStringzl
    Raised by an authentication plugin when the argument string
    provided is formatted incorrectly.
    Nr   r   r   r   r!   r!   F   r   r   r!   c                   ó   — e Zd ZdZy)ÚUnsupportedInterfacesz“
    Raised when an application is given a checker to use that does not
    provide any of the application's supported credentials interfaces.
    Nr   r   r   r   r#   r#   M   r   r   r#   z<WARNING: This authType is not supported by this application.c                  ó    — t        t        «      S )z=
    Find all objects that implement L{ICheckerFactory}.
    )r   r   r   r   r   ÚfindCheckerFactoriesr%   Y   s   € ô ”oÓ&Ð&r   c                 ó\   — t        «       D ]  }|j                  | k(  sŒ|c S  t        | «      ‚)zJ
    Find the first checker factory that supports the given authType.
    )r%   r   r   )r   Úfactorys     r   ÚfindCheckerFactoryr(   `   s6   € ô (Ó)ò ˆØ×Ñ˜xÓ'ØŠNðô ˜(Ó
#Ð#r   c                 ór   — d| v r| j                  dd«      \  }}n| }d}t        |«      j                  |«      S )z¤
    Returns an L{twisted.cred.checkers.ICredentialsChecker} based on the
    contents of a descriptive string. Similar to
    L{twisted.application.strports}.
    ú:é   Ú )Úsplitr(   r   )Údescriptionr   r   s      r   ÚmakeCheckerr/   j   sC   € ð ˆkÑØ)×/Ñ/°°QÓ7Ñˆ‘)àˆØˆ	Ü˜hÓ'×7Ñ7¸	ÓBÐBr   c                   ót   — e Zd ZU dZdZeeee         e	d<   e
j                  Zd„ Zd„ Zd„ Zd„ Zd„ Zd	„ Zd
„ Zy)Ú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}
    NÚsupportedInterfacesc                 ó>   — | j                   du xs || j                   v S )zR
        Returns whether a particular credentials interface is supported.
        N)r2   )ÚselfÚ	interfaces     r   ÚsupportsInterfacez!AuthOptionMixin.supportsInterface”   s%   € ð ×'Ñ'¨4Ð/ÒX°9À×@XÑ@XÐ3XÐXr   c                 óL   — |j                   D ]  }| j                  |«      sŒ y y)z‡
        Returns whether a checker factory will provide at least one of
        the credentials interfaces that we care about.
        TF)r   r6   ©r4   r'   r5   s      r   ÚsupportsCheckerFactoryz&AuthOptionMixin.supportsCheckerFactoryš   s/   € ð
 !×5Ñ5ò 	ˆIØ×%Ñ% iÕ0Ùð	ð r   c                 ór  — g }| j                   €|j                  }n4|j                  D ]%  }| j                  |«      sŒ|j                  |«       Œ' |st	        |j                  «      ‚d| vri | d<   d| vrg | d<   | d   j                  |«       |D ]&  }| d   j                  |g «      j                  |«       Œ( y)zM
        Supply a supplied credentials checker to the Options class.
        NÚcredInterfacesÚcredCheckers)r2   r   r6   Úappendr#   Ú
setdefault)r4   ÚcheckerÚ	supportedr5   s       r   Ú
addCheckerzAuthOptionMixin.addChecker¤   sÑ   € ð
 ˆ	Ø×#Ñ#Ð+Ø×4Ñ4‰Ià$×9Ñ9ò 0�	Ø×)Ñ)¨)Õ4Ø×$Ñ$ YÕ/ð0ñ Ü'¨×(DÑ(DÓEÐEà 4Ñ'Ø%'ˆDÐ!Ñ"Ø Ñ%Ø#%ˆD�Ñ Øˆ^Ñ×#Ñ# GÔ,Ø"ò 	MˆIØÐ!Ñ"×-Ñ-¨i¸Ó<×CÑCÀGÕLñ	Mr   c                 óP  — 	 | j                  t        |«      «       y# t        $ r*}t        j                  d|j
                  d   z  «      ‚d}~wt        $ r*}t        j                  d|j
                  d   z  «      ‚d}~wt        $ r}t        j                  d|z  «      ‚d}~ww xY w)zB
        Specify an authentication method for the server.
        zAuth plugin not supported: %sr   NzAuth plugin not recognized: %szUnexpected error: %s)rA   r/   r#   r	   Ú
UsageErrorÚargsr   Ú	Exception)r4   r.   Úes      r   Úopt_authzAuthOptionMixin.opt_auth»   s‘   € ð	?Ø�O‰OœK¨Ó4Õ5øÜ$ò 	PÜ×"Ñ"Ð#BÀQÇVÁVÈAÁYÑ#NÓOÐOûÜò 	QÜ×"Ñ"Ð#CÀaÇfÁfÈQÁiÑ#OÓPÐPûÜò 	?Ü×"Ñ"Ð#9¸AÑ#=Ó>Ð>ûð	?ús,   ‚ �	B%¦%AÁB%Á%A<Á<B%ÂB Â B%c              #   óz   K  — t        «       D ]*  }|j                  D ]  }| j                  |«      sŒ|–—  Œ* Œ, y­w)zŒ
        Return a list of which authTypes will be displayed by --help-auth.
        This makes it a lot easier to test this module.
        N)r%   r   r6   r8   s      r   Ú_checkerFactoriesForOptHelpAuthz/AuthOptionMixin._checkerFactoriesForOptHelpAuthÈ   sE   è ø€ ô
 ,Ó-ò 	ˆGØ$×9Ñ9ò �	Ø×)Ñ)¨)Õ4Ø!’MÙññ	ùs   ‚.;±
;c                 óŽ  — | j                   j                  d«       | j                   j                  d«       | j                   j                  d«       d}| j                  «       D ]0  }t        |j                  «      |kD  sŒt        |j                  «      }Œ2 d|z  }| j                   j                  |dz  «       | j                   j                  |dz  «       | j                  «       D ]6  }| j                   j                  ||j                  |j
                  fz  «       Œ8 | j                   j                  d«       t        d«      ‚)z<
        Show all authentication methods available.
        z#Usage: --auth AuthType[:ArgString]
z-For detailed help: --help-auth-type AuthType
ú
r   z  %%-%is	%%s
)ÚAuthTypezArgString format)z========z================)Ú
authOutputÚwriterI   Úlenr   r   Ú
SystemExit)r4   ÚfirstLengthr'   ÚformatStrings       r   Úopt_help_authzAuthOptionMixin.opt_help_authÓ   s  € ð 	�‰×ÑÐDÔEØ�‰×ÑÐNÔOØ�‰×Ñ˜dÔ#àˆØ×;Ñ;Ó=ò 	4ˆGÜ�7×#Ñ#Ó$ {Ó2Ü! '×"2Ñ"2Ó3‘ð	4ð )¨;Ñ6ˆØ�‰×Ñ˜lÐ-MÑMÔNØ�‰×Ñ˜lÐ-MÑMÔNØ×;Ñ;Ó=ò 	ˆGØ�O‰O×!Ñ!Ø × 0Ñ 0°'×2IÑ2IÐJÑJõð	ð 	�‰×Ñ˜dÔ#Ü˜‹mÐr   c                 óÀ  — 	 t        |«      }| j                  j                  d|z  «       | j                  j                  d|j                  z  «       | j                  j                  d«       |j                  j                  «       j                  «       D ].  }| j                  j                  d|j                  «       z  «       Œ0 | j                  j                  d«       | j                  |«      s=| j                  j                  dt        z  «       | j                  j                  d«       t        d«      ‚# t        $ r t        j                  d|z  «      ‚w xY w)zA
        Show help for a particular authentication type.
        zInvalid auth type: %szUsage: --auth %s[:ArgString]
zArgString format: %s
rK   z  %s
r   )r(   r   r	   rC   rM   rN   r   r   ÚstripÚ
splitlinesÚrstripr9   ÚnotSupportedWarningrP   )r4   r   ÚcfÚlines       r   Úopt_help_auth_typez"AuthOptionMixin.opt_help_auth_typeé   s  € ð	GÜ# HÓ-ˆBð 	�‰×ÑÐ>ÀÑIÔJØ�‰×ÑÐ6¸×9KÑ9KÑKÔLØ�‰×Ñ˜dÔ#Ø—K‘K×%Ñ%Ó'×2Ñ2Ó4ò 	<ˆDØ�O‰O×!Ñ! (¨T¯[©[«]Ñ":Õ;ð	<à�‰×Ñ˜dÔ#Ø×*Ñ*¨2Ô.Ø�O‰O×!Ñ! (Ô-@Ñ"@ÔAØ�O‰O×!Ñ! $Ô'Ü˜‹mÐøô ò 	GÜ×"Ñ"Ð#:¸XÑ#EÓFÐFð	Gús   ‚D; Ä;"E)r   r   r   r   r2   r   r   r   r   Ú__annotations__ÚsysÚstdoutrM   r6   r9   rA   rG   rI   rS   r[   r   r   r   r1   r1   x   sR   … ñð0 @DÐ˜ (¨4°	©?Ñ";Ñ<ÓCØ—‘€JòYòòMò.?ò	òó,r   r1   )r   r]   Útypingr   r   r   Úzope.interfacer   r   Útwisted.pluginr   Útwisted.pythonr	   r   rE   r   r   r!   r#   rX   r%   r(   r/   r1   r   r   r   ú<module>rc      s‚   ðñó ß +Ñ +ç /å %Ý  ô�iô ô<�yô ôÐ&ô ôÐ 0ô ôÐ,ô ð XÐ ò'ò$òC÷Bò Br   