Avoid using stored EP URLs for auth configs in RIDP.
@@ -532,6 +532,10 @@ public class IdentityProviderManager implements IdpManager {
identityProvider
.setProvisioningConnectorConfigs(new ProvisioningConnectorConfig[]{scimProvConn});
+ // Override few endpoint URLs which are initially persisted in the database and can be out dated with hostname
+ // changes.
+ updateSuperTenantIdpWithNewEPUrls(identityProvider);
+
return identityProvider;
}
@@ -1764,5 +1768,64 @@ public class IdentityProviderManager implements IdpManager {
}
+ /**
+ * Updates the persisted endpoint URLs (e.g. SAML endpoint) if the hostname/port has been changed.
+ * @param residentIDP
+ * @throws IdentityProviderManagementException
+ */
+ private void updateSuperTenantIdpWithNewEPUrls(IdentityProvider residentIDP)
+ throws IdentityProviderManagementException {
+
+ // Not all endpoints are persisted. So we need to update only a few properties.
+
+ String samlSSOUrl = IdentityUtil.getServerURL(IdentityConstants.ServerConfig.SAMLSSO, true, true);
+ updateFederationAuthenticationConfigProperty(residentIDP,
+ IdentityApplicationConstants.Authenticator
+ .SAML2SSO.NAME, IdentityApplicationConstants.Authenticator.SAML2SSO.SSO_URL, samlSSOUrl);
+
+ String samlLogoutUrl = IdentityUtil.getServerURL(IdentityConstants.ServerConfig.SAMLSSO, true, true);;
+ updateFederationAuthenticationConfigProperty(residentIDP,
+ IdentityApplicationConstants.Authenticator
+ .SAML2SSO.NAME, IdentityApplicationConstants.Authenticator.SAML2SSO.LOGOUT_REQ_URL, samlLogoutUrl);
+
+ String passiveStsUrl = IdentityUtil.getServerURL(IdentityConstants.STS.PASSIVE_STS, true, true);
+ updateFederationAuthenticationConfigProperty(residentIDP,
+ IdentityApplicationConstants.Authenticator.PassiveSTS.NAME, IdentityApplicationConstants
+ .Authenticator.PassiveSTS.IDENTITY_PROVIDER_URL, passiveStsUrl);
+ }
+
+ /**
+ * Updates the property values of the given property name of the given authenticator.
+ *
+ * @param residentIdentityProvider
+ * @param authenticatorName
+ * @param propertyName
+ * @param newValue
+ * @return true if the value was updated, false if the value is up to date.
+ */
+ private boolean updateFederationAuthenticationConfigProperty(IdentityProvider residentIdentityProvider, String
+ authenticatorName, String propertyName, String newValue) {
+
+ FederatedAuthenticatorConfig federatedAuthenticatorConfig = IdentityApplicationManagementUtil
+ .getFederatedAuthenticator(residentIdentityProvider.getFederatedAuthenticatorConfigs(),
+ authenticatorName);
+
+ if (federatedAuthenticatorConfig != null) {
+
+ Property existingProperty = IdentityApplicationManagementUtil.getProperty(federatedAuthenticatorConfig
+ .getProperties(), propertyName);
+
+ if (existingProperty != null) {
+ String existingPropertyValue = existingProperty.getValue();
+
+ if (!StringUtils.equalsIgnoreCase(existingPropertyValue, newValue)) {
+ existingProperty.setValue(newValue);
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
}
