Source:
<code>public void addResidentIdP(IdentityProvider identityProvider, String tenantDomain) throws IdentityApplicationManagementException { if (identityProvider.getHomeRealmId() == null <START> || ("").equals(identityProvider.getHomeRealmId())) { <END> String msg = "Invalid argument: Resident Identity Provider Home Realm Identifier value is empty"; log.error(msg); throw new IdentityApplicationManagementException(msg); } if (identityProvider.getFederatedAuthenticatorConfigs() == null) { identityProvider.setFederatedAuthenticatorConfigs(new FederatedAuthenticatorConfig[0]); } FederatedAuthenticatorConfig fedAuthnConfig = IdentityApplicationManagementUtil .getFederatedAuthenticator(identityProvider.getFederatedAuthenticatorConfigs(), IdentityApplicationConstants.Authenticator.SAML2SSO.NAME); if (fedAuthnConfig == null) { fedAuthnConfig = new FederatedAuthenticatorConfig(); fedAuthnConfig.setName(IdentityApplicationConstants.Authenticator.SAML2SSO.NAME); } if (fedAuthnConfig.getProperties() == null) { fedAuthnConfig.setProperties(new Property[0]); } boolean idPEntityIdAvailable = false; for (Property property : fedAuthnConfig.getProperties()) { if (IdentityApplicationConstants.Authenticator.SAML2SSO.IDP_ENTITY_ID.equals(property.getName())) { idPEntityIdAvailable = true; } } if (!idPEntityIdAvailable) { Property property = new Property(); property.setName(IdentityApplicationConstants.Authenticator.SAML2SSO.IDP_ENTITY_ID); property.setValue(IdPManagementUtil.getResidentIdPEntityId()); if (fedAuthnConfig.getProperties().length > 0) { List<Property> properties = Arrays.asList(fedAuthnConfig.getProperties()); properties.add(property); fedAuthnConfig.setProperties((Property[]) properties.toArray()); } else { fedAuthnConfig.setProperties(new Property[]{property}); } } FederatedAuthenticatorConfig[] federatedAuthenticatorConfigs = {fedAuthnConfig}; identityProvider.setFederatedAuthenticatorConfigs(IdentityApplicationManagementUtil .concatArrays(identityProvider.getFederatedAuthenticatorConfigs(), federatedAuthenticatorConfigs)); dao.addIdP(identityProvider, getTenantIdOfDomain(tenantDomain), tenantDomain); }</code><technical_language>StringUtils</technical_language>

Target:
public void addResidentIdP(IdentityProvider identityProvider, String tenantDomain) throws IdentityApplicationManagementException { if (identityProvider.getHomeRealmId() == null || StringUtils.isEmpty(identityProvider.getHomeRealmId())) { String msg = "Invalid argument: Resident Identity Provider Home Realm Identifier value is empty"; log.error(msg); throw new IdentityApplicationManagementException(msg); } if (identityProvider.getFederatedAuthenticatorConfigs() == null) { identityProvider.setFederatedAuthenticatorConfigs(new FederatedAuthenticatorConfig[0]); } FederatedAuthenticatorConfig fedAuthnConfig = IdentityApplicationManagementUtil .getFederatedAuthenticator(identityProvider.getFederatedAuthenticatorConfigs(), IdentityApplicationConstants.Authenticator.SAML2SSO.NAME); if (fedAuthnConfig == null) { fedAuthnConfig = new FederatedAuthenticatorConfig(); fedAuthnConfig.setName(IdentityApplicationConstants.Authenticator.SAML2SSO.NAME); } if (fedAuthnConfig.getProperties() == null) { fedAuthnConfig.setProperties(new Property[0]); } boolean idPEntityIdAvailable = false; for (Property property : fedAuthnConfig.getProperties()) { if (IdentityApplicationConstants.Authenticator.SAML2SSO.IDP_ENTITY_ID.equals(property.getName())) { idPEntityIdAvailable = true; } } if (!idPEntityIdAvailable) { Property property = new Property(); property.setName(IdentityApplicationConstants.Authenticator.SAML2SSO.IDP_ENTITY_ID); property.setValue(IdPManagementUtil.getResidentIdPEntityId()); if (fedAuthnConfig.getProperties().length > 0) { List<Property> properties = Arrays.asList(fedAuthnConfig.getProperties()); properties.add(property); fedAuthnConfig.setProperties((Property[]) properties.toArray()); } else { fedAuthnConfig.setProperties(new Property[]{property}); } } FederatedAuthenticatorConfig[] federatedAuthenticatorConfigs = {fedAuthnConfig}; identityProvider.setFederatedAuthenticatorConfigs(IdentityApplicationManagementUtil .concatArrays(identityProvider.getFederatedAuthenticatorConfigs(), federatedAuthenticatorConfigs)); dao.addIdP(identityProvider, getTenantIdOfDomain(tenantDomain), tenantDomain); }