本文整理汇总了Python中oic.utils.keyio.KeyBundle.append方法的典型用法代码示例。如果您正苦于以下问题:Python KeyBundle.append方法的具体用法?Python KeyBundle.append怎么用?Python KeyBundle.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oic.utils.keyio.KeyBundle
的用法示例。
在下文中一共展示了KeyBundle.append方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __call__
# 需要导入模块: from oic.utils.keyio import KeyBundle [as 别名]
# 或者: from oic.utils.keyio.KeyBundle import append [as 别名]
def __call__(self):
keyjar = self.conv.entity.keyjar
self.conv.entity.original_keyjar = keyjar.copy()
# invalidate the old key
old_kid = self.op_args["old_kid"]
old_key = keyjar.get_key_by_kid(old_kid)
old_key.inactive_since = time.time()
# setup new key
key_spec = self.op_args["new_key"]
typ = key_spec["type"].upper()
if typ == "RSA":
kb = KeyBundle(keytype=typ, keyusage=key_spec["use"])
kb.append(RSAKey(use=key_spec["use"]).load_key(
RSA.generate(key_spec["bits"])))
elif typ == "EC":
kb = ec_init(key_spec)
else:
raise Exception('Wrong key type')
# add new key to keyjar with
list(kb.keys())[0].kid = self.op_args["new_kid"]
keyjar.add_kb("", kb)
# make jwks and update file
keys = []
for kb in keyjar[""]:
keys.extend(
[k.to_dict() for k in list(kb.keys()) if not k.inactive_since])
jwks = dict(keys=keys)
with open(self.op_args["jwks_path"], "w") as f:
f.write(json.dumps(jwks))
示例2: rotate_jwks
# 需要导入模块: from oic.utils.keyio import KeyBundle [as 别名]
# 或者: from oic.utils.keyio.KeyBundle import append [as 别名]
def rotate_jwks(self):
# type: () -> None
"""Replace the current JWKS with a fresh one."""
self.jwks = KeyJar()
kb = KeyBundle(keyusage=["enc", "sig"])
kb.append(RSAKey(key=RSA.generate(1024), kid=self._create_kid()))
self.jwks.add_kb("", kb)
示例3: _create_symmetric_key
# 需要导入模块: from oic.utils.keyio import KeyBundle [as 别名]
# 或者: from oic.utils.keyio.KeyBundle import append [as 别名]
def _create_symmetric_key(issuer, key):
provider_keys = KeyJar()
key = SYMKey(use='sig', k=key)
kb = KeyBundle(keytype='oct')
kb.append(key)
provider_keys[issuer] = [kb]
return provider_keys
示例4: keybundle_from_local_file
# 需要导入模块: from oic.utils.keyio import KeyBundle [as 别名]
# 或者: from oic.utils.keyio.KeyBundle import append [as 别名]
def keybundle_from_local_file(filename, typ, usage, kid):
if typ.upper() == "RSA":
kb = KeyBundle()
k = RSAKey(kid=kid)
k.load(filename)
k.use = usage[0]
kb.append(k)
for use in usage[1:]:
_k = RSAKey(kid=kid + "1")
_k.use = use
_k.load_key(k.key)
kb.append(_k)
elif typ.lower() == "jwk":
kb = KeyBundle(source=filename, fileformat="jwk", keyusage=usage)
else:
raise UnknownKeyType("Unsupported key type")
return kb