Skip to content

Commit

Permalink
Add new method to get federated authenticator by name.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thisara-Welmilla committed Jan 25, 2025
1 parent 5a3bd8b commit 17a90eb
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@

/**
* Application authentication service. This server only return the system defined authenticators.
* This server is exposed to external and currently only being used for API based authenticator which is only support
* for system defined authenticators.
* This service is exposed and currently only being used for API based authenticator implementation which is currently
* only support for system defined authenticators.
*/
@Deprecated
public class ApplicationAuthenticationService {

private static final Log log = LogFactory.getLog(ApplicationAuthenticationService.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ private List<AuthenticatorData> getAuthenticatorBasicData(AuthServiceRequestWrap
}

ApplicationAuthenticator authenticator = ApplicationAuthenticatorManager.getInstance()
.getAppAuthenticatorByName(name, getTenantDomain((HttpServletRequest) request.getRequest()));
.getApplicationAuthenticatorByName(
name, getTenantDomain((HttpServletRequest) request.getRequest()));
if (authenticator == null) {
throw new AuthServiceException(AuthServiceConstants.ErrorMessage.ERROR_AUTHENTICATOR_NOT_FOUND.code(),
String.format(AuthServiceConstants.ErrorMessage.ERROR_AUTHENTICATOR_NOT_FOUND.description(),
Expand Down Expand Up @@ -472,7 +473,7 @@ private void addAuthenticator(Set<ApplicationAuthenticator> authenticators, Stri
String tenantDomain) {

ApplicationAuthenticator authenticator = ApplicationAuthenticatorManager.getInstance()
.getAppAuthenticatorByName(authenticatorName, tenantDomain);
.getApplicationAuthenticatorByName(authenticatorName, tenantDomain);
if (authenticator != null) {
authenticators.add(authenticator);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ private void loadAuthenticatorConfig(AuthenticationContext context)
for (AuthenticatorConfig authenticatorConfig : stepConfig.getAuthenticatorList()) {
if (authenticatorConfig.getApplicationAuthenticator() == null) {
authenticatorConfig.setApplicationAuthenticator(ApplicationAuthenticatorManager.getInstance()
.getAppAuthenticatorByName(authenticatorConfig.getName(), context.getTenantDomain()));
.getApplicationAuthenticatorByName(
authenticatorConfig.getName(), context.getTenantDomain()));
}
if (authenticatorConfig.getIdps() == null && authenticatorConfig.getIdpNames() == null) {
authenticatorConfig.setIdPs(Collections.emptyMap());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ private void loadStepAuthenticator(StepConfig stepConfig, IdentityProvider idp,
authenticatorConfig.setName(authenticatorName);

ApplicationAuthenticator appAuthenticatorForConfig = ApplicationAuthenticatorManager.getInstance()
.getAppAuthenticatorByName(authenticatorName, tenantDomain);
.getApplicationAuthenticatorByName(authenticatorName, tenantDomain);
if (appAuthenticatorForConfig == null) {
throw new FrameworkException("No authenticator found by the name: " + authenticatorName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public AuthenticatorConfig getAuthenticatorConfig() throws
authenticatorConfig.setName(this.name);
authenticatorConfig.setEnabled(this.enabled);
authenticatorConfig.setApplicationAuthenticator(ApplicationAuthenticatorManager.getInstance()
.getAppAuthenticatorByName(this.name, tenantDomain));
.getApplicationAuthenticatorByName(this.name, tenantDomain));
authenticatorConfig.setAuthenticatorStateInfo(this.authenticatorStateInfo);
authenticatorConfig.setParameterMap(this.parameterMap);
Map<String, IdentityProvider> idps = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public List<ApplicationAuthenticator> getAllAuthenticators(String tenantDomain)
* @param tenantDomain Tenant domain.
* @return ApplicationAuthenticator instance.
*/
public ApplicationAuthenticator getAppAuthenticatorByName(String authenticatorName, String tenantDomain) {
public ApplicationAuthenticator getApplicationAuthenticatorByName(String authenticatorName, String tenantDomain) {

// Check whether the authenticator is in the system defined authenticator.
for (ApplicationAuthenticator authenticator : systemDefinedAuthenticators) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ public static HttpServletRequest getCommonAuthReqWithParams(HttpServletRequest r
*
* @param name Name of the authenticator.
* @return ApplicationAuthenticator.
* @deprecated use {@link ApplicationAuthenticatorManager#getSystemDefinedAuthenticatorByName(String)}.
*/
@Deprecated
public static ApplicationAuthenticator getAppAuthenticatorByName(String name) {
Expand Down

0 comments on commit 17a90eb

Please sign in to comment.