starting to use attribute maps to handle names and nameforms
This commit is contained in:
@@ -320,6 +320,7 @@ def _properties(klass):
|
|||||||
return props
|
return props
|
||||||
|
|
||||||
def _klassdict(klass, text=None, **kwargs):
|
def _klassdict(klass, text=None, **kwargs):
|
||||||
|
""" Does not remove attributes with no values """
|
||||||
spec = {}
|
spec = {}
|
||||||
if text:
|
if text:
|
||||||
spec["text"] = text
|
spec["text"] = text
|
||||||
@@ -414,7 +415,7 @@ def response_factory(signature=False, encrypt=False, **kwargs):
|
|||||||
kwargs["signature"] = sigver.pre_signature_part(kwargs["id"])
|
kwargs["signature"] = sigver.pre_signature_part(kwargs["id"])
|
||||||
if encrypt:
|
if encrypt:
|
||||||
pass
|
pass
|
||||||
return kwargs
|
return _klassdict(samlp.Response, **kwargs)
|
||||||
|
|
||||||
def _attrval(val):
|
def _attrval(val):
|
||||||
if isinstance(val, basestring):
|
if isinstance(val, basestring):
|
||||||
@@ -428,7 +429,7 @@ def _attrval(val):
|
|||||||
|
|
||||||
return attrval
|
return attrval
|
||||||
|
|
||||||
def ava_to_attributes(ava, bmap):
|
def ava_to_attributes(ava, bmap=None):
|
||||||
attrs = []
|
attrs = []
|
||||||
|
|
||||||
for friendly_name, val in ava.items():
|
for friendly_name, val in ava.items():
|
||||||
@@ -438,10 +439,22 @@ def ava_to_attributes(ava, bmap):
|
|||||||
dic["attribute_value"] = attrval
|
dic["attribute_value"] = attrval
|
||||||
|
|
||||||
dic["friendly_name"] = friendly_name
|
dic["friendly_name"] = friendly_name
|
||||||
(dic["name"], dic["name_format"]) = bmap[friendly_name]
|
if bmap:
|
||||||
|
try:
|
||||||
|
(dic["name"], dic["name_format"]) = bmap[friendly_name]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
attrs.append(attribute_factory(**dic))
|
attrs.append(attribute_factory(**dic))
|
||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
|
def do_ava_statement(identity, bmap):
|
||||||
|
"""
|
||||||
|
:param identity: A dictionary with fiendly names as keys
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
return attribute_statement_factory(
|
||||||
|
attribute=ava_to_attributes(identity, bmap))
|
||||||
|
|
||||||
def do_attributes(identity):
|
def do_attributes(identity):
|
||||||
attrs = []
|
attrs = []
|
||||||
if not identity:
|
if not identity:
|
||||||
|
|||||||
Reference in New Issue
Block a user