@@ -86,16 +86,22 @@ public List<Map<String, Object>> provisioning(Collection<String> applicationIden
8686 }
8787
8888 @ Override
89- public List <Map <String , Object >> providersAllowedByIdP (Map <String , Object > identityProvider ) {
90- LOG .debug ("providersAllowedByIdP for : " + identityProvider .get ("type" ));
91-
92- Boolean allowedAll = (Boolean ) identityProvider .getOrDefault ("allowedall" , Boolean .FALSE );
93- if (allowedAll ) {
89+ public List <Map <String , Object >> providersAllowedByIdPs (List <Map <String , Object >> identityProviders ) {
90+ LOG .debug ("providersAllowedByIdPs" );
91+ if (identityProviders .isEmpty ()) {
92+ return emptyList ();
93+ }
94+ if (identityProviders .stream ()
95+ .anyMatch (idp -> (Boolean ) idp .getOrDefault ("allowedall" , Boolean .FALSE ))) {
9496 return this .providers (EntityType .SAML20_SP , EntityType .OIDC10_RP );
9597 }
96- List <Map <String , String >> allowedEntities = (List <Map <String , String >>) identityProvider .getOrDefault ("allowedEntities" , emptyList ());
97- String split = allowedEntities .stream ().map (m -> "\" " + m .get ("name" ) + "\" " )
98+ String split = identityProviders .stream ()
99+ .map (idp -> (List <Map <String , String >>) idp .getOrDefault ("allowedEntities" , emptyList ()))
100+ .flatMap (Collection ::stream )
101+ .map (m -> "\" " + m .get ("name" ) + "\" " )
102+ .distinct ()
98103 .collect (Collectors .joining ("," ));
104+
99105 String body = String .format ("{\" data.entityid\" :{\" $in\" :[%s]}}" , split );
100106 List <Map <String , Object >> results = new ArrayList <>();
101107 List .of (EntityType .SAML20_SP , EntityType .OIDC10_RP ).forEach (entityType -> {
@@ -109,7 +115,14 @@ public List<Map<String, Object>> providersAllowedByIdP(Map<String, Object> ident
109115 }
110116
111117 @ Override
112- public Optional <Map <String , Object >> identityProviderByInstitutionalGUID (String organisationGUID ) {
118+ public List <Map <String , Object >> providersAllowedByIdP (Map <String , Object > identityProvider ) {
119+ LOG .debug ("providersAllowedByIdP for : " + identityProvider .get ("type" ));
120+
121+ return this .providersAllowedByIdPs (List .of (identityProvider ));
122+ }
123+
124+ @ Override
125+ public List <Map <String , Object >> identityProvidersByInstitutionalGUID (String organisationGUID ) {
113126 LOG .debug ("identityProviderByInstitutionalGUID for : " + organisationGUID );
114127
115128 Map <String , Object > baseQuery = getBaseQuery ();
@@ -122,7 +135,7 @@ public Optional<Map<String, Object>> identityProviderByInstitutionalGUID(String
122135 List <Map <String , Object >> identityProviders = restTemplate .postForObject (
123136 String .format ("%s/manage/api/internal/search/%s" , this .url , EntityType .SAML20_IDP .collectionName ()),
124137 baseQuery , List .class );
125- return identityProviders . isEmpty () ? Optional . empty () : Optional . of ( transformProvider (identityProviders . get ( 0 )) );
138+ return transformProvider (identityProviders );
126139 }
127140
128141 private List <Map <String , Object >> getRemoteMetaData (String type ) {
0 commit comments