diff --git a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/main/java/org/wso2/carbon/identity/api/server/idp/v1/core/ServerIdpManagementService.java b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/main/java/org/wso2/carbon/identity/api/server/idp/v1/core/ServerIdpManagementService.java index 282fc34c9d..c64ace027e 100644 --- a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/main/java/org/wso2/carbon/identity/api/server/idp/v1/core/ServerIdpManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/main/java/org/wso2/carbon/identity/api/server/idp/v1/core/ServerIdpManagementService.java @@ -1772,16 +1772,7 @@ private void updateFederatedAuthenticatorConfig(IdentityProvider idp, FederatedA authConfig.setName(base64URLDecode(authenticator.getAuthenticatorId())); authConfig.setDisplayName(getDisplayNameOfAuthenticator(authConfig.getName())); authConfig.setEnabled(authenticator.getIsEnabled()); - /* Resolve definedBy type: If there is authenticator by same name and its type is system: SYSTEM. - If not: USER. */ - FederatedAuthenticatorConfig authenticatorConfig = ApplicationAuthenticatorService.getInstance() - .getFederatedAuthenticatorByName(authenticator.getAuthenticatorId()); - if (authenticatorConfig != null && - DefinedByType.SYSTEM.equals(authenticatorConfig.getDefinedByType())) { - authConfig.setDefinedByType(DefinedByType.SYSTEM); - } else { - authConfig.setDefinedByType(DefinedByType.USER); - } + authConfig.setDefinedByType(resolveDefinedByType(authenticator.getAuthenticatorId())); List authProperties = authenticator.getProperties(); if (IdentityApplicationConstants.Authenticator.SAML2SSO.FED_AUTH_NAME.equals(authConfig.getName())) { @@ -2851,15 +2842,7 @@ private FederatedAuthenticatorConfig createFederatedAuthenticatorConfig(String f authConfig.setName(authenticatorName); authConfig.setDisplayName(getDisplayNameOfAuthenticator(authenticatorName)); authConfig.setEnabled(authenticator.getIsEnabled()); - // Resolve definedBy type: If there is authenticator by same name and its type is system: SYSTEM. If not: USER. - FederatedAuthenticatorConfig authenticatorConfig = ApplicationAuthenticatorService.getInstance() - .getFederatedAuthenticatorByName(authenticatorName); - if (authenticatorConfig != null && - DefinedByType.SYSTEM.equals(authenticatorConfig.getDefinedByType())) { - authConfig.setDefinedByType(DefinedByType.SYSTEM); - } else { - authConfig.setDefinedByType(DefinedByType.USER); - } + authConfig.setDefinedByType(resolveDefinedByType(authenticatorName)); List authProperties = authenticator.getProperties(); if (IdentityApplicationConstants.Authenticator.SAML2SSO.FED_AUTH_NAME.equals(authenticatorName)) { validateSamlMetadata(authProperties); @@ -2873,6 +2856,18 @@ private FederatedAuthenticatorConfig createFederatedAuthenticatorConfig(String f return authConfig; } + private DefinedByType resolveDefinedByType(String authenticatorName) { + + // Resolve definedBy type: If there is authenticator by same name and its type is system: SYSTEM. If not: USER. + FederatedAuthenticatorConfig authenticatorConfig = ApplicationAuthenticatorService.getInstance() + .getFederatedAuthenticatorByName(authenticatorName); + if (authenticatorConfig != null && + DefinedByType.SYSTEM.equals(authenticatorConfig.getDefinedByType())) { + return DefinedByType.SYSTEM; + } + return DefinedByType.USER; + } + /** * Verify if scopes have not been set in both Scopes field and Additional Query Parameters field *