本文整理汇总了Python中saml2.mdie.to_dict函数的典型用法代码示例。如果您正苦于以下问题:Python to_dict函数的具体用法?Python to_dict怎么用?Python to_dict使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了to_dict函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_filter_values_req_opt_1
def test_filter_values_req_opt_1():
r = to_dict(
Attribute(
name="urn:oid:2.5.4.5",
name_format=NAME_FORMAT_URI,
friendly_name="serialNumber",
attribute_value=[AttributeValue(text="54321")],
),
ONTS,
)
o = to_dict(
Attribute(
name="urn:oid:2.5.4.5",
name_format=NAME_FORMAT_URI,
friendly_name="serialNumber",
attribute_value=[AttributeValue(text="12345"), AttributeValue(text="abcd0")],
),
ONTS,
)
ava = {"serialNumber": ["12345", "54321"]}
ava = filter_on_attributes(ava, [r], [o])
assert ava.keys() == ["serialNumber"]
assert _eq(ava["serialNumber"], ["12345", "54321"])
开发者ID:justquick,项目名称:pysaml2,代码行数:25,代码来源:test_20_assertion.py
示例2: test_filter_values_req_opt_2
def test_filter_values_req_opt_2():
r = [
to_dict(
Attribute(
friendly_name="surName",
name="urn:oid:2.5.4.4",
name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"),
ONTS),
to_dict(
Attribute(
friendly_name="givenName",
name="urn:oid:2.5.4.42",
name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"),
ONTS),
to_dict(
Attribute(
friendly_name="mail",
name="urn:oid:0.9.2342.19200300.100.1.3",
name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"),
ONTS)]
o = [
to_dict(
Attribute(
friendly_name="title",
name="urn:oid:2.5.4.12",
name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"),
ONTS)]
ava = {"surname": ["Hedberg"], "givenName": ["Roland"],
"eduPersonAffiliation": ["staff"], "uid": ["rohe0002"]}
raises(MissingValue, "filter_on_attributes(ava, r, o)")
开发者ID:jakew1ll,项目名称:pysaml2,代码行数:32,代码来源:test_20_assertion.py
示例3: test_req_opt
def test_req_opt():
req = [
to_dict(
md.RequestedAttribute(
friendly_name="surname", name="urn:oid:2.5.4.4",
name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri",
is_required="true"), ONTS),
to_dict(
md.RequestedAttribute(
friendly_name="givenname",
name="urn:oid:2.5.4.42",
name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri",
is_required="true"), ONTS),
to_dict(
md.RequestedAttribute(
friendly_name="edupersonaffiliation",
name="urn:oid:1.3.6.1.4.1.5923.1.1.1.1",
name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri",
is_required="true"), ONTS)]
opt = [
to_dict(
md.RequestedAttribute(
friendly_name="title",
name="urn:oid:2.5.4.12",
name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri",
is_required="false"), ONTS)]
policy = Policy()
ava = {'givenname': 'Roland', 'surname': 'Hedberg',
'uid': 'rohe0002', 'edupersonaffiliation': 'staff'}
sp_entity_id = "urn:mace:example.com:saml:curt:sp"
fava = policy.filter(ava, sp_entity_id, None, req, opt)
assert fava
开发者ID:jakew1ll,项目名称:pysaml2,代码行数:35,代码来源:test_20_assertion.py
示例4: test_filter_values_req_2
def test_filter_values_req_2():
a1 = to_dict(Attribute(name="urn:oid:2.5.4.5", name_format=NAME_FORMAT_URI, friendly_name="serialNumber"), ONTS)
a2 = to_dict(Attribute(name="urn:oid:2.5.4.4", name_format=NAME_FORMAT_URI, friendly_name="surName"), ONTS)
required = [a1, a2]
ava = {"serialNumber": ["12345"], "givenName": ["Lars"]}
raises(MissingValue, filter_on_attributes, ava, required)
开发者ID:justquick,项目名称:pysaml2,代码行数:8,代码来源:test_20_assertion.py
示例5: test_filter_on_attributes_without_friendly_name
def test_filter_on_attributes_without_friendly_name():
ava = {"eduPersonTargetedID": "[email protected]", "eduPersonAffiliation": "test",
"extra": "foo"}
eptid = to_dict(
Attribute(name="urn:oid:1.3.6.1.4.1.5923.1.1.1.10", name_format=NAME_FORMAT_URI), ONTS)
ep_affiliation = to_dict(
Attribute(name="urn:oid:1.3.6.1.4.1.5923.1.1.1.1", name_format=NAME_FORMAT_URI), ONTS)
restricted_ava = filter_on_attributes(ava, required=[eptid], optional=[ep_affiliation],
acs=ac_factory())
assert restricted_ava == {"eduPersonTargetedID": "[email protected]",
"eduPersonAffiliation": "test"}
开发者ID:Lefford,项目名称:pysaml2,代码行数:12,代码来源:test_20_assertion.py
示例6: test_filter_values_req_opt_0
def test_filter_values_req_opt_0():
r = to_dict(
Attribute(name="urn:oid:2.5.4.5", name_format=NAME_FORMAT_URI,
friendly_name="serialNumber",
attribute_value=[AttributeValue(text="54321")]), ONTS)
o = to_dict(
Attribute(name="urn:oid:2.5.4.5", name_format=NAME_FORMAT_URI,
friendly_name="serialNumber",
attribute_value=[AttributeValue(text="12345")]), ONTS)
ava = {"serialNumber": ["12345", "54321"]}
ava = filter_on_attributes(ava, [r], [o], acs=ac_factory())
assert list(ava.keys()) == ["serialNumber"]
assert _eq(ava["serialNumber"], ["12345", "54321"])
开发者ID:SUNET,项目名称:pysaml2,代码行数:15,代码来源:test_20_assertion.py
示例7: test_filter_on_attributes_with_missing_required_attribute
def test_filter_on_attributes_with_missing_required_attribute():
ava = {"extra": "foo"}
eptid = to_dict(Attribute(
friendly_name="eduPersonTargetedID", name="urn:oid:1.3.6.1.4.1.5923.1.1.1.10",
name_format=NAME_FORMAT_URI), ONTS)
with pytest.raises(MissingValue):
filter_on_attributes(ava, required=[eptid])
开发者ID:Lefford,项目名称:pysaml2,代码行数:7,代码来源:test_20_assertion.py
示例8: test_filter_on_attributes_with_missing_optional_attribute
def test_filter_on_attributes_with_missing_optional_attribute():
ava = {"extra": "foo"}
eptid = to_dict(Attribute(
friendly_name="eduPersonTargetedID",
name="urn:oid:1.3.6.1.4.1.5923.1.1.1.10",
name_format=NAME_FORMAT_URI), ONTS)
assert filter_on_attributes(ava, optional=[eptid], acs=ac_factory()) == {}
开发者ID:SUNET,项目名称:pysaml2,代码行数:7,代码来源:test_20_assertion.py
示例9: test_filter_on_attributes_with_missing_name_format
def test_filter_on_attributes_with_missing_name_format():
ava = {"eduPersonTargetedID": "[email protected]",
"eduPersonAffiliation": "test",
"extra": "foo"}
eptid = to_dict(Attribute(friendly_name="eduPersonTargetedID",
name="urn:myown:eptid",
name_format=''), ONTS)
ava = filter_on_attributes(ava, optional=[eptid], acs=ac_factory())
assert ava['eduPersonTargetedID'] == "[email protected]"
开发者ID:SUNET,项目名称:pysaml2,代码行数:9,代码来源:test_20_assertion.py
示例10: test_filter_values_req_4
def test_filter_values_req_4():
a = to_dict(Attribute(name="urn:oid:2.5.4.5", name_format=NAME_FORMAT_URI,
friendly_name="serialNumber", attribute_value=[
AttributeValue(text="54321")]), ONTS)
required = [a]
ava = { "serialNumber": ["12345"]}
raises(MissingValue, filter_on_attributes, ava, required)
开发者ID:caustin,项目名称:pysaml2,代码行数:9,代码来源:test_20_assertion.py
示例11: test_filter_on_attributes_1
def test_filter_on_attributes_1():
a = to_dict(Attribute(name="urn:oid:2.5.4.5", name_format=NAME_FORMAT_URI, friendly_name="serialNumber"), ONTS)
required = [a]
ava = {"serialNumber": ["12345"], "givenName": ["Lars"]}
ava = filter_on_attributes(ava, required)
assert ava.keys() == ["serialNumber"]
assert ava["serialNumber"] == ["12345"]
开发者ID:justquick,项目名称:pysaml2,代码行数:9,代码来源:test_20_assertion.py
示例12: test_filter_on_attributes_2
def test_filter_on_attributes_2():
a = to_dict(Attribute(friendly_name="surName",name="urn:oid:2.5.4.4",
name_format=NAME_FORMAT_URI), ONTS)
required = [a]
ava = {"sn":["kakavas"]}
ava = filter_on_attributes(ava,required,acs=ac_factory())
assert list(ava.keys()) == ['sn']
assert ava["sn"] == ["kakavas"]
开发者ID:SUNET,项目名称:pysaml2,代码行数:10,代码来源:test_20_assertion.py
示例13: test_filter_on_attributes_0
def test_filter_on_attributes_0():
a = to_dict(Attribute(name="urn:oid:2.5.4.5", name_format=NAME_FORMAT_URI,
friendly_name="serialNumber"), ONTS)
required = [a]
ava = {"serialNumber": ["12345"]}
ava = filter_on_attributes(ava, required, acs=ac_factory())
assert list(ava.keys()) == ["serialNumber"]
assert ava["serialNumber"] == ["12345"]
开发者ID:SUNET,项目名称:pysaml2,代码行数:10,代码来源:test_20_assertion.py
示例14: test_filter_values_req_6
def test_filter_values_req_6():
a = to_dict(Attribute(name="urn:oid:2.5.4.5", name_format=NAME_FORMAT_URI,
friendly_name="serialNumber", attribute_value=[
AttributeValue(text="54321")]),ONTS)
required = [a]
ava = { "serialNumber": ["12345", "54321"]}
ava = filter_on_attributes(ava, required)
assert ava.keys() == ["serialNumber"]
assert ava["serialNumber"] == ["54321"]
开发者ID:caustin,项目名称:pysaml2,代码行数:11,代码来源:test_20_assertion.py
示例15: store_assertion
def store_assertion(self, assertion, to_sign):
name_id = assertion.subject.name_id
nkey = sha1(code_binary(name_id)).hexdigest()
doc = {
"name_id_key": nkey,
"assertion_id": assertion.id,
"assertion": to_dict(assertion, ONTS.values(), True),
"to_sign": to_sign
}
_ = self.assertion.insert(doc)
开发者ID:SpamapS,项目名称:pysaml2,代码行数:12,代码来源:mongo_store.py
示例16: store_assertion
def store_assertion(self, assertion, to_sign):
name_id = assertion.subject.name_id
_id = code(name_id)
nkey = sha1(_id.encode()).hexdigest()
doc = {
"name_id_key": nkey,
"assertion_id": assertion.id,
"assertion": to_dict(assertion, list(ONTS.values()), True),
"to_sign": to_sign
}
_ = self.assertion.insert(doc)
开发者ID:rohe,项目名称:pysaml2-3,代码行数:13,代码来源:mongo_store.py
示例17: do_entity_descriptor
def do_entity_descriptor(self, entity_descr):
if self.check_validity:
try:
if not valid(entity_descr.valid_until):
logger.error("Entity descriptor (entity id:%s) to old",
entity_descr.entity_id)
self.to_old.append(entity_descr.entity_id)
return
except AttributeError:
pass
# have I seen this entity_id before ? If so if log: ignore it
if entity_descr.entity_id in self.entity:
print("Duplicated Entity descriptor (entity id: '%s')" %
entity_descr.entity_id, file=sys.stderr)
return
_ent = to_dict(entity_descr, metadata_modules())
flag = 0
# verify support for SAML2
for descr in ["spsso", "idpsso", "role", "authn_authority",
"attribute_authority", "pdp", "affiliation"]:
_res = []
try:
_items = _ent["%s_descriptor" % descr]
except KeyError:
continue
if descr == "affiliation": # Not protocol specific
flag += 1
continue
for item in _items:
for prot in item["protocol_support_enumeration"].split(" "):
if prot == samlp.NAMESPACE:
item["protocol_support_enumeration"] = prot
_res.append(item)
break
if not _res:
del _ent["%s_descriptor" % descr]
else:
flag += 1
if self.filter:
_ent = self.filter(_ent)
if not _ent:
flag = 0
if flag:
self.entity[entity_descr.entity_id] = _ent
开发者ID:Amli,项目名称:pysaml2,代码行数:50,代码来源:mdstore.py
示例18: store_authn_statement
def store_authn_statement(self, authn_statement, name_id):
"""
:param authn_statement:
:param name_id:
:return:
"""
logger.debug("store authn about: %s" % name_id)
nkey = sha1(code(name_id)).hexdigest()
logger.debug("Store authn_statement under key: %s" % nkey)
_as = to_dict(authn_statement, ONTS.values(), True)
try:
self.authn[nkey].append(_as)
except KeyError:
self.authn[nkey] = [_as]
return nkey
开发者ID:caustin,项目名称:pysaml2,代码行数:17,代码来源:sdb.py
示例19: ServiceError
resp = ServiceError("Other error: %s" % (err,))
return resp(self.environ, self.start_response)
logger.info("parsed OK")
_resp = self.response.response
logger.debug("%s" % _resp)
session_id = rndstr(16)
_info = [
("Client Address", ip_addresses()),
("Identity Provider", _resp.issuer.text),
("SSO Protocol", samlp.NAMESPACE),
]
assertion = simplify(to_dict(_resp, ONTS.values()))
SESSIONDB[session_id] = {"info": _info, "assertion": assertion}
resp = Response(mako_template="result.mako",
template_lookup=LOOKUP,
headers=[])
uinfo = []
for key, val in self.response.ava.items():
if len(val) == 1:
uinfo.append((key, val[0]))
elif len(val) > 1:
uinfo.append((key, ", ".join([v for v in val])))
uinfo.sort()
argv = {"uinfo": uinfo, "idp": _resp.issuer.text,
"session": "/Session/%s" % session_id}
开发者ID:dv10den,项目名称:pyuma,代码行数:31,代码来源:sp.py
示例20: ServiceError
resp = ServiceError("Other error: %s" % (err,))
return resp(self.environ, self.start_response)
logger.info("parsed OK")
_resp = self.response.response
logger.debug("%s" % _resp)
# verify that I got the authentication Context Class reference
# I wanted
used = []
astat = []
for assertion in _resp.assertion:
for statement in assertion.authn_statement:
used.append(statement.authn_context.authn_context_class_ref.text)
astat.append(simplify(to_dict(statement, ONTS.values())))
resp = Response(mako_template="result.mako",
template_lookup=LOOKUP,
headers=[])
argv = {"used": used, "wanted": SESSIONDB[_resp.in_response_to]["accr"],
"authn_statement": json.dumps(astat, sort_keys=True,
indent=2,
separators=(',', ': '))}
return resp(self.environ, self.start_response, **argv)
def verify_attributes(self, ava):
rest = POLICY.get_entity_categories_restriction(
self.sp.config.entityid, self.sp.metadata)
开发者ID:rohe,项目名称:actester,代码行数:31,代码来源:sp.py
注:本文中的saml2.mdie.to_dict函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论