³ò
—ã=Pc           @   sè   d  Z  d d k l Z d d k Td d k l Z d d k l Z d d k l Z y d d k	 l
 Z
 Wn# e j
 o d d k
 l
 Z
 n Xd Z d Z d Z d Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   s*   
The I{wsse} module provides WS-Security.
iÿÿÿÿ(   t	   getLogger(   t   *(   t   Object(   t   Element(   t   datetime(   t   md5t   dss"   http://www.w3.org/2000/09/xmldsig#t   wssesQ   http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsdt   wsusR   http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsdt   wsencs!   http://www.w3.org/2001/04/xmlenc#t   Securityc           B   s    e  Z d  Z d „  Z d „  Z RS(   s5  
    WS-Security object.
    @ivar tokens: A list of security tokens
    @type tokens: [L{Token},...]
    @ivar signatures: A list of signatures.
    @type signatures: TBD
    @ivar references: A list of references.
    @type references: TBD
    @ivar keys: A list of encryption keys.
    @type keys: TBD
    c         C   s>   t  i |  ƒ t |  _ g  |  _ g  |  _ g  |  _ g  |  _ d S(   t    N(   R   t   __init__t   Truet   mustUnderstandt   tokenst
   signaturest
   referencest   keys(   t   self(    (    s!   suds-0.3.7-py2.6.egg/suds/wsse.pyR   =   s    				c         C   s\   t  d d t ƒ} | i d t |  i ƒ i ƒ  ƒ x$ |  i D] } | i | i ƒ  ƒ q; W| S(   sr   
        Get xml representation of the object.
        @return: The root node.
        @rtype: L{Element}
        R
   t   nsR   (	   R   t   wssenst   sett   strR   t   lowerR   t   appendt   xml(   R   t   roott   t(    (    s!   suds-0.3.7-py2.6.egg/suds/wsse.pyR   F   s    
 (   t   __name__t
   __module__t   __doc__R   R   (    (    (    s!   suds-0.3.7-py2.6.egg/suds/wsse.pyR
   0   s   		t   Tokenc           B   s   e  Z d  Z d „  Z RS(   s    I{Abstract} security token. c         C   s   t  i |  ƒ d  S(   N(   R   R   (   R   (    (    s!   suds-0.3.7-py2.6.egg/suds/wsse.pyR   V   s    (   R   R   R   R   (    (    (    s!   suds-0.3.7-py2.6.egg/suds/wsse.pyR    S   s   t   UsernameTokenc           B   s\   e  Z d  Z e d „  ƒ Z e d „  ƒ Z d d d „ Z d d „ Z d d „ Z	 d „  Z
 RS(   sD  
    Represents a basic I{UsernameToken} WS-Secuirty token.
    @ivar username: A username.
    @type username: str
    @ivar password: A password.
    @type password: str
    @ivar nonce: A set of bytes to prevent reply attacks.
    @type nonce: str
    @ivar created: The token created.
    @type created: L{datetime}
    c         C   s
   t  i ƒ  S(   N(   R   t   now(   t   cls(    (    s!   suds-0.3.7-py2.6.egg/suds/wsse.pyR"   g   s    c         C   s   |  i  ƒ  i ƒ  S(   N(   R"   t	   isoformat(   R#   (    (    s!   suds-0.3.7-py2.6.egg/suds/wsse.pyt   sysdatek   s    c         C   s5   t  i |  ƒ | |  _ | |  _ d |  _ d |  _ d S(   s‹   
        @param username: A username.
        @type username: str
        @param password: A password.
        @type password: str
        N(   R    R   t   usernamet   passwordt   Nonet   noncet   created(   R   R&   R'   (    (    s!   suds-0.3.7-py2.6.egg/suds/wsse.pyR   o   s
    			c         C   s…   | d j ok g  } | i |  i ƒ | i |  i ƒ | i |  i ƒ  ƒ t ƒ  } | i d i | ƒ ƒ | i ƒ  |  _	 n
 | |  _	 d S(   sÇ   
        Set I{nonce} which is arbitraty set of bytes to prevent
        reply attacks.
        @param text: The nonce text value.
            Generated when I{None}.
        @type text: str
        t   :N(
   R(   R   R&   R'   R%   R   t   updatet   joint	   hexdigestR)   (   R   t   textt   st   m(    (    s!   suds-0.3.7-py2.6.egg/suds/wsse.pyt   setnonce|   s    	c         C   s-   | d j o |  i ƒ  |  _ n
 | |  _ d S(   s›   
        Set I{created}.
        @param dt: The created date & time.
            Set as datetime.now() when I{None}.
        @type dt: L{datetime}
        N(   R(   R"   R*   (   R   t   dt(    (    s!   suds-0.3.7-py2.6.egg/suds/wsse.pyt
   setcreated   s    c         C   s   t  d d t ƒ} t  d d t ƒ} | i |  i ƒ | i | ƒ t  d d t ƒ} | i |  i ƒ | i | ƒ |  i d j	 o3 t  d d t ƒ} | i |  i ƒ | i | ƒ n |  i d j	 o9 t  d d t	 ƒ} | i |  i i
 ƒ  ƒ | i | ƒ n | S(   sr   
        Get xml representation of the object.
        @return: The root node.
        @rtype: L{Element}
        R!   R   t   Usernamet   Passwordt   Noncet   CreatedN(   R   R   t   setTextR&   R   R'   R)   R(   R*   t   wsunsR$   (   R   R   t   ut   pt   n(    (    s!   suds-0.3.7-py2.6.egg/suds/wsse.pyR   œ   s     N(   R   R   R   t   classmethodR"   R%   R(   R   R2   R4   R   (    (    (    s!   suds-0.3.7-py2.6.egg/suds/wsse.pyR!   Z   s   N(   s   dss"   http://www.w3.org/2000/09/xmldsig#(   s   wssesQ   http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd(   R   sR   http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd(   R	   s!   http://www.w3.org/2001/04/xmlenc#(   R   t   loggingR    t   sudst   suds.sudsobjectR   t   suds.sax.elementR   R   t   hashlibR   t   ImportErrort   dsnsR   R:   t   wsencnsR
   R    R!   (    (    (    s!   suds-0.3.7-py2.6.egg/suds/wsse.pys   <module>   s(   
    #