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


Python KEYS.keys方法代码示例

本文整理汇总了Python中jwkest.jwk.KEYS.keys方法的典型用法代码示例。如果您正苦于以下问题:Python KEYS.keys方法的具体用法?Python KEYS.keys怎么用?Python KEYS.keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jwkest.jwk.KEYS的用法示例。


在下文中一共展示了KEYS.keys方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_keys

# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import keys [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
开发者ID:dallerbarn,项目名称:pyjwkest,代码行数:13,代码来源:test_2_jwk.py

示例2: test_pjwt_unpack_jwe

# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import keys [as 别名]
def test_pjwt_unpack_jwe():
    keys = KEYS()
    keys.append(RSAKey(use="enc", key=rsa, kid="some-key-id"))

    pj = PopJWT("https://server.example.com", "https://client.example.org",
                sub='12345678')

    jwk = {"kty": "oct", "alg": "HS256",
           "k": "ZoRSOrFzN_FzUA5XKMYoVHyzff5oRJxl-IXRtztJ6uE"}

    jwe = JWE(json.dumps(jwk), alg="RSA-OAEP", enc="A256CBC-HS512")
    _jwe = jwe.encrypt(keys=keys.keys(), kid="some-key-id")

    pjwt = pj.pack_jwe(jwe=_jwe)

    s = pjwt.to_json()

    _jwt = PopJWT(jwe=jwe, keys=keys).unpack(s)

    assert _eq(_jwt.keys(), ['iss', 'aud', 'exp', 'cnf', 'sub', 'iat'])
    assert _eq(_jwt['cnf'].keys(), ['jwk', 'jwe'])

    assert _jwt['cnf']['jwk'] == jwk
开发者ID:Magosgruss,项目名称:pyoidc,代码行数:25,代码来源:test_popjwt.py

示例3: test_pjwt_with_jwe_jwk

# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import keys [as 别名]
def test_pjwt_with_jwe_jwk():
    keys = KEYS()
    keys.append(RSAKey(use="enc", key=rsa, kid="some-key-id"))

    jwe = JWE(alg="RSA-OAEP", enc="A256CBC-HS512")

    pj = PopJWT("https://server.example.com", "https://client.example.org",
                sub='12345678', jwe=jwe, keys=keys)

    jwk = {"kty": "oct", "alg": "HS256",
           "k": "ZoRSOrFzN_FzUA5XKMYoVHyzff5oRJxl-IXRtztJ6uE"}

    pjwt = pj.pack_jwe(jwk=jwk, kid='some-key-id')

    s = pjwt.to_json()

    de_pjwt = PJWT().from_json(s)
    assert _eq(de_pjwt.keys(), ['iss', 'aud', 'exp', 'cnf', 'sub', 'iat'])
    assert list(de_pjwt['cnf'].keys()) == ['jwe']
    _jwe = de_pjwt['cnf']['jwe']
    msg = jwe.decrypt(_jwe, keys.keys())
    assert msg

    assert json.loads(msg.decode('utf8')) == jwk
开发者ID:Magosgruss,项目名称:pyoidc,代码行数:26,代码来源:test_popjwt.py


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