def register(self, url):
if cherrypy.request.process_request_body is True:
_json_doc = cherrypy.request.body.read()
else:
raise cherrypy.HTTPError(400, 'Missing Client registration body')
if _json_doc == b'':
raise cherrypy.HTTPError(400, 'Missing Client registration body')
_args = json.loads(as_unicode(_json_doc))
_mds = MetadataStatement(**_args)
try:
_mds.verify()
except (MessageException, VerificationError) as err:
raise cherrypy.CherryPyException(str(err))
else:
res = requests.post(url, json=_mds.to_json())
if 200 <= res.status_code < 300:
self.signer.metadata_statements[url] = res.text
cherrypy.response.headers['Content-Type'] = 'application/jwt'
return as_bytes(res.text)
else:
raise cherrypy.HTTPError(message=res.text)
评论列表
文章目录