o
    ¯b_  ã                   @   sB   d Z ddlmZ ddlmZ ddlmZ eeƒG dd„ dƒƒZdS )zg
Implementation of RFC2617: HTTP Digest Authentication

@see: U{http://www.faqs.org/rfcs/rfc2617.html}
é    )Úimplementer)Úcredentials)ÚICredentialFactoryc                   @   s,   e Zd ZdZdZdd„ Zdd„ Zdd„ Zd	S )
ÚDigestCredentialFactoryzp
    Wrapper for L{digest.DigestCredentialFactory} that implements the
    L{ICredentialFactory} interface.
    s   digestc                 C   s   t  ||¡| _dS )zN
        Create the digest credential factory that this object wraps.
        N)r   r   Údigest)ÚselfÚ	algorithmÚauthenticationRealm© r
   ú:/usr/lib/python3/dist-packages/twisted/web/_auth/digest.pyÚ__init__   s   
ÿz DigestCredentialFactory.__init__c                 C   s   | j  | ¡ j¡S )aA  
        Generate the challenge for use in the WWW-Authenticate header

        @param request: The L{IRequest} to with access was denied and for the
            response to which this challenge is being generated.

        @return: The L{dict} that can be used to generate a WWW-Authenticate
            header.
        )r   ÚgetChallengeÚgetClientAddressÚhost)r   Úrequestr
   r
   r   r   #   s   
z$DigestCredentialFactory.getChallengec                 C   s   | j  ||j| ¡ j¡S )zª
        Create a L{twisted.cred.credentials.DigestedCredentials} object
        from the given response and request.

        @see: L{ICredentialFactory.decode}
        )r   ÚdecodeÚmethodr   r   )r   Úresponser   r
   r
   r   r   /   s   ÿzDigestCredentialFactory.decodeN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úschemer   r   r   r
   r
   r
   r   r      s    r   N)r   Úzope.interfacer   Útwisted.credr   Útwisted.web.iwebr   r   r
   r
   r
   r   Ú<module>   s   