1414use SimpleSAML \SAML2 \Exception \Protocol \{NoAvailableIDPException , NoPassiveException , NoSupportedIDPException };
1515use SimpleSAML \SAML2 \XML \md \ContactPerson ;
1616use SimpleSAML \SAML2 \XML \saml \NameID ;
17- use SimpleSAML \SAML2 \XML \samlp \{Extensions , IDPEntry , IDPList , RequesterID , Scoping };
17+ use SimpleSAML \SAML2 \XML \saml \{AuthnContextClassRef };
18+ use SimpleSAML \SAML2 \XML \samlp \{Extensions , IDPEntry , IDPList , RequestedAuthnContext , RequesterID , Scoping };
1819use SimpleSAML \Store \StoreFactory ;
1920use Symfony \Bridge \PsrHttpMessage \Factory \HttpFoundationFactory ;
2021use Symfony \Component \HttpFoundation \{RedirectResponse , Request , Response };
2122
2223use function array_intersect ;
2324use function array_key_exists ;
2425use function array_keys ;
26+ use function array_map ;
2527use function call_user_func ;
2628use function count ;
2729use function in_array ;
@@ -469,6 +471,7 @@ private function startSSO2(Configuration $idpMetadata, array $state): Response
469471 $ accr = null ;
470472 if ($ idpMetadata ->getOptionalString ('AuthnContextClassRef ' , null ) !== null ) {
471473 $ accr = $ arrayUtils ->arrayize ($ idpMetadata ->getString ('AuthnContextClassRef ' ));
474+ $ accr = array_map (fn ($ value ): AuthnContextClassRef => new AuthnContextClassRef ($ value ), $ accr );
472475 } elseif (isset ($ state ['saml:AuthnContextClassRef ' ])) {
473476 $ accr = $ arrayUtils ->arrayize ($ state ['saml:AuthnContextClassRef ' ]);
474477 }
@@ -488,7 +491,9 @@ private function startSSO2(Configuration $idpMetadata, array $state): Response
488491 ) {
489492 $ comp = $ state ['saml:AuthnContextComparison ' ];
490493 }
491- $ ar ->setRequestedAuthnContext (['AuthnContextClassRef ' => $ accr , 'Comparison ' => $ comp ]);
494+ $ ar ->setRequestedAuthnContext (
495+ new RequestedAuthnContext ($ accr , $ comp ),
496+ );
492497 } elseif (
493498 $ this ->passAuthnContextClassRef
494499 && isset ($ state ['saml:RequestedAuthnContext ' ])
@@ -534,26 +539,7 @@ private function startSSO2(Configuration $idpMetadata, array $state): Response
534539
535540 $ nameId = $ state ['saml:NameID ' ];
536541 if (is_array ($ nameId )) {
537- // Must be an array > convert to object
538-
539- $ nid = new NameID ();
540- if (!array_key_exists ('Value ' , $ nameId )) {
541- throw new \InvalidArgumentException ('Missing "Value" in array, cannot create NameID from it. ' );
542- }
543-
544- $ nid ->setValue ($ nameId ['Value ' ]);
545- if (array_key_exists ('NameQualifier ' , $ nameId ) && $ nameId ['NameQualifier ' ] !== null ) {
546- $ nid ->setNameQualifier ($ nameId ['NameQualifier ' ]);
547- }
548- if (array_key_exists ('SPNameQualifier ' , $ nameId ) && $ nameId ['SPNameQualifier ' ] !== null ) {
549- $ nid ->setSPNameQualifier ($ nameId ['SPNameQualifier ' ]);
550- }
551- if (array_key_exists ('SPProvidedID ' , $ nameId ) && $ nameId ['SPProvidedId ' ] !== null ) {
552- $ nid ->setSPProvidedID ($ nameId ['SPProvidedID ' ]);
553- }
554- if (array_key_exists ('Format ' , $ nameId ) && $ nameId ['Format ' ] !== null ) {
555- $ nid ->setFormat ($ nameId ['Format ' ]);
556- }
542+ $ nid = NameID::fromArray ($ state ['saml:NameID ' ]);
557543 } else {
558544 $ nid = $ nameId ;
559545 }
0 commit comments