PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB`  $^c@sjddlZddlZddlZddlmZddlZddlmZde fdYZ dS(iN(ttimegm(turlparsetCookiecBseZdZdefdYZdefdYZejdZejdej Z idd6dd6d d 6d d 6d d 6d d 6Z e dZ e d#dZe dZe dZe d#dZe d#d#dZd#d#d#d#d#d#d#dZedZejdZedZejdZedZejdZdZdZdZdZdZd Zd!Z d"Z!RS($s A Cookie object has the following attributes: key The name of the cookie value The value of the cookie A Cookie also supports these predefined optional attributes. If an optional attribute is not set on the cookie it's value is None. domain Restrict cookie usage to this domain path Restrict cookie usage to this path or below expires Cookie is invalid after this UTC timestamp max_age Cookie is invalid this many seconds in the future. Has precedence over the expires attribute. secure Cookie should only be returned on secure (i.e. SSL/TLS) connections. httponly Cookie is intended only for HTTP communication, it can never be utilized in any other context (e.g. browser Javascript). See the documentation of get_expiration() for an explanation of how the expires and max-age attributes interact as well as the role of the timestamp attribute. Expiration values are stored as datetime objects for easy manipulation and comparision. There are two ways to instantiate a Cookie object. Either directly via the constructor or by calling the class function parse() which returns a list of Cookie objects found in a string. To create a cookie to sent to a client: Example: cookie = Cookie('session', session_id, domain=my_domain, path=mypath, httponly=True, secure=True, expires=expiration) headers.append(('Set-Cookie', str(cookie))) To receive cookies from a request: Example: cookies = Cookie.parse(response.getheader('Set-Cookie'), request_url) tExpiredcBseZRS((t__name__t __module__(((s4/usr/lib/python2.7/site-packages/ipapython/cookie.pyR}st URLMismatchcBseZRS((RR(((s4/usr/lib/python2.7/site-packages/ipapython/cookie.pyRss;\s*s@^\s*([a-zA-Z0-9\!\#\$\%\&\'\*\+\-\.\^\_\`\|\~]+)\s*=\s*(.*?)\s*$tdomaintpathtmax_agesmax-agetexpirestsecurethttponlycCst|jS(sg Timestamps (timestamp & expires) are stored as datetime objects in UTC. It's non-obvious how to convert a naive UTC datetime into a unix time value (seconds since the epoch UTC). That functionality is oddly missing from the datetime and time modules. This utility provides that missing functionality. (Rt utctimetuple(tclstdt((s4/usr/lib/python2.7/site-packages/ipapython/cookie.pytdatetime_to_times cCsX|j}|dk r9|jdkr9tdntjj|j|dtS(sO Given a datetime object in UTC generate RFC 1123 date string. gstimezone is not UTCtusegmtN( t utcoffsettNonet total_secondst ValueErrortemailtutilst formatdateRtTrue(RRR((s4/usr/lib/python2.7/site-packages/ipapython/cookie.pytdatetime_to_strings cCsb|j}y&tjtjj|dd!}Wn)tk r]}td||fnX|S(s_ Parse a RFC 822, RFC 1123 date string, return a datetime naive object in UTC. iis)unable to parse expires datetime '%s': %s(tstriptdatetimeRRt parsedatet ExceptionR(RtsRte((s4/usr/lib/python2.7/site-packages/ipapython/cookie.pytparse_datetimes  &cCsS|j}|sdS|jds)dS|jddkrBdS||jd S(s+ Given a URL path, possibly empty, return a path consisting only of directory components. The URL path must end with a trailing slash for the last path element to be considered a directory. Also the URL path must begin with a slash. Empty input returns '/'. Examples: '' -> '/' '/' -> '/' 'foo' -> '/' 'foo/' -> '/' '/foo -> '/' '/foo/' -> '/foo' '/foo/bar' -> '/foo' '/foo/bar/' -> '/foo/bar' t/i(tlowert startswithtcounttrindex(Rturl_path((s4/usr/lib/python2.7/site-packages/ipapython/cookie.pytnormalize_url_paths c Csg}tjj|}d}xn|D]f}tjj|}|r|jd}|jd} | r| ddkr| ddkr| dd!} qtd| nt} n|}t} t } |j tj k} |dkr| r| rt|| }q%|rS| rS| rS|dk r4|j |n|j |t|| }q%|rr| rr|j|| q%|r%td|q%q%W|r|dk r|j |n|j |n|S( s Given a string containing one or more cookies (the HTTP_COOKIES environment variable typically contains multiple cookies) parse the string and return a list of Cookie objects found in the string. iiit"isunterminated quote in '%s'sunknown cookie token '%s'N(Rtfield_retsplitRt kv_pair_retsearchtgroupRRtFalseR#tattrst normalizetappendt_Cookie__set_attr( Rt cookie_stringt request_urltcookiestfieldstcookietfieldtmatchtkeytvaluetkv_pairt is_attribute((s4/usr/lib/python2.7/site-packages/ipapython/cookie.pytparsesB       cCsvd}|j|}x&|D]}|j|kr|}qqW|dk rV||_n|dk rr|j|n|S(s$ A cookie string may contain multiple cookies, parse the cookie string and return the last cookie in the string matching the cookie name or None if not found. This is basically a utility wrapper around the parse() class method which iterates over what parse() returns looking for the specific cookie. When cookie_name appears more than once the last instance is returned rather than the first because the ordering sequence makes the last instance the current value. N(RR?R;t timestampR1(RR4t cookie_nameR5R@t target_cookieR6R8((s4/usr/lib/python2.7/site-packages/ipapython/cookie.pytget_named_cookie_from_stringBs     c CsU||_||_||_||_||_||_||_||_| |_dS(N( R;R<RRR R R R R@( tselfR;R<RRR R R R R@((s4/usr/lib/python2.7/site-packages/ipapython/cookie.pyt__init__as        cCs|jS(s The UTC moment at which cookie was received for purposes of computing the expiration given a Max-Age offset. The expiration will be timestamp + max_age. The timestamp value will aways be a datetime object. By default the timestamp will be the moment the Cookie object is created as this often corresponds to the moment the cookie is received (the intent of the Max-Age attribute). But becuase it's sometimes desirable to force a specific moment for purposes of computing the expiration from the Max-Age the Cookie timestamp can be updated. Setting a value of None causes the timestamp to be set to the current UTC time (now). You may also assign with a numeric UNIX timestamp (seconds since the epoch UTC) or a formatted time sting, in all cases the value will be converted to a datetime object. (t _timestamp(RD((s4/usr/lib/python2.7/site-packages/ipapython/cookie.pyR@mscCs|dkrd|_nt|tjr6||_nmt|tjtfrftjj||_n=t|tjrt j ||_nt d|j j dS(NsDvalue must be datetime, int, long, float, basestring or None, not %s(RRFt isinstanceRtsixt integer_typestfloattutcfromtimestampt string_typesRR!t TypeErrort __class__R(RDR<((s4/usr/lib/python2.7/site-packages/ipapython/cookie.pyR@s   cCs|jS(sH The expiration timestamp (in UTC) as a datetime object for the cookie, or None if not set. You may assign a value of None, a datetime object, a numeric UNIX timestamp (seconds since the epoch UTC) or formatted time string (the latter two will be converted to a datetime object. (t_expires(RD((s4/usr/lib/python2.7/site-packages/ipapython/cookie.pyR s cCs|dkrd|_nt|tjr6||_nmt|tjtfrftjj||_n=t|tjrt j ||_nt d|j j dS(NsDvalue must be datetime, int, long, float, basestring or None, not %s(RRORGRRHRIRJRKRLRR!RMRNR(RDR<((s4/usr/lib/python2.7/site-packages/ipapython/cookie.pyR s   cCs|jS(sq The lifetime duration of the cookie. Computed as an offset from the cookie's timestamp. (t_max_age(RD((s4/usr/lib/python2.7/site-packages/ipapython/cookie.pyR scCsS|dkrd|_n7yt||_Wn!tk rNtd|nXdS(Ns-Max-Age value '%s' not convertable to integer(RRPtintRR(RDR<((s4/usr/lib/python2.7/site-packages/ipapython/cookie.pyR s    cCsNtjj|jd}|dkr:td|nt|||dS(s? Sets one of the predefined cookie attributes. sunknown cookie attribute '%s'N(RR0tgetR#RRtsetattr(RDtnameR<t attr_name((s4/usr/lib/python2.7/site-packages/ipapython/cookie.pyt __set_attrs cCsg}|jd|j|jf|jdk rI|jd|jn|jdk ro|jd|jn|jdk r|jd|jn|jdk r|jdtj |jn|j r|jdn|j r|jdndj |S( Ns%s=%ss Domain=%ssPath=%ss Max-Age=%ss Expires=%stSecuretHttpOnlys; ( R2R;R<RRRR R RRR R tjoin(RDt components((s4/usr/lib/python2.7/site-packages/ipapython/cookie.pyt__str__s   cCsC|jdk r)|jtjd|jS|jdk r?|jSdS(s/ Return the effective expiration of the cookie as a datetime object or None if no expiration is defined. Expiration may be defined either by the "Expires" timestamp attribute or the "Max-Age" duration attribute. If both are set "Max-Age" takes precedence. If neither is set the cookie has no expiration and None will be returned. "Max-Age" specifies the number of seconds in the future from when the cookie is received until it expires. Effectively it means adding "Max-Age" seconds to a timestamp to arrive at an expiration. By default the timestamp used to mark the arrival of the cookie is set to the moment the cookie object is created. However sometimes it is desirable to adjust the received timestamp to something other than the moment of object creation, therefore you can explicitly set the arrival timestamp used in the "Max-Age" calculation. "Expires" specifies an explicit timestamp. If "Max-Age" is set a datetime object is returned which is the sum of the arrival timestamp and "Max-Age". If "Expires" is set a datetime object is returned matching the timestamp specified as the "Expires" value. If neither is set None is returned. tsecondsN(R RR@Rt timedeltaR (RD((s4/usr/lib/python2.7/site-packages/ipapython/cookie.pytget_expirations cCs|j|_d|_|jS(s An expiration may be specified either with an explicit timestamp in the "Expires" attribute or via an offset specified witht the "Max-Age" attribute. The "Max-Age" attribute has precedence over "Expires" if both are specified. This method normalizes the expiration of the cookie such that only a "Expires" attribute remains after consideration of the "Max-Age" attribute. This is useful when storing the cookie for future reference. N(R^R RR (RD((s4/usr/lib/python2.7/site-packages/ipapython/cookie.pytnormalize_expirations cCsgt|\}}}}}}|jdkr?|j|_n|jdkrc|j||_ndS(s If cookie domain and path attributes are not specified then they assume defaults from the request url the cookie was received from. N(RRRR#RR((RDturlt_schemeRRt_paramst_queryt _fragment((s4/usr/lib/python2.7/site-packages/ipapython/cookie.pytset_defaults_from_urls cCs|j||jdS(s Missing cookie attributes will receive default values derived from the request URL. The expiration value is normalized. N(ReR_(RDR`((s4/usr/lib/python2.7/site-packages/ipapython/cookie.pyR1(s cCsd|j|jfS(s Return a string with just the key and value (no attributes). This is appropriate for including in a HTTP Cookie header. s%s=%s;(R;R<(RD((s4/usr/lib/python2.7/site-packages/ipapython/cookie.pyt http_cookie1sc szd}fd}j}t|\}}}}} } j} | d k rtjj} | | krtjd|j| fqn||j stj d|j |fn||j stj d|j |fn|j }j rB|d krBtj d||fqBnjrv|d krvtj d ||fqvntS( s Tests to see if a cookie should be returned when a request is sent to a specific URL. * The request url's host must match the cookie's doman otherwise raises Cookie.URLMismatch. * The path in the request url must contain the cookie's path otherwise raises Cookie.URLMismatch. * If the cookie defines an expiration date then the current time must be less or equal to the cookie's expiration timestamp. Will raise Cookie.Expired if a defined expiration is not valid. If the test fails Cookie.Expired or Cookie.URLMismatch will be raised, otherwise True is returned. cSsddlm}y||Wntk r2tSX|dkrCtS|j}|j}||krktS|j|r|jdrtSntS(s~ Compute domain component and perform test per RFC 6265, Section 5.1.3. "Domain Matching" i(tvalidate_domain_namet.N( t ipalib.utilRgRR/RRR#tendswithR$(t url_domaint cookie_domainRg((s4/usr/lib/python2.7/site-packages/ipapython/cookie.pyt domain_validMs      cs|dkrtS|j}j|}||kr;tS|r|j|r|jdrctS|t|}|jdrtSntS(s Compute path component and perform test per RFC 6265, Section 5.1.4. "Paths and Path-Match" R"N(RRR#R(R$RjtlenR/(R't cookie_patht request_pathttail(RD(s4/usr/lib/python2.7/site-packages/ipapython/cookie.pyt path_validls   s!cookie named '%s'; expired at %s'sBcookie named '%s'; it's domain '%s' does not match URL domain '%s'sDcookie named '%s'; it's path '%s' does not contain the URL path '%s'thttpthttpssDcookie named '%s'; is restricted to HTTP but it's URL scheme is '%s'sPcookie named '%s'; is restricted to secure transport but it's URL scheme is '%s'N(RsRt(Rt(R;RR^RRtutcnowRRRRRRR#R R R( RDR`RmRrRAt url_schemeRkR't _url_paramst _url_queryt _url_fragmenttcookie_expirationtnow((RDs4/usr/lib/python2.7/site-packages/ipapython/cookie.pythttp_return_ok8s6               N("RRt__doc__RRRtretcompileR*t IGNORECASER,R0t classmethodRRRR!R(R?RCREtpropertyR@tsetterR R R3R[R^R_ReR1RfR|(((s4/usr/lib/python2.7/site-packages/ipapython/cookie.pyREsH6   "\     &   ( R~Rt email.utilsRtcalendarRRHtsix.moves.urllib.parseRtobjectR(((s4/usr/lib/python2.7/site-packages/ipapython/cookie.pyts    *