Skip to content

Commit

Permalink
Update /authenticators/meta/tag endpoint to retrieve tag in user defi…
Browse files Browse the repository at this point in the history
…ned authenticators.
  • Loading branch information
Thisara-Welmilla committed Dec 17, 2024
1 parent aaa300d commit 500241c
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,21 @@ public List<String> getTags() {
.getTenantDomainFromContext());

FederatedAuthenticatorConfig[] federatedAuthenticatorConfigs = AuthenticatorsServiceHolder.getInstance()
.getIdentityProviderManager().getAllFederatedAuthenticators();
.getIdentityProviderManager()
.getAllFederatedAuthenticators(ContextLoader.getTenantDomainFromContext());

List<UserDefinedLocalAuthenticatorConfig> userDefinedLocalAuthConfigs = getApplicationAuthenticatorService()
.getAllUserDefinedLocalAuthenticators(ContextLoader.getTenantDomainFromContext());

return buildTagsListResponse(localAuthenticatorConfigs, requestPathAuthenticatorConfigs,
federatedAuthenticatorConfigs);
federatedAuthenticatorConfigs, userDefinedLocalAuthConfigs);
} catch (IdentityApplicationManagementException e) {
throw handleApplicationMgtException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_LISTING_AUTHENTICATORS,
null);
} catch (IdentityProviderManagementException e) {
throw handleIdPException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_LISTING_IDPS, null);
} catch (AuthenticatorMgtException e) {
throw handleAuthenticatorException(e);
}
}

Expand Down Expand Up @@ -616,7 +622,8 @@ private Authenticator addLocalAuthenticator(LocalAuthenticatorConfig config) {

private List<String> buildTagsListResponse(LocalAuthenticatorConfig[] localAuthenticatorConfigs,
RequestPathAuthenticatorConfig[] requestPathAuthenticatorConfigs,
FederatedAuthenticatorConfig[] federatedAuthenticatorConfigs) {
FederatedAuthenticatorConfig[] federatedAuthenticatorConfigs,
List<UserDefinedLocalAuthenticatorConfig> userDefinedLocalAuthConfigs) {

ArrayList<String> tagsList = new ArrayList<>();
if (localAuthenticatorConfigs != null) {
Expand All @@ -643,6 +650,14 @@ private List<String> buildTagsListResponse(LocalAuthenticatorConfig[] localAuthe
}
}
}
if (!userDefinedLocalAuthConfigs.isEmpty()) {
for (UserDefinedLocalAuthenticatorConfig config : userDefinedLocalAuthConfigs) {
String[] tags = config.getTags();
if (ArrayUtils.isNotEmpty(tags)) {
tagsList.addAll(Arrays.asList(tags));
}
}
}
return tagsList.stream().distinct().collect(Collectors.toList());
}

Expand Down

0 comments on commit 500241c

Please sign in to comment.