package at.gv.egovernment.moa.id.auth.modules.eIDAScentralAuth.utils; import java.util.List; import org.apache.commons.lang3.StringUtils; import at.gv.egiz.eaaf.core.api.idp.IConfiguration; import at.gv.egiz.eaaf.core.api.idp.ISPConfiguration; import at.gv.egiz.eaaf.core.impl.utils.KeyValueUtils; import at.gv.egovernment.moa.id.auth.modules.eIDAScentralAuth.EidasCentralAuthConstants; import at.gv.egovernment.moa.id.commons.api.AuthConfiguration; import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants; import at.gv.egovernment.moa.logging.Logger; public class Utils { public static String getCentraleIDASNodeEntityId(ISPConfiguration spConfiguration, IConfiguration authConfig) { //load from service-provider configuration String msNodeEntityID = spConfiguration.getConfigurationValue(MOAIDConfigurationConstants.SERVICE_EXTERNAL_CENTRAL_EIDASNODE_SERVICE_URL); if (StringUtils.isEmpty(msNodeEntityID)) { Logger.debug("No SP-specific central eIDAS-node URL. Switch to general configuration ... "); if (authConfig instanceof AuthConfiguration) { AuthConfiguration moaAuthConfig = (AuthConfiguration)authConfig; List configuratedEntityIDs = KeyValueUtils.getListOfCSVValues( moaAuthConfig.getConfigurationWithKey(MOAIDConfigurationConstants.GENERAL_AUTH_SERVICES_CENTRAL_EIDASNODE_URL)); if (configuratedEntityIDs.size() > 0) msNodeEntityID = configuratedEntityIDs.get(0); else Logger.info("No central eIDAS-node URL in IDP configuration. Switch to backup configuration ... "); } else Logger.info("Basic configuration is NOT of type '" + AuthConfiguration.class.getName() + "' Switch to generic Type ... "); if (StringUtils.isEmpty(msNodeEntityID)) msNodeEntityID = authConfig.getBasicConfiguration(EidasCentralAuthConstants.CONFIG_PROPS_NODE_ENTITYID); } return msNodeEntityID; } }