Skip to content

Commit

Permalink
Update APIs to support custom authentication management.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thisara-Welmilla committed Dec 2, 2024
1 parent 660f2fd commit 9097241
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,13 @@ public List<Authenticator> getAuthenticators(String filter, Integer limit, Integ
LocalAuthenticatorConfig[] localAuthenticatorConfigs = AuthenticatorsServiceHolder.getInstance()
.getApplicationManagementService().getAllLocalAuthenticators(ContextLoader
.getTenantDomainFromContext());

List<UserDefinedLocalAuthenticatorConfig> userDefinedLocalAuthConfigs =
AuthenticatorsServiceHolder.getInstance().getApplicationAuthenticatorService()
.getUserDefinedLocalAuthenticators(ContextLoader.getTenantDomainFromContext());
if (CollectionUtils.isNotEmpty(userDefinedLocalAuthConfigs)) {
localAuthenticatorConfigs = (LocalAuthenticatorConfig[]) ArrayUtils.addAll(localAuthenticatorConfigs,
userDefinedLocalAuthConfigs.toArray(new LocalAuthenticatorConfig[0]));
}
int localAuthenticatorsCount = localAuthenticatorConfigs.length;
RequestPathAuthenticatorConfig[] requestPathAuthenticatorConfigs = new RequestPathAuthenticatorConfig[0];

Expand Down Expand Up @@ -155,6 +161,8 @@ public List<Authenticator> getAuthenticators(String filter, Integer limit, Integ
null);
} catch (IdentityProviderManagementException e) {
throw handleIdPException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_LISTING_IDPS, null);
} catch (AuthenticatorMgtException e) {
throw new RuntimeException(e);
}
}

Expand Down Expand Up @@ -1002,7 +1010,7 @@ private APIError handleAuthenticatorException(AuthenticatorMgtException e) {
errorCode : Constants.AUTHENTICATOR_ERROR_PREFIX + errorCode;
errorResponse.setCode(errorCode);
}
errorResponse.setDescription(e.getMessage());
errorResponse.setDescription(e.getDescription());
status = Response.Status.BAD_REQUEST;
} else if (e instanceof AuthenticatorMgtServerException) {
if (e.getErrorCode() != null) {
Expand All @@ -1012,7 +1020,7 @@ private APIError handleAuthenticatorException(AuthenticatorMgtException e) {
errorCode : Constants.AUTHENTICATOR_ERROR_PREFIX + errorCode;
errorResponse.setCode(errorCode);
}
errorResponse.setDescription(e.getMessage());
errorResponse.setDescription(e.getDescription());
status = Response.Status.INTERNAL_SERVER_ERROR;
} else {
status = Response.Status.INTERNAL_SERVER_ERROR;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ private static UserDefinedAuthenticatorEndpointConfig buildEndpointConfig(Endpoi
.entrySet().stream().collect(Collectors.toMap(
Map.Entry::getKey, entry -> entry.getValue().toString())));
return endpointConfigBuilder.build();
} catch (NoSuchElementException e) {
} catch (NoSuchElementException | IllegalArgumentException e) {
Constants.ErrorMessage error = ERROR_CODE_INVALID_ENDPOINT_CONFIG;
throw new AuthenticatorMgtClientException(error.getCode(), error.getMessage(), error.getMessage());
throw new AuthenticatorMgtClientException(error.getCode(), error.getMessage(), e.getMessage());
}
}

Expand Down

0 comments on commit 9097241

Please sign in to comment.