Updated to use the new attribute conversion functions
This commit is contained in:
@@ -7,6 +7,7 @@ from saml2.time_util import in_a_while
|
|||||||
from saml2.utils import parse_attribute_map, args2dict
|
from saml2.utils import parse_attribute_map, args2dict
|
||||||
from saml2.saml import NAME_FORMAT_URI
|
from saml2.saml import NAME_FORMAT_URI
|
||||||
from saml2.sigver import pre_signature_part, SecurityContext
|
from saml2.sigver import pre_signature_part, SecurityContext
|
||||||
|
from saml2.attribute_converter import from_local_name, ac_factory
|
||||||
|
|
||||||
HELP_MESSAGE = """
|
HELP_MESSAGE = """
|
||||||
Usage: make_metadata [options] 1*configurationfile
|
Usage: make_metadata [options] 1*configurationfile
|
||||||
@@ -87,7 +88,7 @@ def do_contact_person_info(conf, desc):
|
|||||||
pass
|
pass
|
||||||
desc["contact_person"].append(dorg)
|
desc["contact_person"].append(dorg)
|
||||||
|
|
||||||
def do_sp_sso_descriptor(sp, cert, backward_map):
|
def do_sp_sso_descriptor(sp, cert, acs):
|
||||||
desc = {
|
desc = {
|
||||||
"protocol_support_enumeration": samlp.NAMESPACE,
|
"protocol_support_enumeration": samlp.NAMESPACE,
|
||||||
"assertion_consumer_service": {
|
"assertion_consumer_service": {
|
||||||
@@ -113,35 +114,14 @@ def do_sp_sso_descriptor(sp, cert, backward_map):
|
|||||||
requested_attribute = []
|
requested_attribute = []
|
||||||
if "required_attributes" in sp:
|
if "required_attributes" in sp:
|
||||||
for attr in sp["required_attributes"]:
|
for attr in sp["required_attributes"]:
|
||||||
try:
|
reqa = from_local_name(acs, attr, NAME_FORMAT_URI)
|
||||||
requested_attribute.append({
|
reqa["is_required"] = "true"
|
||||||
"is_required": "true",
|
requested_attribute.append(reqa)
|
||||||
"friendly_name": attr,
|
|
||||||
"name_format": NAME_FORMAT_URI,
|
|
||||||
"name": backward_map[attr][0]
|
|
||||||
})
|
|
||||||
except KeyError:
|
|
||||||
requested_attribute.append({
|
|
||||||
"is_required": "true",
|
|
||||||
"friendly_name": attr,
|
|
||||||
"name_format": NAME_FORMAT_URI,
|
|
||||||
"name": attr
|
|
||||||
})
|
|
||||||
|
|
||||||
if "optional_attributes" in sp:
|
if "optional_attributes" in sp:
|
||||||
for attr in sp["optional_attributes"]:
|
for attr in sp["optional_attributes"]:
|
||||||
try:
|
reqa = from_local_name(acs, attr, NAME_FORMAT_URI)
|
||||||
requested_attribute.append({
|
requested_attribute.append(reqa)
|
||||||
"friendly_name": attr,
|
|
||||||
"name_format": NAME_FORMAT_URI,
|
|
||||||
"name": backward_map[attr][0]
|
|
||||||
})
|
|
||||||
except KeyError:
|
|
||||||
requested_attribute.append({
|
|
||||||
"friendly_name": attr,
|
|
||||||
"name_format": NAME_FORMAT_URI,
|
|
||||||
"name": attr
|
|
||||||
})
|
|
||||||
|
|
||||||
if requested_attribute:
|
if requested_attribute:
|
||||||
desc["attribute_consuming_service"] = {
|
desc["attribute_consuming_service"] = {
|
||||||
@@ -203,10 +183,15 @@ def do_aa_descriptor(aa, cert):
|
|||||||
def entity_descriptor(confd, valid_for):
|
def entity_descriptor(confd, valid_for):
|
||||||
mycert = "".join(open(confd["cert_file"]).readlines()[1:-1])
|
mycert = "".join(open(confd["cert_file"]).readlines()[1:-1])
|
||||||
|
|
||||||
if "attribute_maps" in confd:
|
if "attribute_map_dir" in confd:
|
||||||
(forward,backward) = parse_attribute_map(confd["attribute_maps"])
|
attrconverters = ac_factory(confd["attribute_map_dir"])
|
||||||
else:
|
else:
|
||||||
backward = {}
|
attrconverters = [AttributeConverter()]
|
||||||
|
|
||||||
|
#if "attribute_maps" in confd:
|
||||||
|
# (forward,backward) = parse_attribute_map(confd["attribute_maps"])
|
||||||
|
#else:
|
||||||
|
# backward = {}
|
||||||
|
|
||||||
ed = {
|
ed = {
|
||||||
"entity_id": confd["entityid"],
|
"entity_id": confd["entityid"],
|
||||||
@@ -220,7 +205,7 @@ def entity_descriptor(confd, valid_for):
|
|||||||
if "sp" in confd["service"]:
|
if "sp" in confd["service"]:
|
||||||
# The SP
|
# The SP
|
||||||
ed["sp_sso_descriptor"] = do_sp_sso_descriptor(confd["service"]["sp"],
|
ed["sp_sso_descriptor"] = do_sp_sso_descriptor(confd["service"]["sp"],
|
||||||
mycert, backward)
|
mycert, attrconverters)
|
||||||
if "idp" in confd["service"]:
|
if "idp" in confd["service"]:
|
||||||
ed["idp_sso_descriptor"] = do_idp_sso_descriptor(
|
ed["idp_sso_descriptor"] = do_idp_sso_descriptor(
|
||||||
confd["service"]["idp"], mycert)
|
confd["service"]["idp"], mycert)
|
||||||
|
|||||||
Reference in New Issue
Block a user