Current File : //opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyc
�
>X5Sc@s0dZddlZddlZddlZddlZddlZddlZddlZddlmZej	ddkZ
e
r�ddlmZe
ZeZeeefZn=ddlmZeZeZejdd	d
�ZeefZyddlZWnek
rddlZnXdefd��YZe�Zd
Z ddd�Z!d�Z"e#edd�Z%d�Z&de'fd��YZ(de(fd��YZ)de(fd��YZ*de*fd��YZ+de*fd��YZ,de+fd��YZ-d �Z.d!�Z/d"�Z0d#�Z1d$efd%��YZ2d&e2fd'��YZ3d(e2fd)��YZ4d*efd+��YZ5d,e5fd-��YZ6d.efd/��YZ7d0e7fd1��YZ8d2e7fd3��YZ9d4e9fd5��YZ:d6efd7��YZ;d8e;e7fd9��YZ<d:e;e8fd;��YZ=dS(<s
    itsdangerous
    ~~~~~~~~~~~~

    A module that implements various functions to deal with untrusted
    sources.  Mainly useful for web applications.

    :copyright: (c) 2014 by Armin Ronacher and the Django Software Foundation.
    :license: BSD, see LICENSE for more details.
i����N(tdatetimeii(tizip(treducetto_bytesitbigt_CompactJSONcBs eZdZd�Zd�ZRS(s6Wrapper around simplejson that strips whitespace.
    cCs
tj|�S(N(tjsontloads(tselftpayload((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR/scCstj|dd�S(Nt
separatorst,t:(RR(Rtdumps(Rtobj((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR
2s(t__name__t
__module__t__doc__RR
(((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR+s	i�nMsutf-8tstrictcCs(t|t�r$|j||�}n|S(N(t
isinstancet	text_typetencode(tstencodingterrors((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyt
want_bytes=scCst|ji�t�S(s6Checks wheather a serializer generates text or binary.(RR
R(t
serializer((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pytis_text_serializerCstcompare_digestcCs�tdk	rt||�St|�t|�k}|rFd}|}nd}|}x7tt|�t|��D]\}}|||AO}qnW|dkS(s8Returns True if the two strings are equal, False otherwise.

    The time taken is independent of the number of characters that match.  Do
    not use this function for anything else than comparision with known
    length targets.

    This is should be implemented in C in order to get it completely right.
    iiN(t_builtin_constant_time_comparetNonetlenRt	bytearray(tval1tval2tlen_eqtresulttlefttxty((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pytconstant_time_compareMs	
	(tBadDatacBs>eZdZdZd�Zd�Zer<eZd�ZnRS(s�Raised if bad data of any sort was encountered.  This is the
    base for all exceptions that itsdangerous is currently using.

    .. versionadded:: 0.15
    cCstj||�||_dS(N(t	Exceptiont__init__tmessage(RR,((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR+lscCs
t|j�S(N(RR,(R((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyt__str__pscCs|j�jd�S(Nsutf-8(t__unicode__R(R((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR-usN(	RRRRR,R+R-tPY2R.(((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR)ds		t
BadPayloadcBseZdZdd�ZRS(s�This error is raised in situations when payload is loaded without
    checking the signature first and an exception happend as a result of
    that.  The original exception that caused that will be stored on the
    exception as :attr:`original_error`.

    This can also happen with a :class:`JSONWebSignatureSerializer` that
    is subclassed and uses a different serializer for the payload than
    the expected one.

    .. versionadded:: 0.15
    cCstj||�||_dS(N(R)R+toriginal_error(RR,R1((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR+�sN(RRRRR+(((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR0ystBadSignaturecBseZdZdd�ZRS(s�This error is raised if a signature does not match.  As of
    itsdangerous 0.14 there are helpful attributes on the exception
    instances.  You can also catch down the baseclass :exc:`BadData`.
    cCstj||�||_dS(N(R)R+R	(RR,R	((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR+�sN(RRRRR+(((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR2�stBadTimeSignaturecBseZdZddd�ZRS(s�Raised for time based signatures that fail.  This is a subclass
    of :class:`BadSignature` so you can catch those down as well.
    cCs tj|||�||_dS(N(R2R+tdate_signed(RR,R	R4((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR+�sN(RRRRR+(((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR3�st	BadHeadercBs eZdZdddd�ZRS(s�Raised if a signed header is invalid in some form.  This only
    happens for serializers that have a header that goes with the
    signature.

    .. versionadded:: 0.24
    cCs)tj|||�||_||_dS(N(R2R+theaderR1(RR,R	R6R1((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR+�s	N(RRRRR+(((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR5�stSignatureExpiredcBseZdZRS(s�Signature timestamp is older than required max_age.  This is a
    subclass of :exc:`BadTimeSignature` so you can use the baseclass for
    catching the error.
    (RRR(((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR7�scCs"t|�}tj|�jd�S(s�base64 encodes a single bytestring (and is tolerant to getting
    called with a unicode string).
    The resulting bytestring is safe for putting into URLs.
    t=(Rtbase64turlsafe_b64encodetstrip(tstring((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyt
base64_encode�scCs8t|dddd�}tj|dt|�d�S(s�base64 decodes a single bytestring (and is tolerant to getting
    called with a unicode string).
    The result is also a bytestring.
    RtasciiRtignoreR8i(RR9turlsafe_b64decodeR(R<((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyt
base64_decode�scCsY|dkst�g}x+|rE|jt|d@��|dL}qWdjt|��S(Nii�it(tAssertionErrortappendtint_to_bytetjointreversed(tnumtrv((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pytint_to_bytes�s	cCstd�t|�d�S(NcSs|d>|BS(Ni((tatb((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyt<lambda>�si(RR (tbytestr((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pytbytes_to_int�stSigningAlgorithmcBs eZdZd�Zd�ZRS(szSubclasses of `SigningAlgorithm` have to implement `get_signature` to
    provide signature generation functionality.
    cCs
t��dS(s1Returns the signature for the given key and valueN(tNotImplementedError(Rtkeytvalue((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyt
get_signature�scCst||j||��S(s;Verifies the given signature matches the expected signature(R(RT(RRRRStsig((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pytverify_signature�s(RRRRTRV(((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyRP�s	t
NoneAlgorithmcBseZdZd�ZRS(sjThis class provides a algorithm that does not perform any signing and
    returns an empty signature.
    cCsdS(NRB((RRRRS((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyRT�s(RRRRT(((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyRW�st
HMACAlgorithmcBs2eZdZeej�Zdd�Zd�Z	RS(s5This class provides signature generation using HMACs.cCs%|dkr|j}n||_dS(N(Rtdefault_digest_methodt
digest_method(RRZ((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR+scCs(tj|d|d|j�}|j�S(Ntmsgt	digestmod(thmactnewRZtdigest(RRRRStmac((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyRTsN(
RRRtstaticmethodthashlibtsha1RYRR+RT(((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyRX�stSignercBsqeZdZeej�ZdZd
dd
d
d
d�Z	d�Z
d�Zd�Zd�Z
d�Zd	�ZRS(s�This class can sign bytes and unsign it and validate the signature
    provided.

    Salt can be used to namespace the hash, so that a signed string is only
    valid for a given namespace.  Leaving this at the default value or re-using
    a salt value across different parts of your application where the same
    signed value in one part can mean something different in another part
    is a security risk.

    See :ref:`the-salt` for an example of what the salt is doing and how you
    can utilize it.

    .. versionadded:: 0.14
       `key_derivation` and `digest_method` were added as arguments to the
       class constructor.

    .. versionadded:: 0.18
        `algorithm` was added as an argument to the class constructor.
    s
django-concatt.cCs�t|�|_||_|dkr*dn||_|dkrK|j}n||_|dkrl|j}n||_|dkr�t	|j�}n||_
dS(Nsitsdangerous.Signer(Rt
secret_keytsepRtsalttdefault_key_derivationtkey_derivationRYRZRXt	algorithm(RRfRhRgRjRZRk((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR+3s			cCs�t|j�}|jdkr8|j||j�j�S|jdkre|j|d|j�j�S|jdkr�tj|jd|j�}|j|�|j�S|jdkr�|jSt	d��dS(	snThis method is called to derive the key.  If you're unhappy with
        the default key derivation choices you can override them here.
        Keep in mind that the key derivation in itsdangerous is not intended
        to be used as a security method to make a complex key out of a short
        password.  Instead you should use large random secret keys.
        tconcats
django-concattsignerR]R\tnonesUnknown key derivation methodN(
RRhRjRZRfR_R]R^tupdatet	TypeError(RRhR`((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyt
derive_keyBs


cCs7t|�}|j�}|jj||�}t|�S(s)Returns the signature for the given value(RRqRkRTR=(RRSRRRU((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyRTXscCs|t|j�|j|�S(sSigns the given string.(RRgRT(RRS((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pytsign_scCsG|j�}yt|�}Wntk
r0tSX|jj|||�S(s+Verifies the signature for the given value.(RqRAR*tFalseRkRV(RRSRURR((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyRVcs
cCs�t|�}t|j�}||kr=td|j��n|j|d�\}}|j||�rk|Std|d|��dS(sUnsigns the given string.sNo %r found in valueisSignature %r does not matchR	N(RRgR2trsplitRV(Rtsigned_valueRgRSRU((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pytunsignls
cCs.y|j|�tSWntk
r)tSXdS(swJust validates the given signed value.  Returns `True` if the
        signature exists and is valid, `False` otherwise.N(RvtTrueR2Rs(RRu((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pytvalidatexs


N(RRRRaRbRcRYRiRR+RqRTRrRVRvRx(((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyRds							tTimestampSignercBsDeZdZd�Zd�Zd�Zded�Zdd�Z	RS(s8Works like the regular :class:`Signer` but also records the time
    of the signing and can be used to expire signatures.  The unsign
    method can rause a :exc:`SignatureExpired` method if the unsigning
    failed because the signature is expired.  This exception is a subclass
    of :exc:`BadSignature`.
    cCsttj�t�S(s�Returns the current timestamp.  This implementation returns the
        seconds since 1/1/2011.  The function must return an integer.
        (tintttimetEPOCH(R((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyt
get_timestamp�scCstj|t�S(s[Used to convert the timestamp from `get_timestamp` into a
        datetime object.
        (RtutcfromtimestampR|(Rtts((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyttimestamp_to_datetime�scCsVt|�}tt|j���}t|j�}|||}|||j|�S(s<Signs the given string and also attaches a time information.(RR=RJR}RgRT(RRSt	timestampRg((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyRr�s
c
Cs�ytj||�}d}Wn(tk
rF}|}|jp@d}nXt|j�}||kr�|rq|�ntdd|��n|j|d�\}}yt	t
|��}Wntk
r�d}nX|dk	r�tt|�d|d|��n|dkrtdd|��n|dk	ru|j
�|}	|	|krutd|	|fd|d|j|���qun|r�||j|�fS|S(	s@Works like the regular :meth:`~Signer.unsign` but can also
        validate the time.  See the base docstring of the class for
        the general behavior.  If `return_timestamp` is set to `True`
        the timestamp of the signature will be returned as naive
        :class:`datetime.datetime` object in UTC.
        RBstimestamp missingR	iR4sMalformed timestampsSignature age %s > %s secondsN(RdRvRR2R	RRgR3RtRORAR*RR}R7R�(
RRStmax_agetreturn_timestampR$t	sig_errorteRgR�tage((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyRv�s>
	

cCs4y|j|d|�tSWntk
r/tSXdS(swJust validates the given signed value.  Returns `True` if the
        signature exists and is valid, `False` otherwise.R�N(RvRwR2Rs(RRuR�((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyRx�s

N(
RRRR}R�RrRRsRvRx(((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyRy�s			7t
SerializercBs�eZdZeZeZdd
d
d
d�Zd
d�Z	d�Z
d
d�Zd
d�Zd
d�Z
d
d�Zd
d	�Zd
d
�Zd
d
d�Zd�ZRS(s�This class provides a serialization interface on top of the
    signer.  It provides a similar API to json/pickle and other modules but is
    slightly differently structured internally.  If you want to change the
    underlying implementation for parsing and loading you have to override the
    :meth:`load_payload` and :meth:`dump_payload` functions.

    This implementation uses simplejson if available for dumping and loading
    and will fall back to the standard library's json module if it's not
    available.

    Starting with 0.14 you do not need to subclass this class in order to
    switch out or customer the :class:`Signer`.  You can instead also pass a
    different class to the constructor as well as keyword arguments as
    dictionary that should be forwarded::

        s = Serializer(signer_kwargs={'key_derivation': 'hmac'})

    .. versionchanged:: 0.14:
       The `signer` and `signer_kwargs` parameters were added to the
       constructor.
    titsdangerouscCs�t|�|_t|�|_|dkr6|j}n||_t|�|_|dkrf|j}n||_|pxi|_	dS(N(
RRfRhRtdefault_serializerRRtdefault_signerRmt
signer_kwargs(RRfRhRRmR�((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR+s		cCs�|dkr!|j}|j}nt|�}y)|rH|jd�}n|j|�SWn%tk
r}}tdd|��nXdS(sLoads the encoded object.  This function raises :class:`BadPayload`
        if the payload is not valid.  The `serializer` parameter can be used to
        override the serializer stored on the class.  The encoded payload is
        always byte based.
        sutf-8sRCould not load the payload because an exception occurred on unserializing the dataR1N(RRRtdecodeRR*R0(RR	Rtis_textR�((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pytload_payload
s		cCst|jj|��S(s�Dumps the encoded object.  The return value is always a
        bytestring.  If the internal serializer is text based the value
        will automatically be encoded to utf-8.
        (RRR
(RR((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pytdump_payload!scCs4|dkr|j}n|j|jd||j�S(s�A method that creates a new instance of the signer to be used.
        The default implementation uses the :class:`Signer` baseclass.
        RhN(RRhRmRfR�(RRh((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pytmake_signer(scCsLt|j|��}|j|�j|�}|jrH|jd�}n|S(s�Returns a signed string serialized with the internal serializer.
        The return value can be either a byte or unicode string depending
        on the format of the internal serializer.
        sutf-8(RR�R�RrRR�(RRRhR	RI((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR
0s
	cCs|j|j||��dS(s�Like :meth:`dumps` but dumps into a file.  The file handle has
        to be compatible with what the internal serializer expects.
        N(twriteR
(RRtfRh((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pytdump;scCs+t|�}|j|j|�j|��S(shReverse of :meth:`dumps`, raises :exc:`BadSignature` if the
        signature validation fails.
        (RR�R�Rv(RRRh((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyRAscCs|j|j�|�S(s)Like :meth:`loads` but loads from a file.(Rtread(RR�Rh((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pytloadHscCs|j||�S(sELike :meth:`loads` but without verifying the signature.  This is
        potentially very dangerous to use depending on how your serializer
        works.  The return value is ``(signature_okay, payload)`` instead of
        just the payload.  The first item will be a boolean that indicates
        if the signature is okay (``True``) or if it failed.  This function
        never fails.

        Use it for debugging only and if you know that your serializer module
        is not exploitable (eg: do not use it with a pickle serializer).

        .. versionadded:: 0.15
        (t_loads_unsafe_impl(RRRh((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pytloads_unsafeLs
cCs�y&t|j|d||pi�fSWnjtk
r�}|jdkrQtdfSy#t|j|j|pli�fSWq�tk
r�tdfSXnXdS(seLowlevel helper function to implement :meth:`loads_unsafe` in
        serializer subclasses.
        RhN(RwRR2R	RRsR�R0(RRRhtload_kwargstload_payload_kwargsR�((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR�[s&

cOs|j|j�||�S(sYLike :meth:`loads_unsafe` but loads from a file.

        .. versionadded:: 0.15
        (R�R�(RR�targstkwargs((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pytload_unsafeksN(RRRRR�RdR�RR+R�R�R�R
R�RR�R�R�R�(((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR��s 	tTimedSerializercBs5eZdZeZdedd�Zddd�ZRS(sQUses the :class:`TimestampSigner` instead of the default
    :meth:`Signer`.
    cCsJ|j|�j||dt�\}}|j|�}|rF||fS|S(s�Reverse of :meth:`dumps`, raises :exc:`BadSignature` if the
        signature validation fails.  If a `max_age` is provided it will
        ensure the signature is not older than that time in seconds.  In
        case the signature is outdated, :exc:`SignatureExpired` is raised
        which is a subclass of :exc:`BadSignature`.  All arguments are
        forwarded to the signer's :meth:`~TimestampSigner.unsign` method.
        R�(R�RvRwR�(RRR�R�Rhtbase64dR�R	((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyRzs
cCs)i|d6}i}|j||||�S(NR�(R�(RRR�RhR�R�((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR��s
N(	RRRRyR�RRsRR�(((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR�sstJSONWebSignatureSerializercBs�eZdZieej�d6eej�d6eej�d6e�d6Z	dZ
eZdddddd�Zed�Zd�Zd�Zddd	�Zd
�Zddd�Zded�Zded
�ZRS(ssThis serializer implements JSON Web Signature (JWS) support.  Only
    supports the JWS Compact Serialization.
    tHS256tHS384tHS512RncCsStj||||||�|dkr4|j}n||_|j|�|_dS(N(R�R+Rtdefault_algorithmtalgorithm_nametmake_algorithmRk(RRfRhRRmR�R�((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR+�s
	c	Cs=t|�}d|kr'td��n|jdd�\}}yt|�}Wn%tk
rv}tdd|��nXyt|�}Wn%tk
r�}tdd|��nXytj||dt�}Wn%t	k
r�}tdd|��nXt
|t�std	d
|��ntj||�}|r9||fS|S(NResNo "." found in valueis:Could not base64 decode the header because of an exceptionR1s;Could not base64 decode the payload because of an exceptionRs5Could not unserialize header because it was malformeds#Header payload is not a JSON objectR6(RR0tsplitRAR*R5R�R�RR)Rtdict(	RR	t
return_headertbase64d_headertbase64d_payloadtjson_headerR�tjson_payloadR6((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR��s6	
	

	
	
cCs<t|jj|��}t|jj|��}|d|S(NRe(R=RR
(RR6RR�R�((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR��scCs3y|j|SWntk
r.td��nXdS(NsAlgorithm not supported(tjws_algorithmstKeyErrorRQ(RR�((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR��s
c
Csp|dkr|j}n|dkr*dnd}|dkrH|j}n|j|jd|ddd|d|�S(NRnRhRgReRjRk(RRhRkRmRf(RRhRkRj((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR��scCs)|r|j�ni}|j|d<|S(Ntalg(tcopyR�(Rt
header_fieldsR6((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pytmake_header�s
cCs=|j|�}|j||j�}|j|j||��S(s�Like :meth:`~Serializer.dumps` but creates a JSON Web Signature.  It
        also allows for specifying additional fields to be included in the JWS
        Header.
        (R�R�RkRrR�(RRRhR�R6Rm((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR
�scCs�|j|j||j�jt|��dt�\}}|jd�|jkrltdd|d|��n|r|||fS|S(syReverse of :meth:`dumps`. If requested via `return_header` it will
        return a tuple of payload and header.
        R�R�sAlgorithm mismatchR6R	(	R�R�RkRvRRwtgetR�R5(RRRhR�R	R6((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR�s$
cCs#i|d6}|j||||�S(NR�(R�(RRRhR�R�((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR��s
N(RRRRXRbtsha256tsha384tsha512RWR�R�tcompact_jsonR�RR+RsR�R�R�R�R�R
RR�(((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR��s$
					tTimedJSONWebSignatureSerializercBsJeZdZdZdd�Zd�Zded�Zd�Z	d�Z
RS(szWorks like the regular :class:`JSONWebSignatureSerializer` but also
    records the time of the signing and can be used to expire signatures.

    JWS currently does not specify this behavior but it mentions a possibility
    extension like this in the spec.  Expiry date is encoded into the header
    similarily as specified in `draft-ietf-oauth-json-web-token
    <http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html#expDef`_.

    The unsign method can raise a :exc:`SignatureExpired` method if the
    unsigning failed because the signature is expired.  This exception is a
    subclass of :exc:`BadSignature`.
    icKs8tj|||�|dkr+|j}n||_dS(N(R�R+RtDEFAULT_EXPIRES_INt
expires_in(RRfR�R�((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR+scCsCtj||�}|j�}||j}||d<||d<|S(Ntiattexp(R�R�tnowR�(RR�R6R�R�((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR�s


cCs�tj|||dt�\}}d|krBtdd|��nt|dt�ob|ddksztdd|��n|d|j�kr�tdd|d|j|���n|r�||fS|S(	NR�R�sMissing expiry dateR	isexpiry date is not an IntDatesSignature expiredR4(	R�RRwR2Rtnumber_typesR�R7tget_issue_date(RRRhR�R	R6((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyRs	
cCs5|jd�}t|t�r1tjt|��SdS(NR�(R�RR�RR~Rz(RR6RI((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR�-scCsttj��S(N(RzR{(R((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR�2sN(RRRR�RR+R�RsRR�R�(((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR��s		tURLSafeSerializerMixincBs eZdZd�Zd�ZRS(s�Mixed in with a regular serializer it will attempt to zlib compress
    the string to make it shorter if necessary.  It will also base64 encode
    the string so that it can safely be placed in a URL.
    cCs�t}|jd�r(|d}t}nyt|�}Wn%tk
r_}tdd|��nX|r�ytj|�}Wq�tk
r�}tdd|��q�Xntt	|�j
|�S(NReis;Could not base64 decode the payload because of an exceptionR1sACould not zlib decompress the payload before decoding the payload(Rst
startswithRwRAR*R0tzlibt
decompresstsuperR�R�(RR	R�RR�((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR�<s 
		
	cCs{tt|�j|�}t}tj|�}t|�t|�dkrX|}t}nt|�}|rwd|}n|S(NiRe(	R�R�R�RsR�tcompressRRwR=(RRRt
is_compressedt
compressedR�((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR�Ns	
(RRRR�R�(((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR�6s	tURLSafeSerializercBseZdZeZRS(s�Works like :class:`Serializer` but dumps and loads into a URL
    safe string consisting of the upper and lowercase character of the
    alphabet as well as ``'_'``, ``'-'`` and ``'.'``.
    (RRRR�R�(((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR�[stURLSafeTimedSerializercBseZdZeZRS(s�Works like :class:`TimedSerializer` but dumps and loads into a URL
    safe string consisting of the upper and lowercase character of the
    alphabet as well as ``'_'``, ``'-'`` and ``'.'``.
    (RRRR�R�(((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyR�cs(>RtsysR]R�R{R9RbtoperatorRtversion_infoR/t	itertoolsRtunicodeRtchrRERztlongtfloatR�t	functoolsRtziptstrtmethodcallert
simplejsonRtImportErrortobjectRR�R|RRtgetattrRRR(R*R)R0R2R3R5R7R=RARJRORPRWRXRdRyR�R�R�R�R�R�R�(((s;/opt/imh-python/lib/python2.7/site-packages/itsdangerous.pyt<module>sh
											r]�l;%