@@ -435,6 +435,58 @@ def do_endpoints(conf, endpoints):
435
435
}
436
436
437
437
438
+ def do_attribute_consuming_service (conf , spsso ):
439
+
440
+ service_description = service_name = None
441
+ requested_attributes = []
442
+ acs = conf .attribute_converters
443
+ req = conf .getattr ("required_attributes" , "sp" )
444
+ if req :
445
+ requested_attributes .extend (do_requested_attribute (req , acs ,
446
+ is_required = "true" ))
447
+
448
+ opt = conf .getattr ("optional_attributes" , "sp" )
449
+
450
+ if opt :
451
+ requested_attributes .extend (do_requested_attribute (opt , acs ))
452
+
453
+ try :
454
+ if conf .description :
455
+ try :
456
+ (text , lang ) = conf .description
457
+ except ValueError :
458
+ text = conf .description
459
+ lang = "en"
460
+ service_description = [md .ServiceDescription (text = text , lang = lang )]
461
+ except KeyError :
462
+ pass
463
+
464
+ try :
465
+ if conf .name :
466
+ try :
467
+ (text , lang ) = conf .name
468
+ except ValueError :
469
+ text = conf .name
470
+ lang = "en"
471
+ service_name = [md .ServiceName (text = text , lang = lang )]
472
+ except KeyError :
473
+ pass
474
+
475
+ # Must be both requested attributes and service name
476
+ if requested_attributes :
477
+ if not service_name :
478
+ service_name = [md .ServiceName (text = "" , lang = "en" )]
479
+
480
+ ac_serv = md .AttributeConsumingService (
481
+ index = "1" , service_name = service_name ,
482
+ requested_attribute = requested_attributes )
483
+
484
+ if service_description :
485
+ ac_serv .service_description = service_description
486
+
487
+ spsso .attribute_consuming_service = [ac_serv ]
488
+
489
+
438
490
def do_spsso_descriptor (conf , cert = None ):
439
491
spsso = md .SPSSODescriptor ()
440
492
spsso .protocol_support_enumeration = samlp .NAMESPACE
@@ -479,46 +531,8 @@ def do_spsso_descriptor(conf, cert=None):
479
531
except KeyError :
480
532
setattr (spsso , key , DEFAULTS [key ])
481
533
482
- requested_attributes = []
483
- acs = conf .attribute_converters
484
- req = conf .getattr ("required_attributes" , "sp" )
485
- if req :
486
- requested_attributes .extend (do_requested_attribute (req , acs ,
487
- is_required = "true" ))
488
-
534
+ do_attribute_consuming_service (conf , spsso )
489
535
_do_nameid_format (spsso , conf , "sp" )
490
-
491
- opt = conf .getattr ("optional_attributes" , "sp" )
492
-
493
- if opt :
494
- requested_attributes .extend (do_requested_attribute (opt , acs ))
495
-
496
- if requested_attributes :
497
- # endpoints that might publish requested attributes
498
- if spsso .attribute_consuming_service :
499
- for acs in spsso .attribute_consuming_service :
500
- if not acs .requested_attribute :
501
- acs .requested_attribute = requested_attributes
502
- else :
503
- spsso .attribute_consuming_service = [md .AttributeConsumingService (
504
- requested_attribute = requested_attributes ,
505
- service_name = [md .ServiceName (lang = "en" , text = conf .name )],
506
- index = "1" ,
507
- )]
508
-
509
- # try:
510
- # if conf.description:
511
- # try:
512
- # (text, lang) = conf.description
513
- # except ValueError:
514
- # text = conf.description
515
- # lang = "en"
516
- # spsso.attribute_consuming_service[0].service_description = [
517
- # md.ServiceDescription(text=text,
518
- # lang=lang)]
519
- # except KeyError:
520
- # pass
521
-
522
536
return spsso
523
537
524
538
0 commit comments