o
    ¯b^  ã                   @   sN   d Z ddlZddlmZ ddlmZmZ ddlmZ eeƒG dd„ dƒƒZ	dS )z¡
HTTP BASIC authentication.

@see: U{http://tools.ietf.org/html/rfc1945}
@see: U{http://tools.ietf.org/html/rfc2616}
@see: U{http://tools.ietf.org/html/rfc2617}
é    N)Úimplementer)ÚcredentialsÚerror)ÚICredentialFactoryc                   @   s,   e Zd ZdZdZdd„ Zdd„ Zdd„ Zd	S )
ÚBasicCredentialFactoryzÌ
    Credential Factory for HTTP Basic Authentication

    @type authenticationRealm: L{bytes}
    @ivar authenticationRealm: The HTTP authentication realm which will be issued in
        challenges.
    s   basicc                 C   s
   || _ d S )N©ÚauthenticationRealm)Úselfr   © r
   ú9/usr/lib/python3/dist-packages/twisted/web/_auth/basic.pyÚ__init__"   s   
zBasicCredentialFactory.__init__c                 C   s
   d| j iS )zy
        Return a challenge including the HTTP authentication realm with which
        this factory was created.
        Úrealmr   )r	   Úrequestr
   r
   r   ÚgetChallenge%   s   
z#BasicCredentialFactory.getChallengec                 C   sZ   z	t  |d ¡}W n t jy   t d¡‚w | dd¡}t|ƒdkr(tj|Ž S t d¡‚)zŠ
        Parse the base64-encoded, colon-separated username and password into a
        L{credentials.UsernamePassword} instance.
        s   ===zInvalid credentialsó   :é   é   )	ÚbinasciiÚ
a2b_base64ÚErrorr   ÚLoginFailedÚsplitÚlenr   ÚUsernamePassword)r	   Úresponser   Úcredsr
   r
   r   Údecode,   s   
ÿ

zBasicCredentialFactory.decodeN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úschemer   r   r   r
   r
   r
   r   r      s    r   )
r    r   Úzope.interfacer   Útwisted.credr   r   Útwisted.web.iwebr   r   r
   r
   r
   r   Ú<module>   s   	