ó î?€Yc @s}ddlmZmZddlmZmZddlmZddlmZi de fd6de fd6d e fd 6d e fd 6d e fd6de fd6de fd6de fd6de fd6de fd6de fd6Z dddddd d!d"d#d$d%d&g Z d'e fd(„ƒYZd)e fd*„ƒYZd+e fd,„ƒYZd-efd.„ƒYZd/efd0„ƒYZd1S(2iÿÿÿÿ(tbase64url_decodetbase64url_encode(t json_decodet json_encode(tJWA(tJWKt Algorithmtalgs JWK Set URLtjkus JSON Web KeytjwksKey IDtkids X.509 URLtx5usX.509 Certificate Chaintx5cs"X.509 Certificate SHA-1 Thumbprinttx5ts$X.509 Certificate SHA-256 Thumbprintsx5t#S256tTypettyps Content TypetctytCriticaltcrittHS256tHS384tHS512tRS256tRS384tRS512tES256tES384tES512tPS256tPS384tPS512tInvalidJWSSignaturecBseZdZddd„ZRS(s_Invalid JWS Signature. This exception is raised when a signature cannot be validated. cCsXd}|rt|ƒ}nd}|r>|dt|ƒ7}ntt|ƒj|ƒdS(Ns&Unknown Signature Verification Failures {%s}(tNonetstrtsuperRt__init__(tselftmessaget exceptiontmsg((s0/usr/lib/python2.7/site-packages/jwcrypto/jws.pyR#'sN(t__name__t __module__t__doc__R R#(((s0/usr/lib/python2.7/site-packages/jwcrypto/jws.pyR!stInvalidJWSObjectcBseZdZddd„ZRS(svInvalid JWS Object. This exception is raised when the JWS Object is invalid and/or improperly formatted. cCsTd}|r|d|7}n|r:|dt|ƒ7}ntt|ƒj|ƒdS(NsInvalid JWS Objects [%s]s {%s}(R!R"R+R#(R$R%R&R'((s0/usr/lib/python2.7/site-packages/jwcrypto/jws.pyR#9s N(R(R)R*R R#(((s0/usr/lib/python2.7/site-packages/jwcrypto/jws.pyR+2stInvalidJWSOperationcBseZdZddd„ZRS(s†Invalid JWS Object. This exception is raised when a requested operation cannot be execute due to unsatisfied conditions. cCsRd}|r|}nd}|r8|dt|ƒ7}ntt|ƒj|ƒdS(NsUnknown Operation Failures {%s}(R R!R"R,R#(R$R%R&R'((s0/usr/lib/python2.7/site-packages/jwcrypto/jws.pyR#Is N(R(R)R*R R#(((s0/usr/lib/python2.7/site-packages/jwcrypto/jws.pyR,BstJWSCorecBs5eZdZdd„Zd„Zd„Zd„ZRS(sÔThe inner JWS Core object. This object SHOULD NOT be used directly, the JWS object should be used instead as JWS perform necessary checks on the validity of the object and requested operations. cCs¦||_|j||ƒ|_t|tƒs<tdƒ‚n||_|dk rŠt|tƒrot |ƒ}nt |j dƒƒ|_ n d|_ t |ƒ|_ dS(sCore JWS token handling. :param alg: The algorithm used to produce the signature. See RFC 7518 :param key: A (:class:`jwcrypto.jwk.JWK`) key of appropriate type for the "alg" provided in the 'protected' json string. :param header: A JSON string representing the protected header. :param payload(bytes): An arbitrary value :param algs: An optional list of allowed algorithms :raises ValueError: if the key is not a :class:`JWK` object :raises InvalidJWAAlgorithm: if the algorithm is not valid, is unknown or otherwise not yet implemented. skey is not a JWK objectsutf-8tN(Rt_jwatenginet isinstanceRt ValueErrortkeyR tdictRRtencodet protectedtpayload(R$RR3theaderR7talgs((s0/usr/lib/python2.7/site-packages/jwcrypto/jws.pyR#]s    cCs=|dkrt}n||kr0tdƒ‚ntj|ƒS(NsAlgorithm not allowed(R tdefault_allowed_algsR,Rt signing_alg(R$tnametallowed((s0/usr/lib/python2.7/site-packages/jwcrypto/jws.pyR/zs    cCsadj|j|jgƒjdƒ}|jj|j|ƒ}i|jd6|jd6t|ƒd6S(sGenerates a signaturet.sutf-8R6R7t signature(tjoinR6R7R5R0tsignR3R(R$tsiginR?((s0/usr/lib/python2.7/site-packages/jwcrypto/jws.pyRAs $  cCspyAdj|j|jgƒjdƒ}|jj|j||ƒWn(tk rk}tdt |ƒƒ‚nXt S(s^Verifies a signature :raises InvalidJWSSignature: if the verification fails. R>sutf-8sVerification failed( R@R6R7R5R0tverifyR3t ExceptionRtreprtTrue(R$R?RBte((s0/usr/lib/python2.7/site-packages/jwcrypto/jws.pyRC‰s $N(R(R)R*R R#R/RARC(((s0/usr/lib/python2.7/site-packages/jwcrypto/jws.pyR-Ts    tJWScBs¿eZdZdd„Zd„Zed„ƒZejd„ƒZed„ƒZ d„Z dd„Z dd„Z ddd „Z dddd „Zed „Zed „ƒZed „ƒZRS(sFJSON Web Signature object This object represent a JWS token. cCs8tƒ|_|r"||jdisUnrecognized representationiiisInvalid formatN(R4RIRRR!RPtdecodeR`R2tsplittlenR+RDRERC( R$traw_jwsR3RRbtdjwststosR[R]RG((s0/usr/lib/python2.7/site-packages/jwcrypto/jws.pyt deserializesJ            c Cs·|jjdd ƒs$tdƒ‚ntƒ}|r€t|tƒrQt|ƒ}nt|ƒ}d|kr€|j|dƒq€n|rÅt|tƒr¤t|ƒ}nt|ƒ}|j ||ƒ}nd|kr |d krê|d}q ||dkr t dƒ‚q n|d kr't dƒ‚nt ||||jdƒ}|j ƒ}tƒ} t |dƒ| d<|r|| dR7R8iN( RIR,RRSRTRR@RPR`ReR(R$tcompactR6RaRmRbRh((s0/usr/lib/python2.7/site-packages/jwcrypto/jws.pyt serialize¤sN           cCsAd|jkrtdƒ‚n|js6tdƒ‚n|jdS(NR7sPayload not availablesPayload not verified(RIR,RU(R$((s0/usr/lib/python2.7/site-packages/jwcrypto/jws.pyR7Üs  cCs|j}d|krttƒ}d|krOt|dƒ}|j||ƒ}n|j||jdtƒƒƒ}|Sd|jkr tƒ}xz|dD]n}tƒ}d|kr×t|dƒ}|j||ƒ}n|j||jdtƒƒƒ}|j|ƒq—W|Stdƒ‚dS(NR?R6R8R_sJOSE Header(s) not available(RIR4RRZRSRPR`R,(R$RatjhR[tjhlRb((s0/usr/lib/python2.7/site-packages/jwcrypto/jws.pyt jose_headeräs&    !   !N(R(R)R*R R#RNtpropertyROtsetterRURZR^RCRjRoRTRqR7Rt(((s0/usr/lib/python2.7/site-packages/jwcrypto/jws.pyRH–s    " +<K 8N(tjwcrypto.commonRRRRt jwcrypto.jwaRt jwcrypto.jwkRRFRTRLR:RDRR+R,tobjectR-RH(((s0/usr/lib/python2.7/site-packages/jwcrypto/jws.pyts0            B