@@ -920,54 +920,71 @@ private function fillSpName($t)
920920 $ this ->adapter = Adapter::getInstance ($ this ->wayfConfiguration ->getString (self ::INTERFACE , self ::RPC ));
921921 try {
922922 if (null !== $ clientIdWithPrefix ) {
923- $ parts = explode (': ' , $ clientIdWithPrefix );
924- $ clientId = end ($ parts );
923+ $ this ->fillSpNameForOidc ($ t , $ clientIdWithPrefix );
924+ } else {
925+ $ this ->fillSpNameForSaml ($ t );
926+ }
927+ } catch (\Exception $ e ) {
928+ Logger::debug ("Fill SP name - caught exception {$ e }" );
929+ //OK, we will just display the disco
930+ }
931+ }
925932
926- $ clientIdAttr = $ this ->wayfConfiguration ->getString (self ::CLIENT_ID_ATTR , null );
927- if (null === $ clientIdAttr ) {
928- $ facility = $ this ->adapter ->getFacilityByClientId ($ clientId );
929- } else {
930- $ facility = $ this ->adapter ->getFacilityByClientId ($ clientId , $ clientIdAttr );
931- }
933+ private function fillSpNameForOidc ($ t , $ clientIdWithPrefix )
934+ {
935+ if (null === $ clientIdWithPrefix ) {
936+ return ;
937+ }
938+ $ parts = explode (': ' , $ clientIdWithPrefix );
939+ $ clientId = end ($ parts );
932940
933- if (null !== $ facility ) {
934- $ spNameAttrName = $ this ->wayfConfiguration ->getString (
935- self ::SERVICE_NAME_ATTR ,
936- self ::SERVICE_NAME_DEFAULT_ATTR_NAME
937- );
938- $ spNameMap = $ this ->adapter ->getFacilityAttribute ($ facility , $ spNameAttrName );
939- if (!empty ($ spNameMap )) {
940- $ this ->spName = $ t ->getTranslation ($ spNameMap );
941- }
942- }
941+ $ clientIdAttr = $ this ->wayfConfiguration ->getString (self ::CLIENT_ID_ATTR , null );
942+ if (null === $ clientIdAttr ) {
943+ $ facility = $ this ->adapter ->getFacilityByClientId ($ clientId );
944+ } else {
945+ $ facility = $ this ->adapter ->getFacilityByClientId ($ clientId , $ clientIdAttr );
946+ }
947+
948+ if (null !== $ facility ) {
949+ $ spNameAttrName = $ this ->wayfConfiguration ->getString (
950+ self ::SERVICE_NAME_ATTR ,
951+ self ::SERVICE_NAME_DEFAULT_ATTR_NAME
952+ );
953+ $ spNameMap = $ this ->adapter ->getFacilityAttribute ($ facility , $ spNameAttrName );
954+ if (!empty ($ spNameMap )) {
955+ $ this ->spName = $ t ->getTranslation ($ spNameMap );
956+ }
957+ }
958+ }
959+
960+ private function fillSpNameForSaml ($ t )
961+ {
962+ $ this ->spName = null ;
963+ if (!empty ($ this ->originalsp ['entityid ' ])) {
964+ $ entityId = $ this ->originalsp ['entityid ' ];
965+ $ entityIdAttr = $ this ->wayfConfiguration ->getString (self ::ENTITY_ID_ATTR , null );
966+ if (null === $ entityIdAttr ) {
967+ $ facility = $ this ->adapter ->getFacilityByEntityId ($ entityId );
943968 } else {
944- $ entityId = $ this ->originalsp ['entityid ' ];
945- $ entityIdAttr = $ this ->wayfConfiguration ->getString (self ::ENTITY_ID_ATTR , null );
946- if (null === $ entityIdAttr ) {
947- $ facility = $ this ->adapter ->getFacilityByEntityId ($ entityId );
948- } else {
949- $ facility = $ this ->adapter ->getFacilityByEntityId ($ entityId , $ entityIdAttr );
950- }
969+ $ facility = $ this ->adapter ->getFacilityByEntityId ($ entityId , $ entityIdAttr );
970+ }
951971
952- if (null !== $ facility ) {
953- $ spNameAttr = $ this ->wayfConfiguration ->getString (
954- self ::SERVICE_NAME_ATTR ,
955- self ::SERVICE_NAME_DEFAULT_ATTR_NAME
956- );
957- $ spNameMap = $ this ->adapter ->getFacilityAttribute ($ facility , $ spNameAttr );
958- if (!empty ($ spNameMap )) {
959- $ this ->spName = $ t ->getTranslation ($ spNameMap );
960- }
961- }
962- if (empty ($ entityId )) {
963- if (!empty ($ this ->originalsp [self ::NAME ])) {
964- $ this ->spName = $ t ->translate ->getTranslation ($ this ->originalsp [self ::NAME ]);
965- }
966- }
972+ if (null === $ facility ) {
973+ return ;
967974 }
968- } catch (\Exception $ e ) {
969- Logger::warning ("Fill SP name - caught exception {$ e }" );
970- //OK, we will just display the disco
975+
976+ $ spNameAttr = $ this ->wayfConfiguration ->getString (
977+ self ::SERVICE_NAME_ATTR ,
978+ self ::SERVICE_NAME_DEFAULT_ATTR_NAME
979+ );
980+
981+ $ spNameMap = $ this ->adapter ->getFacilityAttribute ($ facility , $ spNameAttr );
982+ if (!empty ($ spNameMap )) {
983+ $ this ->spName = $ t ->getTranslation ($ spNameMap );
984+ }
985+ }
986+ if (empty ($ this ->spName ) && !empty ($ this ->originalsp [self ::NAME ])) {
987+ $ this ->spName = $ t ->translate ->getTranslation ($ this ->originalsp [self ::NAME ]);
971988 }
972989 }
973990}
0 commit comments