59
59
XMLNSXS = " xmlns:xs=\" http://www.w3.org/2001/XMLSchema\" "
60
60
bXMLNSXS = b" xmlns:xs=\" http://www.w3.org/2001/XMLSchema\" "
61
61
62
+
62
63
def metadata_tostring_fix (desc , nspair , xmlstring = "" ):
63
64
if not xmlstring :
64
65
xmlstring = desc .to_string (nspair )
65
66
66
67
if six .PY2 :
67
68
if "\" xs:string\" " in xmlstring and XMLNSXS not in xmlstring :
68
- xmlstring = xmlstring .replace (MDNS , MDNS + XMLNSXS )
69
+ xmlstring = xmlstring .replace (MDNS , MDNS + XMLNSXS )
69
70
else :
70
71
if b"\" xs:string\" " in xmlstring and bXMLNSXS not in xmlstring :
71
- xmlstring = xmlstring .replace (bMDNS , bMDNS + bXMLNSXS )
72
+ xmlstring = xmlstring .replace (bMDNS , bMDNS + bXMLNSXS )
72
73
73
74
return xmlstring
74
75
@@ -77,7 +78,7 @@ def create_metadata_string(configfile, config=None, valid=None, cert=None,
77
78
keyfile = None , mid = None , name = None , sign = None ):
78
79
valid_for = 0
79
80
nspair = {"xs" : "http://www.w3.org/2001/XMLSchema" }
80
- #paths = [".", "/opt/local/bin"]
81
+ # paths = [".", "/opt/local/bin"]
81
82
82
83
if valid :
83
84
valid_for = int (valid ) # Hours
@@ -97,21 +98,17 @@ def create_metadata_string(configfile, config=None, valid=None, cert=None,
97
98
secc = security_context (conf )
98
99
99
100
if mid :
100
- desc = entities_descriptor (eds , valid_for , name , mid ,
101
- sign , secc )
102
- valid_instance (desc )
103
-
104
- return metadata_tostring_fix (desc , nspair )
101
+ eid , xmldoc = entities_descriptor (eds , valid_for , name , mid ,
102
+ sign , secc )
105
103
else :
106
104
eid = eds [0 ]
107
105
if sign :
108
106
eid , xmldoc = sign_entity_descriptor (eid , mid , secc )
109
107
else :
110
108
xmldoc = None
111
109
112
- valid_instance (eid )
113
- xmldoc = metadata_tostring_fix (eid , nspair , xmldoc )
114
- return xmldoc
110
+ valid_instance (eid )
111
+ return metadata_tostring_fix (eid , nspair , xmldoc )
115
112
116
113
117
114
def _localized_name (val , klass ):
@@ -346,6 +343,7 @@ def do_idpdisc(discovery_response):
346
343
return idpdisc .DiscoveryResponse (index = "0" , location = discovery_response ,
347
344
binding = idpdisc .NAMESPACE )
348
345
346
+
349
347
ENDPOINTS = {
350
348
"sp" : {
351
349
"artifact_resolution_service" : (md .ArtifactResolutionService , True ),
@@ -425,7 +423,8 @@ def do_endpoints(conf, endpoints):
425
423
servs = []
426
424
i = 1
427
425
for args in conf [endpoint ]:
428
- if isinstance (args , six .string_types ): # Assume it's the location
426
+ if isinstance (args ,
427
+ six .string_types ): # Assume it's the location
429
428
args = {"location" : args ,
430
429
"binding" : DEFAULT_BINDING [endpoint ]}
431
430
elif isinstance (args , tuple ) or isinstance (args , list ):
@@ -453,16 +452,16 @@ def do_endpoints(conf, endpoints):
453
452
pass
454
453
return service
455
454
455
+
456
456
DEFAULT = {
457
457
"want_assertions_signed" : "true" ,
458
458
"authn_requests_signed" : "false" ,
459
459
"want_authn_requests_signed" : "false" ,
460
- #"want_authn_requests_only_with_valid_cert": "false",
460
+ # "want_authn_requests_only_with_valid_cert": "false",
461
461
}
462
462
463
463
464
464
def do_attribute_consuming_service (conf , spsso ):
465
-
466
465
service_description = service_name = None
467
466
requested_attributes = []
468
467
acs = conf .attribute_converters
@@ -557,7 +556,8 @@ def do_spsso_descriptor(conf, cert=None, enc_cert=None):
557
556
558
557
if cert or enc_cert :
559
558
metadata_key_usage = conf .metadata_key_usage
560
- spsso .key_descriptor = do_key_descriptor (cert = cert , enc_cert = enc_cert , use = metadata_key_usage )
559
+ spsso .key_descriptor = do_key_descriptor (cert = cert , enc_cert = enc_cert ,
560
+ use = metadata_key_usage )
561
561
562
562
for key in ["want_assertions_signed" , "authn_requests_signed" ]:
563
563
try :
@@ -605,10 +605,11 @@ def do_idpsso_descriptor(conf, cert=None, enc_cert=None):
605
605
idpsso .extensions .add_extension_element (do_uiinfo (ui_info ))
606
606
607
607
if cert or enc_cert :
608
- idpsso .key_descriptor = do_key_descriptor (cert , enc_cert , use = conf .metadata_key_usage )
608
+ idpsso .key_descriptor = do_key_descriptor (cert , enc_cert ,
609
+ use = conf .metadata_key_usage )
609
610
610
611
for key in ["want_authn_requests_signed" ]:
611
- # "want_authn_requests_only_with_valid_cert"]:
612
+ # "want_authn_requests_only_with_valid_cert"]:
612
613
try :
613
614
val = conf .getattr (key , "idp" )
614
615
if val is None :
@@ -635,7 +636,8 @@ def do_aa_descriptor(conf, cert=None, enc_cert=None):
635
636
_do_nameid_format (aad , conf , "aa" )
636
637
637
638
if cert or enc_cert :
638
- aad .key_descriptor = do_key_descriptor (cert , enc_cert , use = conf .metadata_key_usage )
639
+ aad .key_descriptor = do_key_descriptor (cert , enc_cert ,
640
+ use = conf .metadata_key_usage )
639
641
640
642
attributes = conf .getattr ("attribute" , "aa" )
641
643
if attributes :
@@ -664,7 +666,8 @@ def do_aq_descriptor(conf, cert=None, enc_cert=None):
664
666
_do_nameid_format (aqs , conf , "aq" )
665
667
666
668
if cert or enc_cert :
667
- aqs .key_descriptor = do_key_descriptor (cert , enc_cert , use = conf .metadata_key_usage )
669
+ aqs .key_descriptor = do_key_descriptor (cert , enc_cert ,
670
+ use = conf .metadata_key_usage )
668
671
669
672
return aqs
670
673
@@ -685,7 +688,8 @@ def do_pdp_descriptor(conf, cert=None, enc_cert=None):
685
688
_do_nameid_format (pdp , conf , "pdp" )
686
689
687
690
if cert :
688
- pdp .key_descriptor = do_key_descriptor (cert , enc_cert , use = conf .metadata_key_usage )
691
+ pdp .key_descriptor = do_key_descriptor (cert , enc_cert ,
692
+ use = conf .metadata_key_usage )
689
693
690
694
return pdp
691
695
@@ -702,7 +706,8 @@ def entity_descriptor(confd):
702
706
if confd .encryption_keypairs is not None :
703
707
enc_cert = []
704
708
for _encryption in confd .encryption_keypairs :
705
- enc_cert .append ("" .join (open (_encryption ["cert_file" ]).readlines ()[1 :- 1 ]))
709
+ enc_cert .append (
710
+ "" .join (open (_encryption ["cert_file" ]).readlines ()[1 :- 1 ]))
706
711
707
712
entd = md .EntityDescriptor ()
708
713
entd .entity_id = confd .entityid
@@ -736,13 +741,15 @@ def entity_descriptor(confd):
736
741
entd .idpsso_descriptor = do_idpsso_descriptor (confd , mycert , enc_cert )
737
742
if "aa" in serves :
738
743
confd .context = "aa"
739
- entd .attribute_authority_descriptor = do_aa_descriptor (confd , mycert , enc_cert )
744
+ entd .attribute_authority_descriptor = do_aa_descriptor (confd , mycert ,
745
+ enc_cert )
740
746
if "pdp" in serves :
741
747
confd .context = "pdp"
742
748
entd .pdp_descriptor = do_pdp_descriptor (confd , mycert , enc_cert )
743
749
if "aq" in serves :
744
750
confd .context = "aq"
745
- entd .authn_authority_descriptor = do_aq_descriptor (confd , mycert , enc_cert )
751
+ entd .authn_authority_descriptor = do_aq_descriptor (confd , mycert ,
752
+ enc_cert )
746
753
747
754
return entd
748
755
0 commit comments