@@ -543,107 +543,109 @@ class EntityCategories(object):
543
543
pass
544
544
545
545
546
- class Assertion (dict ):
547
- """ Handles assertions about subjects """
548
-
549
- def __init__ (self , dic = None ):
550
- dict .__init__ (self , dic )
551
- self .acs = []
552
-
553
- @staticmethod
554
- def _authn_context_decl (decl , authn_auth = None ):
555
- """
556
- Construct the authn context with a authn context declaration
557
- :param decl: The authn context declaration
558
- :param authn_auth: Authenticating Authority
559
- :return: An AuthnContext instance
560
- """
546
+ def _authn_context_class_ref (authn_class , authn_auth = None ):
547
+ """
548
+ Construct the authn context with a authn context class reference
549
+ :param authn_class: The authn context class reference
550
+ :param authn_auth: Authenticating Authority
551
+ :return: An AuthnContext instance
552
+ """
553
+ cntx_class = factory (saml .AuthnContextClassRef , text = authn_class )
554
+ if authn_auth :
561
555
return factory (saml .AuthnContext ,
562
- authn_context_decl = decl ,
556
+ authn_context_class_ref = cntx_class ,
563
557
authenticating_authority = factory (
564
558
saml .AuthenticatingAuthority , text = authn_auth ))
565
-
566
- def _authn_context_decl_ref (self , decl_ref , authn_auth = None ):
567
- """
568
- Construct the authn context with a authn context declaration reference
569
- :param decl_ref: The authn context declaration reference
570
- :param authn_auth: Authenticating Authority
571
- :return: An AuthnContext instance
572
- """
559
+ else :
573
560
return factory (saml .AuthnContext ,
574
- authn_context_decl_ref = decl_ref ,
575
- authenticating_authority = factory (
576
- saml .AuthenticatingAuthority , text = authn_auth ))
561
+ authn_context_class_ref = cntx_class )
577
562
578
- @staticmethod
579
- def _authn_context_class_ref (authn_class , authn_auth = None ):
580
- """
581
- Construct the authn context with a authn context class reference
582
- :param authn_class: The authn context class reference
583
- :param authn_auth: Authenticating Authority
584
- :return: An AuthnContext instance
585
- """
586
- cntx_class = factory (saml .AuthnContextClassRef , text = authn_class )
587
- if authn_auth :
588
- return factory (saml .AuthnContext ,
589
- authn_context_class_ref = cntx_class ,
590
- authenticating_authority = factory (
591
- saml .AuthenticatingAuthority , text = authn_auth ))
592
- else :
593
- return factory (saml .AuthnContext ,
594
- authn_context_class_ref = cntx_class )
595
-
596
- def _authn_statement (self , authn_class = None , authn_auth = None ,
597
- authn_decl = None , authn_decl_ref = None , authn_instant = "" ,
598
- subject_locality = "" ):
599
- """
600
- Construct the AuthnStatement
601
- :param authn_class: Authentication Context Class reference
602
- :param authn_auth: Authenticating Authority
603
- :param authn_decl: Authentication Context Declaration
604
- :param authn_decl_ref: Authentication Context Declaration reference
605
- :param authn_instant: When the Authentication was performed.
606
- Assumed to be seconds since the Epoch.
607
- :param subject_locality: Specifies the DNS domain name and IP address
608
- for the system from which the assertion subject was apparently
609
- authenticated.
610
- :return: An AuthnContext instance
611
- """
612
- if authn_instant :
613
- _instant = instant (time_stamp = authn_instant )
614
- else :
615
- _instant = instant ()
616
-
617
- if authn_class :
618
- res = factory (
619
- saml .AuthnStatement ,
620
- authn_instant = _instant ,
621
- session_index = sid (),
622
- authn_context = self ._authn_context_class_ref (
623
- authn_class , authn_auth ))
624
- elif authn_decl :
625
- res = factory (
626
- saml .AuthnStatement ,
627
- authn_instant = _instant ,
628
- session_index = sid (),
629
- authn_context = self ._authn_context_decl (authn_decl , authn_auth ))
630
- elif authn_decl_ref :
631
- res = factory (
632
- saml .AuthnStatement ,
633
- authn_instant = _instant ,
634
- session_index = sid (),
635
- authn_context = self ._authn_context_decl_ref (authn_decl_ref ,
636
- authn_auth ))
637
- else :
638
- res = factory (
639
- saml .AuthnStatement ,
640
- authn_instant = _instant ,
641
- session_index = sid ())
642
563
643
- if subject_locality :
644
- res .subject_locality = saml .SubjectLocality (text = subject_locality )
564
+ def _authn_context_decl (decl , authn_auth = None ):
565
+ """
566
+ Construct the authn context with a authn context declaration
567
+ :param decl: The authn context declaration
568
+ :param authn_auth: Authenticating Authority
569
+ :return: An AuthnContext instance
570
+ """
571
+ return factory (saml .AuthnContext ,
572
+ authn_context_decl = decl ,
573
+ authenticating_authority = factory (
574
+ saml .AuthenticatingAuthority , text = authn_auth ))
645
575
646
- return res
576
+
577
+ def _authn_context_decl_ref (decl_ref , authn_auth = None ):
578
+ """
579
+ Construct the authn context with a authn context declaration reference
580
+ :param decl_ref: The authn context declaration reference
581
+ :param authn_auth: Authenticating Authority
582
+ :return: An AuthnContext instance
583
+ """
584
+ return factory (saml .AuthnContext ,
585
+ authn_context_decl_ref = decl_ref ,
586
+ authenticating_authority = factory (
587
+ saml .AuthenticatingAuthority , text = authn_auth ))
588
+
589
+
590
+ def authn_statement (authn_class = None , authn_auth = None ,
591
+ authn_decl = None , authn_decl_ref = None , authn_instant = "" ,
592
+ subject_locality = "" ):
593
+ """
594
+ Construct the AuthnStatement
595
+ :param authn_class: Authentication Context Class reference
596
+ :param authn_auth: Authenticating Authority
597
+ :param authn_decl: Authentication Context Declaration
598
+ :param authn_decl_ref: Authentication Context Declaration reference
599
+ :param authn_instant: When the Authentication was performed.
600
+ Assumed to be seconds since the Epoch.
601
+ :param subject_locality: Specifies the DNS domain name and IP address
602
+ for the system from which the assertion subject was apparently
603
+ authenticated.
604
+ :return: An AuthnContext instance
605
+ """
606
+ if authn_instant :
607
+ _instant = instant (time_stamp = authn_instant )
608
+ else :
609
+ _instant = instant ()
610
+
611
+ if authn_class :
612
+ res = factory (
613
+ saml .AuthnStatement ,
614
+ authn_instant = _instant ,
615
+ session_index = sid (),
616
+ authn_context = _authn_context_class_ref (
617
+ authn_class , authn_auth ))
618
+ elif authn_decl :
619
+ res = factory (
620
+ saml .AuthnStatement ,
621
+ authn_instant = _instant ,
622
+ session_index = sid (),
623
+ authn_context = _authn_context_decl (authn_decl , authn_auth ))
624
+ elif authn_decl_ref :
625
+ res = factory (
626
+ saml .AuthnStatement ,
627
+ authn_instant = _instant ,
628
+ session_index = sid (),
629
+ authn_context = _authn_context_decl_ref (authn_decl_ref ,
630
+ authn_auth ))
631
+ else :
632
+ res = factory (
633
+ saml .AuthnStatement ,
634
+ authn_instant = _instant ,
635
+ session_index = sid ())
636
+
637
+ if subject_locality :
638
+ res .subject_locality = saml .SubjectLocality (text = subject_locality )
639
+
640
+ return res
641
+
642
+
643
+ class Assertion (dict ):
644
+ """ Handles assertions about subjects """
645
+
646
+ def __init__ (self , dic = None ):
647
+ dict .__init__ (self , dic )
648
+ self .acs = []
647
649
648
650
def construct (self , sp_entity_id , in_response_to , consumer_url ,
649
651
name_id , attrconvs , policy , issuer , authn_class = None ,
@@ -695,10 +697,10 @@ def construct(self, sp_entity_id, in_response_to, consumer_url,
695
697
conds = policy .conditions (sp_entity_id )
696
698
697
699
if authn_auth or authn_class or authn_decl or authn_decl_ref :
698
- _authn_statement = self . _authn_statement (authn_class , authn_auth ,
699
- authn_decl , authn_decl_ref ,
700
- authn_instant ,
701
- subject_locality )
700
+ _authn_statement = authn_statement (authn_class , authn_auth ,
701
+ authn_decl , authn_decl_ref ,
702
+ authn_instant ,
703
+ subject_locality )
702
704
else :
703
705
_authn_statement = None
704
706
0 commit comments