
    Vh
                     ^   d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl	m
Z
mZ ddlmZ  ee       G d d	             Z ee       G d
 d             Z ee       G d d             Z ee
       G d dej"                               Z ee
       G d dej"                               Zg dZy)z*
Credential managers for L{twisted.mail}.
    N)implementer)credentials)IllegalClientResponse)IChallengeResponseIClientAuthentication)nativeStringc                       e Zd Zd Zd Zd Zy)CramMD5ClientAuthenticatorc                     || _         y Nuserselfr   s     B/home/dcms/DCMS/lib/python3.12/site-packages/twisted/mail/_cred.py__init__z#CramMD5ClientAuthenticator.__init__   	    	    c                      y)Ns   CRAM-MD5 r   s    r   getNamez"CramMD5ClientAuthenticator.getName   s    r   c                     t        j                  ||t        j                        j	                         }| j
                  dz   |j                  d      z   S )N)	digestmod    ascii)hmacHMAChashlibmd5	hexdigestr   encode)r   secretchalresponses       r   challengeResponsez,CramMD5ClientAuthenticator.challengeResponse   s>    99VTW[[AKKMyy4(//'":::r   N__name__
__module____qualname__r   r   r&   r   r   r   r
   r
      s    ;r   r
   c                   $    e Zd Zd Zd Zd Zd Zy)LOGINAuthenticatorc                 4    || _         | j                  | _        y r   )r   challengeUsernamer&   r   s     r   r   zLOGINAuthenticator.__init__#   s    	!%!7!7r   c                      y)Ns   LOGINr   r   s    r   r   zLOGINAuthenticator.getName'       r   c                 <    | j                   | _        | j                  S r   )challengeSecretr&   r   r   r#   r$   s      r   r.   z$LOGINAuthenticator.challengeUsername*   s    !%!5!5yyr   c                     |S r   r   r3   s      r   r2   z"LOGINAuthenticator.challengeSecret/   s    r   N)r(   r)   r*   r   r   r.   r2   r   r   r   r,   r,   !   s    8
r   r,   c                       e Zd Zd Zd Zd Zy)PLAINAuthenticatorc                     || _         y r   r   r   s     r   r   zPLAINAuthenticator.__init__6   r   r   c                      y)Ns   PLAINr   r   s    r   r   zPLAINAuthenticator.getName9   r0   r   c                 ,    d| j                   z   dz   |z   S )N    r   r3   s      r   r&   z$PLAINAuthenticator.challengeResponse<   s    tyy 5(611r   Nr'   r   r   r   r6   r6   4   s    2r   r6   c                   $    e Zd Zd Zd Zd Zd Zy)LOGINCredentialsc                 j    ddg| _         ddg| _        t        j                  j	                  | d d        y )Ns	   Password s
   User Name s   passwords   username)
challenges	responsesr   UsernamePasswordr   r   s    r   r   zLOGINCredentials.__init__B   s2    (.9%{3$$--dD$?r   c                 6    | j                   j                         S r   )r>   popr   s    r   getChallengezLOGINCredentials.getChallengeG   s    ""$$r   c                 `    t        | t        | j                  j                               |       y r   )setattrr   r?   rB   )r   r%   s     r   setResponsezLOGINCredentials.setResponseJ   s     l4>>#5#5#78(Cr   c                 ,    t        | j                        S r   )boolr>   r   s    r   moreChallengeszLOGINCredentials.moreChallengesM   s    DOO$$r   Nr(   r)   r*   r   rC   rF   rI   r   r   r   r<   r<   @   s    @
%D%r   r<   c                   $    e Zd Zd Zd Zd Zd Zy)PLAINCredentialsc                 F    t         j                  j                  | d d        y r   )r   r@   r   r   s    r   r   zPLAINCredentials.__init__S   s    $$--dD$?r   c                      y)Nr   r   r   s    r   rC   zPLAINCredentials.getChallengeV   s    r   c                 x    |j                  d      }t        |      dk7  rt        d      |\  }| _        | _        y )Nr:      z*Malformed Response - wrong number of parts)splitlenr   usernamepassword)r   r%   partsuselesss       r   rF   zPLAINCredentials.setResponseY   s7    u%u:?'(TUU05-r   c                      y)NFr   r   s    r   rI   zPLAINCredentials.moreChallenges_   s    r   NrJ   r   r   r   rL   rL   Q   s    @6r   rL   )r
   r<   r,   rL   r6   )__doc__r   r   zope.interfacer   twisted.credr   twisted.mail._exceptr   twisted.mail.interfacesr   r   twisted.python.compatr   r
   r,   r6   r@   r<   rL   __all__r   r   r   <module>r_      s   
   & $ 6 M . "#	; 	; $	; "#  $$ "#2 2 $2  %{33 % !%   {33  !"r   