Skip to content

Commit

Permalink
Address comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thisara-Welmilla committed Dec 17, 2024
1 parent 5fe52b8 commit 129eebd
Showing 1 changed file with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> tags = resolveAuthenticatorTags(config);
if (tags.isEmpty()) {
federatedAuthenticator.setTags(tags);
}

if (DefinedByType.SYSTEM == config.getDefinedByType()) {
Expand All @@ -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<FederatedAuthenticatorListItem> build(FederatedAuthenticatorConfig[] fedAuthConfigs,
Expand All @@ -160,9 +161,9 @@ public static List<FederatedAuthenticatorListItem> 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<String> 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,
Expand Down Expand Up @@ -466,21 +467,19 @@ private static void resolveEndpointConfiguration(FederatedAuthenticator authenti
}
}

private static String[] resolveAuthenticatorTags(FederatedAuthenticatorConfig config) {
private static List<String> 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<>();
}

/**
Expand Down

0 comments on commit 129eebd

Please sign in to comment.