当前位置: 首页>>代码示例>>Python>>正文


Python KeyBundle.append方法代码示例

本文整理汇总了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))
开发者ID:rohe,项目名称:otest,代码行数:35,代码来源:operation.py

示例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)
开发者ID:its-dirg,项目名称:oidc-fed,代码行数:9,代码来源:__init__.py

示例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
开发者ID:its-dirg,项目名称:id_token_verify,代码行数:10,代码来源:verify_id_token.py

示例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
开发者ID:borgand,项目名称:SATOSA,代码行数:19,代码来源:FakeOp.py


注:本文中的oic.utils.keyio.KeyBundle.append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。