B
    Rœ±[9  ã               @   sJ   d dl mZ d dlZdd„ Zdd„ ZdZG dd	„ d	eƒZG d
d„ dƒZdS )é    )ÚhexlifyNc              C   s   t tt ¡ ƒ d¡ƒ} d|  S )NÚasciis   AUTH EXTERNAL %b
)r   ÚstrÚosÚgeteuidÚencode)Zhex_uid© r   ú+lib/python3.7/site-packages/jeepney/auth.pyÚmake_auth_external   s    r
   c              C   s&   ddl m}  td|   d¡ƒ}d| S )zéFormat an AUTH command line for the ANONYMOUS mechanism

    Jeepney's higher-level wrappers don't currently use this mechanism,
    but third-party code may choose to.

    See <https://tools.ietf.org/html/rfc4505> for details.
    é   )Ú__version__z
Jeepney %sr   s   AUTH ANONYMOUS %s
)Ú r   r   r   )r   Ztracer   r   r	   Úmake_auth_anonymous   s    r   s   BEGIN
c               @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚAuthenticationErrorz%Raised when DBus authentication failsc             C   s
   || _ d S )N)Údata)Úselfr   r   r   r	   Ú__init__   s    zAuthenticationError.__init__c             C   s
   d| j  S )Nz#Authentication failed. Bus sent: %r)r   )r   r   r   r	   Ú__str__   s    zAuthenticationError.__str__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r	   r      s   r   c               @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )Ú
SASLParserc             C   s   d| _ d| _d | _d S )Nó    F)ÚbufferÚauthenticatedÚerror)r   r   r   r	   r      s    zSASLParser.__init__c             C   s   |  d¡rd| _n|| _d S )Ns   OK T)Ú
startswithr   r   )r   Úliner   r   r	   Úprocess_line$   s    
zSASLParser.process_linec             C   sF   |  j |7  _ x2d| j kr@| js@| j  dd¡\}| _ |  |¡ qW d S )Ns   
r   )r   r   Úsplitr   )r   r   r   r   r   r	   Úfeed*   s    zSASLParser.feedN)r   r   r   r   r   r!   r   r   r   r	   r      s   r   )	Zbinasciir   r   r
   r   ZBEGINÚ
ValueErrorr   r   r   r   r   r	   Ú<module>   s   