HEX
Server: Apache
System: Linux msm5694.mjhst.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: camjab_ssh (1000)
PHP: 5.3.29
Disabled: NONE
Upload Files
File: //lib/python2.7/site-packages/josepy/jws.pyc
ó
›t0^c@s
dZddlZddlZddlZddlZddlZddlmZmZm	Z	m
Z
mZmZde
fd„ƒYZde	jfd„ƒYZde	jfd	„ƒYZd
e	jfd„ƒYZde
fd
„ƒYZedkreejƒƒndS(sJSON Web Signature.iÿÿÿÿN(tb64terrorst	json_utiltjwatjwktutilt	MediaTypecBs2eZdZdZed„ƒZed„ƒZRS(s MediaType field encoder/decoder.sapplication/cCs9d|kr5d|kr*tjdƒ‚n|j|S|S(sDecoder.t/t;sUnexpected semi-colon(RtDeserializationErrortPREFIX(tclstvalue((s./usr/lib/python2.7/site-packages/josepy/jws.pytdecodes
cCs9d|kr5|j|jƒs$t‚|t|jƒS|S(sEncoder.R(t
startswithR
tAssertionErrortlen(RR((s./usr/lib/python2.7/site-packages/josepy/jws.pytencodes(t__name__t
__module__t__doc__R
tclassmethodR
R(((s./usr/lib/python2.7/site-packages/josepy/jws.pyRs
tHeadercBs eZdZejddejjdeƒZ	ejddeƒZ
ejddejjdeƒZejddeƒZ
ejddeƒZejdded	dƒZejd
dejdeƒZejddejdeƒZejdd
ejdejdeƒZejdd
ejdejdeƒZejdded	dƒZd„Zd„Zd„Zejd„ƒZejd„ƒZejd„ƒZRS(s6JOSE Header.

    .. warning:: This class supports **only** Registered Header
        Parameter Names (as defined in section 4.1 of the
        protocol). If you need Public Header Parameter Names (4.2)
        or Private Header Parameter Names (4.3), you must subclass
        and override :meth:`from_json` and :meth:`to_partial_json`
        appropriately.

    .. warning:: This class does not support any extensions through
        the "crit" (Critical) Header Parameter (4.1.11) and as a
        conforming implementation, :meth:`from_json` treats its
        occurrence as an error. Please subclass if you seek for
        a different behaviour.

    :ivar x5tS256: "x5t#S256"
    :ivar str typ: MIME Media Type, inc. :const:`MediaType.PREFIX`.
    :ivar str cty: Content-Type, inc. :const:`MediaType.PREFIX`.

    talgtdecodert	omitemptytjkuRtkidtx5utx5ctdefaulttx5tsx5t#S256ttyptencodertctytcritcs&t‡fd†tjˆjƒDƒƒS(s4Fields that would not be omitted in the JSON object.c3sB|]8\}}|jtˆ|ƒƒs|tˆ|ƒfVqdS(N(tomittgetattr(t.0tnametfield(tself(s./usr/lib/python2.7/site-packages/josepy/jws.pys	<genexpr>Ns	(tdicttsixt	iteritemst_fields(R)((R)s./usr/lib/python2.7/site-packages/josepy/jws.pytnot_omittedLscCsŒt|t|ƒƒs3tdjt|ƒƒƒ‚n|jƒ}|jƒ}t|ƒj|ƒrotdƒ‚n|j|ƒt|ƒ|S(NsHeader cannot be added to: {0}s+Addition of overlapping headers not defined(t
isinstancettypet	TypeErrortformatR.tsettintersectiontupdate(R)tothertnot_omitted_selftnot_omitted_other((s./usr/lib/python2.7/site-packages/josepy/jws.pyt__add__Rs	
cCs(|jdkr!tjdƒ‚n|jS(síFind key based on header.

        .. todo:: Supports only "jwk" header parameter lookup.

        :returns: (Public) key found in the header.
        :rtype: .JWK

        :raises josepy.errors.Error: if key could not be found

        sNo key foundN(RtNoneRtError(R)((s./usr/lib/python2.7/site-packages/josepy/jws.pytfind_key`scCstjdƒ‚dS(Ns("crit" is not supported, please subclass(RR	(tunused_value((s./usr/lib/python2.7/site-packages/josepy/jws.pyR#oscCs8g|D]-}tjtjjtjj|jƒƒ^qS(N(tbase64t	b64encodetOpenSSLtcryptotdump_certificatet
FILETYPE_ASN1twrapped(Rtcert((s./usr/lib/python2.7/site-packages/josepy/jws.pyRwscCsGytd„|DƒƒSWn(tjjk
rB}tj|ƒ‚nXdS(Ncss<|]2}tjtjjtjjtj|ƒƒƒVqdS(N(RtComparableX509R@RAtload_certificateRCR>t	b64decode(R&RE((s./usr/lib/python2.7/site-packages/josepy/jws.pys	<genexpr>s(ttupleR@RAR;RR	(Rterror((s./usr/lib/python2.7/site-packages/josepy/jws.pyR|s
	(((RRRRtFieldRtJWASignaturet	from_jsontTrueRRRtJWKRRRtdecode_b64joseRtx5tS256RRR
R R"R#R.R9R<RR!(((s./usr/lib/python2.7/site-packages/josepy/jws.pyR&s.!			t	SignaturecBseZdZeZdZejddeddƒZ	ejddedeƒdej
ƒZejddejd	ej
ƒZe	jd
„ƒZ	e	jd„ƒZ	d„Zed
„ƒZed„ƒZdd„Zeeeƒd„ƒZd„Zed„ƒZRS(sJWS Signature.

    :ivar combined: Combined Header (protected and unprotected,
        :class:`Header`).
    :ivar unicode protected: JWS protected header (Jose Base-64 decoded).
    :ivar header: JWS Unprotected Header (:class:`Header`).
    :ivar str signature: The signature.

    tcombinedt	protectedRRttheaderRt	signatureR!cCstj|jdƒƒS(Nsutf-8(Rtencode_b64joseR(R((s./usr/lib/python2.7/site-packages/josepy/jws.pyRT›scCstj|ƒjdƒS(Nsutf-8(RRPR
(R((s./usr/lib/python2.7/site-packages/josepy/jws.pyRT scKsPd|kr|j|ƒ}ntt|ƒj||jjdk	sLt‚dS(NRS(t_with_combinedtsuperRRt__init__RSRR:R(R)tkwargs((s./usr/lib/python2.7/site-packages/josepy/jws.pyR[¤scCs}d|kst‚|jd|jdjƒ}|jd|jdjƒ}|ri||jj|ƒ}n|}||d<|S(NRSRVRT(RtgetR-Rt
header_clst
json_loads(RR\RVRTRS((s./usr/lib/python2.7/site-packages/josepy/jws.pyRYªs
cCs'tj|jdƒƒdtj|ƒS(Nsutf-8t.(RR?R(RRTtpayload((s./usr/lib/python2.7/site-packages/josepy/jws.pyt_msg¸sc	CsX|dkr|jjƒn|}|jjjd|jd|jd|j|j|ƒƒS(sEVerify.

        :param JWK key: Key used for verification.

        tkeytsigtmsgN(	R:RSR<RtverifyRcRWRbRT(R)RaRc((s./usr/lib/python2.7/site-packages/josepy/jws.pyRf½s!cKs#t||jƒst‚|}||d<|rA|jƒ|d<nt|ƒj|jjƒsbt‚|j|jjƒs}t‚i}x0|D](}	|	|krŠ|j|	ƒ||	<qŠqŠW|rÔ|j|j	ƒ}
nd}
|j|}	|j
|j|j|
|ƒƒ}|d|
d|	d|ƒS(s;Sign.

        :param JWK key: Key for signature.

        RRRURTRVRW(
R/tktyRt
public_keyR3tissubsetR^R-tpopt
json_dumpstsignRcRb(RRaRcRtinclude_jwktprotectR\t
header_paramstprotected_paramsRVRTRW((s./usr/lib/python2.7/site-packages/josepy/jws.pyRlÈs"
!
!cCs3tt|ƒjƒ}|djƒs/|d=n|S(NRV(RZRRtfields_to_partial_jsonR.(R)tfields((s./usr/lib/python2.7/site-packages/josepy/jws.pyRqés
cCsStt|ƒj|ƒ}|j|ƒ}d|djƒkrOtjdƒ‚n|S(NRRSsalg not present(RZRRtfields_from_jsonRYR.RR	(RtjobjRrtfields_with_combined((s./usr/lib/python2.7/site-packages/josepy/jws.pyRsïs
(scombinedN(RRRRR^t	__slots__RRKRNRTRMRVRPRXRWR!RR[RRYRbR:Rft	frozensetRlRqRs(((s./usr/lib/python2.7/site-packages/josepy/jws.pyRR†s*			tJWScBsweZdZd
ZeZdd„Zed„ƒZ	e
d„ƒZd„Zed„ƒZ
ed„Zed	„ƒZRS(sgJSON Web Signature.

    :ivar str payload: JWS Payload.
    :ivar str signature: JWS Signatures.

    Rat
signaturescs t‡‡fd†ˆjDƒƒS(sVerify.c3s$|]}|jˆjˆƒVqdS(N(RfRa(R&Rd(RcR)(s./usr/lib/python2.7/site-packages/josepy/jws.pys	<genexpr>s(tallRy(R)Rc((RcR)s./usr/lib/python2.7/site-packages/josepy/jws.pyRfscKs(|d|d|jjd||fƒS(sSign.RaRy(t
signature_clsRl(RRaR\((s./usr/lib/python2.7/site-packages/josepy/jws.pyRlscCs&t|jƒdkst‚|jdS(sPGet a singleton signature.

        :rtype: :class:`JWS.signature_cls`

        ii(RRyR(R)((s./usr/lib/python2.7/site-packages/josepy/jws.pyRW
scCs€t|jƒdkst‚d|jjjƒks9t‚tj|jjj	dƒƒdtj|j
ƒdtj|jjƒS(s7Compact serialization.

        :rtype: bytes

        iRsutf-8R`(RRyRRWRVR.RR?RTRRa(R)((s./usr/lib/python2.7/site-packages/josepy/jws.pyt
to_compacts3cCs‘y|jdƒ\}}}Wn tk
r>tjdƒ‚nX|jdtj|ƒjdƒdtj|ƒƒ}|dtj|ƒd|fƒS(sACompact deserialization.

        :param bytes compact:

        R`sOCompact JWS serialization should comprise of exactly 3 dot-separated componentsRTsutf-8RWRaRy(tsplitt
ValueErrorRR	R{RRHR
(RtcompactRTRaRWRd((s./usr/lib/python2.7/site-packages/josepy/jws.pytfrom_compact)s

	cCsv|jst‚tj|jƒ}|r]t|jƒdkr]|jdjƒ}||d<|Si|d6|jd6SdS(NiiRaRy(RyRRRXRaRtto_partial_json(R)tflatRatret((s./usr/lib/python2.7/site-packages/josepy/jws.pyR<s
c	s¨d|kr*d|kr*tjdƒ‚nzd|krjˆdtj|jdƒƒdˆjj|ƒfƒSˆdtj|dƒdt‡fd†|dDƒƒƒSdS(NRWRysFlat mixed with non-flatRac3s!|]}ˆjj|ƒVqdS(N(R{RM(R&Rd(R(s./usr/lib/python2.7/site-packages/josepy/jws.pys	<genexpr>Ss(RR	RRPRjR{RMRI(RRt((Rs./usr/lib/python2.7/site-packages/josepy/jws.pyRMJs(spayloads
signaturesN(RRRRvRRR{R:RfRRltpropertyRWR|R€RNRRM(((s./usr/lib/python2.7/site-packages/josepy/jws.pyRxøs
	tCLIcBskeZdZed„ƒZed„ƒZed„ƒZed„ƒZed„ƒZedd„ƒZ
RS(sJWS CLI.c
Csà|jjj|jjƒƒ}|jjƒ|jdkrFg|_n|jrb|jj	dƒnt
jdtj
jƒjƒd|d|jdt|jƒƒ}|jrÉtj|jƒjdƒƒntj|jƒƒdS(sSign.RRaRcRnsutf-8N(RRgtloadRctreadtcloseRnR:RtappendRxRltsyststdinRR3R+tprint_R|R
tjson_dumps_pretty(RtargsRcRd((s./usr/lib/python2.7/site-packages/josepy/jws.pyRlZs
	-	cCsì|jr*tjtjjƒjƒƒ}nCytjtjjƒƒ}Wn$tj	k
rl}t
j|ƒdSX|jdk	rÂ|jdk	s‘t‚|jj|jjƒƒjƒ}|jjƒnd}tjj|jƒ|jd|ƒS(sVerify.iÿÿÿÿRcN(RRxR€RŠR‹R‡RR_RR;R+RŒRcR:RgRR†RhRˆtstdouttwriteRaRf(RRŽRdRJRc((s./usr/lib/python2.7/site-packages/josepy/jws.pyRfls	!
!cCstjj|ƒS(N(RRLRM(Rtarg((s./usr/lib/python2.7/site-packages/josepy/jws.pyt	_alg_type‚scCs|tjjkst‚|S(N(RRR^R-R(RR‘((s./usr/lib/python2.7/site-packages/josepy/jws.pyt_header_type†scCs&|tjjkst‚tjj|S(N(RROtTYPESR(RR‘((s./usr/lib/python2.7/site-packages/josepy/jws.pyt	_kty_type‹scCsN|dkrtjd}ntjƒ}|jdddƒ|jƒ}|jdƒ}|jd|j	ƒ|jddd	tj
d
ƒdtƒ|jdd
d	|jdt
jƒ|jddddd	|jƒ|jdƒ}|jd|jƒ|jddd	tj
d
ƒdtƒ|jdd	|jdtƒ|j|ƒ}|j|ƒS(s Parse arguments and sign/verify.is	--compacttactiont
store_trueRltfuncs-ks--keyR0trbtrequireds-as--algRs-ps	--protectR‰Rfs--ktyN(R:RŠtargvtargparsetArgumentParsertadd_argumenttadd_subparserst
add_parsertset_defaultsRltFileTypeRNR’RtRS256R“RftFalseR•t
parse_argsR˜(RRŽtparsert
subparserstparser_signt
parser_verifytparsed((s./usr/lib/python2.7/site-packages/josepy/jws.pytruns*N(RRRRRlRfR’R“R•R:R«(((s./usr/lib/python2.7/site-packages/josepy/jws.pyR…Wst__main__(RRœR>RŠR@R+tjosepyRRRRRRtobjectRtJSONObjectWithFieldsRRRRxR…RtexitR«(((s./usr/lib/python2.7/site-packages/josepy/jws.pyt<module>s.`r_V