U
    
W[ê  ã                   @   sT   d Z ddlmZmZ ddlmZ ddlmZ ddlm	Z	 ee	ƒG dd„ de
ƒƒZdS )	zg
Implementation of RFC2617: HTTP Digest Authentication

@see: U{http://www.faqs.org/rfcs/rfc2617.html}
é    )ÚdivisionÚabsolute_import)Ú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Ú	algorithmZ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	   Zresponser   r   r   r   r   /   s    þzDigestCredentialFactory.decodeN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Zschemer   r   r   r   r   r   r   r      s
   r   N)r   Z
__future__r   r   Zzope.interfacer   Ztwisted.credr   Ztwisted.web.iwebr   Úobjectr   r   r   r   r   Ú<module>   s   