@@ -314,7 +314,42 @@ def certs(self, entity_id, descriptor, use="signing"):
314
314
'''
315
315
Returns certificates for the given Entity
316
316
'''
317
- raise NotImplementedError
317
+ ent = self [entity_id ]
318
+
319
+ def extract_certs (srvs ):
320
+ res = []
321
+ for srv in srvs :
322
+ for key in srv ["key_descriptor" ]:
323
+ if "use" in key and key ["use" ] == use :
324
+ for dat in key ["key_info" ]["x509_data" ]:
325
+ cert = repack_cert (
326
+ dat ["x509_certificate" ]["text" ])
327
+ if cert not in res :
328
+ res .append (cert )
329
+ elif not "use" in key :
330
+ for dat in key ["key_info" ]["x509_data" ]:
331
+ cert = repack_cert (
332
+ dat ["x509_certificate" ]["text" ])
333
+ if cert not in res :
334
+ res .append (cert )
335
+
336
+ return res
337
+
338
+ if descriptor == "any" :
339
+ res = []
340
+ for descr in ["spsso" , "idpsso" , "role" , "authn_authority" ,
341
+ "attribute_authority" , "pdp" ]:
342
+ try :
343
+ srvs = ent ["%s_descriptor" % descr ]
344
+ except KeyError :
345
+ continue
346
+
347
+ res .extend (extract_certs (srvs ))
348
+ else :
349
+ srvs = ent ["%s_descriptor" % descriptor ]
350
+ res = extract_certs (srvs )
351
+
352
+ return res
318
353
319
354
320
355
class InMemoryMetaData (MetaData ):
@@ -511,45 +546,6 @@ def construct_source_id(self):
511
546
512
547
return res
513
548
514
- def certs (self , entity_id , descriptor , use = "signing" ):
515
- ent = self .__getitem__ (entity_id )
516
- if descriptor == "any" :
517
- res = []
518
- for descr in ["spsso" , "idpsso" , "role" , "authn_authority" ,
519
- "attribute_authority" , "pdp" ]:
520
- try :
521
- srvs = ent ["%s_descriptor" % descr ]
522
- except KeyError :
523
- continue
524
-
525
- for srv in srvs :
526
- for key in srv ["key_descriptor" ]:
527
- if "use" in key and key ["use" ] == use :
528
- for dat in key ["key_info" ]["x509_data" ]:
529
- cert = repack_cert (
530
- dat ["x509_certificate" ]["text" ])
531
- if cert not in res :
532
- res .append (cert )
533
- elif not "use" in key :
534
- for dat in key ["key_info" ]["x509_data" ]:
535
- cert = repack_cert (
536
- dat ["x509_certificate" ]["text" ])
537
- if cert not in res :
538
- res .append (cert )
539
- else :
540
- srvs = ent ["%s_descriptor" % descriptor ]
541
-
542
- res = []
543
- for srv in srvs :
544
- for key in srv ["key_descriptor" ]:
545
- if "use" in key and key ["use" ] == use :
546
- for dat in key ["key_info" ]["x509_data" ]:
547
- res .append (dat ["x509_certificate" ]["text" ])
548
- elif not "use" in key :
549
- for dat in key ["key_info" ]["x509_data" ]:
550
- res .append (dat ["x509_certificate" ]["text" ])
551
- return res
552
-
553
549
def signed (self ):
554
550
if self .entities_descr and self .entities_descr .signature :
555
551
return True
@@ -567,8 +563,8 @@ def parse_and_check_signature(self, txt):
567
563
return True
568
564
569
565
node_name = self .node_name \
570
- or "%s:%s" % (md .EntitiesDescriptor .c_namespace ,
571
- md .EntitiesDescriptor .c_tag )
566
+ or "%s:%s" % (md .EntitiesDescriptor .c_namespace ,
567
+ md .EntitiesDescriptor .c_tag )
572
568
573
569
if self .security .verify_signature (
574
570
txt , node_name = node_name , cert_file = self .cert ):
@@ -752,7 +748,7 @@ def __getitem__(self, item):
752
748
raise KeyError
753
749
754
750
755
- class MetadataStore (object ):
751
+ class MetadataStore (MetaData ):
756
752
def __init__ (self , onts , attrc , config , ca_certs = None ,
757
753
check_validity = True ,
758
754
disable_ssl_certificate_validation = False ,
@@ -1062,45 +1058,6 @@ def name(self, entity_id, langpref="en"):
1062
1058
return name (_md [entity_id ], langpref )
1063
1059
return None
1064
1060
1065
- def certs (self , entity_id , descriptor , use = "signing" ):
1066
- ent = self .__getitem__ (entity_id )
1067
- if descriptor == "any" :
1068
- res = []
1069
- for descr in ["spsso" , "idpsso" , "role" , "authn_authority" ,
1070
- "attribute_authority" , "pdp" ]:
1071
- try :
1072
- srvs = ent ["%s_descriptor" % descr ]
1073
- except KeyError :
1074
- continue
1075
-
1076
- for srv in srvs :
1077
- for key in srv ["key_descriptor" ]:
1078
- if "use" in key and key ["use" ] == use :
1079
- for dat in key ["key_info" ]["x509_data" ]:
1080
- cert = repack_cert (
1081
- dat ["x509_certificate" ]["text" ])
1082
- if cert not in res :
1083
- res .append (cert )
1084
- elif not "use" in key :
1085
- for dat in key ["key_info" ]["x509_data" ]:
1086
- cert = repack_cert (
1087
- dat ["x509_certificate" ]["text" ])
1088
- if cert not in res :
1089
- res .append (cert )
1090
- else :
1091
- srvs = ent ["%s_descriptor" % descriptor ]
1092
-
1093
- res = []
1094
- for srv in srvs :
1095
- for key in srv ["key_descriptor" ]:
1096
- if "use" in key and key ["use" ] == use :
1097
- for dat in key ["key_info" ]["x509_data" ]:
1098
- res .append (dat ["x509_certificate" ]["text" ])
1099
- elif not "use" in key :
1100
- for dat in key ["key_info" ]["x509_data" ]:
1101
- res .append (dat ["x509_certificate" ]["text" ])
1102
- return res
1103
-
1104
1061
def vo_members (self , entity_id ):
1105
1062
ad = self .__getitem__ (entity_id )["affiliation_descriptor" ]
1106
1063
return [m ["text" ] for m in ad ["affiliate_member" ]]
0 commit comments