2626use SimpleSAML \Store ;
2727use SimpleSAML \Store \StoreFactory ;
2828use SimpleSAML \Utils ;
29+ use SimpleSAML \SAML2 \XML \samlp \AuthnContextComparisonTypeEnum ;
30+
31+ use function array_column ;
2932
3033class SP extends Auth \Source
3134{
@@ -507,17 +510,16 @@ private function startSSO2(Configuration $idpMetadata, array $state): void
507510 }
508511
509512 if ($ accr !== null ) {
510- $ comp = Constants:: COMPARISON_EXACT ;
513+ $ comp = AuthnContextComparisonTypeEnum::Exact ;
511514 if ($ idpMetadata ->getOptionalString ('AuthnContextComparison ' , null ) !== null ) {
512515 $ comp = $ idpMetadata ->getString ('AuthnContextComparison ' );
513516 } elseif (
514517 isset ($ state ['saml:AuthnContextComparison ' ])
515- && in_array ($ state ['saml:AuthnContextComparison ' ], [
516- Constants::COMPARISON_EXACT ,
517- Constants::COMPARISON_MINIMUM ,
518- Constants::COMPARISON_MAXIMUM ,
519- Constants::COMPARISON_BETTER ,
520- ], true )
518+ && in_array (
519+ $ state ['saml:AuthnContextComparison ' ],
520+ array_column (AuthnContextComparisonTypeEnum::cases (), 'value ' ),
521+ true ,
522+ )
521523 ) {
522524 $ comp = $ state ['saml:AuthnContextComparison ' ];
523525 }
@@ -531,12 +533,7 @@ private function startSSO2(Configuration $idpMetadata, array $state): void
531533 isset ($ state ['saml:RequestedAuthnContext ' ]['Comparison ' ])
532534 && in_array (
533535 $ state ['saml:RequestedAuthnContext ' ]['Comparison ' ],
534- [
535- Constants::COMPARISON_EXACT ,
536- Constants::COMPARISON_MINIMUM ,
537- Constants::COMPARISON_MAXIMUM ,
538- Constants::COMPARISON_BETTER ,
539- ],
536+ array_column (AuthnContextComparisonTypeEnum::cases (), 'value ' ),
540537 true ,
541538 )
542539 ) {
@@ -911,7 +908,7 @@ public function reauthenticate(array &$state): void
911908 if (
912909 $ this ->passAuthnContextClassRef
913910 && isset ($ state ['saml:RequestedAuthnContext ' ])
914- && $ state ['saml:RequestedAuthnContext ' ]['Comparison ' ] === Constants:: COMPARISON_EXACT
911+ && $ state ['saml:RequestedAuthnContext ' ]['Comparison ' ] === AuthnContextComparisonTypeEnum::Exact-> value
915912 && isset ($ data ['saml:sp:AuthnContext ' ])
916913 && $ state ['saml:RequestedAuthnContext ' ]['AuthnContextClassRef ' ][0 ] !== $ data ['saml:sp:AuthnContext ' ]
917914 ) {
0 commit comments