def from_jwt(self, txt, keyjar, verify=True, **kwargs):
algarg = {}<EOL>if '<STR_LIT>' in kwargs:<EOL><INDENT>algarg['<STR_LIT>'] = kwargs['<STR_LIT>']<EOL><DEDENT>if '<STR_LIT>' in kwargs:<EOL><INDENT>algarg['<STR_LIT>'] = kwargs['<STR_LIT>']<EOL><DEDENT>_decryptor = jwe_factory(txt, **algarg)<EOL>if _decryptor:<EOL><INDENT>logger.debug("<STR_LIT>".format(_decryptor.jwt.headers))<EOL>dkeys = keyjar.get_decrypt_key(owner="<STR_LIT>")<EOL>logger.debug('<STR_LIT>'.format(_decryptor.__class__))<EOL>_res = _decryptor.decrypt(txt, dkeys)<EOL>logger.debug('<STR_LIT>'.format(_res))<EOL>if isinstance(_res, tuple):<EOL><INDENT>txt = as_unicode(_res[<NUM_LIT:0>])<EOL><DEDENT>elif isinstance(_res, list) and len(_res) == <NUM_LIT:2>:<EOL><INDENT>txt = as_unicode(_res[<NUM_LIT:0>])<EOL><DEDENT>else:<EOL><INDENT>txt = as_unicode(_res)<EOL><DEDENT>self.jwe_header = _decryptor.jwt.headers<EOL><DEDENT>try:<EOL><INDENT>_verifier = jws_factory(txt, alg=kwargs['<STR_LIT>'])<EOL><DEDENT>except:<EOL><INDENT>_verifier = jws_factory(txt)<EOL><DEDENT>if _verifier:<EOL><INDENT>try:<EOL><INDENT>_jwt = _verifier.jwt<EOL>jso = _jwt.payload()<EOL>_header = _jwt.headers<EOL>key = []<EOL>logger.debug("<STR_LIT>".format(jso))<EOL>logger.debug("<STR_LIT>".format(_header))<EOL>if _header["<STR_LIT>"] == "<STR_LIT:none>":<EOL><INDENT>pass<EOL><DEDENT>elif verify:<EOL><INDENT>if keyjar:<EOL><INDENT>key.extend(keyjar.get_jwt_verify_keys(_jwt, **kwargs))<EOL><DEDENT>if "<STR_LIT>" in _header and _header["<STR_LIT>"] != "<STR_LIT:none>":<EOL><INDENT>if not key:<EOL><INDENT>raise MissingSigningKey(<EOL>"<STR_LIT>" % _header["<STR_LIT>"])<EOL><DEDENT><DEDENT>logger.debug("<STR_LIT>")<EOL>try:<EOL><INDENT>_verifier.verify_compact(txt, key)<EOL><DEDENT>except NoSuitableSigningKeys:<EOL><INDENT>if keyjar:<EOL><INDENT>update_keyjar(keyjar)<EOL>key = keyjar.get_jwt_verify_keys(_jwt, **kwargs)<EOL>_verifier.verify_compact(txt, key)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>except Exception:<EOL><INDENT>raise<EOL><DEDENT>else:<EOL><INDENT>self.jws_header = _jwt.headers<EOL><DEDENT><DEDENT>else:<EOL><INDENT>jso = json.loads(txt)<EOL><DEDENT>self.jwt = txt<EOL>return self.from_dict(jso)<EOL>
Given a signed and/or encrypted JWT, verify its correctness and then
create a class instance from the content.

:param txt: The JWT
:param key: keys that might be used to decrypt and/or verify the
    signature of the JWT
:param verify: Whether the signature should be verified or not
:param keyjar: A KeyJar that might contain the necessary key.
:param kwargs: Extra key word arguments
:return: A class instance