private ValidationResult discoverIdentityProvidersForSelectionList(List<String> eligibleLocalIdpList,List<String> eligibleExternalIdpList,AuthnRequestState t){
  log.debug("Discovering eligible identity providers for authentication.");
  Validate.isTrue(t.isChooseIDPViewRequired() == null);
  IdmAccessor accessor=t.getIdmAccessor();
  String tenantIDPCookie=t.getTenantIDPCookie();
  String selectedIDPEntityId=tenantIDPCookie;
  if (tenantIDPCookie == null || tenantIDPCookie.isEmpty()) {
    String tenantIDPHeader=t.getTenantIDPSelectHeader();
    if (tenantIDPHeader == null || tenantIDPHeader.isEmpty()) {
      List<String> eligibleIdps=new ArrayList<>();
      eligibleIdps.add(accessor.getIdpEntityId());
      eligibleIdps.addAll(eligibleExternalIdpList);
      t.setIDPEntityIdList(eligibleIdps);
      log.debug("No IDP header or cookie is available. Redirect to choose idp view.");
      t.setNeedChooseIDPView(true);
      return null;
    }
 else {
      log.debug("EntityId from IDP header is " + tenantIDPHeader);
      selectedIDPEntityId=tenantIDPHeader;
      t.addTenantIDPCookie(tenantIDPHeader,t.getResponse());
    }
  }
  t.setNeedChooseIDPView(false);
  if (eligibleLocalIdpList.contains(selectedIDPEntityId)) {
    log.debug("Tenant IDP cookie is set to local idp. Not proxying.");
    t.setProxying(false);
  }
 else {
    IDPConfig idpConfigToUse=accessor.getExternalIdpConfigForTenant(accessor.getTenant(),selectedIDPEntityId);
    if (idpConfigToUse == null) {
      log.warn("External IDP with entity id : " + selectedIDPEntityId + " is not registered.");
      return new ValidationResult(OasisNames.REQUESTER,OasisNames.NO_SUPPORTED_IDP);
    }
 else {
      t.setExtIDPToUse(idpConfigToUse);
      t.setProxying(true);
    }
  }
  return null;
}

private ValidationResult discoverIdentityProvidersForSelectionList ( List < String > eligibleLocalIdpList , List < String > eligibleExternalIdpList , AuthnRequestState t ) { log . debug ( "Discovering eligible identity providers for authentication." ) ; Validate . isTrue ( t . isChooseIDPViewRequired ( ) == null ) ; IdmAccessor accessor = t . getIdmAccessor ( ) ; String tenantIDPCookie = t . getTenantIDPCookie ( ) ; String selectedIDPEntityId = tenantIDPCookie ; if ( tenantIDPCookie == null || tenantIDPCookie . isEmpty ( ) ) { String tenantIDPHeader = t . getTenantIDPSelectHeader ( ) ; if ( tenantIDPHeader == null || tenantIDPHeader . isEmpty ( ) ) { List < String > eligibleIdps = new ArrayList < > ( ) ; eligibleIdps . add ( accessor . getIdpEntityId ( ) ) ; eligibleIdps . addAll ( eligibleExternalIdpList ) ; t . setIDPEntityIdList ( eligibleIdps ) ; log . debug ( "No IDP header or cookie is available. Redirect to choose idp view." ) ; t . setNeedChooseIDPView ( true ) ; return null ; } else { log . debug ( "EntityId from IDP header is " + tenantIDPHeader ) ; selectedIDPEntityId = tenantIDPHeader ; t . addTenantIDPCookie ( tenantIDPHeader , t . getResponse ( ) ) ; } } t . setNeedChooseIDPView ( false ) ; if ( eligibleLocalIdpList . contains ( selectedIDPEntityId ) ) { log . debug ( "Tenant IDP cookie is set to local idp. Not proxying." ) ; t . setProxying ( false ) ; } else { IDPConfig idpConfigToUse = accessor . getExternalIdpConfigForTenant ( accessor . getTenant ( ) , selectedIDPEntityId ) ; if ( idpConfigToUse == null ) { log . warn ( "External IDP with entity id : " + selectedIDPEntityId + " is not registered." ) ; return new ValidationResult ( OasisNames . REQUESTER , OasisNames . NO_SUPPORTED_IDP ) ; } else { t . setExtIDPToUse ( idpConfigToUse ) ; t . setProxying ( true ) ; } } return null ; }
discover eligible idps that can be selected by user if proxying and choose idp view is enabled . set up proxy parameters and whether needloginview is required . set cookies if idp has been selected . set validation result in invalid cases .
