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/impl/FederatedAuthenticatorConfigBuilderFactory.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/impl/FederatedAuthenticatorConfigBuilderFactory.java index ef6c99e585..b3403632e0 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/impl/FederatedAuthenticatorConfigBuilderFactory.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/impl/FederatedAuthenticatorConfigBuilderFactory.java @@ -124,9 +124,9 @@ public static FederatedAuthenticator build(FederatedAuthenticatorConfig config) federatedAuthenticator.setName(config.getName()); federatedAuthenticator.setIsEnabled(config.isEnabled()); - String[] tags = resolveAuthenticatorTags(config); - if (ArrayUtils.isNotEmpty(tags)) { - federatedAuthenticator.setTags(Arrays.asList(tags)); + List tags = resolveAuthenticatorTags(config); + if (tags.isEmpty()) { + federatedAuthenticator.setTags(tags); } if (DefinedByType.SYSTEM == config.getDefinedByType()) { @@ -147,6 +147,7 @@ public static FederatedAuthenticator build(FederatedAuthenticatorConfig config) * FederatedAuthenticatorConfig. * * @param fedAuthConfigs Array of FederatedAuthenticatorConfig instances. + * @param idpResourceId Identity provider resource ID. * @return List of FederatedAuthenticatorListItem instances. */ public static List build(FederatedAuthenticatorConfig[] fedAuthConfigs, @@ -160,9 +161,9 @@ public static List build(FederatedAuthenticatorC authenticatorListItem.setIsEnabled(config.isEnabled()); authenticatorListItem.definedBy(FederatedAuthenticatorListItem.DefinedByEnum.valueOf( config.getDefinedByType().toString())); - String[] tags = resolveAuthenticatorTags(config); - if (ArrayUtils.isNotEmpty(tags)) { - authenticatorListItem.setTags(Arrays.asList(tags)); + List tags = resolveAuthenticatorTags(config); + if (tags.isEmpty()) { + authenticatorListItem.setTags(tags); } authenticatorListItem.setSelf(ContextLoader.buildURIForBody(String.format(V1_API_PATH_COMPONENT + IDP_PATH_COMPONENT + "/%s/federated-authenticators/%s", idpResourceId, @@ -466,21 +467,19 @@ private static void resolveEndpointConfiguration(FederatedAuthenticator authenti } } - private static String[] resolveAuthenticatorTags(FederatedAuthenticatorConfig config) { + private static List resolveAuthenticatorTags(FederatedAuthenticatorConfig config) { /* If the authenticator is defined by the user, return the tags of the authenticator config. Otherwise, return the tags of the system registered federated authenticator template. */ if (DefinedByType.USER == config.getDefinedByType()) { - return config.getTags(); - + return Arrays.asList(config.getTags()); } + FederatedAuthenticatorConfig federatedAuthenticatorConfig = ApplicationAuthenticatorService.getInstance().getFederatedAuthenticatorByName(config.getName()); - if (federatedAuthenticatorConfig != null) { - return federatedAuthenticatorConfig.getTags(); - } - return new String[0]; + return federatedAuthenticatorConfig != null ? Arrays.asList(federatedAuthenticatorConfig.getTags()) + : new ArrayList<>(); } /**