本文整理汇总了Python中jwkest.jwk.KEYS.dump_jwks方法的典型用法代码示例。如果您正苦于以下问题:Python KEYS.dump_jwks方法的具体用法?Python KEYS.dump_jwks怎么用?Python KEYS.dump_jwks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jwkest.jwk.KEYS
的用法示例。
在下文中一共展示了KEYS.dump_jwks方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_dump_jwk
# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import dump_jwks [as 别名]
def test_dump_jwk():
keylist0 = KEYS()
keylist0.wrap_add(pem_cert2rsa(CERT))
jwk = keylist0.dump_jwks()
print(jwk)
_wk = json.loads(jwk)
assert list(_wk.keys()) == ["keys"]
assert len(_wk["keys"]) == 1
assert _eq(list(_wk["keys"][0].keys()), ["kty", "e", "n"])
示例2: test_keys
# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import dump_jwks [as 别名]
def test_keys():
keyl = KEYS()
keyl.load_dict(JWKS)
assert len(keyl) == 3
print(keyl.keys())
print(keyl.dump_jwks())
assert _eq(keyl.keys(), ['RSA', 'oct', 'EC'])
assert len(keyl['rsa']) == 1
assert len(keyl['oct']) == 1
assert len(keyl['ec']) == 1
示例3: test_keys
# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import dump_jwks [as 别名]
def test_keys():
keyl = KEYS()
keyl.load_dict(JWKS)
assert len(keyl) == 3
print(keyl.keys())
print(keyl.dump_jwks())
assert _eq(keyl.key_types(), ["RSA", "oct", "EC"])
assert len(keyl["rsa"]) == 1
assert len(keyl["oct"]) == 1
assert len(keyl["ec"]) == 1
示例4: test_load_jwk
# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import dump_jwks [as 别名]
def test_load_jwk():
keylist0 = KEYS()
keylist0.wrap_add(pem_cert2rsa(CERT))
jwk = keylist0.dump_jwks()
keylist1 = KEYS()
keylist1.load_jwks(jwk)
print(keylist1)
assert len(keylist1) == 1
key = keylist1["rsa"][0]
assert key.kty == 'RSA'
assert isinstance(key.key, _RSAobj)
示例5: setUp
# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import dump_jwks [as 别名]
def setUp(self):
self.user = User.objects.create(username='henk')
mock_get = self.patch('requests.get')
mock_get.return_value.json.return_value = {"jwks_uri": "http://example.com/jwks",
"issuer": "http://example.com"}
keys = KEYS()
keys.add({'key': key, 'kty': 'RSA'})
self.patch('jwkest.jwk.request', return_value=Mock(status_code=200,
text=keys.dump_jwks()))
api_settings.OIDC_ENDPOINT = 'http://example.com'
api_settings.OIDC_AUDIENCE = 'you'
示例6: setUp
# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import dump_jwks [as 别名]
def setUp(self):
self.user = User.objects.create(username='henk')
self.responder = FakeRequests()
self.responder.set_response("http://example.com/.well-known/openid-configuration",
{"jwks_uri": "http://example.com/jwks",
"issuer": "http://example.com",
"userinfo_endpoint": "http://example.com/userinfo"})
self.mock_get = self.patch('requests.get')
self.mock_get.side_effect = self.responder.get
keys = KEYS()
keys.add({'key': key, 'kty': 'RSA', 'kid': key.kid})
self.patch('jwkest.jwk.request', return_value=Mock(status_code=200,
text=keys.dump_jwks()))
示例7: usage
# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import dump_jwks [as 别名]
# created, with their type, name and usage (encryption of signature)
key = create_and_store_rsa_key_pair("foo", size=4096)
key2 = create_and_store_rsa_key_pair("foo2", size=4096)
rsa = RSAKey().load_key(key)
print "--- JWK ---"
print json.dumps(rsa.serialize(), sort_keys=True, indent=4, separators=(',', ': '))
print
########################################################
keys = KEYS()
keys.wrap_add(key, use="sig", kid="rsa1")
keys.wrap_add(key2, use="enc", kid="rsa1")
print "--- JWKS---"
print keys.dump_jwks()
print
########################################################
key_conf = [
{"type": "RSA", "name": "rsa_key", "use": ["enc", "sig"]},
{"type": "EC", "name": "elliptic_curve_1", "crv": "P-256", "use": ["sig"]},
{"type": "EC", "name": "elliptic_curve_2", "crv": "P-256", "use": ["enc"]}
]
jwks, keyjar, kdd = build_keyjar(key_conf, "m%d", None, None)
print "--- JWKS from keyjar ---"
print jwks
示例8: print
# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import dump_jwks [as 别名]
# and this will give you the serialization of the private key
ser_rsa = rsa.serialize(private=True)
print("--- JWK (private) ----")
print(json.dumps(ser_rsa, sort_keys=True, indent=4, separators=(',', ': ')))
print()
# ============================================================================
# And now for the JWKS
keys = KEYS()
keys.wrap_add(key, use="sig", kid="rsa1")
print("--- JWKS ----")
print(keys.dump_jwks())
# Build a number of keys from a specification and place them in a keyjar
key_conf = [
{"type": "RSA", "name": "rsa_key", "use": ["enc", "sig"]},
{"type": "EC", "crv": "P-256", "use": ["sig"]},
{"type": "EC", "crv": "P-256", "use": ["enc"]}
]
# The function return a set of representations of the keys that was
# created.
# jwks: a JWKS representation
# keyjar: a oic.utils.keyio.KeyJar instance with the keys added
# kdd: a simple dictionary enumerating which key ids that can be used for
# which key operations.
jwks, keyjar, kdd = build_keyjar(key_conf, "m%d", None, None)
示例9: jwks
# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import dump_jwks [as 别名]
def jwks(_request, _uri, headers):
ks = KEYS()
ks.add(self.key.serialize())
return 200, headers, ks.dump_jwks()